@infrab4a/connect 4.1.2-beta.5 → 4.1.2-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('reflect-metadata');
6
- var classTransformer = require('class-transformer');
7
6
  var tslib_1 = require('tslib');
7
+ var classTransformer = require('class-transformer');
8
8
  var dateFns = require('date-fns');
9
9
  var lodash = require('lodash');
10
10
  var debug = require('debug');
@@ -60,6 +60,181 @@ class BaseModel {
60
60
  }
61
61
  }
62
62
 
63
+ class Filter extends BaseModel {
64
+ static get identifiersFields() {
65
+ return ['id'];
66
+ }
67
+ }
68
+
69
+ class CategoryBase extends BaseModel {
70
+ static get identifiersFields() {
71
+ return ['id'];
72
+ }
73
+ }
74
+ tslib_1.__decorate([
75
+ classTransformer.Type(() => CategoryBase),
76
+ tslib_1.__metadata("design:type", CategoryBase)
77
+ ], CategoryBase.prototype, "parent", void 0);
78
+ tslib_1.__decorate([
79
+ classTransformer.Type(() => Filter),
80
+ tslib_1.__metadata("design:type", Array)
81
+ ], CategoryBase.prototype, "filters", void 0);
82
+
83
+ class CategoryForProduct extends CategoryBase {
84
+ static get identifiersFields() {
85
+ return ['id'];
86
+ }
87
+ }
88
+
89
+ class ProductBase extends BaseModel {
90
+ get evaluation() {
91
+ return {
92
+ reviews: this.reviews,
93
+ count: this.reviewsTotal,
94
+ rating: this.rate,
95
+ };
96
+ }
97
+ set evaluation(evaluation) {
98
+ if (!evaluation) {
99
+ this.reviews = null;
100
+ this.reviewsTotal = null;
101
+ this.rate = null;
102
+ return;
103
+ }
104
+ this.reviews = evaluation.reviews || this.reviews;
105
+ this.reviewsTotal = evaluation.count || this.reviewsTotal;
106
+ this.rate = evaluation.rating || this.rate;
107
+ }
108
+ static get identifiersFields() {
109
+ return ['id'];
110
+ }
111
+ }
112
+
113
+ class ProductForKit extends ProductBase {
114
+ static get identifiersFields() {
115
+ return ['id'];
116
+ }
117
+ }
118
+ tslib_1.__decorate([
119
+ classTransformer.Type(() => CategoryForProduct),
120
+ tslib_1.__metadata("design:type", CategoryForProduct)
121
+ ], ProductForKit.prototype, "category", void 0);
122
+
123
+ class KitProduct extends BaseModel {
124
+ static get identifiersFields() {
125
+ return ['productId', 'kitProductId'];
126
+ }
127
+ }
128
+ tslib_1.__decorate([
129
+ classTransformer.Type(() => ProductForKit),
130
+ tslib_1.__metadata("design:type", ProductForKit)
131
+ ], KitProduct.prototype, "kit", void 0);
132
+ tslib_1.__decorate([
133
+ classTransformer.Type(() => ProductForKit),
134
+ tslib_1.__metadata("design:type", ProductForKit)
135
+ ], KitProduct.prototype, "product", void 0);
136
+
137
+ class ProductForCategory extends ProductBase {
138
+ static get identifiersFields() {
139
+ return ['id'];
140
+ }
141
+ }
142
+ tslib_1.__decorate([
143
+ classTransformer.Type(() => KitProduct),
144
+ tslib_1.__metadata("design:type", Array)
145
+ ], ProductForCategory.prototype, "kitProducts", void 0);
146
+
147
+ class Category extends CategoryBase {
148
+ static get identifiersFields() {
149
+ return ['id'];
150
+ }
151
+ }
152
+ tslib_1.__decorate([
153
+ classTransformer.Type(() => ProductForCategory),
154
+ tslib_1.__metadata("design:type", Array)
155
+ ], Category.prototype, "childrenProducts", void 0);
156
+
157
+ class CategoryCollectionChildren extends BaseModel {
158
+ static get identifiersFields() {
159
+ return ['collectionId', 'categoryId'];
160
+ }
161
+ }
162
+ tslib_1.__decorate([
163
+ classTransformer.Type(() => CategoryCollectionChildren),
164
+ tslib_1.__metadata("design:type", CategoryCollectionChildren)
165
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
166
+
167
+ class CategoryFilter extends BaseModel {
168
+ static get identifiersFields() {
169
+ return ['id'];
170
+ }
171
+ }
172
+ tslib_1.__decorate([
173
+ classTransformer.Type(() => Filter),
174
+ tslib_1.__metadata("design:type", Filter)
175
+ ], CategoryFilter.prototype, "filter", void 0);
176
+ tslib_1.__decorate([
177
+ classTransformer.Type(() => Category),
178
+ tslib_1.__metadata("design:type", Category)
179
+ ], CategoryFilter.prototype, "category", void 0);
180
+
181
+ exports.GenderDestination = void 0;
182
+ (function (GenderDestination) {
183
+ GenderDestination["FEMALE"] = "female";
184
+ GenderDestination["MALE"] = "male";
185
+ GenderDestination["UNISEX"] = "unisex";
186
+ })(exports.GenderDestination || (exports.GenderDestination = {}));
187
+
188
+ exports.Shops = void 0;
189
+ (function (Shops) {
190
+ Shops["MENSMARKET"] = "mensmarket";
191
+ Shops["GLAMSHOP"] = "Glamshop";
192
+ Shops["GLAMPOINTS"] = "Glampoints";
193
+ Shops["ALL"] = "ALL";
194
+ })(exports.Shops || (exports.Shops = {}));
195
+
196
+ class FilterOption extends BaseModel {
197
+ static get identifiersFields() {
198
+ return ['id'];
199
+ }
200
+ }
201
+
202
+ class Product extends ProductBase {
203
+ static get identifiersFields() {
204
+ return ['id'];
205
+ }
206
+ }
207
+ tslib_1.__decorate([
208
+ classTransformer.Type(() => CategoryForProduct),
209
+ tslib_1.__metadata("design:type", CategoryForProduct)
210
+ ], Product.prototype, "category", void 0);
211
+ tslib_1.__decorate([
212
+ classTransformer.Type(() => KitProduct),
213
+ tslib_1.__metadata("design:type", Array)
214
+ ], Product.prototype, "kitProducts", void 0);
215
+
216
+ class Variant extends BaseModel {
217
+ static get identifiersFields() {
218
+ return ['id', 'productId'];
219
+ }
220
+ }
221
+
222
+ class Wishlist extends Category {
223
+ static get identifiersFields() {
224
+ return ['id'];
225
+ }
226
+ }
227
+
228
+ class Buy2Win extends BaseModel {
229
+ static get identifiersFields() {
230
+ return ['id'];
231
+ }
232
+ }
233
+ tslib_1.__decorate([
234
+ classTransformer.Type(() => Category),
235
+ tslib_1.__metadata("design:type", Array)
236
+ ], Buy2Win.prototype, "categories", void 0);
237
+
63
238
  exports.Where = void 0;
64
239
  (function (Where) {
65
240
  Where["EQUALS"] = "==";
@@ -85,6 +260,18 @@ exports.UpdateOptionActions = void 0;
85
260
  UpdateOptionActions["NULL"] = "null";
86
261
  })(exports.UpdateOptionActions || (exports.UpdateOptionActions = {}));
87
262
 
263
+ class CampaignDashboard extends BaseModel {
264
+ static get identifiersFields() {
265
+ return ['id'];
266
+ }
267
+ }
268
+
269
+ class CampaignHashtag extends BaseModel {
270
+ static get identifiersFields() {
271
+ return ['id'];
272
+ }
273
+ }
274
+
88
275
  exports.AccessoryImportances = void 0;
89
276
  (function (AccessoryImportances) {
90
277
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -311,7 +498,7 @@ class Edition extends BaseModel {
311
498
  }
312
499
  }
313
500
 
314
- class Payment extends BaseModel {
501
+ class Transaction extends BaseModel {
315
502
  static get identifiersFields() {
316
503
  return ['id'];
317
504
  }
@@ -319,163 +506,173 @@ class Payment extends BaseModel {
319
506
  tslib_1.__decorate([
320
507
  classTransformer.Expose({ name: 'refuse_reason' }),
321
508
  tslib_1.__metadata("design:type", String)
322
- ], Payment.prototype, "refuseReason", void 0);
509
+ ], Transaction.prototype, "refuseReason", void 0);
323
510
  tslib_1.__decorate([
324
511
  classTransformer.Expose({ name: 'status_reason' }),
325
512
  tslib_1.__metadata("design:type", String)
326
- ], Payment.prototype, "statusReason", void 0);
513
+ ], Transaction.prototype, "statusReason", void 0);
327
514
  tslib_1.__decorate([
328
515
  classTransformer.Expose({ name: 'acquirer_response_code' }),
329
516
  tslib_1.__metadata("design:type", String)
330
- ], Payment.prototype, "acquirerResponseCode", void 0);
517
+ ], Transaction.prototype, "acquirerResponseCode", void 0);
331
518
  tslib_1.__decorate([
332
519
  classTransformer.Expose({ name: 'acquirer_name' }),
333
520
  tslib_1.__metadata("design:type", String)
334
- ], Payment.prototype, "acquirerName", void 0);
521
+ ], Transaction.prototype, "acquirerName", void 0);
335
522
  tslib_1.__decorate([
336
523
  classTransformer.Expose({ name: 'acquirer_id' }),
337
524
  tslib_1.__metadata("design:type", String)
338
- ], Payment.prototype, "acquirerId", void 0);
525
+ ], Transaction.prototype, "acquirerId", void 0);
339
526
  tslib_1.__decorate([
340
527
  classTransformer.Expose({ name: 'authorization_code' }),
341
528
  tslib_1.__metadata("design:type", String)
342
- ], Payment.prototype, "authorizationCode", void 0);
529
+ ], Transaction.prototype, "authorizationCode", void 0);
343
530
  tslib_1.__decorate([
344
531
  classTransformer.Expose({ name: 'soft_descriptor' }),
345
532
  tslib_1.__metadata("design:type", String)
346
- ], Payment.prototype, "softDescriptor", void 0);
533
+ ], Transaction.prototype, "softDescriptor", void 0);
347
534
  tslib_1.__decorate([
348
535
  classTransformer.Expose({ name: 'date_created' }),
349
536
  tslib_1.__metadata("design:type", String)
350
- ], Payment.prototype, "dateCreated", void 0);
537
+ ], Transaction.prototype, "dateCreated", void 0);
351
538
  tslib_1.__decorate([
352
539
  classTransformer.Expose({ name: 'date_updated' }),
353
540
  tslib_1.__metadata("design:type", String)
354
- ], Payment.prototype, "dateUpdated", void 0);
541
+ ], Transaction.prototype, "dateUpdated", void 0);
355
542
  tslib_1.__decorate([
356
543
  classTransformer.Expose({ name: 'authorized_amount' }),
357
544
  tslib_1.__metadata("design:type", Number)
358
- ], Payment.prototype, "authorizedAmount", void 0);
545
+ ], Transaction.prototype, "authorizedAmount", void 0);
359
546
  tslib_1.__decorate([
360
547
  classTransformer.Expose({ name: 'paid_amount' }),
361
548
  tslib_1.__metadata("design:type", Number)
362
- ], Payment.prototype, "paidAmount", void 0);
549
+ ], Transaction.prototype, "paidAmount", void 0);
363
550
  tslib_1.__decorate([
364
551
  classTransformer.Expose({ name: 'refunded_amount' }),
365
552
  tslib_1.__metadata("design:type", Number)
366
- ], Payment.prototype, "refundedAmount", void 0);
553
+ ], Transaction.prototype, "refundedAmount", void 0);
367
554
  tslib_1.__decorate([
368
555
  classTransformer.Expose({ name: 'card_holder_name' }),
369
556
  tslib_1.__metadata("design:type", String)
370
- ], Payment.prototype, "cardHolderName", void 0);
557
+ ], Transaction.prototype, "cardHolderName", void 0);
371
558
  tslib_1.__decorate([
372
559
  classTransformer.Expose({ name: 'card_last_digits' }),
373
560
  tslib_1.__metadata("design:type", String)
374
- ], Payment.prototype, "cardLastDigits", void 0);
561
+ ], Transaction.prototype, "cardLastDigits", void 0);
375
562
  tslib_1.__decorate([
376
563
  classTransformer.Expose({ name: 'card_first_digits' }),
377
564
  tslib_1.__metadata("design:type", String)
378
- ], Payment.prototype, "cardFirstDigits", void 0);
565
+ ], Transaction.prototype, "cardFirstDigits", void 0);
379
566
  tslib_1.__decorate([
380
567
  classTransformer.Expose({ name: 'card_brand' }),
381
568
  tslib_1.__metadata("design:type", String)
382
- ], Payment.prototype, "cardBrand", void 0);
569
+ ], Transaction.prototype, "cardBrand", void 0);
383
570
  tslib_1.__decorate([
384
571
  classTransformer.Expose({ name: 'card_pin_mode' }),
385
572
  tslib_1.__metadata("design:type", String)
386
- ], Payment.prototype, "cardPinMode", void 0);
573
+ ], Transaction.prototype, "cardPinMode", void 0);
387
574
  tslib_1.__decorate([
388
575
  classTransformer.Expose({ name: 'card_magstripe_fallback' }),
389
576
  tslib_1.__metadata("design:type", Boolean)
390
- ], Payment.prototype, "cardMagstripeFallback", void 0);
577
+ ], Transaction.prototype, "cardMagstripeFallback", void 0);
391
578
  tslib_1.__decorate([
392
579
  classTransformer.Expose({ name: 'cvm_pin' }),
393
580
  tslib_1.__metadata("design:type", Boolean)
394
- ], Payment.prototype, "cvmPin", void 0);
581
+ ], Transaction.prototype, "cvmPin", void 0);
395
582
  tslib_1.__decorate([
396
583
  classTransformer.Expose({ name: 'postback_url' }),
397
584
  tslib_1.__metadata("design:type", String)
398
- ], Payment.prototype, "postbackUrl", void 0);
585
+ ], Transaction.prototype, "postbackUrl", void 0);
399
586
  tslib_1.__decorate([
400
587
  classTransformer.Expose({ name: 'payment_method' }),
401
588
  tslib_1.__metadata("design:type", String)
402
- ], Payment.prototype, "paymentMethod", void 0);
589
+ ], Transaction.prototype, "paymentMethod", void 0);
403
590
  tslib_1.__decorate([
404
591
  classTransformer.Expose({ name: 'capture_method' }),
405
592
  tslib_1.__metadata("design:type", String)
406
- ], Payment.prototype, "captureMethod", void 0);
593
+ ], Transaction.prototype, "captureMethod", void 0);
407
594
  tslib_1.__decorate([
408
595
  classTransformer.Expose({ name: 'antifraud_score' }),
409
596
  tslib_1.__metadata("design:type", String)
410
- ], Payment.prototype, "antifraudScore", void 0);
597
+ ], Transaction.prototype, "antifraudScore", void 0);
411
598
  tslib_1.__decorate([
412
599
  classTransformer.Expose({ name: 'boleto_url' }),
413
600
  tslib_1.__metadata("design:type", String)
414
- ], Payment.prototype, "boletoUrl", void 0);
601
+ ], Transaction.prototype, "boletoUrl", void 0);
415
602
  tslib_1.__decorate([
416
603
  classTransformer.Expose({ name: 'boleto_barcode' }),
417
604
  tslib_1.__metadata("design:type", String)
418
- ], Payment.prototype, "boletoBarcode", void 0);
605
+ ], Transaction.prototype, "boletoBarcode", void 0);
419
606
  tslib_1.__decorate([
420
607
  classTransformer.Expose({ name: 'boleto_expiration_date' }),
421
608
  tslib_1.__metadata("design:type", String)
422
- ], Payment.prototype, "boletoExpirationDate", void 0);
609
+ ], Transaction.prototype, "boletoExpirationDate", void 0);
423
610
  tslib_1.__decorate([
424
611
  classTransformer.Expose({ name: 'subscription_id' }),
425
612
  tslib_1.__metadata("design:type", String)
426
- ], Payment.prototype, "subscriptionId", void 0);
613
+ ], Transaction.prototype, "subscriptionId", void 0);
427
614
  tslib_1.__decorate([
428
615
  classTransformer.Expose({ name: 'split_rules' }),
429
616
  tslib_1.__metadata("design:type", String)
430
- ], Payment.prototype, "splitRules", void 0);
617
+ ], Transaction.prototype, "splitRules", void 0);
431
618
  tslib_1.__decorate([
432
619
  classTransformer.Expose({ name: 'antifraud_metadata' }),
433
620
  tslib_1.__metadata("design:type", Object)
434
- ], Payment.prototype, "antifraudMetadata", void 0);
621
+ ], Transaction.prototype, "antifraudMetadata", void 0);
435
622
  tslib_1.__decorate([
436
623
  classTransformer.Expose({ name: 'reference_key' }),
437
624
  tslib_1.__metadata("design:type", String)
438
- ], Payment.prototype, "referenceKey", void 0);
625
+ ], Transaction.prototype, "referenceKey", void 0);
439
626
  tslib_1.__decorate([
440
627
  classTransformer.Expose({ name: 'local_transaction_id' }),
441
628
  tslib_1.__metadata("design:type", String)
442
- ], Payment.prototype, "localTransactionId", void 0);
629
+ ], Transaction.prototype, "localTransactionId", void 0);
443
630
  tslib_1.__decorate([
444
631
  classTransformer.Expose({ name: 'local_time' }),
445
632
  tslib_1.__metadata("design:type", String)
446
- ], Payment.prototype, "localTime", void 0);
633
+ ], Transaction.prototype, "localTime", void 0);
447
634
  tslib_1.__decorate([
448
635
  classTransformer.Expose({ name: 'fraud_covered' }),
449
636
  tslib_1.__metadata("design:type", Boolean)
450
- ], Payment.prototype, "fraudCovered", void 0);
637
+ ], Transaction.prototype, "fraudCovered", void 0);
451
638
  tslib_1.__decorate([
452
639
  classTransformer.Expose({ name: 'fraud_reimbursed' }),
453
640
  tslib_1.__metadata("design:type", String)
454
- ], Payment.prototype, "fraudReimbursed", void 0);
641
+ ], Transaction.prototype, "fraudReimbursed", void 0);
455
642
  tslib_1.__decorate([
456
643
  classTransformer.Expose({ name: 'order_id' }),
457
644
  tslib_1.__metadata("design:type", String)
458
- ], Payment.prototype, "orderId", void 0);
645
+ ], Transaction.prototype, "orderId", void 0);
459
646
  tslib_1.__decorate([
460
647
  classTransformer.Expose({ name: 'risk_level' }),
461
648
  tslib_1.__metadata("design:type", String)
462
- ], Payment.prototype, "riskLevel", void 0);
649
+ ], Transaction.prototype, "riskLevel", void 0);
463
650
  tslib_1.__decorate([
464
651
  classTransformer.Expose({ name: 'receipt_url' }),
465
652
  tslib_1.__metadata("design:type", String)
466
- ], Payment.prototype, "receiptUrl", void 0);
653
+ ], Transaction.prototype, "receiptUrl", void 0);
467
654
  tslib_1.__decorate([
468
655
  classTransformer.Expose({ name: 'private_label' }),
469
656
  tslib_1.__metadata("design:type", String)
470
- ], Payment.prototype, "privateLabel", void 0);
657
+ ], Transaction.prototype, "privateLabel", void 0);
471
658
  tslib_1.__decorate([
472
659
  classTransformer.Expose({ name: 'pix_qr_code' }),
473
660
  tslib_1.__metadata("design:type", String)
474
- ], Payment.prototype, "pixQrCode", void 0);
661
+ ], Transaction.prototype, "pixQrCode", void 0);
475
662
  tslib_1.__decorate([
476
663
  classTransformer.Expose({ name: 'pix_expiration_date' }),
477
664
  tslib_1.__metadata("design:type", String)
478
- ], Payment.prototype, "pixExpirationDate", void 0);
665
+ ], Transaction.prototype, "pixExpirationDate", void 0);
666
+
667
+ class Payment extends BaseModel {
668
+ static get identifiersFields() {
669
+ return ['id'];
670
+ }
671
+ }
672
+ tslib_1.__decorate([
673
+ classTransformer.Type(() => Transaction),
674
+ tslib_1.__metadata("design:type", Transaction)
675
+ ], Payment.prototype, "transaction", void 0);
479
676
 
480
677
  class SubscriptionPayment extends BaseModel {
481
678
  static get identifiersFields() {
@@ -1987,251 +2184,70 @@ class RecoveryPassword {
1987
2184
  }
1988
2185
  }
1989
2186
 
1990
- class Filter extends BaseModel {
2187
+ class LineItem extends Product {
2188
+ }
2189
+
2190
+ class ShippingMethod extends BaseModel {
1991
2191
  static get identifiersFields() {
1992
2192
  return ['id'];
1993
2193
  }
1994
2194
  }
1995
2195
 
1996
- class CategoryBase extends BaseModel {
2196
+ class Checkout extends BaseModel {
1997
2197
  static get identifiersFields() {
1998
2198
  return ['id'];
1999
2199
  }
2000
2200
  }
2001
2201
  tslib_1.__decorate([
2002
- classTransformer.Type(() => CategoryBase),
2003
- tslib_1.__metadata("design:type", CategoryBase)
2004
- ], CategoryBase.prototype, "parent", void 0);
2005
- tslib_1.__decorate([
2006
- classTransformer.Type(() => Filter),
2202
+ classTransformer.Type(() => LineItem),
2007
2203
  tslib_1.__metadata("design:type", Array)
2008
- ], CategoryBase.prototype, "filters", void 0);
2204
+ ], Checkout.prototype, "lineItems", void 0);
2205
+ tslib_1.__decorate([
2206
+ classTransformer.Type(() => User),
2207
+ tslib_1.__metadata("design:type", User)
2208
+ ], Checkout.prototype, "user", void 0);
2209
+ tslib_1.__decorate([
2210
+ classTransformer.Type(() => UserAddress),
2211
+ tslib_1.__metadata("design:type", UserAddress)
2212
+ ], Checkout.prototype, "shippingAddress", void 0);
2213
+ tslib_1.__decorate([
2214
+ classTransformer.Type(() => UserAddress),
2215
+ tslib_1.__metadata("design:type", UserAddress)
2216
+ ], Checkout.prototype, "billingAddress", void 0);
2217
+ tslib_1.__decorate([
2218
+ classTransformer.Type(() => ShippingMethod),
2219
+ tslib_1.__metadata("design:type", ShippingMethod)
2220
+ ], Checkout.prototype, "shipping", void 0);
2221
+ tslib_1.__decorate([
2222
+ classTransformer.Type(() => Coupon),
2223
+ tslib_1.__metadata("design:type", Coupon)
2224
+ ], Checkout.prototype, "coupon", void 0);
2009
2225
 
2010
- class CategoryForProduct extends CategoryBase {
2226
+ exports.OrderStatus = void 0;
2227
+ (function (OrderStatus) {
2228
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
2229
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
2230
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
2231
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
2232
+ OrderStatus["ENVIADO"] = "Enviado";
2233
+ OrderStatus["ENTREGUE"] = "Entregue";
2234
+ OrderStatus["CANCELADO"] = "Cancelado";
2235
+ OrderStatus["CREDIT_CARD"] = "credit_card";
2236
+ })(exports.OrderStatus || (exports.OrderStatus = {}));
2237
+
2238
+ class Order extends Checkout {
2239
+ }
2240
+ tslib_1.__decorate([
2241
+ classTransformer.Type(() => Payment),
2242
+ tslib_1.__metadata("design:type", Payment)
2243
+ ], Order.prototype, "payment", void 0);
2244
+
2245
+ class OrderBlocked extends BaseModel {
2011
2246
  static get identifiersFields() {
2012
2247
  return ['id'];
2013
2248
  }
2014
2249
  }
2015
2250
 
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
- }
2035
- static get identifiersFields() {
2036
- return ['id'];
2037
- }
2038
- }
2039
-
2040
- class ProductForKit extends ProductBase {
2041
- static get identifiersFields() {
2042
- return ['id'];
2043
- }
2044
- }
2045
- tslib_1.__decorate([
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
- }
2055
- tslib_1.__decorate([
2056
- classTransformer.Type(() => ProductForKit),
2057
- tslib_1.__metadata("design:type", ProductForKit)
2058
- ], KitProduct.prototype, "kit", void 0);
2059
- tslib_1.__decorate([
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
- }
2069
- tslib_1.__decorate([
2070
- classTransformer.Type(() => KitProduct),
2071
- tslib_1.__metadata("design:type", Array)
2072
- ], ProductForCategory.prototype, "kitProducts", void 0);
2073
-
2074
- class Category extends CategoryBase {
2075
- static get identifiersFields() {
2076
- return ['id'];
2077
- }
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'];
2087
- }
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'];
2097
- }
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'];
2126
- }
2127
- }
2128
-
2129
- class Product extends ProductBase {
2130
- static get identifiersFields() {
2131
- return ['id'];
2132
- }
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'];
2146
- }
2147
- }
2148
-
2149
- class Wishlist extends Category {
2150
- static get identifiersFields() {
2151
- return ['id'];
2152
- }
2153
- }
2154
-
2155
- class Buy2Win extends BaseModel {
2156
- static get identifiersFields() {
2157
- return ['id'];
2158
- }
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'];
2168
- }
2169
- }
2170
-
2171
- class CampaignHashtag extends BaseModel {
2172
- static get identifiersFields() {
2173
- return ['id'];
2174
- }
2175
- }
2176
-
2177
- class LineItem extends Product {
2178
- }
2179
-
2180
- class ShippingMethod extends BaseModel {
2181
- static get identifiersFields() {
2182
- return ['id'];
2183
- }
2184
- }
2185
-
2186
- class Checkout extends BaseModel {
2187
- static get identifiersFields() {
2188
- return ['id'];
2189
- }
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
2251
  class CheckoutSubscription extends BaseModel {
2236
2252
  static get identifiersFields() {
2237
2253
  return ['id'];
@@ -2268,6 +2284,12 @@ class RoundProductPricesHelper {
2268
2284
  }
2269
2285
  }
2270
2286
 
2287
+ class Sequence extends BaseModel {
2288
+ static get identifiersFields() {
2289
+ return ['id'];
2290
+ }
2291
+ }
2292
+
2271
2293
  exports.FilterType = void 0;
2272
2294
  (function (FilterType) {
2273
2295
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -2782,7 +2804,7 @@ const withFindFirestore = (MixinBase) => {
2782
2804
  const collection = this.collection(this.buildCollectionPathForFind(find.filters));
2783
2805
  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;
2784
2806
  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 }));
2785
- const { filters, limits, orderBy } = intercepted.find || find;
2807
+ const { filters, limits, orderBy } = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.find) || find;
2786
2808
  const queries = this.makeFirestoreWhere(filters || {});
2787
2809
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
2788
2810
  const offsets = await this.defineLimits(filters, limits);
@@ -2940,155 +2962,22 @@ const withCrudFirestore = (MixinBase) => {
2940
2962
  };
2941
2963
  };
2942
2964
 
2943
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2965
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2944
2966
  constructor({ firestore, interceptors }) {
2945
2967
  super({
2946
2968
  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,
2969
+ collectionName: 'categories',
2970
+ model: Category,
2961
2971
  interceptors,
2962
2972
  });
2963
- this.parentRepository = parentRepository;
2964
2973
  }
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
-
3076
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3077
- constructor({ firestore, interceptors }) {
3078
- super({
3079
- firestore,
3080
- collectionName: 'categories',
3081
- model: Category,
3082
- interceptors,
3083
- });
3084
- }
3085
- async getCategoryBySlug(slug, shop) {
3086
- const categoryDocs = await firestore.getDocs(firestore.query(this.collection(this.collectionName), firestore.where('slug', '==', slug), firestore.where('shop', '==', shop), firestore.where('published', '==', true)));
3087
- if (categoryDocs.size > 1)
3088
- throw new DuplicatedResultsError('Query returned duplicated values');
3089
- if (categoryDocs.empty)
3090
- throw new NotFoundError(`Document with slug ${slug} not found`);
3091
- return categoryDocs.docs[0].data();
2974
+ async getCategoryBySlug(slug, shop) {
2975
+ const categoryDocs = await firestore.getDocs(firestore.query(this.collection(this.collectionName), firestore.where('slug', '==', slug), firestore.where('shop', '==', shop), firestore.where('published', '==', true)));
2976
+ if (categoryDocs.size > 1)
2977
+ throw new DuplicatedResultsError('Query returned duplicated values');
2978
+ if (categoryDocs.empty)
2979
+ throw new NotFoundError(`Document with slug ${slug} not found`);
2980
+ return categoryDocs.docs[0].data();
3092
2981
  }
3093
2982
  async getCategoriesForHome(categoryIds, limit = 4, gender) {
3094
2983
  const categorySnap = await firestore.getDocs(firestore.query(this.collection(this.collectionName), firestore.where('id', 'in', categoryIds.filter(Boolean)), firestore.where('published', '==', true)));
@@ -3212,6 +3101,101 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
3212
3101
  }
3213
3102
  }
3214
3103
 
3104
+ class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3105
+ constructor({ firestore, interceptors }) {
3106
+ super({
3107
+ firestore,
3108
+ collectionName: 'sequences',
3109
+ model: Sequence,
3110
+ interceptors,
3111
+ });
3112
+ }
3113
+ }
3114
+
3115
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3116
+ constructor({ firestore, interceptors }) {
3117
+ super({
3118
+ firestore,
3119
+ collectionName: 'dms',
3120
+ model: Home,
3121
+ interceptors,
3122
+ });
3123
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3124
+ var _a, _b, _c;
3125
+ return ({
3126
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3127
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3128
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3129
+ 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)) || [],
3130
+ });
3131
+ };
3132
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3133
+ var _a;
3134
+ return ({
3135
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3136
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3137
+ });
3138
+ };
3139
+ }
3140
+ buildModelInstance() {
3141
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3142
+ return {
3143
+ toFirestore: (data) => {
3144
+ const modifiedData = this.homeToFirestore(data);
3145
+ return toFirestore(modifiedData);
3146
+ },
3147
+ fromFirestore: (snap) => {
3148
+ const instance = fromFirestore(snap);
3149
+ return this.homeFromFirestore(instance);
3150
+ },
3151
+ };
3152
+ }
3153
+ homeToFirestore(home) {
3154
+ var _a, _b, _c, _d;
3155
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3156
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3157
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3158
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3159
+ }
3160
+ return home;
3161
+ }
3162
+ homeFromFirestore(home) {
3163
+ var _a;
3164
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3165
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3166
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3167
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3168
+ home.data.createdAt =
3169
+ home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3170
+ home.data.expiresAt =
3171
+ home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3172
+ }
3173
+ return home;
3174
+ }
3175
+ }
3176
+
3177
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3178
+ constructor({ firestore, interceptors }) {
3179
+ super({
3180
+ firestore,
3181
+ collectionName: 'shopMenus',
3182
+ model: ShopMenu,
3183
+ interceptors,
3184
+ });
3185
+ }
3186
+ }
3187
+
3188
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3189
+ constructor({ firestore, interceptors, }) {
3190
+ super({
3191
+ firestore,
3192
+ collectionName: 'shopSettings',
3193
+ model: ShopSettings,
3194
+ interceptors,
3195
+ });
3196
+ }
3197
+ }
3198
+
3215
3199
  class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3216
3200
  constructor({ firestore, interceptors }) {
3217
3201
  super({
@@ -3342,6 +3326,17 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3342
3326
  }
3343
3327
  }
3344
3328
 
3329
+ class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3330
+ constructor({ firestore, interceptors, }) {
3331
+ super({
3332
+ firestore,
3333
+ collectionName: 'paymentBlockedAttempts',
3334
+ model: OrderBlocked,
3335
+ interceptors,
3336
+ });
3337
+ }
3338
+ }
3339
+
3345
3340
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3346
3341
  constructor({ firestore, interceptors }) {
3347
3342
  super({
@@ -3364,87 +3359,136 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3364
3359
  }
3365
3360
  }
3366
3361
 
3367
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3362
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3368
3363
  constructor({ firestore, interceptors }) {
3369
3364
  super({
3370
3365
  firestore,
3371
- collectionName: 'dms',
3372
- model: Home,
3366
+ collectionName: 'leads',
3367
+ model: Lead,
3373
3368
  interceptors,
3374
3369
  });
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
- };
3391
3370
  }
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
- };
3371
+ }
3372
+
3373
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3374
+ constructor({ firestore, interceptors }, parentRepository) {
3375
+ super({
3376
+ firestore,
3377
+ collectionName: 'editions',
3378
+ parentIdField: 'subscriptionId',
3379
+ model: Edition,
3380
+ interceptors,
3381
+ });
3382
+ this.parentRepository = parentRepository;
3404
3383
  }
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;
3384
+ }
3385
+
3386
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3387
+ constructor({ firestore, interceptors, }) {
3388
+ super({
3389
+ firestore,
3390
+ collectionName: 'subscription',
3391
+ model: Subscription,
3392
+ interceptors,
3393
+ });
3413
3394
  }
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;
3395
+ }
3396
+
3397
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3398
+ constructor({ firestore, interceptors }, parentRepository) {
3399
+ super({
3400
+ firestore,
3401
+ collectionName: 'payments',
3402
+ parentIdField: 'subscriptionId',
3403
+ model: SubscriptionPayment,
3404
+ interceptors,
3405
+ });
3406
+ this.parentRepository = parentRepository;
3426
3407
  }
3427
3408
  }
3428
3409
 
3429
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3410
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3411
+ constructor({ firestore, interceptors }, parentRepository) {
3412
+ super({
3413
+ firestore,
3414
+ collectionName: 'address',
3415
+ parentIdField: 'userId',
3416
+ model: UserAddress,
3417
+ interceptors,
3418
+ });
3419
+ this.parentRepository = parentRepository;
3420
+ }
3421
+ }
3422
+
3423
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3424
+ constructor({ firestore, interceptors }, parentRepository) {
3425
+ super({
3426
+ firestore,
3427
+ collectionName: 'CX',
3428
+ parentIdField: 'userId',
3429
+ model: BeautyProfile,
3430
+ interceptors,
3431
+ });
3432
+ this.parentRepository = parentRepository;
3433
+ }
3434
+ }
3435
+
3436
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3430
3437
  constructor({ firestore, interceptors }) {
3431
3438
  super({
3432
3439
  firestore,
3433
- collectionName: 'shopMenus',
3434
- model: ShopMenu,
3440
+ collectionName: 'users',
3441
+ model: User,
3435
3442
  interceptors,
3436
3443
  });
3437
3444
  }
3445
+ async get(identifiers) {
3446
+ const user = await super.get({ id: identifiers.id });
3447
+ user.beautyProfile = await this.getBeautyProfile(user.id);
3448
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
3449
+ return user;
3450
+ }
3451
+ async checkIfExistsByField(field, value) {
3452
+ const result = await this.find({ filters: { [field]: value } });
3453
+ return result.count > 0;
3454
+ }
3455
+ buildModelInstance() {
3456
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3457
+ return {
3458
+ toFirestore: (data) => {
3459
+ const plain = toFirestore(data);
3460
+ delete plain.isSubscriber;
3461
+ return plain;
3462
+ },
3463
+ fromFirestore,
3464
+ };
3465
+ }
3466
+ async getBeautyProfile(userId) {
3467
+ const beautyProfile = await firestore.getDoc(firestore.doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
3468
+ return beautyProfile.data();
3469
+ }
3470
+ async checkIfIsSubscriber(userId) {
3471
+ const docs = await firestore.getDocs(firestore.query(this.collection('subscription'), firestore.where('user.id', '==', userId), firestore.where('status', '==', 'active')));
3472
+ return !!docs && !!docs.size;
3473
+ }
3474
+ buildBeautyProfileModelInstance() {
3475
+ return {
3476
+ toFirestore: (data) => data.toPlain(),
3477
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
3478
+ };
3479
+ }
3438
3480
  }
3439
3481
 
3440
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3441
- constructor({ firestore, interceptors, }) {
3482
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3483
+ constructor({ firestore, interceptors }, parentRepository) {
3442
3484
  super({
3443
3485
  firestore,
3444
- collectionName: 'shopSettings',
3445
- model: ShopSettings,
3486
+ collectionName: 'payment_method',
3487
+ parentIdField: 'userId',
3488
+ model: UserPaymentMethod,
3446
3489
  interceptors,
3447
3490
  });
3491
+ this.parentRepository = parentRepository;
3448
3492
  }
3449
3493
  }
3450
3494
 
@@ -5699,6 +5743,8 @@ exports.Log = Log;
5699
5743
  exports.Logger = Logger;
5700
5744
  exports.NotFoundError = NotFoundError;
5701
5745
  exports.Order = Order;
5746
+ exports.OrderBlocked = OrderBlocked;
5747
+ exports.OrderBlockedFirestoreRepository = OrderBlockedFirestoreRepository;
5702
5748
  exports.OrderFirestoreRepository = OrderFirestoreRepository;
5703
5749
  exports.Payment = Payment;
5704
5750
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
@@ -5714,6 +5760,8 @@ exports.Register = Register;
5714
5760
  exports.RegisterFirebaseAuthService = RegisterFirebaseAuthService;
5715
5761
  exports.RequiredArgumentError = RequiredArgumentError;
5716
5762
  exports.RoundProductPricesHelper = RoundProductPricesHelper;
5763
+ exports.Sequence = Sequence;
5764
+ exports.SequenceFirestoreRepository = SequenceFirestoreRepository;
5717
5765
  exports.ShippingMethod = ShippingMethod;
5718
5766
  exports.ShopMenu = ShopMenu;
5719
5767
  exports.ShopMenuFirestoreRepository = ShopMenuFirestoreRepository;