@infrab4a/connect 4.1.2-beta.14 → 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 (53) 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 -3
  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 -6
  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 -6
  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/interfaces/payment-provider.interface.d.ts +0 -6
  35. package/src/domain/shopping/models/order-blocked.d.ts +0 -26
  36. package/src/domain/shopping/models/payment.transaction.d.ts +0 -66
  37. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -4
  38. package/src/domain/shopping/services/adyen-card-payment.service.d.ts +0 -28
  39. package/src/domain/shopping/services/antifraude.service.d.ts +0 -19
  40. package/src/domain/shopping/services/glampoints-payment.service.d.ts +0 -4
  41. package/src/domain/shopping/services/index.d.ts +0 -6
  42. package/src/domain/shopping/services/pagarme-bank-slip-payment.service.d.ts +0 -8
  43. package/src/domain/shopping/services/pagarme-card-payment.service.d.ts +0 -10
  44. package/src/domain/shopping/services/pagarme-pix-payment.service.d.ts +0 -8
  45. package/src/domain/shopping/types/adyen-credentials.type.d.ts +0 -6
  46. package/src/domain/shopping/types/index.d.ts +0 -5
  47. package/src/domain/shopping/types/pagarme-credentials.type.d.ts +0 -5
  48. package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
  49. package/src/domain/shopping/types/payment-method.type.d.ts +0 -2
  50. package/src/domain/shopping/types/payment-provider.type.d.ts +0 -2
  51. package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
  52. package/src/infra/firebase/firestore/repositories/general/sequences-firestore.repository.d.ts +0 -7
  53. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.d.ts +0 -7
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'reflect-metadata';
2
+ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transformer';
2
3
  import * as tslib_1 from 'tslib';
3
4
  import { __decorate, __metadata, __rest } from 'tslib';
4
- import { plainToInstance, instanceToPlain, Type, Expose } from 'class-transformer';
5
5
  import { parseISO } from 'date-fns';
6
6
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
7
7
  import { isNil, isArray as isArray$1, first, last, flatten, compact, get, isString, each, unset, isObject as isObject$1, set, isNumber, isEmpty, chunk, isDate, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
@@ -12,49 +12,6 @@ import axios from 'axios';
12
12
  import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
13
13
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
14
14
  import { mutation, query as query$1 } from 'gql-query-builder';
15
- import * as moment from 'moment';
16
-
17
- var PaymentMethods;
18
- (function (PaymentMethods) {
19
- PaymentMethods["CARD"] = "card";
20
- PaymentMethods["BANKSLIP"] = "bankSlip";
21
- PaymentMethods["PIX"] = "pix";
22
- PaymentMethods["POINTS"] = "glampoints";
23
- })(PaymentMethods || (PaymentMethods = {}));
24
-
25
- var PaymentProviders;
26
- (function (PaymentProviders) {
27
- PaymentProviders["PAGARME"] = "pagarMe";
28
- PaymentProviders["ADYEN"] = "adyen";
29
- PaymentProviders["GLAMPOINTS"] = "glampoints";
30
- })(PaymentProviders || (PaymentProviders = {}));
31
-
32
- class BasePaymentMethodFactory {
33
- constructor(methods) {
34
- this.methods = methods;
35
- }
36
- build(method) {
37
- return this.methods[method];
38
- }
39
- }
40
-
41
- class AdyenPaymentMethodFactory extends BasePaymentMethodFactory {
42
- }
43
-
44
- class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
45
- }
46
-
47
- class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
48
- }
49
-
50
- class PaymentProviderFactory {
51
- constructor(paymentProviders) {
52
- this.paymentProviders = paymentProviders;
53
- }
54
- build(provider) {
55
- return this.paymentProviders[provider];
56
- }
57
- }
58
15
 
59
16
  class BaseModel {
60
17
  get identifier() {
@@ -79,181 +36,6 @@ class BaseModel {
79
36
  }
80
37
  }
81
38
 
82
- class Filter extends BaseModel {
83
- static get identifiersFields() {
84
- return ['id'];
85
- }
86
- }
87
-
88
- class CategoryBase extends BaseModel {
89
- static get identifiersFields() {
90
- return ['id'];
91
- }
92
- }
93
- __decorate([
94
- Type(() => CategoryBase),
95
- __metadata("design:type", CategoryBase)
96
- ], CategoryBase.prototype, "parent", void 0);
97
- __decorate([
98
- Type(() => Filter),
99
- __metadata("design:type", Array)
100
- ], CategoryBase.prototype, "filters", void 0);
101
-
102
- class CategoryForProduct extends CategoryBase {
103
- static get identifiersFields() {
104
- return ['id'];
105
- }
106
- }
107
-
108
- class ProductBase extends BaseModel {
109
- get evaluation() {
110
- return {
111
- reviews: this.reviews,
112
- count: this.reviewsTotal,
113
- rating: this.rate,
114
- };
115
- }
116
- set evaluation(evaluation) {
117
- if (!evaluation) {
118
- this.reviews = null;
119
- this.reviewsTotal = null;
120
- this.rate = null;
121
- return;
122
- }
123
- this.reviews = evaluation.reviews || this.reviews;
124
- this.reviewsTotal = evaluation.count || this.reviewsTotal;
125
- this.rate = evaluation.rating || this.rate;
126
- }
127
- static get identifiersFields() {
128
- return ['id'];
129
- }
130
- }
131
-
132
- class ProductForKit extends ProductBase {
133
- static get identifiersFields() {
134
- return ['id'];
135
- }
136
- }
137
- __decorate([
138
- Type(() => CategoryForProduct),
139
- __metadata("design:type", CategoryForProduct)
140
- ], ProductForKit.prototype, "category", void 0);
141
-
142
- class KitProduct extends BaseModel {
143
- static get identifiersFields() {
144
- return ['productId', 'kitProductId'];
145
- }
146
- }
147
- __decorate([
148
- Type(() => ProductForKit),
149
- __metadata("design:type", ProductForKit)
150
- ], KitProduct.prototype, "kit", void 0);
151
- __decorate([
152
- Type(() => ProductForKit),
153
- __metadata("design:type", ProductForKit)
154
- ], KitProduct.prototype, "product", void 0);
155
-
156
- class ProductForCategory extends ProductBase {
157
- static get identifiersFields() {
158
- return ['id'];
159
- }
160
- }
161
- __decorate([
162
- Type(() => KitProduct),
163
- __metadata("design:type", Array)
164
- ], ProductForCategory.prototype, "kitProducts", void 0);
165
-
166
- class Category extends CategoryBase {
167
- static get identifiersFields() {
168
- return ['id'];
169
- }
170
- }
171
- __decorate([
172
- Type(() => ProductForCategory),
173
- __metadata("design:type", Array)
174
- ], Category.prototype, "childrenProducts", void 0);
175
-
176
- class CategoryCollectionChildren extends BaseModel {
177
- static get identifiersFields() {
178
- return ['collectionId', 'categoryId'];
179
- }
180
- }
181
- __decorate([
182
- Type(() => CategoryCollectionChildren),
183
- __metadata("design:type", CategoryCollectionChildren)
184
- ], CategoryCollectionChildren.prototype, "parent", void 0);
185
-
186
- class CategoryFilter extends BaseModel {
187
- static get identifiersFields() {
188
- return ['id'];
189
- }
190
- }
191
- __decorate([
192
- Type(() => Filter),
193
- __metadata("design:type", Filter)
194
- ], CategoryFilter.prototype, "filter", void 0);
195
- __decorate([
196
- Type(() => Category),
197
- __metadata("design:type", Category)
198
- ], CategoryFilter.prototype, "category", void 0);
199
-
200
- var GenderDestination;
201
- (function (GenderDestination) {
202
- GenderDestination["FEMALE"] = "female";
203
- GenderDestination["MALE"] = "male";
204
- GenderDestination["UNISEX"] = "unisex";
205
- })(GenderDestination || (GenderDestination = {}));
206
-
207
- var Shops;
208
- (function (Shops) {
209
- Shops["MENSMARKET"] = "mensmarket";
210
- Shops["GLAMSHOP"] = "Glamshop";
211
- Shops["GLAMPOINTS"] = "Glampoints";
212
- Shops["ALL"] = "ALL";
213
- })(Shops || (Shops = {}));
214
-
215
- class FilterOption extends BaseModel {
216
- static get identifiersFields() {
217
- return ['id'];
218
- }
219
- }
220
-
221
- class Product extends ProductBase {
222
- static get identifiersFields() {
223
- return ['id'];
224
- }
225
- }
226
- __decorate([
227
- Type(() => CategoryForProduct),
228
- __metadata("design:type", CategoryForProduct)
229
- ], Product.prototype, "category", void 0);
230
- __decorate([
231
- Type(() => KitProduct),
232
- __metadata("design:type", Array)
233
- ], Product.prototype, "kitProducts", void 0);
234
-
235
- class Variant extends BaseModel {
236
- static get identifiersFields() {
237
- return ['id', 'productId'];
238
- }
239
- }
240
-
241
- class Wishlist extends Category {
242
- static get identifiersFields() {
243
- return ['id'];
244
- }
245
- }
246
-
247
- class Buy2Win extends BaseModel {
248
- static get identifiersFields() {
249
- return ['id'];
250
- }
251
- }
252
- __decorate([
253
- Type(() => Category),
254
- __metadata("design:type", Array)
255
- ], Buy2Win.prototype, "categories", void 0);
256
-
257
39
  var Where;
258
40
  (function (Where) {
259
41
  Where["EQUALS"] = "==";
@@ -279,18 +61,6 @@ var UpdateOptionActions;
279
61
  UpdateOptionActions["NULL"] = "null";
280
62
  })(UpdateOptionActions || (UpdateOptionActions = {}));
281
63
 
282
- class CampaignDashboard extends BaseModel {
283
- static get identifiersFields() {
284
- return ['id'];
285
- }
286
- }
287
-
288
- class CampaignHashtag extends BaseModel {
289
- static get identifiersFields() {
290
- return ['id'];
291
- }
292
- }
293
-
294
64
  var AccessoryImportances;
295
65
  (function (AccessoryImportances) {
296
66
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -517,178 +287,171 @@ class Edition extends BaseModel {
517
287
  }
518
288
  }
519
289
 
520
- class PaymentTransaction extends BaseModel {
290
+ class Payment extends BaseModel {
291
+ static get identifiersFields() {
292
+ return ['id'];
293
+ }
521
294
  }
522
295
  __decorate([
523
296
  Expose({ name: 'refuse_reason' }),
524
297
  __metadata("design:type", String)
525
- ], PaymentTransaction.prototype, "refuseReason", void 0);
298
+ ], Payment.prototype, "refuseReason", void 0);
526
299
  __decorate([
527
300
  Expose({ name: 'status_reason' }),
528
301
  __metadata("design:type", String)
529
- ], PaymentTransaction.prototype, "statusReason", void 0);
302
+ ], Payment.prototype, "statusReason", void 0);
530
303
  __decorate([
531
304
  Expose({ name: 'acquirer_response_code' }),
532
305
  __metadata("design:type", String)
533
- ], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
306
+ ], Payment.prototype, "acquirerResponseCode", void 0);
534
307
  __decorate([
535
308
  Expose({ name: 'acquirer_name' }),
536
309
  __metadata("design:type", String)
537
- ], PaymentTransaction.prototype, "acquirerName", void 0);
310
+ ], Payment.prototype, "acquirerName", void 0);
538
311
  __decorate([
539
312
  Expose({ name: 'acquirer_id' }),
540
313
  __metadata("design:type", String)
541
- ], PaymentTransaction.prototype, "acquirerId", void 0);
314
+ ], Payment.prototype, "acquirerId", void 0);
542
315
  __decorate([
543
316
  Expose({ name: 'authorization_code' }),
544
317
  __metadata("design:type", String)
545
- ], PaymentTransaction.prototype, "authorizationCode", void 0);
318
+ ], Payment.prototype, "authorizationCode", void 0);
546
319
  __decorate([
547
320
  Expose({ name: 'soft_descriptor' }),
548
321
  __metadata("design:type", String)
549
- ], PaymentTransaction.prototype, "softDescriptor", void 0);
322
+ ], Payment.prototype, "softDescriptor", void 0);
550
323
  __decorate([
551
324
  Expose({ name: 'date_created' }),
552
325
  __metadata("design:type", String)
553
- ], PaymentTransaction.prototype, "dateCreated", void 0);
326
+ ], Payment.prototype, "dateCreated", void 0);
554
327
  __decorate([
555
328
  Expose({ name: 'date_updated' }),
556
329
  __metadata("design:type", String)
557
- ], PaymentTransaction.prototype, "dateUpdated", void 0);
330
+ ], Payment.prototype, "dateUpdated", void 0);
558
331
  __decorate([
559
332
  Expose({ name: 'authorized_amount' }),
560
333
  __metadata("design:type", Number)
561
- ], PaymentTransaction.prototype, "authorizedAmount", void 0);
334
+ ], Payment.prototype, "authorizedAmount", void 0);
562
335
  __decorate([
563
336
  Expose({ name: 'paid_amount' }),
564
337
  __metadata("design:type", Number)
565
- ], PaymentTransaction.prototype, "paidAmount", void 0);
338
+ ], Payment.prototype, "paidAmount", void 0);
566
339
  __decorate([
567
340
  Expose({ name: 'refunded_amount' }),
568
341
  __metadata("design:type", Number)
569
- ], PaymentTransaction.prototype, "refundedAmount", void 0);
342
+ ], Payment.prototype, "refundedAmount", void 0);
570
343
  __decorate([
571
344
  Expose({ name: 'card_holder_name' }),
572
345
  __metadata("design:type", String)
573
- ], PaymentTransaction.prototype, "cardHolderName", void 0);
346
+ ], Payment.prototype, "cardHolderName", void 0);
574
347
  __decorate([
575
348
  Expose({ name: 'card_last_digits' }),
576
349
  __metadata("design:type", String)
577
- ], PaymentTransaction.prototype, "cardLastDigits", void 0);
350
+ ], Payment.prototype, "cardLastDigits", void 0);
578
351
  __decorate([
579
352
  Expose({ name: 'card_first_digits' }),
580
353
  __metadata("design:type", String)
581
- ], PaymentTransaction.prototype, "cardFirstDigits", void 0);
354
+ ], Payment.prototype, "cardFirstDigits", void 0);
582
355
  __decorate([
583
356
  Expose({ name: 'card_brand' }),
584
357
  __metadata("design:type", String)
585
- ], PaymentTransaction.prototype, "cardBrand", void 0);
358
+ ], Payment.prototype, "cardBrand", void 0);
586
359
  __decorate([
587
360
  Expose({ name: 'card_pin_mode' }),
588
361
  __metadata("design:type", String)
589
- ], PaymentTransaction.prototype, "cardPinMode", void 0);
362
+ ], Payment.prototype, "cardPinMode", void 0);
590
363
  __decorate([
591
364
  Expose({ name: 'card_magstripe_fallback' }),
592
365
  __metadata("design:type", Boolean)
593
- ], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
366
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
594
367
  __decorate([
595
368
  Expose({ name: 'cvm_pin' }),
596
369
  __metadata("design:type", Boolean)
597
- ], PaymentTransaction.prototype, "cvmPin", void 0);
370
+ ], Payment.prototype, "cvmPin", void 0);
598
371
  __decorate([
599
372
  Expose({ name: 'postback_url' }),
600
373
  __metadata("design:type", String)
601
- ], PaymentTransaction.prototype, "postbackUrl", void 0);
374
+ ], Payment.prototype, "postbackUrl", void 0);
602
375
  __decorate([
603
376
  Expose({ name: 'payment_method' }),
604
377
  __metadata("design:type", String)
605
- ], PaymentTransaction.prototype, "paymentMethod", void 0);
378
+ ], Payment.prototype, "paymentMethod", void 0);
606
379
  __decorate([
607
380
  Expose({ name: 'capture_method' }),
608
381
  __metadata("design:type", String)
609
- ], PaymentTransaction.prototype, "captureMethod", void 0);
382
+ ], Payment.prototype, "captureMethod", void 0);
610
383
  __decorate([
611
384
  Expose({ name: 'antifraud_score' }),
612
385
  __metadata("design:type", String)
613
- ], PaymentTransaction.prototype, "antifraudScore", void 0);
386
+ ], Payment.prototype, "antifraudScore", void 0);
614
387
  __decorate([
615
388
  Expose({ name: 'boleto_url' }),
616
389
  __metadata("design:type", String)
617
- ], PaymentTransaction.prototype, "boletoUrl", void 0);
390
+ ], Payment.prototype, "boletoUrl", void 0);
618
391
  __decorate([
619
392
  Expose({ name: 'boleto_barcode' }),
620
393
  __metadata("design:type", String)
621
- ], PaymentTransaction.prototype, "boletoBarcode", void 0);
394
+ ], Payment.prototype, "boletoBarcode", void 0);
622
395
  __decorate([
623
396
  Expose({ name: 'boleto_expiration_date' }),
624
397
  __metadata("design:type", String)
625
- ], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
398
+ ], Payment.prototype, "boletoExpirationDate", void 0);
626
399
  __decorate([
627
400
  Expose({ name: 'subscription_id' }),
628
401
  __metadata("design:type", String)
629
- ], PaymentTransaction.prototype, "subscriptionId", void 0);
402
+ ], Payment.prototype, "subscriptionId", void 0);
630
403
  __decorate([
631
404
  Expose({ name: 'split_rules' }),
632
405
  __metadata("design:type", String)
633
- ], PaymentTransaction.prototype, "splitRules", void 0);
406
+ ], Payment.prototype, "splitRules", void 0);
634
407
  __decorate([
635
408
  Expose({ name: 'antifraud_metadata' }),
636
409
  __metadata("design:type", Object)
637
- ], PaymentTransaction.prototype, "antifraudMetadata", void 0);
410
+ ], Payment.prototype, "antifraudMetadata", void 0);
638
411
  __decorate([
639
412
  Expose({ name: 'reference_key' }),
640
413
  __metadata("design:type", String)
641
- ], PaymentTransaction.prototype, "referenceKey", void 0);
414
+ ], Payment.prototype, "referenceKey", void 0);
642
415
  __decorate([
643
416
  Expose({ name: 'local_transaction_id' }),
644
417
  __metadata("design:type", String)
645
- ], PaymentTransaction.prototype, "localTransactionId", void 0);
418
+ ], Payment.prototype, "localTransactionId", void 0);
646
419
  __decorate([
647
420
  Expose({ name: 'local_time' }),
648
421
  __metadata("design:type", String)
649
- ], PaymentTransaction.prototype, "localTime", void 0);
422
+ ], Payment.prototype, "localTime", void 0);
650
423
  __decorate([
651
424
  Expose({ name: 'fraud_covered' }),
652
425
  __metadata("design:type", Boolean)
653
- ], PaymentTransaction.prototype, "fraudCovered", void 0);
426
+ ], Payment.prototype, "fraudCovered", void 0);
654
427
  __decorate([
655
428
  Expose({ name: 'fraud_reimbursed' }),
656
429
  __metadata("design:type", String)
657
- ], PaymentTransaction.prototype, "fraudReimbursed", void 0);
430
+ ], Payment.prototype, "fraudReimbursed", void 0);
658
431
  __decorate([
659
432
  Expose({ name: 'order_id' }),
660
433
  __metadata("design:type", String)
661
- ], PaymentTransaction.prototype, "orderId", void 0);
434
+ ], Payment.prototype, "orderId", void 0);
662
435
  __decorate([
663
436
  Expose({ name: 'risk_level' }),
664
437
  __metadata("design:type", String)
665
- ], PaymentTransaction.prototype, "riskLevel", void 0);
438
+ ], Payment.prototype, "riskLevel", void 0);
666
439
  __decorate([
667
440
  Expose({ name: 'receipt_url' }),
668
441
  __metadata("design:type", String)
669
- ], PaymentTransaction.prototype, "receiptUrl", void 0);
442
+ ], Payment.prototype, "receiptUrl", void 0);
670
443
  __decorate([
671
444
  Expose({ name: 'private_label' }),
672
445
  __metadata("design:type", String)
673
- ], PaymentTransaction.prototype, "privateLabel", void 0);
446
+ ], Payment.prototype, "privateLabel", void 0);
674
447
  __decorate([
675
448
  Expose({ name: 'pix_qr_code' }),
676
449
  __metadata("design:type", String)
677
- ], PaymentTransaction.prototype, "pixQrCode", void 0);
450
+ ], Payment.prototype, "pixQrCode", void 0);
678
451
  __decorate([
679
452
  Expose({ name: 'pix_expiration_date' }),
680
453
  __metadata("design:type", String)
681
- ], PaymentTransaction.prototype, "pixExpirationDate", void 0);
682
-
683
- class Payment extends BaseModel {
684
- static get identifiersFields() {
685
- return ['id'];
686
- }
687
- }
688
- __decorate([
689
- Type(() => PaymentTransaction),
690
- __metadata("design:type", PaymentTransaction)
691
- ], Payment.prototype, "transaction", void 0);
454
+ ], Payment.prototype, "pixExpirationDate", void 0);
692
455
 
693
456
  class SubscriptionPayment extends BaseModel {
694
457
  static get identifiersFields() {
@@ -2200,571 +1963,272 @@ class RecoveryPassword {
2200
1963
  }
2201
1964
  }
2202
1965
 
2203
- class LineItem extends Product {
2204
- }
2205
-
2206
- class ShippingMethod extends BaseModel {
1966
+ class Filter extends BaseModel {
2207
1967
  static get identifiersFields() {
2208
1968
  return ['id'];
2209
1969
  }
2210
1970
  }
2211
1971
 
2212
- class Checkout extends BaseModel {
1972
+ class CategoryBase extends BaseModel {
2213
1973
  static get identifiersFields() {
2214
1974
  return ['id'];
2215
1975
  }
2216
1976
  }
2217
1977
  __decorate([
2218
- Type(() => LineItem),
2219
- __metadata("design:type", Array)
2220
- ], Checkout.prototype, "lineItems", void 0);
2221
- __decorate([
2222
- Type(() => User),
2223
- __metadata("design:type", User)
2224
- ], Checkout.prototype, "user", void 0);
2225
- __decorate([
2226
- Type(() => UserAddress),
2227
- __metadata("design:type", UserAddress)
2228
- ], Checkout.prototype, "shippingAddress", void 0);
2229
- __decorate([
2230
- Type(() => UserAddress),
2231
- __metadata("design:type", UserAddress)
2232
- ], Checkout.prototype, "billingAddress", void 0);
2233
- __decorate([
2234
- Type(() => ShippingMethod),
2235
- __metadata("design:type", ShippingMethod)
2236
- ], Checkout.prototype, "shipping", void 0);
1978
+ Type(() => CategoryBase),
1979
+ __metadata("design:type", CategoryBase)
1980
+ ], CategoryBase.prototype, "parent", void 0);
2237
1981
  __decorate([
2238
- Type(() => Coupon),
2239
- __metadata("design:type", Coupon)
2240
- ], Checkout.prototype, "coupon", void 0);
1982
+ Type(() => Filter),
1983
+ __metadata("design:type", Array)
1984
+ ], CategoryBase.prototype, "filters", void 0);
2241
1985
 
2242
- var OrderStatus;
2243
- (function (OrderStatus) {
2244
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
2245
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
2246
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
2247
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
2248
- OrderStatus["ENVIADO"] = "Enviado";
2249
- OrderStatus["ENTREGUE"] = "Entregue";
2250
- OrderStatus["CANCELADO"] = "Cancelado";
2251
- OrderStatus["CREDIT_CARD"] = "credit_card";
2252
- })(OrderStatus || (OrderStatus = {}));
2253
-
2254
- class Order extends Checkout {
2255
- }
2256
- __decorate([
2257
- Type(() => PaymentTransaction),
2258
- __metadata("design:type", PaymentTransaction)
2259
- ], Order.prototype, "payment", void 0);
1986
+ class CategoryForProduct extends CategoryBase {
1987
+ static get identifiersFields() {
1988
+ return ['id'];
1989
+ }
1990
+ }
2260
1991
 
2261
- class OrderBlocked extends BaseModel {
1992
+ class ProductBase extends BaseModel {
1993
+ get evaluation() {
1994
+ return {
1995
+ reviews: this.reviews,
1996
+ count: this.reviewsTotal,
1997
+ rating: this.rate,
1998
+ };
1999
+ }
2000
+ set evaluation(evaluation) {
2001
+ if (!evaluation) {
2002
+ this.reviews = null;
2003
+ this.reviewsTotal = null;
2004
+ this.rate = null;
2005
+ return;
2006
+ }
2007
+ this.reviews = evaluation.reviews || this.reviews;
2008
+ this.reviewsTotal = evaluation.count || this.reviewsTotal;
2009
+ this.rate = evaluation.rating || this.rate;
2010
+ }
2262
2011
  static get identifiersFields() {
2263
2012
  return ['id'];
2264
2013
  }
2265
2014
  }
2266
2015
 
2267
- class CheckoutSubscription extends BaseModel {
2016
+ class ProductForKit extends ProductBase {
2268
2017
  static get identifiersFields() {
2269
2018
  return ['id'];
2270
2019
  }
2271
2020
  }
2272
2021
  __decorate([
2273
- Type(() => UserAddress),
2274
- __metadata("design:type", UserAddress)
2275
- ], CheckoutSubscription.prototype, "shippingAddress", void 0);
2022
+ Type(() => CategoryForProduct),
2023
+ __metadata("design:type", CategoryForProduct)
2024
+ ], ProductForKit.prototype, "category", void 0);
2025
+
2026
+ class KitProduct extends BaseModel {
2027
+ static get identifiersFields() {
2028
+ return ['productId', 'kitProductId'];
2029
+ }
2030
+ }
2276
2031
  __decorate([
2277
- Type(() => UserAddress),
2278
- __metadata("design:type", UserAddress)
2279
- ], CheckoutSubscription.prototype, "billingAddress", void 0);
2032
+ Type(() => ProductForKit),
2033
+ __metadata("design:type", ProductForKit)
2034
+ ], KitProduct.prototype, "kit", void 0);
2280
2035
  __decorate([
2281
- Type(() => SubscriptionPlan),
2282
- __metadata("design:type", SubscriptionPlan)
2283
- ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
2036
+ Type(() => ProductForKit),
2037
+ __metadata("design:type", ProductForKit)
2038
+ ], KitProduct.prototype, "product", void 0);
2039
+
2040
+ class ProductForCategory extends ProductBase {
2041
+ static get identifiersFields() {
2042
+ return ['id'];
2043
+ }
2044
+ }
2284
2045
  __decorate([
2285
- Type(() => Coupon),
2286
- __metadata("design:type", Coupon)
2287
- ], CheckoutSubscription.prototype, "coupon", void 0);
2046
+ Type(() => KitProduct),
2047
+ __metadata("design:type", Array)
2048
+ ], ProductForCategory.prototype, "kitProducts", void 0);
2288
2049
 
2289
- class AdyenCardService {
2290
- constructor(credentials) {
2291
- this.credentials = credentials;
2050
+ class Category extends CategoryBase {
2051
+ static get identifiersFields() {
2052
+ return ['id'];
2292
2053
  }
2293
- async pay(checkout, card) {
2294
- try {
2295
- const result = await axios({
2296
- method: 'POST',
2297
- url: this.credentials.URL_TRANSACTION,
2298
- headers: {
2299
- 'x-api-key': this.credentials.API_KEY,
2300
- 'content-type': 'application/json',
2301
- },
2302
- data: this.createCardPayment(checkout, card),
2303
- });
2304
- if (result.data.resultCode !== 'Authorised') {
2305
- this.checkoutAntiFraudService.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2306
- 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`));
2307
- }
2308
- const payment = {
2309
- createdAt: new Date(),
2310
- updatedAt: new Date(),
2311
- userId: checkout.user.id,
2312
- checkoutId: checkout.id,
2313
- totalPrice: checkout.totalPrice,
2314
- transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
2315
- };
2316
- return payment;
2317
- }
2318
- catch (error) { }
2054
+ }
2055
+ __decorate([
2056
+ Type(() => ProductForCategory),
2057
+ __metadata("design:type", Array)
2058
+ ], Category.prototype, "childrenProducts", void 0);
2059
+
2060
+ class CategoryCollectionChildren extends BaseModel {
2061
+ static get identifiersFields() {
2062
+ return ['collectionId', 'categoryId'];
2319
2063
  }
2320
- createCardPayment(checkout, card) {
2321
- return {
2322
- amount: {
2323
- currency: 'BRL',
2324
- value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
2325
- },
2326
- paymentMethod: {
2327
- type: 'scheme',
2328
- storedPaymentMethodId: card.cardId,
2329
- },
2330
- reference: checkout.id,
2331
- shopperInteraction: 'Ecommerce',
2332
- merchantAccount: this.credentials.MERCHANT_ACCOUNT,
2333
- shopperReference: checkout.user.id,
2334
- recurringProcessingModel: 'CardOnFile',
2335
- returnUrl: this.credentials.URL_POSTBACK,
2336
- installments: {
2337
- value: card.installments,
2338
- },
2339
- };
2064
+ }
2065
+ __decorate([
2066
+ Type(() => CategoryCollectionChildren),
2067
+ __metadata("design:type", CategoryCollectionChildren)
2068
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
2069
+
2070
+ class CategoryFilter extends BaseModel {
2071
+ static get identifiersFields() {
2072
+ return ['id'];
2340
2073
  }
2341
- addCard() {
2342
- throw new Error('Method not implemented.');
2074
+ }
2075
+ __decorate([
2076
+ Type(() => Filter),
2077
+ __metadata("design:type", Filter)
2078
+ ], CategoryFilter.prototype, "filter", void 0);
2079
+ __decorate([
2080
+ Type(() => Category),
2081
+ __metadata("design:type", Category)
2082
+ ], CategoryFilter.prototype, "category", void 0);
2083
+
2084
+ var GenderDestination;
2085
+ (function (GenderDestination) {
2086
+ GenderDestination["FEMALE"] = "female";
2087
+ GenderDestination["MALE"] = "male";
2088
+ GenderDestination["UNISEX"] = "unisex";
2089
+ })(GenderDestination || (GenderDestination = {}));
2090
+
2091
+ var Shops;
2092
+ (function (Shops) {
2093
+ Shops["MENSMARKET"] = "mensmarket";
2094
+ Shops["GLAMSHOP"] = "Glamshop";
2095
+ Shops["GLAMPOINTS"] = "Glampoints";
2096
+ Shops["ALL"] = "ALL";
2097
+ })(Shops || (Shops = {}));
2098
+
2099
+ class FilterOption extends BaseModel {
2100
+ static get identifiersFields() {
2101
+ return ['id'];
2343
2102
  }
2344
2103
  }
2345
2104
 
2346
- class CheckoutAntiFraudService {
2347
- constructor(orderRepository, orderBlockedRepository) {
2348
- this.orderRepository = orderRepository;
2349
- this.orderBlockedRepository = orderBlockedRepository;
2350
- this.LIMIT_ORDERS_DAY = 2;
2351
- this.LIMIT_ORDERS_WEEK = 7;
2352
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
2353
- }
2354
- async validAntiFraud(checkout, boleto, pix, card) {
2355
- if (this.couponValidation(checkout))
2356
- return false;
2357
- if (pix)
2358
- return true;
2359
- if (boleto && !this.verifyBoletoOrder(checkout))
2360
- return false;
2361
- if (card && !(await this.verifyBlockedOrderAttempts(checkout, card)))
2362
- return false;
2363
- if (card && !(await this.verifyDayAndWeekOrders(checkout, card)))
2364
- return false;
2365
- return true;
2366
- }
2367
- couponValidation(checkout) {
2368
- var _a, _b;
2369
- if (((_a = checkout.coupon) === null || _a === void 0 ? void 0 : _a.nickname) === 'FALHADEPAGAMENTO') {
2370
- console.error(`Falha de pagamento com cupom. CheckoutId: ${JSON.stringify({
2371
- checkoutId: checkout.id,
2372
- user: checkout.user.id,
2373
- coupon: (_b = checkout.coupon) === null || _b === void 0 ? void 0 : _b.nickname,
2374
- })}`);
2375
- return false;
2376
- }
2377
- return true;
2378
- }
2379
- async verifyDayAndWeekOrders(checkout, card) {
2380
- var _a, _b, _c, _d, _e, _f, _g, _h;
2381
- 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'));
2382
- for (const key in ordersPerDay) {
2383
- if (ordersPerDay[key] > this.LIMIT_ORDERS_DAY) {
2384
- await this.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'day');
2385
- return false;
2386
- }
2387
- }
2388
- 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'));
2389
- for (const key in ordersPerWeek) {
2390
- if (ordersPerDay[key] > this.LIMIT_ORDERS_WEEK) {
2391
- await this.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'week');
2392
- return false;
2393
- }
2394
- }
2395
- return true;
2396
- }
2397
- async validateOrdersByRange(cpf, email, phone, zip, card, range) {
2398
- const ordersCpf = await this.countOrdersByField('user', 'cpf', cpf, range);
2399
- const ordersByEmail = await this.countOrdersByField('user', 'email', email, range);
2400
- const ordersByPhone = await this.countOrdersByField('user', 'phone', phone, range);
2401
- const ordersByZip = await this.countOrdersByField('shippingAddress', 'zip', zip, range);
2402
- return {
2403
- cpf: ordersCpf,
2404
- email: ordersByEmail,
2405
- phone: ordersByPhone,
2406
- zip: ordersByZip,
2407
- };
2408
- }
2409
- async countOrdersByField(property, field, value, range) {
2410
- const filters = {
2411
- [property]: {
2412
- [field]: value,
2413
- },
2414
- ['createdAt']: [
2415
- { operator: Where.GTE, value: range.firstDate },
2416
- { operator: Where.LTE, value: range.lastDate },
2417
- ],
2418
- };
2419
- const docs = await (await this.orderRepository.find({ filters })).count;
2420
- return docs;
2421
- }
2422
- async verifyBoletoOrder(checkout) {
2423
- var _a;
2424
- const maxOrderValue = 5000;
2425
- if (checkout.totalPrice && checkout.totalPrice > maxOrderValue && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
2426
- await this.createBlockedOrderOrPayment(checkout, 'Boleto not authorized', 'Boleto', 'day');
2427
- return false;
2428
- }
2429
- return true;
2430
- }
2431
- async verifyBlockedOrderAttempts(checkout, card) {
2432
- var _a, _b, _c, _d;
2433
- const day = `${moment().format('YYYY-MM-DD')}T00:00:00`;
2434
- const endOfDay = `${moment().format('YYYY-MM-DD')}T23:59:59`;
2435
- const ordersBlockedWithCpf = await this.orderBlockedRepository
2436
- .find({
2437
- filters: {
2438
- customer: { cpf: { operator: Where.EQUALS, value: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf } },
2439
- date: [
2440
- { operator: Where.GTE, value: new Date(day) },
2441
- { operator: Where.LTE, value: new Date(endOfDay) },
2442
- ],
2443
- },
2444
- })
2445
- .then((data) => data.data);
2446
- const ordersBlockedWithEmail = await this.orderBlockedRepository
2447
- .find({
2448
- filters: {
2449
- customer: { email: { operator: Where.EQUALS, value: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email } },
2450
- date: [
2451
- { operator: Where.GTE, value: new Date(day) },
2452
- { operator: Where.LTE, value: new Date(endOfDay) },
2453
- ],
2454
- },
2455
- })
2456
- .then((data) => data.data);
2457
- const ordersBlockedWithCep = await this.orderBlockedRepository
2458
- .find({
2459
- filters: {
2460
- customer: { shippingAddress: { zip: { operator: Where.EQUALS, value: (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip } } },
2461
- date: [
2462
- { operator: Where.GTE, value: new Date(day) },
2463
- { operator: Where.LTE, value: new Date(endOfDay) },
2464
- ],
2465
- },
2466
- })
2467
- .then((data) => data.data);
2468
- const ordersBlockedWithPhone = await this.orderBlockedRepository
2469
- .find({
2470
- filters: {
2471
- customer: { phoneNumber: { operator: Where.EQUALS, value: (_d = checkout.user) === null || _d === void 0 ? void 0 : _d.phone } },
2472
- date: [
2473
- { operator: Where.GTE, value: new Date(day) },
2474
- { operator: Where.LTE, value: new Date(endOfDay) },
2475
- ],
2476
- },
2477
- })
2478
- .then((data) => data.data);
2479
- const blockedUniqueEmails = ordersBlockedWithEmail.filter((e) => {
2480
- var _a;
2481
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf);
2482
- });
2483
- const blockedUniqueCeps = ordersBlockedWithCep.filter((e) => {
2484
- var _a, _b;
2485
- 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);
2486
- });
2487
- const blockedUniquePhone = ordersBlockedWithPhone.filter((e) => {
2488
- var _a, _b, _c, _d, _e, _f;
2489
- return (e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) &&
2490
- e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
2491
- ((_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()));
2492
- });
2493
- const blockedAttempts = ordersBlockedWithCpf
2494
- .concat(blockedUniqueEmails)
2495
- .concat(blockedUniqueCeps)
2496
- .concat(blockedUniquePhone);
2497
- if (blockedAttempts.length >= this.LIMIT_BLOCKED_ORDERS_DAY) {
2498
- await this.createBlockedOrderOrPayment(checkout, 'More than 5 attempts have failed', 'Failed attempts', 'day', card || null);
2499
- return false;
2500
- }
2501
- return true;
2502
- }
2503
- async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
2504
- var _a, _b, _c, _d, _e, _f, _g, _h;
2505
- const paymentBlocked = {
2506
- customer: {
2507
- name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
2508
- cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
2509
- id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
2510
- email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
2511
- phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
2512
- isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
2513
- subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
2514
- shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
2515
- },
2516
- blockType,
2517
- limiteRange,
2518
- type,
2519
- card,
2520
- checkout: {
2521
- id: checkout.id,
2522
- shop: checkout.shop,
2523
- total: checkout.totalPrice,
2524
- },
2525
- date: new Date(),
2526
- };
2527
- await this.orderBlockedRepository.create(paymentBlocked);
2528
- }
2529
- getDateRange(range = 'day') {
2530
- switch (range) {
2531
- case 'day':
2532
- return {
2533
- firstDate: moment().startOf('D').valueOf(),
2534
- lastDate: moment().endOf('D').valueOf(),
2535
- };
2536
- case 'week':
2537
- return {
2538
- firstDate: moment().subtract(7, 'd').startOf('D').valueOf(),
2539
- lastDate: moment().endOf('D').valueOf(),
2540
- };
2541
- default:
2542
- return {
2543
- firstDate: moment().startOf('D').valueOf(),
2544
- lastDate: moment().endOf('D').valueOf(),
2545
- };
2546
- }
2105
+ class Product extends ProductBase {
2106
+ static get identifiersFields() {
2107
+ return ['id'];
2547
2108
  }
2548
- formatZip(zip) {
2549
- if (zip.length === 8)
2550
- return zip.substring(0, 5) + '-' + zip.substring(5, 8);
2551
- return zip;
2109
+ }
2110
+ __decorate([
2111
+ Type(() => CategoryForProduct),
2112
+ __metadata("design:type", CategoryForProduct)
2113
+ ], Product.prototype, "category", void 0);
2114
+ __decorate([
2115
+ Type(() => KitProduct),
2116
+ __metadata("design:type", Array)
2117
+ ], Product.prototype, "kitProducts", void 0);
2118
+
2119
+ class Variant extends BaseModel {
2120
+ static get identifiersFields() {
2121
+ return ['id', 'productId'];
2552
2122
  }
2553
2123
  }
2554
2124
 
2555
- class GlampointsPaymentService {
2556
- pay(checkout) {
2557
- const payment = {
2558
- createdAt: new Date(),
2559
- updatedAt: new Date(),
2560
- userId: checkout.user.id,
2561
- checkoutId: checkout.id,
2562
- totalPrice: checkout.totalPrice,
2563
- transaction: {
2564
- amount: 0,
2565
- acquirerResponseCode: '0000',
2566
- acquirerName: 'glampoints',
2567
- authorizedAmount: 0,
2568
- captureMethod: 'ecommerce',
2569
- installments: 1,
2570
- cost: 0,
2571
- paidAmount: 0,
2572
- paymentMethod: 'glampoints',
2573
- referer: 'api_key',
2574
- refundedAmount: 0,
2575
- status: 'paid',
2576
- statusReason: 'acquirer',
2577
- },
2578
- };
2579
- return Promise.resolve(payment);
2125
+ class Wishlist extends Category {
2126
+ static get identifiersFields() {
2127
+ return ['id'];
2580
2128
  }
2581
2129
  }
2582
2130
 
2583
- class PagarmeBankSlipService {
2584
- constructor(credentials) {
2585
- this.credentials = credentials;
2586
- }
2587
- async pay(checkout) {
2588
- try {
2589
- const result = await axios({
2590
- method: 'POST',
2591
- url: this.credentials.URL_TRANSACTION,
2592
- data: this.createBoletoPayment(checkout),
2593
- });
2594
- if (result.data.status !== 'processing') {
2595
- console.log('Erro ao gerar o boleto para o checkout: ');
2596
- return Promise.reject(new Error(`Erro ao gerar o boleto para o checkout: ${checkout.id}`));
2597
- }
2598
- const payment = {
2599
- createdAt: new Date(),
2600
- updatedAt: new Date(),
2601
- userId: checkout.user.id,
2602
- checkoutId: checkout.id,
2603
- totalPrice: checkout.totalPrice,
2604
- transaction: result.data,
2605
- };
2606
- return payment;
2607
- }
2608
- catch (error) {
2609
- console.log(error);
2610
- }
2131
+ class Buy2Win extends BaseModel {
2132
+ static get identifiersFields() {
2133
+ return ['id'];
2611
2134
  }
2612
- createBoletoPayment(checkout) {
2613
- return {
2614
- api_key: this.credentials.API_KEY,
2615
- amount: Math.floor(checkout.totalPrice * 100),
2616
- boleto_rules: ['strict_expiration_date'],
2617
- boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
2618
- boleto_expiration_date: moment().add(3, 'day').format('YYYY-MM-DD'),
2619
- payment_method: 'boleto',
2620
- postback_url: this.credentials.URL_POSTBACK,
2621
- customer: {
2622
- external_id: checkout.user.id,
2623
- type: 'individual',
2624
- country: 'br',
2625
- name: checkout.user.displayName,
2626
- documents: [
2627
- {
2628
- type: 'cpf',
2629
- number: checkout.user.cpf,
2630
- },
2631
- ],
2632
- },
2633
- };
2135
+ }
2136
+ __decorate([
2137
+ Type(() => Category),
2138
+ __metadata("design:type", Array)
2139
+ ], Buy2Win.prototype, "categories", void 0);
2140
+
2141
+ class CampaignDashboard extends BaseModel {
2142
+ static get identifiersFields() {
2143
+ return ['id'];
2634
2144
  }
2635
2145
  }
2636
2146
 
2637
- class PagarmeCardService {
2638
- constructor(credentials) {
2639
- this.credentials = credentials;
2640
- }
2641
- async pay(checkout, card) {
2642
- try {
2643
- const result = await axios({
2644
- method: 'POST',
2645
- url: this.credentials.URL_TRANSACTION,
2646
- data: this.createCardPayment(checkout, card),
2647
- });
2648
- if (result.data.status !== 'paid') {
2649
- this.checkoutAntiFraudService.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2650
- 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`));
2651
- }
2652
- const payment = {
2653
- createdAt: new Date(),
2654
- updatedAt: new Date(),
2655
- userId: checkout.user.id,
2656
- checkoutId: checkout.id,
2657
- totalPrice: checkout.totalPrice,
2658
- transaction: result.data,
2659
- };
2660
- return payment;
2661
- }
2662
- catch (error) {
2663
- console.log(error);
2664
- }
2665
- }
2666
- addCard() {
2667
- throw new Error('Method not implemented.');
2668
- }
2669
- createCardPayment(checkout, card) {
2670
- var _a, _b, _c, _d, _e, _f;
2671
- return {
2672
- api_key: this.credentials.API_KEY,
2673
- amount: Math.floor(checkout.totalPrice * 100),
2674
- card_id: card.cardId,
2675
- payment_method: 'credit_card',
2676
- installments: card.installments,
2677
- soft_descriptor: checkout.shop,
2678
- customer: {
2679
- external_id: checkout.user.id,
2680
- name: checkout.user.displayName,
2681
- type: 'individual',
2682
- country: 'br',
2683
- email: checkout.user.email,
2684
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2685
- documents: [
2686
- {
2687
- type: 'cpf',
2688
- number: checkout.user.cpf,
2689
- },
2690
- ],
2691
- },
2692
- billing: {
2693
- name: checkout.user.displayName,
2694
- address: {
2695
- country: 'br',
2696
- state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
2697
- city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
2698
- neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
2699
- street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
2700
- street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
2701
- zipcode: checkout.billingAddress
2702
- ? checkout.billingAddress.zip.replace('-', '')
2703
- : (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
2704
- },
2705
- },
2706
- items: checkout.lineItems.map((item) => {
2707
- return {
2708
- id: item.id,
2709
- title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
2710
- unit_price: Math.floor(item.pricePaid * 100),
2711
- quantity: item.quantity,
2712
- tangible: true,
2713
- };
2714
- }),
2715
- };
2147
+ class CampaignHashtag extends BaseModel {
2148
+ static get identifiersFields() {
2149
+ return ['id'];
2716
2150
  }
2717
2151
  }
2718
2152
 
2719
- class PagarmePixService {
2720
- constructor(credentials) {
2721
- this.credentials = credentials;
2153
+ class LineItem extends Product {
2154
+ }
2155
+
2156
+ class ShippingMethod extends BaseModel {
2157
+ static get identifiersFields() {
2158
+ return ['id'];
2722
2159
  }
2723
- async pay(checkout) {
2724
- try {
2725
- const result = await axios({
2726
- method: 'POST',
2727
- url: this.credentials.URL_TRANSACTION,
2728
- data: this.createPixPayment(checkout),
2729
- });
2730
- const payment = {
2731
- createdAt: new Date(),
2732
- updatedAt: new Date(),
2733
- userId: checkout.user.id,
2734
- checkoutId: checkout.id,
2735
- totalPrice: checkout.totalPrice,
2736
- transaction: result.data,
2737
- };
2738
- return payment;
2739
- }
2740
- catch (error) {
2741
- console.log(error);
2742
- }
2160
+ }
2161
+
2162
+ class Checkout extends BaseModel {
2163
+ static get identifiersFields() {
2164
+ return ['id'];
2743
2165
  }
2744
- createPixPayment(checkout) {
2745
- return {
2746
- payment_method: 'pix',
2747
- amount: Math.floor(checkout.totalPrice * 100),
2748
- api_key: this.credentials.API_KEY,
2749
- postback_url: this.credentials.URL_POSTBACK,
2750
- pix_expiration_date: moment().add(1, 'day').format('YYYY-MM-DD'),
2751
- customer: {
2752
- external_id: checkout.user.id,
2753
- type: 'individual',
2754
- country: 'br',
2755
- name: checkout.user.displayName,
2756
- email: checkout.user.email.trim(),
2757
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2758
- documents: [
2759
- {
2760
- type: 'cpf',
2761
- number: checkout.user.cpf,
2762
- },
2763
- ],
2764
- },
2765
- };
2166
+ }
2167
+ __decorate([
2168
+ Type(() => LineItem),
2169
+ __metadata("design:type", Array)
2170
+ ], Checkout.prototype, "lineItems", void 0);
2171
+ __decorate([
2172
+ Type(() => User),
2173
+ __metadata("design:type", User)
2174
+ ], Checkout.prototype, "user", void 0);
2175
+ __decorate([
2176
+ Type(() => UserAddress),
2177
+ __metadata("design:type", UserAddress)
2178
+ ], Checkout.prototype, "shippingAddress", void 0);
2179
+ __decorate([
2180
+ Type(() => UserAddress),
2181
+ __metadata("design:type", UserAddress)
2182
+ ], Checkout.prototype, "billingAddress", void 0);
2183
+ __decorate([
2184
+ Type(() => ShippingMethod),
2185
+ __metadata("design:type", ShippingMethod)
2186
+ ], Checkout.prototype, "shipping", void 0);
2187
+ __decorate([
2188
+ Type(() => Coupon),
2189
+ __metadata("design:type", Coupon)
2190
+ ], Checkout.prototype, "coupon", void 0);
2191
+
2192
+ var OrderStatus;
2193
+ (function (OrderStatus) {
2194
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
2195
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
2196
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
2197
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
2198
+ OrderStatus["ENVIADO"] = "Enviado";
2199
+ OrderStatus["ENTREGUE"] = "Entregue";
2200
+ OrderStatus["CANCELADO"] = "Cancelado";
2201
+ OrderStatus["CREDIT_CARD"] = "credit_card";
2202
+ })(OrderStatus || (OrderStatus = {}));
2203
+
2204
+ class Order extends Checkout {
2205
+ }
2206
+ __decorate([
2207
+ Type(() => Payment),
2208
+ __metadata("design:type", Payment)
2209
+ ], Order.prototype, "payment", void 0);
2210
+
2211
+ class CheckoutSubscription extends BaseModel {
2212
+ static get identifiersFields() {
2213
+ return ['id'];
2766
2214
  }
2767
- }
2215
+ }
2216
+ __decorate([
2217
+ Type(() => UserAddress),
2218
+ __metadata("design:type", UserAddress)
2219
+ ], CheckoutSubscription.prototype, "shippingAddress", void 0);
2220
+ __decorate([
2221
+ Type(() => UserAddress),
2222
+ __metadata("design:type", UserAddress)
2223
+ ], CheckoutSubscription.prototype, "billingAddress", void 0);
2224
+ __decorate([
2225
+ Type(() => SubscriptionPlan),
2226
+ __metadata("design:type", SubscriptionPlan)
2227
+ ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
2228
+ __decorate([
2229
+ Type(() => Coupon),
2230
+ __metadata("design:type", Coupon)
2231
+ ], CheckoutSubscription.prototype, "coupon", void 0);
2768
2232
 
2769
2233
  class RoundProductPricesHelper {
2770
2234
  static roundProductPrices(product) {
@@ -2780,12 +2244,6 @@ class RoundProductPricesHelper {
2780
2244
  }
2781
2245
  }
2782
2246
 
2783
- class Sequence extends BaseModel {
2784
- static get identifiersFields() {
2785
- return ['id'];
2786
- }
2787
- }
2788
-
2789
2247
  var FilterType;
2790
2248
  (function (FilterType) {
2791
2249
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -3300,7 +2758,7 @@ const withFindFirestore = (MixinBase) => {
3300
2758
  const collection = this.collection(this.buildCollectionPathForFind(find.filters));
3301
2759
  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;
3302
2760
  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 }));
3303
- const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
2761
+ const { filters, limits, orderBy } = intercepted.find || find;
3304
2762
  const queries = this.makeFirestoreWhere(filters || {});
3305
2763
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
3306
2764
  const offsets = await this.defineLimits(filters, limits);
@@ -3458,6 +2916,139 @@ const withCrudFirestore = (MixinBase) => {
3458
2916
  };
3459
2917
  };
3460
2918
 
2919
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2920
+ constructor({ firestore, interceptors }) {
2921
+ super({
2922
+ firestore,
2923
+ collectionName: 'leads',
2924
+ model: Lead,
2925
+ interceptors,
2926
+ });
2927
+ }
2928
+ }
2929
+
2930
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2931
+ constructor({ firestore, interceptors }, parentRepository) {
2932
+ super({
2933
+ firestore,
2934
+ collectionName: 'editions',
2935
+ parentIdField: 'subscriptionId',
2936
+ model: Edition,
2937
+ interceptors,
2938
+ });
2939
+ this.parentRepository = parentRepository;
2940
+ }
2941
+ }
2942
+
2943
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2944
+ constructor({ firestore, interceptors, }) {
2945
+ super({
2946
+ firestore,
2947
+ collectionName: 'subscription',
2948
+ model: Subscription,
2949
+ interceptors,
2950
+ });
2951
+ }
2952
+ }
2953
+
2954
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2955
+ constructor({ firestore, interceptors }, parentRepository) {
2956
+ super({
2957
+ firestore,
2958
+ collectionName: 'payments',
2959
+ parentIdField: 'subscriptionId',
2960
+ model: SubscriptionPayment,
2961
+ interceptors,
2962
+ });
2963
+ this.parentRepository = parentRepository;
2964
+ }
2965
+ }
2966
+
2967
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2968
+ constructor({ firestore, interceptors }, parentRepository) {
2969
+ super({
2970
+ firestore,
2971
+ collectionName: 'address',
2972
+ parentIdField: 'userId',
2973
+ model: UserAddress,
2974
+ interceptors,
2975
+ });
2976
+ this.parentRepository = parentRepository;
2977
+ }
2978
+ }
2979
+
2980
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2981
+ constructor({ firestore, interceptors }, parentRepository) {
2982
+ super({
2983
+ firestore,
2984
+ collectionName: 'CX',
2985
+ parentIdField: 'userId',
2986
+ model: BeautyProfile,
2987
+ interceptors,
2988
+ });
2989
+ this.parentRepository = parentRepository;
2990
+ }
2991
+ }
2992
+
2993
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2994
+ constructor({ firestore, interceptors }) {
2995
+ super({
2996
+ firestore,
2997
+ collectionName: 'users',
2998
+ model: User,
2999
+ interceptors,
3000
+ });
3001
+ }
3002
+ async get(identifiers) {
3003
+ const user = await super.get({ id: identifiers.id });
3004
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3005
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3006
+ return user;
3007
+ }
3008
+ async checkIfExistsByField(field, value) {
3009
+ const result = await this.find({ filters: { [field]: value } });
3010
+ return result.count > 0;
3011
+ }
3012
+ buildModelInstance() {
3013
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3014
+ return {
3015
+ toFirestore: (data) => {
3016
+ const plain = toFirestore(data);
3017
+ delete plain.isSubscriber;
3018
+ return plain;
3019
+ },
3020
+ fromFirestore,
3021
+ };
3022
+ }
3023
+ async getBeautyProfile(userId) {
3024
+ const beautyProfile = await getDoc(doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
3025
+ return beautyProfile.data();
3026
+ }
3027
+ async checkIfIsSubscriber(userId) {
3028
+ const docs = await getDocs(query(this.collection('subscription'), where('user.id', '==', userId), where('status', '==', 'active')));
3029
+ return !!docs && !!docs.size;
3030
+ }
3031
+ buildBeautyProfileModelInstance() {
3032
+ return {
3033
+ toFirestore: (data) => data.toPlain(),
3034
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3035
+ };
3036
+ }
3037
+ }
3038
+
3039
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3040
+ constructor({ firestore, interceptors }, parentRepository) {
3041
+ super({
3042
+ firestore,
3043
+ collectionName: 'payment_method',
3044
+ parentIdField: 'userId',
3045
+ model: UserPaymentMethod,
3046
+ interceptors,
3047
+ });
3048
+ this.parentRepository = parentRepository;
3049
+ }
3050
+ }
3051
+
3461
3052
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3462
3053
  constructor({ firestore, interceptors }) {
3463
3054
  super({
@@ -3538,155 +3129,60 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3538
3129
  },
3539
3130
  });
3540
3131
  return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3541
- }
3542
- async fetchReviews(status) {
3543
- const { data: products } = await this.find();
3544
- products.forEach((product) => {
3545
- var _a;
3546
- if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3547
- return;
3548
- const productInfo = {
3549
- productId: product.id,
3550
- productName: product.name,
3551
- productSku: product.sku,
3552
- };
3553
- this.reviews.pending = [];
3554
- this.reviews.approved = [];
3555
- this.reviews.rejected = [];
3556
- product.reviews.forEach((review) => {
3557
- if ([null, undefined].includes(review.status))
3558
- return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3559
- if (review.status === false)
3560
- return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3561
- if (!!review.status)
3562
- return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3563
- return review;
3564
- });
3565
- });
3566
- return this.reviews[status];
3567
- }
3568
- cleanShoppingCountFromIds() {
3569
- return;
3570
- }
3571
- findCatalog(params) {
3572
- return this.find(params);
3573
- }
3574
- }
3575
-
3576
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3577
- constructor({ firestore, interceptors }, parentRepository) {
3578
- super({
3579
- firestore,
3580
- collectionName: 'variants',
3581
- parentIdField: 'productId',
3582
- model: Variant,
3583
- interceptors,
3584
- });
3585
- this.parentRepository = parentRepository;
3586
- }
3587
- }
3588
-
3589
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3590
- constructor({ firestore, interceptors }) {
3591
- super({
3592
- firestore,
3593
- collectionName: 'subscriptionProducts',
3594
- model: Product,
3595
- interceptors,
3596
- });
3597
- }
3598
- }
3599
-
3600
- class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3601
- constructor({ firestore, interceptors }) {
3602
- super({
3603
- firestore,
3604
- collectionName: 'sequences',
3605
- model: Sequence,
3606
- interceptors,
3607
- });
3608
- }
3609
- }
3610
-
3611
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3612
- constructor({ firestore, interceptors }) {
3613
- super({
3614
- firestore,
3615
- collectionName: 'dms',
3616
- model: Home,
3617
- interceptors,
3618
- });
3619
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3620
- var _a, _b, _c;
3621
- return ({
3622
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3623
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3624
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3625
- 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)) || [],
3626
- });
3627
- };
3628
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3132
+ }
3133
+ async fetchReviews(status) {
3134
+ const { data: products } = await this.find();
3135
+ products.forEach((product) => {
3629
3136
  var _a;
3630
- return ({
3631
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3632
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3137
+ if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
3138
+ return;
3139
+ const productInfo = {
3140
+ productId: product.id,
3141
+ productName: product.name,
3142
+ productSku: product.sku,
3143
+ };
3144
+ this.reviews.pending = [];
3145
+ this.reviews.approved = [];
3146
+ this.reviews.rejected = [];
3147
+ product.reviews.forEach((review) => {
3148
+ if ([null, undefined].includes(review.status))
3149
+ return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
3150
+ if (review.status === false)
3151
+ return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3152
+ if (!!review.status)
3153
+ return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3154
+ return review;
3633
3155
  });
3634
- };
3635
- }
3636
- buildModelInstance() {
3637
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3638
- return {
3639
- toFirestore: (data) => {
3640
- const modifiedData = this.homeToFirestore(data);
3641
- return toFirestore(modifiedData);
3642
- },
3643
- fromFirestore: (snap) => {
3644
- const instance = fromFirestore(snap);
3645
- return this.homeFromFirestore(instance);
3646
- },
3647
- };
3156
+ });
3157
+ return this.reviews[status];
3648
3158
  }
3649
- homeToFirestore(home) {
3650
- var _a, _b, _c, _d;
3651
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3652
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3653
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3654
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3655
- }
3656
- return home;
3159
+ cleanShoppingCountFromIds() {
3160
+ return;
3657
3161
  }
3658
- homeFromFirestore(home) {
3659
- var _a;
3660
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3661
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3662
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3663
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3664
- home.data.createdAt =
3665
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3666
- home.data.expiresAt =
3667
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3668
- }
3669
- return home;
3162
+ findCatalog(params) {
3163
+ return this.find(params);
3670
3164
  }
3671
3165
  }
3672
3166
 
3673
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3674
- constructor({ firestore, interceptors }) {
3167
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3168
+ constructor({ firestore, interceptors }, parentRepository) {
3675
3169
  super({
3676
3170
  firestore,
3677
- collectionName: 'shopMenus',
3678
- model: ShopMenu,
3171
+ collectionName: 'variants',
3172
+ parentIdField: 'productId',
3173
+ model: Variant,
3679
3174
  interceptors,
3680
3175
  });
3176
+ this.parentRepository = parentRepository;
3681
3177
  }
3682
3178
  }
3683
3179
 
3684
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3685
- constructor({ firestore, interceptors, }) {
3180
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3181
+ constructor({ firestore, interceptors }) {
3686
3182
  super({
3687
3183
  firestore,
3688
- collectionName: 'shopSettings',
3689
- model: ShopSettings,
3184
+ collectionName: 'subscriptionProducts',
3185
+ model: Product,
3690
3186
  interceptors,
3691
3187
  });
3692
3188
  }
@@ -3822,17 +3318,6 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3822
3318
  }
3823
3319
  }
3824
3320
 
3825
- class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3826
- constructor({ firestore, interceptors, }) {
3827
- super({
3828
- firestore,
3829
- collectionName: 'paymentBlockedAttempts',
3830
- model: OrderBlocked,
3831
- interceptors,
3832
- });
3833
- }
3834
- }
3835
-
3836
3321
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3837
3322
  constructor({ firestore, interceptors }) {
3838
3323
  super({
@@ -3855,136 +3340,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3855
3340
  }
3856
3341
  }
3857
3342
 
3858
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3343
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3859
3344
  constructor({ firestore, interceptors }) {
3860
3345
  super({
3861
3346
  firestore,
3862
- collectionName: 'leads',
3863
- model: Lead,
3864
- interceptors,
3865
- });
3866
- }
3867
- }
3868
-
3869
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3870
- constructor({ firestore, interceptors }, parentRepository) {
3871
- super({
3872
- firestore,
3873
- collectionName: 'editions',
3874
- parentIdField: 'subscriptionId',
3875
- model: Edition,
3876
- interceptors,
3877
- });
3878
- this.parentRepository = parentRepository;
3879
- }
3880
- }
3881
-
3882
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3883
- constructor({ firestore, interceptors, }) {
3884
- super({
3885
- firestore,
3886
- collectionName: 'subscription',
3887
- model: Subscription,
3347
+ collectionName: 'dms',
3348
+ model: Home,
3888
3349
  interceptors,
3889
3350
  });
3351
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3352
+ var _a, _b, _c;
3353
+ return ({
3354
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3355
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3356
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3357
+ 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)) || [],
3358
+ });
3359
+ };
3360
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3361
+ var _a;
3362
+ return ({
3363
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3364
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3365
+ });
3366
+ };
3890
3367
  }
3891
- }
3892
-
3893
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3894
- constructor({ firestore, interceptors }, parentRepository) {
3895
- super({
3896
- firestore,
3897
- collectionName: 'payments',
3898
- parentIdField: 'subscriptionId',
3899
- model: SubscriptionPayment,
3900
- interceptors,
3901
- });
3902
- this.parentRepository = parentRepository;
3368
+ buildModelInstance() {
3369
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3370
+ return {
3371
+ toFirestore: (data) => {
3372
+ const modifiedData = this.homeToFirestore(data);
3373
+ return toFirestore(modifiedData);
3374
+ },
3375
+ fromFirestore: (snap) => {
3376
+ const instance = fromFirestore(snap);
3377
+ return this.homeFromFirestore(instance);
3378
+ },
3379
+ };
3903
3380
  }
3904
- }
3905
-
3906
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3907
- constructor({ firestore, interceptors }, parentRepository) {
3908
- super({
3909
- firestore,
3910
- collectionName: 'address',
3911
- parentIdField: 'userId',
3912
- model: UserAddress,
3913
- interceptors,
3914
- });
3915
- this.parentRepository = parentRepository;
3381
+ homeToFirestore(home) {
3382
+ var _a, _b, _c, _d;
3383
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3384
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3385
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3386
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3387
+ }
3388
+ return home;
3916
3389
  }
3917
- }
3918
-
3919
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3920
- constructor({ firestore, interceptors }, parentRepository) {
3921
- super({
3922
- firestore,
3923
- collectionName: 'CX',
3924
- parentIdField: 'userId',
3925
- model: BeautyProfile,
3926
- interceptors,
3927
- });
3928
- this.parentRepository = parentRepository;
3390
+ homeFromFirestore(home) {
3391
+ var _a;
3392
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3393
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3394
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3395
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3396
+ home.data.createdAt =
3397
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3398
+ home.data.expiresAt =
3399
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3400
+ }
3401
+ return home;
3929
3402
  }
3930
3403
  }
3931
3404
 
3932
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3405
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3933
3406
  constructor({ firestore, interceptors }) {
3934
3407
  super({
3935
3408
  firestore,
3936
- collectionName: 'users',
3937
- model: User,
3409
+ collectionName: 'shopMenus',
3410
+ model: ShopMenu,
3938
3411
  interceptors,
3939
3412
  });
3940
3413
  }
3941
- async get(identifiers) {
3942
- const user = await super.get({ id: identifiers.id });
3943
- user.beautyProfile = await this.getBeautyProfile(user.id);
3944
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3945
- return user;
3946
- }
3947
- async checkIfExistsByField(field, value) {
3948
- const result = await this.find({ filters: { [field]: value } });
3949
- return result.count > 0;
3950
- }
3951
- buildModelInstance() {
3952
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3953
- return {
3954
- toFirestore: (data) => {
3955
- const plain = toFirestore(data);
3956
- delete plain.isSubscriber;
3957
- return plain;
3958
- },
3959
- fromFirestore,
3960
- };
3961
- }
3962
- async getBeautyProfile(userId) {
3963
- const beautyProfile = await getDoc(doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
3964
- return beautyProfile.data();
3965
- }
3966
- async checkIfIsSubscriber(userId) {
3967
- const docs = await getDocs(query(this.collection('subscription'), where('user.id', '==', userId), where('status', '==', 'active')));
3968
- return !!docs && !!docs.size;
3969
- }
3970
- buildBeautyProfileModelInstance() {
3971
- return {
3972
- toFirestore: (data) => data.toPlain(),
3973
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3974
- };
3975
- }
3976
3414
  }
3977
3415
 
3978
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3979
- constructor({ firestore, interceptors }, parentRepository) {
3416
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3417
+ constructor({ firestore, interceptors, }) {
3980
3418
  super({
3981
3419
  firestore,
3982
- collectionName: 'payment_method',
3983
- parentIdField: 'userId',
3984
- model: UserPaymentMethod,
3420
+ collectionName: 'shopSettings',
3421
+ model: ShopSettings,
3985
3422
  interceptors,
3986
3423
  });
3987
- this.parentRepository = parentRepository;
3988
3424
  }
3989
3425
  }
3990
3426
 
@@ -6074,4 +5510,4 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6074
5510
  }
6075
5511
  }
6076
5512
 
6077
- export { AccessoryImportances, Address, AdyenCardService, AdyenPaymentMethodFactory, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutAntiFraudService, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, GlampointsPaymentMethodFactory, GlampointsPaymentService, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderBlocked, OrderBlockedFirestoreRepository, OrderFirestoreRepository, OrderStatus, PagarmeBankSlipService, PagarmeCardService, PagarmePaymentMethodFactory, PagarmePixService, Payment, PaymentFirestoreRepository, PaymentMethods, PaymentProviderFactory, PaymentProviders, PaymentTransaction, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, Sequence, SequenceFirestoreRepository, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
5513
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Campaign, CampaignBanner, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };