@infrab4a/connect 4.2.4-beta.8 → 4.2.5-beta.0

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 (54) hide show
  1. package/index.cjs.js +1158 -1860
  2. package/index.esm.js +1031 -1696
  3. package/package.json +1 -1
  4. package/src/domain/catalog/models/category-base.d.ts +2 -0
  5. package/src/domain/index.d.ts +3 -4
  6. package/src/domain/shopping/index.d.ts +0 -4
  7. package/src/domain/shopping/models/index.d.ts +0 -3
  8. package/src/domain/shopping/models/order.d.ts +2 -2
  9. package/src/domain/shopping/models/payment.d.ts +61 -7
  10. package/src/domain/shopping/models/types/index.d.ts +4 -4
  11. package/src/domain/shopping/repositories/index.d.ts +0 -1
  12. package/src/infra/firebase/firestore/repositories/index.d.ts +2 -3
  13. package/src/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -1
  14. package/src/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +2 -1
  15. package/src/utils/index.d.ts +2 -2
  16. package/src/domain/general/index.d.ts +0 -2
  17. package/src/domain/general/models/index.d.ts +0 -1
  18. package/src/domain/general/models/sequences.d.ts +0 -9
  19. package/src/domain/general/repositories/index.d.ts +0 -1
  20. package/src/domain/general/repositories/sequences.repository.d.ts +0 -4
  21. package/src/domain/shopping/enums/index.d.ts +0 -2
  22. package/src/domain/shopping/enums/payment-methods.enum.d.ts +0 -6
  23. package/src/domain/shopping/enums/payment-providers.enum.d.ts +0 -5
  24. package/src/domain/shopping/factories/adyen-payment-method.factory.d.ts +0 -8
  25. package/src/domain/shopping/factories/base-payment-method.factory.d.ts +0 -7
  26. package/src/domain/shopping/factories/glampoints-payment-method.factory.d.ts +0 -8
  27. package/src/domain/shopping/factories/index.d.ts +0 -4
  28. package/src/domain/shopping/factories/pagarme-payment-method.factory.d.ts +0 -10
  29. package/src/domain/shopping/factories/payment-provider.factory.d.ts +0 -15
  30. package/src/domain/shopping/interfaces/index.d.ts +0 -5
  31. package/src/domain/shopping/interfaces/payment-method-factory.interface.d.ts +0 -14
  32. package/src/domain/shopping/interfaces/payment-provider-bank-slip.interface.d.ts +0 -5
  33. package/src/domain/shopping/interfaces/payment-provider-card.interface.d.ts +0 -7
  34. package/src/domain/shopping/interfaces/payment-provider-glampoints.interface.d.ts +0 -5
  35. package/src/domain/shopping/interfaces/payment-provider-pix.interface.d.ts +0 -5
  36. package/src/domain/shopping/models/order-blocked.d.ts +0 -26
  37. package/src/domain/shopping/models/payment.transaction.d.ts +0 -66
  38. package/src/domain/shopping/repositories/order-blocked.repository.d.ts +0 -4
  39. package/src/domain/shopping/services/adyen-card-payment.service.d.ts +0 -28
  40. package/src/domain/shopping/services/antifraude.service.d.ts +0 -19
  41. package/src/domain/shopping/services/glampoints-payment.service.d.ts +0 -4
  42. package/src/domain/shopping/services/index.d.ts +0 -6
  43. package/src/domain/shopping/services/pagarme-bank-slip-payment.service.d.ts +0 -8
  44. package/src/domain/shopping/services/pagarme-card-payment.service.d.ts +0 -10
  45. package/src/domain/shopping/services/pagarme-pix-payment.service.d.ts +0 -8
  46. package/src/domain/shopping/types/adyen-credentials.type.d.ts +0 -6
  47. package/src/domain/shopping/types/index.d.ts +0 -5
  48. package/src/domain/shopping/types/pagarme-credentials.type.d.ts +0 -5
  49. package/src/domain/shopping/types/payment-card-info.type.d.ts +0 -4
  50. package/src/domain/shopping/types/payment-method.type.d.ts +0 -2
  51. package/src/domain/shopping/types/payment-provider.type.d.ts +0 -2
  52. package/src/infra/firebase/firestore/repositories/general/index.d.ts +0 -1
  53. package/src/infra/firebase/firestore/repositories/general/sequences-firestore.repository.d.ts +0 -7
  54. package/src/infra/firebase/firestore/repositories/shopping/order-blocked-firestore.repository.d.ts +0 -7
package/index.esm.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import 'reflect-metadata';
2
- import * as tslib_1 from 'tslib';
3
- import { __decorate, __metadata, __rest } from 'tslib';
4
- import { plainToInstance, instanceToPlain, Type, Expose } from 'class-transformer';
5
- import { parseISO, format, startOfDay, endOfDay, subDays, addDays } from 'date-fns';
6
- export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub, subDays } from 'date-fns';
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';
2
+ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transformer';
3
+ import { __decorate, __metadata, __values, __spreadArray, __read, __extends, __rest } from 'tslib';
4
+ import { parseISO } from 'date-fns';
5
+ export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
+ import { isNil, isArray, first, last, flatten, compact, get, isString, each, unset, isObject, set, isNumber, isEmpty, chunk, isDate, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
8
7
  export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, unset } from 'lodash';
9
8
  import { debug } from 'debug';
10
9
  import { CustomError } from 'ts-custom-error';
@@ -13,48 +12,6 @@ import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, st
13
12
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
14
13
  import { mutation, query as query$1 } from 'gql-query-builder';
15
14
 
16
- var PaymentMethods;
17
- (function (PaymentMethods) {
18
- PaymentMethods["CARD"] = "card";
19
- PaymentMethods["BANKSLIP"] = "bankSlip";
20
- PaymentMethods["PIX"] = "pix";
21
- PaymentMethods["POINTS"] = "glampoints";
22
- })(PaymentMethods || (PaymentMethods = {}));
23
-
24
- var PaymentProviders;
25
- (function (PaymentProviders) {
26
- PaymentProviders["PAGARME"] = "pagarMe";
27
- PaymentProviders["ADYEN"] = "adyen";
28
- PaymentProviders["GLAMPOINTS"] = "glampoints";
29
- })(PaymentProviders || (PaymentProviders = {}));
30
-
31
- class BasePaymentMethodFactory {
32
- constructor(methods) {
33
- this.methods = methods;
34
- }
35
- build(method) {
36
- return this.methods[method];
37
- }
38
- }
39
-
40
- class AdyenPaymentMethodFactory extends BasePaymentMethodFactory {
41
- }
42
-
43
- class GlampointsPaymentMethodFactory extends BasePaymentMethodFactory {
44
- }
45
-
46
- class PagarmePaymentMethodFactory extends BasePaymentMethodFactory {
47
- }
48
-
49
- class PaymentProviderFactory {
50
- constructor(paymentProviders) {
51
- this.paymentProviders = paymentProviders;
52
- }
53
- build(provider) {
54
- return this.paymentProviders[provider];
55
- }
56
- }
57
-
58
15
  class BaseModel {
59
16
  get identifier() {
60
17
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
@@ -78,187 +35,6 @@ class BaseModel {
78
35
  }
79
36
  }
80
37
 
81
- class Filter extends BaseModel {
82
- static get identifiersFields() {
83
- return ['id'];
84
- }
85
- }
86
-
87
- class CategoryBase extends BaseModel {
88
- static get identifiersFields() {
89
- return ['id'];
90
- }
91
- }
92
- __decorate([
93
- Type(() => CategoryBase),
94
- __metadata("design:type", CategoryBase)
95
- ], CategoryBase.prototype, "parent", void 0);
96
- __decorate([
97
- Type(() => Filter),
98
- __metadata("design:type", Array)
99
- ], CategoryBase.prototype, "filters", void 0);
100
-
101
- class CategoryForProduct extends CategoryBase {
102
- static get identifiersFields() {
103
- return ['id'];
104
- }
105
- }
106
-
107
- class ProductBase extends BaseModel {
108
- get evaluation() {
109
- return {
110
- reviews: this.reviews,
111
- count: this.reviewsTotal,
112
- rating: this.rate,
113
- };
114
- }
115
- set evaluation(evaluation) {
116
- if (!evaluation) {
117
- this.reviews = null;
118
- this.reviewsTotal = null;
119
- this.rate = null;
120
- return;
121
- }
122
- this.reviews = evaluation.reviews || this.reviews;
123
- this.reviewsTotal = evaluation.count || this.reviewsTotal;
124
- this.rate = evaluation.rating || this.rate;
125
- }
126
- static get identifiersFields() {
127
- return ['id'];
128
- }
129
- }
130
-
131
- class ProductForKit extends ProductBase {
132
- static get identifiersFields() {
133
- return ['id'];
134
- }
135
- }
136
- __decorate([
137
- Type(() => CategoryForProduct),
138
- __metadata("design:type", CategoryForProduct)
139
- ], ProductForKit.prototype, "category", void 0);
140
-
141
- class KitProduct extends BaseModel {
142
- static get identifiersFields() {
143
- return ['productId', 'kitProductId'];
144
- }
145
- }
146
- __decorate([
147
- Type(() => ProductForKit),
148
- __metadata("design:type", ProductForKit)
149
- ], KitProduct.prototype, "kit", void 0);
150
- __decorate([
151
- Type(() => ProductForKit),
152
- __metadata("design:type", ProductForKit)
153
- ], KitProduct.prototype, "product", void 0);
154
-
155
- class ProductForCategory extends ProductBase {
156
- static get identifiersFields() {
157
- return ['id'];
158
- }
159
- }
160
- __decorate([
161
- Type(() => KitProduct),
162
- __metadata("design:type", Array)
163
- ], ProductForCategory.prototype, "kitProducts", void 0);
164
-
165
- class Category extends CategoryBase {
166
- static get identifiersFields() {
167
- return ['id'];
168
- }
169
- }
170
- __decorate([
171
- Type(() => ProductForCategory),
172
- __metadata("design:type", Array)
173
- ], Category.prototype, "childrenProducts", void 0);
174
-
175
- class CategoryCollectionChildren extends BaseModel {
176
- static get identifiersFields() {
177
- return ['collectionId', 'categoryId'];
178
- }
179
- }
180
- __decorate([
181
- Type(() => CategoryCollectionChildren),
182
- __metadata("design:type", CategoryCollectionChildren)
183
- ], CategoryCollectionChildren.prototype, "parent", void 0);
184
-
185
- class CategoryFilter extends BaseModel {
186
- static get identifiersFields() {
187
- return ['id'];
188
- }
189
- }
190
- __decorate([
191
- Type(() => Filter),
192
- __metadata("design:type", Filter)
193
- ], CategoryFilter.prototype, "filter", void 0);
194
- __decorate([
195
- Type(() => Category),
196
- __metadata("design:type", Category)
197
- ], CategoryFilter.prototype, "category", void 0);
198
-
199
- var GenderDestination;
200
- (function (GenderDestination) {
201
- GenderDestination["FEMALE"] = "female";
202
- GenderDestination["MALE"] = "male";
203
- GenderDestination["UNISEX"] = "unisex";
204
- })(GenderDestination || (GenderDestination = {}));
205
-
206
- var Shops;
207
- (function (Shops) {
208
- Shops["MENSMARKET"] = "mensmarket";
209
- Shops["GLAMSHOP"] = "Glamshop";
210
- Shops["GLAMPOINTS"] = "Glampoints";
211
- Shops["ALL"] = "ALL";
212
- })(Shops || (Shops = {}));
213
-
214
- class FilterOption extends BaseModel {
215
- static get identifiersFields() {
216
- return ['id'];
217
- }
218
- }
219
-
220
- class Product extends ProductBase {
221
- static get identifiersFields() {
222
- return ['id'];
223
- }
224
- }
225
- __decorate([
226
- Type(() => CategoryForProduct),
227
- __metadata("design:type", CategoryForProduct)
228
- ], Product.prototype, "category", void 0);
229
- __decorate([
230
- Type(() => KitProduct),
231
- __metadata("design:type", Array)
232
- ], Product.prototype, "kitProducts", void 0);
233
-
234
- class ProductReviews extends BaseModel {
235
- static get identifiersFields() {
236
- return ['id'];
237
- }
238
- }
239
-
240
- class Variant extends BaseModel {
241
- static get identifiersFields() {
242
- return ['id', 'productId'];
243
- }
244
- }
245
-
246
- class Wishlist extends Category {
247
- static get identifiersFields() {
248
- return ['id'];
249
- }
250
- }
251
-
252
- class Buy2Win extends BaseModel {
253
- static get identifiersFields() {
254
- return ['id'];
255
- }
256
- }
257
- __decorate([
258
- Type(() => Category),
259
- __metadata("design:type", Array)
260
- ], Buy2Win.prototype, "categories", void 0);
261
-
262
38
  var Where;
263
39
  (function (Where) {
264
40
  Where["EQUALS"] = "==";
@@ -284,18 +60,6 @@ var UpdateOptionActions;
284
60
  UpdateOptionActions["NULL"] = "null";
285
61
  })(UpdateOptionActions || (UpdateOptionActions = {}));
286
62
 
287
- class CampaignDashboard extends BaseModel {
288
- static get identifiersFields() {
289
- return ['id'];
290
- }
291
- }
292
-
293
- class CampaignHashtag extends BaseModel {
294
- static get identifiersFields() {
295
- return ['id'];
296
- }
297
- }
298
-
299
63
  var AccessoryImportances;
300
64
  (function (AccessoryImportances) {
301
65
  AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
@@ -522,178 +286,171 @@ var Status;
522
286
  Status["CANCELLED"] = "Cancelado";
523
287
  })(Status || (Status = {}));
524
288
 
525
- class PaymentTransaction extends BaseModel {
289
+ class Payment extends BaseModel {
290
+ static get identifiersFields() {
291
+ return ['id'];
292
+ }
526
293
  }
527
294
  __decorate([
528
295
  Expose({ name: 'refuse_reason' }),
529
296
  __metadata("design:type", String)
530
- ], PaymentTransaction.prototype, "refuseReason", void 0);
297
+ ], Payment.prototype, "refuseReason", void 0);
531
298
  __decorate([
532
299
  Expose({ name: 'status_reason' }),
533
300
  __metadata("design:type", String)
534
- ], PaymentTransaction.prototype, "statusReason", void 0);
301
+ ], Payment.prototype, "statusReason", void 0);
535
302
  __decorate([
536
303
  Expose({ name: 'acquirer_response_code' }),
537
304
  __metadata("design:type", String)
538
- ], PaymentTransaction.prototype, "acquirerResponseCode", void 0);
305
+ ], Payment.prototype, "acquirerResponseCode", void 0);
539
306
  __decorate([
540
307
  Expose({ name: 'acquirer_name' }),
541
308
  __metadata("design:type", String)
542
- ], PaymentTransaction.prototype, "acquirerName", void 0);
309
+ ], Payment.prototype, "acquirerName", void 0);
543
310
  __decorate([
544
311
  Expose({ name: 'acquirer_id' }),
545
312
  __metadata("design:type", String)
546
- ], PaymentTransaction.prototype, "acquirerId", void 0);
313
+ ], Payment.prototype, "acquirerId", void 0);
547
314
  __decorate([
548
315
  Expose({ name: 'authorization_code' }),
549
316
  __metadata("design:type", String)
550
- ], PaymentTransaction.prototype, "authorizationCode", void 0);
317
+ ], Payment.prototype, "authorizationCode", void 0);
551
318
  __decorate([
552
319
  Expose({ name: 'soft_descriptor' }),
553
320
  __metadata("design:type", String)
554
- ], PaymentTransaction.prototype, "softDescriptor", void 0);
321
+ ], Payment.prototype, "softDescriptor", void 0);
555
322
  __decorate([
556
323
  Expose({ name: 'date_created' }),
557
324
  __metadata("design:type", String)
558
- ], PaymentTransaction.prototype, "dateCreated", void 0);
325
+ ], Payment.prototype, "dateCreated", void 0);
559
326
  __decorate([
560
327
  Expose({ name: 'date_updated' }),
561
328
  __metadata("design:type", String)
562
- ], PaymentTransaction.prototype, "dateUpdated", void 0);
329
+ ], Payment.prototype, "dateUpdated", void 0);
563
330
  __decorate([
564
331
  Expose({ name: 'authorized_amount' }),
565
332
  __metadata("design:type", Number)
566
- ], PaymentTransaction.prototype, "authorizedAmount", void 0);
333
+ ], Payment.prototype, "authorizedAmount", void 0);
567
334
  __decorate([
568
335
  Expose({ name: 'paid_amount' }),
569
336
  __metadata("design:type", Number)
570
- ], PaymentTransaction.prototype, "paidAmount", void 0);
337
+ ], Payment.prototype, "paidAmount", void 0);
571
338
  __decorate([
572
339
  Expose({ name: 'refunded_amount' }),
573
340
  __metadata("design:type", Number)
574
- ], PaymentTransaction.prototype, "refundedAmount", void 0);
341
+ ], Payment.prototype, "refundedAmount", void 0);
575
342
  __decorate([
576
343
  Expose({ name: 'card_holder_name' }),
577
344
  __metadata("design:type", String)
578
- ], PaymentTransaction.prototype, "cardHolderName", void 0);
345
+ ], Payment.prototype, "cardHolderName", void 0);
579
346
  __decorate([
580
347
  Expose({ name: 'card_last_digits' }),
581
348
  __metadata("design:type", String)
582
- ], PaymentTransaction.prototype, "cardLastDigits", void 0);
349
+ ], Payment.prototype, "cardLastDigits", void 0);
583
350
  __decorate([
584
351
  Expose({ name: 'card_first_digits' }),
585
352
  __metadata("design:type", String)
586
- ], PaymentTransaction.prototype, "cardFirstDigits", void 0);
353
+ ], Payment.prototype, "cardFirstDigits", void 0);
587
354
  __decorate([
588
355
  Expose({ name: 'card_brand' }),
589
356
  __metadata("design:type", String)
590
- ], PaymentTransaction.prototype, "cardBrand", void 0);
357
+ ], Payment.prototype, "cardBrand", void 0);
591
358
  __decorate([
592
359
  Expose({ name: 'card_pin_mode' }),
593
360
  __metadata("design:type", String)
594
- ], PaymentTransaction.prototype, "cardPinMode", void 0);
361
+ ], Payment.prototype, "cardPinMode", void 0);
595
362
  __decorate([
596
363
  Expose({ name: 'card_magstripe_fallback' }),
597
364
  __metadata("design:type", Boolean)
598
- ], PaymentTransaction.prototype, "cardMagstripeFallback", void 0);
365
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
599
366
  __decorate([
600
367
  Expose({ name: 'cvm_pin' }),
601
368
  __metadata("design:type", Boolean)
602
- ], PaymentTransaction.prototype, "cvmPin", void 0);
369
+ ], Payment.prototype, "cvmPin", void 0);
603
370
  __decorate([
604
371
  Expose({ name: 'postback_url' }),
605
372
  __metadata("design:type", String)
606
- ], PaymentTransaction.prototype, "postbackUrl", void 0);
373
+ ], Payment.prototype, "postbackUrl", void 0);
607
374
  __decorate([
608
375
  Expose({ name: 'payment_method' }),
609
376
  __metadata("design:type", String)
610
- ], PaymentTransaction.prototype, "paymentMethod", void 0);
377
+ ], Payment.prototype, "paymentMethod", void 0);
611
378
  __decorate([
612
379
  Expose({ name: 'capture_method' }),
613
380
  __metadata("design:type", String)
614
- ], PaymentTransaction.prototype, "captureMethod", void 0);
381
+ ], Payment.prototype, "captureMethod", void 0);
615
382
  __decorate([
616
383
  Expose({ name: 'antifraud_score' }),
617
384
  __metadata("design:type", String)
618
- ], PaymentTransaction.prototype, "antifraudScore", void 0);
385
+ ], Payment.prototype, "antifraudScore", void 0);
619
386
  __decorate([
620
387
  Expose({ name: 'boleto_url' }),
621
388
  __metadata("design:type", String)
622
- ], PaymentTransaction.prototype, "boletoUrl", void 0);
389
+ ], Payment.prototype, "boletoUrl", void 0);
623
390
  __decorate([
624
391
  Expose({ name: 'boleto_barcode' }),
625
392
  __metadata("design:type", String)
626
- ], PaymentTransaction.prototype, "boletoBarcode", void 0);
393
+ ], Payment.prototype, "boletoBarcode", void 0);
627
394
  __decorate([
628
395
  Expose({ name: 'boleto_expiration_date' }),
629
396
  __metadata("design:type", String)
630
- ], PaymentTransaction.prototype, "boletoExpirationDate", void 0);
397
+ ], Payment.prototype, "boletoExpirationDate", void 0);
631
398
  __decorate([
632
399
  Expose({ name: 'subscription_id' }),
633
400
  __metadata("design:type", String)
634
- ], PaymentTransaction.prototype, "subscriptionId", void 0);
401
+ ], Payment.prototype, "subscriptionId", void 0);
635
402
  __decorate([
636
403
  Expose({ name: 'split_rules' }),
637
404
  __metadata("design:type", String)
638
- ], PaymentTransaction.prototype, "splitRules", void 0);
405
+ ], Payment.prototype, "splitRules", void 0);
639
406
  __decorate([
640
407
  Expose({ name: 'antifraud_metadata' }),
641
408
  __metadata("design:type", Object)
642
- ], PaymentTransaction.prototype, "antifraudMetadata", void 0);
409
+ ], Payment.prototype, "antifraudMetadata", void 0);
643
410
  __decorate([
644
411
  Expose({ name: 'reference_key' }),
645
412
  __metadata("design:type", String)
646
- ], PaymentTransaction.prototype, "referenceKey", void 0);
413
+ ], Payment.prototype, "referenceKey", void 0);
647
414
  __decorate([
648
415
  Expose({ name: 'local_transaction_id' }),
649
416
  __metadata("design:type", String)
650
- ], PaymentTransaction.prototype, "localTransactionId", void 0);
417
+ ], Payment.prototype, "localTransactionId", void 0);
651
418
  __decorate([
652
419
  Expose({ name: 'local_time' }),
653
420
  __metadata("design:type", String)
654
- ], PaymentTransaction.prototype, "localTime", void 0);
421
+ ], Payment.prototype, "localTime", void 0);
655
422
  __decorate([
656
423
  Expose({ name: 'fraud_covered' }),
657
424
  __metadata("design:type", Boolean)
658
- ], PaymentTransaction.prototype, "fraudCovered", void 0);
425
+ ], Payment.prototype, "fraudCovered", void 0);
659
426
  __decorate([
660
427
  Expose({ name: 'fraud_reimbursed' }),
661
428
  __metadata("design:type", String)
662
- ], PaymentTransaction.prototype, "fraudReimbursed", void 0);
429
+ ], Payment.prototype, "fraudReimbursed", void 0);
663
430
  __decorate([
664
431
  Expose({ name: 'order_id' }),
665
432
  __metadata("design:type", String)
666
- ], PaymentTransaction.prototype, "orderId", void 0);
433
+ ], Payment.prototype, "orderId", void 0);
667
434
  __decorate([
668
435
  Expose({ name: 'risk_level' }),
669
436
  __metadata("design:type", String)
670
- ], PaymentTransaction.prototype, "riskLevel", void 0);
437
+ ], Payment.prototype, "riskLevel", void 0);
671
438
  __decorate([
672
439
  Expose({ name: 'receipt_url' }),
673
440
  __metadata("design:type", String)
674
- ], PaymentTransaction.prototype, "receiptUrl", void 0);
441
+ ], Payment.prototype, "receiptUrl", void 0);
675
442
  __decorate([
676
443
  Expose({ name: 'private_label' }),
677
444
  __metadata("design:type", String)
678
- ], PaymentTransaction.prototype, "privateLabel", void 0);
445
+ ], Payment.prototype, "privateLabel", void 0);
679
446
  __decorate([
680
447
  Expose({ name: 'pix_qr_code' }),
681
448
  __metadata("design:type", String)
682
- ], PaymentTransaction.prototype, "pixQrCode", void 0);
449
+ ], Payment.prototype, "pixQrCode", void 0);
683
450
  __decorate([
684
451
  Expose({ name: 'pix_expiration_date' }),
685
452
  __metadata("design:type", String)
686
- ], PaymentTransaction.prototype, "pixExpirationDate", void 0);
687
-
688
- class Payment extends BaseModel {
689
- static get identifiersFields() {
690
- return ['id'];
691
- }
692
- }
693
- __decorate([
694
- Type(() => PaymentTransaction),
695
- __metadata("design:type", PaymentTransaction)
696
- ], Payment.prototype, "transaction", void 0);
453
+ ], Payment.prototype, "pixExpirationDate", void 0);
697
454
 
698
455
  class SubscriptionPayment extends BaseModel {
699
456
  static get identifiersFields() {
@@ -705,478 +462,401 @@ __decorate([
705
462
  __metadata("design:type", Payment)
706
463
  ], SubscriptionPayment.prototype, "payment", void 0);
707
464
 
708
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
709
- function isFunction(x) {
710
- return typeof x === 'function';
711
- }
712
-
713
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
714
- var _enable_super_gross_mode_that_will_cause_bad_things = false;
715
- var config = {
716
- Promise: undefined,
717
- set useDeprecatedSynchronousErrorHandling(value) {
718
- if (value) {
719
- var error = /*@__PURE__*/ new Error();
720
- /*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
721
- }
722
- _enable_super_gross_mode_that_will_cause_bad_things = value;
723
- },
724
- get useDeprecatedSynchronousErrorHandling() {
725
- return _enable_super_gross_mode_that_will_cause_bad_things;
726
- },
727
- };
728
-
729
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
730
- function hostReportError(err) {
731
- setTimeout(function () { throw err; }, 0);
465
+ function isFunction(value) {
466
+ return typeof value === 'function';
732
467
  }
733
468
 
734
- /** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
735
- var empty = {
736
- closed: true,
737
- next: function (value) { },
738
- error: function (err) {
739
- if (config.useDeprecatedSynchronousErrorHandling) {
740
- throw err;
741
- }
742
- else {
743
- hostReportError(err);
744
- }
745
- },
746
- complete: function () { }
747
- };
748
-
749
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
750
- var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
751
-
752
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
753
- function isObject(x) {
754
- return x !== null && typeof x === 'object';
469
+ function createErrorClass(createImpl) {
470
+ var _super = function (instance) {
471
+ Error.call(instance);
472
+ instance.stack = new Error().stack;
473
+ };
474
+ var ctorFunc = createImpl(_super);
475
+ ctorFunc.prototype = Object.create(Error.prototype);
476
+ ctorFunc.prototype.constructor = ctorFunc;
477
+ return ctorFunc;
755
478
  }
756
479
 
757
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
758
- var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
759
- function UnsubscriptionErrorImpl(errors) {
760
- Error.call(this);
761
- this.message = errors ?
762
- errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
480
+ var UnsubscriptionError = createErrorClass(function (_super) {
481
+ return function UnsubscriptionErrorImpl(errors) {
482
+ _super(this);
483
+ this.message = errors
484
+ ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
485
+ : '';
763
486
  this.name = 'UnsubscriptionError';
764
487
  this.errors = errors;
765
- return this;
488
+ };
489
+ });
490
+
491
+ function arrRemove(arr, item) {
492
+ if (arr) {
493
+ var index = arr.indexOf(item);
494
+ 0 <= index && arr.splice(index, 1);
766
495
  }
767
- UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
768
- return UnsubscriptionErrorImpl;
769
- })();
770
- var UnsubscriptionError = UnsubscriptionErrorImpl;
771
-
772
- /** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
773
- var Subscription$1 = /*@__PURE__*/ (function () {
774
- function Subscription(unsubscribe) {
496
+ }
497
+
498
+ var Subscription$1 = (function () {
499
+ function Subscription(initialTeardown) {
500
+ this.initialTeardown = initialTeardown;
775
501
  this.closed = false;
776
- this._parentOrParents = null;
777
- this._subscriptions = null;
778
- if (unsubscribe) {
779
- this._ctorUnsubscribe = true;
780
- this._unsubscribe = unsubscribe;
781
- }
502
+ this._parentage = null;
503
+ this._finalizers = null;
782
504
  }
783
505
  Subscription.prototype.unsubscribe = function () {
506
+ var e_1, _a, e_2, _b;
784
507
  var errors;
785
- if (this.closed) {
786
- return;
787
- }
788
- var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
789
- this.closed = true;
790
- this._parentOrParents = null;
791
- this._subscriptions = null;
792
- if (_parentOrParents instanceof Subscription) {
793
- _parentOrParents.remove(this);
794
- }
795
- else if (_parentOrParents !== null) {
796
- for (var index = 0; index < _parentOrParents.length; ++index) {
797
- var parent_1 = _parentOrParents[index];
798
- parent_1.remove(this);
799
- }
800
- }
801
- if (isFunction(_unsubscribe)) {
802
- if (_ctorUnsubscribe) {
803
- this._unsubscribe = undefined;
804
- }
805
- try {
806
- _unsubscribe.call(this);
807
- }
808
- catch (e) {
809
- errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
810
- }
811
- }
812
- if (isArray(_subscriptions)) {
813
- var index = -1;
814
- var len = _subscriptions.length;
815
- while (++index < len) {
816
- var sub = _subscriptions[index];
817
- if (isObject(sub)) {
508
+ if (!this.closed) {
509
+ this.closed = true;
510
+ var _parentage = this._parentage;
511
+ if (_parentage) {
512
+ this._parentage = null;
513
+ if (Array.isArray(_parentage)) {
818
514
  try {
819
- sub.unsubscribe();
515
+ for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
516
+ var parent_1 = _parentage_1_1.value;
517
+ parent_1.remove(this);
518
+ }
820
519
  }
821
- catch (e) {
822
- errors = errors || [];
823
- if (e instanceof UnsubscriptionError) {
824
- errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
825
- }
826
- else {
827
- errors.push(e);
520
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
521
+ finally {
522
+ try {
523
+ if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
828
524
  }
525
+ finally { if (e_1) throw e_1.error; }
829
526
  }
830
527
  }
528
+ else {
529
+ _parentage.remove(this);
530
+ }
831
531
  }
832
- }
833
- if (errors) {
834
- throw new UnsubscriptionError(errors);
835
- }
836
- };
837
- Subscription.prototype.add = function (teardown) {
838
- var subscription = teardown;
839
- if (!teardown) {
840
- return Subscription.EMPTY;
841
- }
842
- switch (typeof teardown) {
843
- case 'function':
844
- subscription = new Subscription(teardown);
845
- case 'object':
846
- if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
847
- return subscription;
532
+ var initialFinalizer = this.initialTeardown;
533
+ if (isFunction(initialFinalizer)) {
534
+ try {
535
+ initialFinalizer();
536
+ }
537
+ catch (e) {
538
+ errors = e instanceof UnsubscriptionError ? e.errors : [e];
848
539
  }
849
- else if (this.closed) {
850
- subscription.unsubscribe();
851
- return subscription;
540
+ }
541
+ var _finalizers = this._finalizers;
542
+ if (_finalizers) {
543
+ this._finalizers = null;
544
+ try {
545
+ for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
546
+ var finalizer = _finalizers_1_1.value;
547
+ try {
548
+ execFinalizer(finalizer);
549
+ }
550
+ catch (err) {
551
+ errors = errors !== null && errors !== void 0 ? errors : [];
552
+ if (err instanceof UnsubscriptionError) {
553
+ errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
554
+ }
555
+ else {
556
+ errors.push(err);
557
+ }
558
+ }
559
+ }
852
560
  }
853
- else if (!(subscription instanceof Subscription)) {
854
- var tmp = subscription;
855
- subscription = new Subscription();
856
- subscription._subscriptions = [tmp];
561
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
562
+ finally {
563
+ try {
564
+ if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
565
+ }
566
+ finally { if (e_2) throw e_2.error; }
857
567
  }
858
- break;
859
- default: {
860
- throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
861
568
  }
862
- }
863
- var _parentOrParents = subscription._parentOrParents;
864
- if (_parentOrParents === null) {
865
- subscription._parentOrParents = this;
866
- }
867
- else if (_parentOrParents instanceof Subscription) {
868
- if (_parentOrParents === this) {
869
- return subscription;
569
+ if (errors) {
570
+ throw new UnsubscriptionError(errors);
870
571
  }
871
- subscription._parentOrParents = [_parentOrParents, this];
872
- }
873
- else if (_parentOrParents.indexOf(this) === -1) {
874
- _parentOrParents.push(this);
875
572
  }
876
- else {
877
- return subscription;
573
+ };
574
+ Subscription.prototype.add = function (teardown) {
575
+ var _a;
576
+ if (teardown && teardown !== this) {
577
+ if (this.closed) {
578
+ execFinalizer(teardown);
579
+ }
580
+ else {
581
+ if (teardown instanceof Subscription) {
582
+ if (teardown.closed || teardown._hasParent(this)) {
583
+ return;
584
+ }
585
+ teardown._addParent(this);
586
+ }
587
+ (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
588
+ }
878
589
  }
879
- var subscriptions = this._subscriptions;
880
- if (subscriptions === null) {
881
- this._subscriptions = [subscription];
590
+ };
591
+ Subscription.prototype._hasParent = function (parent) {
592
+ var _parentage = this._parentage;
593
+ return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
594
+ };
595
+ Subscription.prototype._addParent = function (parent) {
596
+ var _parentage = this._parentage;
597
+ this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
598
+ };
599
+ Subscription.prototype._removeParent = function (parent) {
600
+ var _parentage = this._parentage;
601
+ if (_parentage === parent) {
602
+ this._parentage = null;
882
603
  }
883
- else {
884
- subscriptions.push(subscription);
604
+ else if (Array.isArray(_parentage)) {
605
+ arrRemove(_parentage, parent);
885
606
  }
886
- return subscription;
887
607
  };
888
- Subscription.prototype.remove = function (subscription) {
889
- var subscriptions = this._subscriptions;
890
- if (subscriptions) {
891
- var subscriptionIndex = subscriptions.indexOf(subscription);
892
- if (subscriptionIndex !== -1) {
893
- subscriptions.splice(subscriptionIndex, 1);
894
- }
608
+ Subscription.prototype.remove = function (teardown) {
609
+ var _finalizers = this._finalizers;
610
+ _finalizers && arrRemove(_finalizers, teardown);
611
+ if (teardown instanceof Subscription) {
612
+ teardown._removeParent(this);
895
613
  }
896
614
  };
897
- Subscription.EMPTY = (function (empty) {
615
+ Subscription.EMPTY = (function () {
616
+ var empty = new Subscription();
898
617
  empty.closed = true;
899
618
  return empty;
900
- }(new Subscription()));
619
+ })();
901
620
  return Subscription;
902
621
  }());
903
- function flattenUnsubscriptionErrors(errors) {
904
- return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
622
+ var EMPTY_SUBSCRIPTION = Subscription$1.EMPTY;
623
+ function isSubscription(value) {
624
+ return (value instanceof Subscription$1 ||
625
+ (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
626
+ }
627
+ function execFinalizer(finalizer) {
628
+ if (isFunction(finalizer)) {
629
+ finalizer();
630
+ }
631
+ else {
632
+ finalizer.unsubscribe();
633
+ }
634
+ }
635
+
636
+ var config = {
637
+ onUnhandledError: null,
638
+ onStoppedNotification: null,
639
+ Promise: undefined,
640
+ useDeprecatedSynchronousErrorHandling: false,
641
+ useDeprecatedNextContext: false,
642
+ };
643
+
644
+ var timeoutProvider = {
645
+ setTimeout: function (handler, timeout) {
646
+ var args = [];
647
+ for (var _i = 2; _i < arguments.length; _i++) {
648
+ args[_i - 2] = arguments[_i];
649
+ }
650
+ var delegate = timeoutProvider.delegate;
651
+ if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
652
+ return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
653
+ }
654
+ return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
655
+ },
656
+ clearTimeout: function (handle) {
657
+ var delegate = timeoutProvider.delegate;
658
+ return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
659
+ },
660
+ delegate: undefined,
661
+ };
662
+
663
+ function reportUnhandledError(err) {
664
+ timeoutProvider.setTimeout(function () {
665
+ {
666
+ throw err;
667
+ }
668
+ });
669
+ }
670
+
671
+ function noop() { }
672
+
673
+ var context = null;
674
+ function errorContext(cb) {
675
+ if (config.useDeprecatedSynchronousErrorHandling) {
676
+ var isRoot = !context;
677
+ if (isRoot) {
678
+ context = { errorThrown: false, error: null };
679
+ }
680
+ cb();
681
+ if (isRoot) {
682
+ var _a = context, errorThrown = _a.errorThrown, error = _a.error;
683
+ context = null;
684
+ if (errorThrown) {
685
+ throw error;
686
+ }
687
+ }
688
+ }
689
+ else {
690
+ cb();
691
+ }
905
692
  }
906
693
 
907
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
908
- var rxSubscriber = /*@__PURE__*/ (function () {
909
- return typeof Symbol === 'function'
910
- ? /*@__PURE__*/ Symbol('rxSubscriber')
911
- : '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
912
- })();
913
-
914
- /** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
915
- var Subscriber = /*@__PURE__*/ (function (_super) {
916
- tslib_1.__extends(Subscriber, _super);
917
- function Subscriber(destinationOrNext, error, complete) {
694
+ var Subscriber = (function (_super) {
695
+ __extends(Subscriber, _super);
696
+ function Subscriber(destination) {
918
697
  var _this = _super.call(this) || this;
919
- _this.syncErrorValue = null;
920
- _this.syncErrorThrown = false;
921
- _this.syncErrorThrowable = false;
922
698
  _this.isStopped = false;
923
- switch (arguments.length) {
924
- case 0:
925
- _this.destination = empty;
926
- break;
927
- case 1:
928
- if (!destinationOrNext) {
929
- _this.destination = empty;
930
- break;
931
- }
932
- if (typeof destinationOrNext === 'object') {
933
- if (destinationOrNext instanceof Subscriber) {
934
- _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
935
- _this.destination = destinationOrNext;
936
- destinationOrNext.add(_this);
937
- }
938
- else {
939
- _this.syncErrorThrowable = true;
940
- _this.destination = new SafeSubscriber(_this, destinationOrNext);
941
- }
942
- break;
943
- }
944
- default:
945
- _this.syncErrorThrowable = true;
946
- _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
947
- break;
699
+ if (destination) {
700
+ _this.destination = destination;
701
+ if (isSubscription(destination)) {
702
+ destination.add(_this);
703
+ }
704
+ }
705
+ else {
706
+ _this.destination = EMPTY_OBSERVER;
948
707
  }
949
708
  return _this;
950
709
  }
951
- Subscriber.prototype[rxSubscriber] = function () { return this; };
952
710
  Subscriber.create = function (next, error, complete) {
953
- var subscriber = new Subscriber(next, error, complete);
954
- subscriber.syncErrorThrowable = false;
955
- return subscriber;
711
+ return new SafeSubscriber(next, error, complete);
956
712
  };
957
713
  Subscriber.prototype.next = function (value) {
958
- if (!this.isStopped) {
714
+ if (this.isStopped) ;
715
+ else {
959
716
  this._next(value);
960
717
  }
961
718
  };
962
719
  Subscriber.prototype.error = function (err) {
963
- if (!this.isStopped) {
720
+ if (this.isStopped) ;
721
+ else {
964
722
  this.isStopped = true;
965
723
  this._error(err);
966
724
  }
967
725
  };
968
726
  Subscriber.prototype.complete = function () {
969
- if (!this.isStopped) {
727
+ if (this.isStopped) ;
728
+ else {
970
729
  this.isStopped = true;
971
730
  this._complete();
972
731
  }
973
732
  };
974
733
  Subscriber.prototype.unsubscribe = function () {
975
- if (this.closed) {
976
- return;
734
+ if (!this.closed) {
735
+ this.isStopped = true;
736
+ _super.prototype.unsubscribe.call(this);
737
+ this.destination = null;
977
738
  }
978
- this.isStopped = true;
979
- _super.prototype.unsubscribe.call(this);
980
739
  };
981
740
  Subscriber.prototype._next = function (value) {
982
741
  this.destination.next(value);
983
742
  };
984
743
  Subscriber.prototype._error = function (err) {
985
- this.destination.error(err);
986
- this.unsubscribe();
744
+ try {
745
+ this.destination.error(err);
746
+ }
747
+ finally {
748
+ this.unsubscribe();
749
+ }
987
750
  };
988
751
  Subscriber.prototype._complete = function () {
989
- this.destination.complete();
990
- this.unsubscribe();
991
- };
992
- Subscriber.prototype._unsubscribeAndRecycle = function () {
993
- var _parentOrParents = this._parentOrParents;
994
- this._parentOrParents = null;
995
- this.unsubscribe();
996
- this.closed = false;
997
- this.isStopped = false;
998
- this._parentOrParents = _parentOrParents;
999
- return this;
752
+ try {
753
+ this.destination.complete();
754
+ }
755
+ finally {
756
+ this.unsubscribe();
757
+ }
1000
758
  };
1001
759
  return Subscriber;
1002
760
  }(Subscription$1));
1003
- var SafeSubscriber = /*@__PURE__*/ (function (_super) {
1004
- tslib_1.__extends(SafeSubscriber, _super);
1005
- function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
1006
- var _this = _super.call(this) || this;
1007
- _this._parentSubscriber = _parentSubscriber;
1008
- var next;
1009
- var context = _this;
1010
- if (isFunction(observerOrNext)) {
1011
- next = observerOrNext;
1012
- }
1013
- else if (observerOrNext) {
1014
- next = observerOrNext.next;
1015
- error = observerOrNext.error;
1016
- complete = observerOrNext.complete;
1017
- if (observerOrNext !== empty) {
1018
- context = Object.create(observerOrNext);
1019
- if (isFunction(context.unsubscribe)) {
1020
- _this.add(context.unsubscribe.bind(context));
1021
- }
1022
- context.unsubscribe = _this.unsubscribe.bind(_this);
1023
- }
1024
- }
1025
- _this._context = context;
1026
- _this._next = next;
1027
- _this._error = error;
1028
- _this._complete = complete;
1029
- return _this;
761
+ var _bind = Function.prototype.bind;
762
+ function bind(fn, thisArg) {
763
+ return _bind.call(fn, thisArg);
764
+ }
765
+ var ConsumerObserver = (function () {
766
+ function ConsumerObserver(partialObserver) {
767
+ this.partialObserver = partialObserver;
1030
768
  }
1031
- SafeSubscriber.prototype.next = function (value) {
1032
- if (!this.isStopped && this._next) {
1033
- var _parentSubscriber = this._parentSubscriber;
1034
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
1035
- this.__tryOrUnsub(this._next, value);
769
+ ConsumerObserver.prototype.next = function (value) {
770
+ var partialObserver = this.partialObserver;
771
+ if (partialObserver.next) {
772
+ try {
773
+ partialObserver.next(value);
1036
774
  }
1037
- else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
1038
- this.unsubscribe();
775
+ catch (error) {
776
+ handleUnhandledError(error);
1039
777
  }
1040
778
  }
1041
779
  };
1042
- SafeSubscriber.prototype.error = function (err) {
1043
- if (!this.isStopped) {
1044
- var _parentSubscriber = this._parentSubscriber;
1045
- var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
1046
- if (this._error) {
1047
- if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
1048
- this.__tryOrUnsub(this._error, err);
1049
- this.unsubscribe();
1050
- }
1051
- else {
1052
- this.__tryOrSetError(_parentSubscriber, this._error, err);
1053
- this.unsubscribe();
1054
- }
1055
- }
1056
- else if (!_parentSubscriber.syncErrorThrowable) {
1057
- this.unsubscribe();
1058
- if (useDeprecatedSynchronousErrorHandling) {
1059
- throw err;
1060
- }
1061
- hostReportError(err);
780
+ ConsumerObserver.prototype.error = function (err) {
781
+ var partialObserver = this.partialObserver;
782
+ if (partialObserver.error) {
783
+ try {
784
+ partialObserver.error(err);
1062
785
  }
1063
- else {
1064
- if (useDeprecatedSynchronousErrorHandling) {
1065
- _parentSubscriber.syncErrorValue = err;
1066
- _parentSubscriber.syncErrorThrown = true;
1067
- }
1068
- else {
1069
- hostReportError(err);
1070
- }
1071
- this.unsubscribe();
786
+ catch (error) {
787
+ handleUnhandledError(error);
1072
788
  }
1073
789
  }
1074
- };
1075
- SafeSubscriber.prototype.complete = function () {
1076
- var _this = this;
1077
- if (!this.isStopped) {
1078
- var _parentSubscriber = this._parentSubscriber;
1079
- if (this._complete) {
1080
- var wrappedComplete = function () { return _this._complete.call(_this._context); };
1081
- if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
1082
- this.__tryOrUnsub(wrappedComplete);
1083
- this.unsubscribe();
1084
- }
1085
- else {
1086
- this.__tryOrSetError(_parentSubscriber, wrappedComplete);
1087
- this.unsubscribe();
1088
- }
1089
- }
1090
- else {
1091
- this.unsubscribe();
1092
- }
790
+ else {
791
+ handleUnhandledError(err);
1093
792
  }
1094
793
  };
1095
- SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
1096
- try {
1097
- fn.call(this._context, value);
1098
- }
1099
- catch (err) {
1100
- this.unsubscribe();
1101
- if (config.useDeprecatedSynchronousErrorHandling) {
1102
- throw err;
794
+ ConsumerObserver.prototype.complete = function () {
795
+ var partialObserver = this.partialObserver;
796
+ if (partialObserver.complete) {
797
+ try {
798
+ partialObserver.complete();
1103
799
  }
1104
- else {
1105
- hostReportError(err);
800
+ catch (error) {
801
+ handleUnhandledError(error);
1106
802
  }
1107
803
  }
1108
804
  };
1109
- SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
1110
- if (!config.useDeprecatedSynchronousErrorHandling) {
1111
- throw new Error('bad call');
1112
- }
1113
- try {
1114
- fn.call(this._context, value);
805
+ return ConsumerObserver;
806
+ }());
807
+ var SafeSubscriber = (function (_super) {
808
+ __extends(SafeSubscriber, _super);
809
+ function SafeSubscriber(observerOrNext, error, complete) {
810
+ var _this = _super.call(this) || this;
811
+ var partialObserver;
812
+ if (isFunction(observerOrNext) || !observerOrNext) {
813
+ partialObserver = {
814
+ next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
815
+ error: error !== null && error !== void 0 ? error : undefined,
816
+ complete: complete !== null && complete !== void 0 ? complete : undefined,
817
+ };
1115
818
  }
1116
- catch (err) {
1117
- if (config.useDeprecatedSynchronousErrorHandling) {
1118
- parent.syncErrorValue = err;
1119
- parent.syncErrorThrown = true;
1120
- return true;
819
+ else {
820
+ var context_1;
821
+ if (_this && config.useDeprecatedNextContext) {
822
+ context_1 = Object.create(observerOrNext);
823
+ context_1.unsubscribe = function () { return _this.unsubscribe(); };
824
+ partialObserver = {
825
+ next: observerOrNext.next && bind(observerOrNext.next, context_1),
826
+ error: observerOrNext.error && bind(observerOrNext.error, context_1),
827
+ complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
828
+ };
1121
829
  }
1122
830
  else {
1123
- hostReportError(err);
1124
- return true;
831
+ partialObserver = observerOrNext;
1125
832
  }
1126
833
  }
1127
- return false;
1128
- };
1129
- SafeSubscriber.prototype._unsubscribe = function () {
1130
- var _parentSubscriber = this._parentSubscriber;
1131
- this._context = null;
1132
- this._parentSubscriber = null;
1133
- _parentSubscriber.unsubscribe();
1134
- };
834
+ _this.destination = new ConsumerObserver(partialObserver);
835
+ return _this;
836
+ }
1135
837
  return SafeSubscriber;
1136
838
  }(Subscriber));
1137
-
1138
- /** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
1139
- function canReportError(observer) {
1140
- while (observer) {
1141
- var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
1142
- if (closed_1 || isStopped) {
1143
- return false;
1144
- }
1145
- else if (destination && destination instanceof Subscriber) {
1146
- observer = destination;
1147
- }
1148
- else {
1149
- observer = null;
1150
- }
839
+ function handleUnhandledError(error) {
840
+ {
841
+ reportUnhandledError(error);
1151
842
  }
1152
- return true;
1153
843
  }
1154
-
1155
- /** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
1156
- function toSubscriber(nextOrObserver, error, complete) {
1157
- if (nextOrObserver) {
1158
- if (nextOrObserver instanceof Subscriber) {
1159
- return nextOrObserver;
1160
- }
1161
- if (nextOrObserver[rxSubscriber]) {
1162
- return nextOrObserver[rxSubscriber]();
1163
- }
1164
- }
1165
- if (!nextOrObserver && !error && !complete) {
1166
- return new Subscriber(empty);
1167
- }
1168
- return new Subscriber(nextOrObserver, error, complete);
844
+ function defaultErrorHandler(err) {
845
+ throw err;
1169
846
  }
847
+ var EMPTY_OBSERVER = {
848
+ closed: true,
849
+ next: noop,
850
+ error: defaultErrorHandler,
851
+ complete: noop,
852
+ };
1170
853
 
1171
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
1172
- var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
854
+ var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
1173
855
 
1174
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
1175
856
  function identity(x) {
1176
857
  return x;
1177
858
  }
1178
859
 
1179
- /** PURE_IMPORTS_START _identity PURE_IMPORTS_END */
1180
860
  function pipeFromArray(fns) {
1181
861
  if (fns.length === 0) {
1182
862
  return identity;
@@ -1189,10 +869,8 @@ function pipeFromArray(fns) {
1189
869
  };
1190
870
  }
1191
871
 
1192
- /** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
1193
- var Observable = /*@__PURE__*/ (function () {
872
+ var Observable = (function () {
1194
873
  function Observable(subscribe) {
1195
- this._isScalar = false;
1196
874
  if (subscribe) {
1197
875
  this._subscribe = subscribe;
1198
876
  }
@@ -1204,64 +882,52 @@ var Observable = /*@__PURE__*/ (function () {
1204
882
  return observable;
1205
883
  };
1206
884
  Observable.prototype.subscribe = function (observerOrNext, error, complete) {
1207
- var operator = this.operator;
1208
- var sink = toSubscriber(observerOrNext, error, complete);
1209
- if (operator) {
1210
- sink.add(operator.call(sink, this.source));
1211
- }
1212
- else {
1213
- sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
1214
- this._subscribe(sink) :
1215
- this._trySubscribe(sink));
1216
- }
1217
- if (config.useDeprecatedSynchronousErrorHandling) {
1218
- if (sink.syncErrorThrowable) {
1219
- sink.syncErrorThrowable = false;
1220
- if (sink.syncErrorThrown) {
1221
- throw sink.syncErrorValue;
1222
- }
1223
- }
1224
- }
1225
- return sink;
885
+ var _this = this;
886
+ var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
887
+ errorContext(function () {
888
+ var _a = _this, operator = _a.operator, source = _a.source;
889
+ subscriber.add(operator
890
+ ?
891
+ operator.call(subscriber, source)
892
+ : source
893
+ ?
894
+ _this._subscribe(subscriber)
895
+ :
896
+ _this._trySubscribe(subscriber));
897
+ });
898
+ return subscriber;
1226
899
  };
1227
900
  Observable.prototype._trySubscribe = function (sink) {
1228
901
  try {
1229
902
  return this._subscribe(sink);
1230
903
  }
1231
904
  catch (err) {
1232
- if (config.useDeprecatedSynchronousErrorHandling) {
1233
- sink.syncErrorThrown = true;
1234
- sink.syncErrorValue = err;
1235
- }
1236
- if (canReportError(sink)) {
1237
- sink.error(err);
1238
- }
1239
- else {
1240
- console.warn(err);
1241
- }
905
+ sink.error(err);
1242
906
  }
1243
907
  };
1244
908
  Observable.prototype.forEach = function (next, promiseCtor) {
1245
909
  var _this = this;
1246
910
  promiseCtor = getPromiseCtor(promiseCtor);
1247
911
  return new promiseCtor(function (resolve, reject) {
1248
- var subscription;
1249
- subscription = _this.subscribe(function (value) {
1250
- try {
1251
- next(value);
1252
- }
1253
- catch (err) {
1254
- reject(err);
1255
- if (subscription) {
1256
- subscription.unsubscribe();
912
+ var subscriber = new SafeSubscriber({
913
+ next: function (value) {
914
+ try {
915
+ next(value);
1257
916
  }
1258
- }
1259
- }, reject, resolve);
917
+ catch (err) {
918
+ reject(err);
919
+ subscriber.unsubscribe();
920
+ }
921
+ },
922
+ error: reject,
923
+ complete: resolve,
924
+ });
925
+ _this.subscribe(subscriber);
1260
926
  });
1261
927
  };
1262
928
  Observable.prototype._subscribe = function (subscriber) {
1263
- var source = this.source;
1264
- return source && source.subscribe(subscriber);
929
+ var _a;
930
+ return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
1265
931
  };
1266
932
  Observable.prototype[observable] = function () {
1267
933
  return this;
@@ -1271,9 +937,6 @@ var Observable = /*@__PURE__*/ (function () {
1271
937
  for (var _i = 0; _i < arguments.length; _i++) {
1272
938
  operations[_i] = arguments[_i];
1273
939
  }
1274
- if (operations.length === 0) {
1275
- return this;
1276
- }
1277
940
  return pipeFromArray(operations)(this);
1278
941
  };
1279
942
  Observable.prototype.toPromise = function (promiseCtor) {
@@ -1281,7 +944,7 @@ var Observable = /*@__PURE__*/ (function () {
1281
944
  promiseCtor = getPromiseCtor(promiseCtor);
1282
945
  return new promiseCtor(function (resolve, reject) {
1283
946
  var value;
1284
- _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
947
+ _this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
1285
948
  });
1286
949
  };
1287
950
  Observable.create = function (subscribe) {
@@ -1290,155 +953,139 @@ var Observable = /*@__PURE__*/ (function () {
1290
953
  return Observable;
1291
954
  }());
1292
955
  function getPromiseCtor(promiseCtor) {
1293
- if (!promiseCtor) {
1294
- promiseCtor = config.Promise || Promise;
1295
- }
1296
- if (!promiseCtor) {
1297
- throw new Error('no Promise impl found');
1298
- }
1299
- return promiseCtor;
956
+ var _a;
957
+ return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
958
+ }
959
+ function isObserver(value) {
960
+ return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
961
+ }
962
+ function isSubscriber(value) {
963
+ return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
1300
964
  }
1301
965
 
1302
- /** PURE_IMPORTS_START PURE_IMPORTS_END */
1303
- var ObjectUnsubscribedErrorImpl = /*@__PURE__*/ (function () {
1304
- function ObjectUnsubscribedErrorImpl() {
1305
- Error.call(this);
1306
- this.message = 'object unsubscribed';
966
+ var ObjectUnsubscribedError = createErrorClass(function (_super) {
967
+ return function ObjectUnsubscribedErrorImpl() {
968
+ _super(this);
1307
969
  this.name = 'ObjectUnsubscribedError';
1308
- return this;
1309
- }
1310
- ObjectUnsubscribedErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
1311
- return ObjectUnsubscribedErrorImpl;
1312
- })();
1313
- var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
1314
-
1315
- /** PURE_IMPORTS_START tslib,_Subscription PURE_IMPORTS_END */
1316
- var SubjectSubscription = /*@__PURE__*/ (function (_super) {
1317
- tslib_1.__extends(SubjectSubscription, _super);
1318
- function SubjectSubscription(subject, subscriber) {
1319
- var _this = _super.call(this) || this;
1320
- _this.subject = subject;
1321
- _this.subscriber = subscriber;
1322
- _this.closed = false;
1323
- return _this;
1324
- }
1325
- SubjectSubscription.prototype.unsubscribe = function () {
1326
- if (this.closed) {
1327
- return;
1328
- }
1329
- this.closed = true;
1330
- var subject = this.subject;
1331
- var observers = subject.observers;
1332
- this.subject = null;
1333
- if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
1334
- return;
1335
- }
1336
- var subscriberIndex = observers.indexOf(this.subscriber);
1337
- if (subscriberIndex !== -1) {
1338
- observers.splice(subscriberIndex, 1);
1339
- }
970
+ this.message = 'object unsubscribed';
1340
971
  };
1341
- return SubjectSubscription;
1342
- }(Subscription$1));
972
+ });
1343
973
 
1344
- /** PURE_IMPORTS_START tslib,_Observable,_Subscriber,_Subscription,_util_ObjectUnsubscribedError,_SubjectSubscription,_internal_symbol_rxSubscriber PURE_IMPORTS_END */
1345
- var SubjectSubscriber = /*@__PURE__*/ (function (_super) {
1346
- tslib_1.__extends(SubjectSubscriber, _super);
1347
- function SubjectSubscriber(destination) {
1348
- var _this = _super.call(this, destination) || this;
1349
- _this.destination = destination;
1350
- return _this;
1351
- }
1352
- return SubjectSubscriber;
1353
- }(Subscriber));
1354
- var Subject = /*@__PURE__*/ (function (_super) {
1355
- tslib_1.__extends(Subject, _super);
974
+ var Subject = (function (_super) {
975
+ __extends(Subject, _super);
1356
976
  function Subject() {
1357
977
  var _this = _super.call(this) || this;
1358
- _this.observers = [];
1359
978
  _this.closed = false;
979
+ _this.currentObservers = null;
980
+ _this.observers = [];
1360
981
  _this.isStopped = false;
1361
982
  _this.hasError = false;
1362
983
  _this.thrownError = null;
1363
984
  return _this;
1364
985
  }
1365
- Subject.prototype[rxSubscriber] = function () {
1366
- return new SubjectSubscriber(this);
1367
- };
1368
986
  Subject.prototype.lift = function (operator) {
1369
987
  var subject = new AnonymousSubject(this, this);
1370
988
  subject.operator = operator;
1371
989
  return subject;
1372
990
  };
1373
- Subject.prototype.next = function (value) {
991
+ Subject.prototype._throwIfClosed = function () {
1374
992
  if (this.closed) {
1375
993
  throw new ObjectUnsubscribedError();
1376
994
  }
1377
- if (!this.isStopped) {
1378
- var observers = this.observers;
1379
- var len = observers.length;
1380
- var copy = observers.slice();
1381
- for (var i = 0; i < len; i++) {
1382
- copy[i].next(value);
995
+ };
996
+ Subject.prototype.next = function (value) {
997
+ var _this = this;
998
+ errorContext(function () {
999
+ var e_1, _a;
1000
+ _this._throwIfClosed();
1001
+ if (!_this.isStopped) {
1002
+ if (!_this.currentObservers) {
1003
+ _this.currentObservers = Array.from(_this.observers);
1004
+ }
1005
+ try {
1006
+ for (var _b = __values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
1007
+ var observer = _c.value;
1008
+ observer.next(value);
1009
+ }
1010
+ }
1011
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1012
+ finally {
1013
+ try {
1014
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1015
+ }
1016
+ finally { if (e_1) throw e_1.error; }
1017
+ }
1383
1018
  }
1384
- }
1019
+ });
1385
1020
  };
1386
1021
  Subject.prototype.error = function (err) {
1387
- if (this.closed) {
1388
- throw new ObjectUnsubscribedError();
1389
- }
1390
- this.hasError = true;
1391
- this.thrownError = err;
1392
- this.isStopped = true;
1393
- var observers = this.observers;
1394
- var len = observers.length;
1395
- var copy = observers.slice();
1396
- for (var i = 0; i < len; i++) {
1397
- copy[i].error(err);
1398
- }
1399
- this.observers.length = 0;
1022
+ var _this = this;
1023
+ errorContext(function () {
1024
+ _this._throwIfClosed();
1025
+ if (!_this.isStopped) {
1026
+ _this.hasError = _this.isStopped = true;
1027
+ _this.thrownError = err;
1028
+ var observers = _this.observers;
1029
+ while (observers.length) {
1030
+ observers.shift().error(err);
1031
+ }
1032
+ }
1033
+ });
1400
1034
  };
1401
1035
  Subject.prototype.complete = function () {
1402
- if (this.closed) {
1403
- throw new ObjectUnsubscribedError();
1404
- }
1405
- this.isStopped = true;
1406
- var observers = this.observers;
1407
- var len = observers.length;
1408
- var copy = observers.slice();
1409
- for (var i = 0; i < len; i++) {
1410
- copy[i].complete();
1411
- }
1412
- this.observers.length = 0;
1036
+ var _this = this;
1037
+ errorContext(function () {
1038
+ _this._throwIfClosed();
1039
+ if (!_this.isStopped) {
1040
+ _this.isStopped = true;
1041
+ var observers = _this.observers;
1042
+ while (observers.length) {
1043
+ observers.shift().complete();
1044
+ }
1045
+ }
1046
+ });
1413
1047
  };
1414
1048
  Subject.prototype.unsubscribe = function () {
1415
- this.isStopped = true;
1416
- this.closed = true;
1417
- this.observers = null;
1049
+ this.isStopped = this.closed = true;
1050
+ this.observers = this.currentObservers = null;
1418
1051
  };
1052
+ Object.defineProperty(Subject.prototype, "observed", {
1053
+ get: function () {
1054
+ var _a;
1055
+ return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
1056
+ },
1057
+ enumerable: false,
1058
+ configurable: true
1059
+ });
1419
1060
  Subject.prototype._trySubscribe = function (subscriber) {
1420
- if (this.closed) {
1421
- throw new ObjectUnsubscribedError();
1422
- }
1423
- else {
1424
- return _super.prototype._trySubscribe.call(this, subscriber);
1425
- }
1061
+ this._throwIfClosed();
1062
+ return _super.prototype._trySubscribe.call(this, subscriber);
1426
1063
  };
1427
1064
  Subject.prototype._subscribe = function (subscriber) {
1428
- if (this.closed) {
1429
- throw new ObjectUnsubscribedError();
1065
+ this._throwIfClosed();
1066
+ this._checkFinalizedStatuses(subscriber);
1067
+ return this._innerSubscribe(subscriber);
1068
+ };
1069
+ Subject.prototype._innerSubscribe = function (subscriber) {
1070
+ var _this = this;
1071
+ var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
1072
+ if (hasError || isStopped) {
1073
+ return EMPTY_SUBSCRIPTION;
1430
1074
  }
1431
- else if (this.hasError) {
1432
- subscriber.error(this.thrownError);
1433
- return Subscription$1.EMPTY;
1075
+ this.currentObservers = null;
1076
+ observers.push(subscriber);
1077
+ return new Subscription$1(function () {
1078
+ _this.currentObservers = null;
1079
+ arrRemove(observers, subscriber);
1080
+ });
1081
+ };
1082
+ Subject.prototype._checkFinalizedStatuses = function (subscriber) {
1083
+ var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
1084
+ if (hasError) {
1085
+ subscriber.error(thrownError);
1434
1086
  }
1435
- else if (this.isStopped) {
1087
+ else if (isStopped) {
1436
1088
  subscriber.complete();
1437
- return Subscription$1.EMPTY;
1438
- }
1439
- else {
1440
- this.observers.push(subscriber);
1441
- return new SubjectSubscription(this, subscriber);
1442
1089
  }
1443
1090
  };
1444
1091
  Subject.prototype.asObservable = function () {
@@ -1451,8 +1098,8 @@ var Subject = /*@__PURE__*/ (function (_super) {
1451
1098
  };
1452
1099
  return Subject;
1453
1100
  }(Observable));
1454
- var AnonymousSubject = /*@__PURE__*/ (function (_super) {
1455
- tslib_1.__extends(AnonymousSubject, _super);
1101
+ var AnonymousSubject = (function (_super) {
1102
+ __extends(AnonymousSubject, _super);
1456
1103
  function AnonymousSubject(destination, source) {
1457
1104
  var _this = _super.call(this) || this;
1458
1105
  _this.destination = destination;
@@ -1460,31 +1107,20 @@ var AnonymousSubject = /*@__PURE__*/ (function (_super) {
1460
1107
  return _this;
1461
1108
  }
1462
1109
  AnonymousSubject.prototype.next = function (value) {
1463
- var destination = this.destination;
1464
- if (destination && destination.next) {
1465
- destination.next(value);
1466
- }
1110
+ var _a, _b;
1111
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
1467
1112
  };
1468
1113
  AnonymousSubject.prototype.error = function (err) {
1469
- var destination = this.destination;
1470
- if (destination && destination.error) {
1471
- this.destination.error(err);
1472
- }
1114
+ var _a, _b;
1115
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
1473
1116
  };
1474
1117
  AnonymousSubject.prototype.complete = function () {
1475
- var destination = this.destination;
1476
- if (destination && destination.complete) {
1477
- this.destination.complete();
1478
- }
1118
+ var _a, _b;
1119
+ (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
1479
1120
  };
1480
1121
  AnonymousSubject.prototype._subscribe = function (subscriber) {
1481
- var source = this.source;
1482
- if (source) {
1483
- return this.source.subscribe(subscriber);
1484
- }
1485
- else {
1486
- return Subscription$1.EMPTY;
1487
- }
1122
+ var _a, _b;
1123
+ return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
1488
1124
  };
1489
1125
  return AnonymousSubject;
1490
1126
  }(Subject));
@@ -1526,11 +1162,11 @@ class ReflectHelper {
1526
1162
  }
1527
1163
  static first({ key, target, property, own = true }) {
1528
1164
  const values = ReflectHelper.get({ key, target, property, own });
1529
- return isArray$1(values) ? first(values) : values;
1165
+ return isArray(values) ? first(values) : values;
1530
1166
  }
1531
1167
  static last({ key, target, property, own = true }) {
1532
1168
  const values = ReflectHelper.get({ key, target, property, own });
1533
- return isArray$1(values) ? last(values) : values;
1169
+ return isArray(values) ? last(values) : values;
1534
1170
  }
1535
1171
  static set({ key, target, property, value, propertyDescriptor }) {
1536
1172
  Reflect.defineMetadata(key, value, target, property);
@@ -1556,7 +1192,7 @@ class ReflectHelper {
1556
1192
  const values = target[property];
1557
1193
  let value = values.value;
1558
1194
  const propertyDescriptor = values.propertyDescriptor;
1559
- if (!isArray$1(value))
1195
+ if (!isArray(value))
1560
1196
  value = [value];
1561
1197
  return flatten(value.map((val) => {
1562
1198
  return {
@@ -2096,152 +1732,196 @@ __decorate([
2096
1732
  __metadata("design:type", Array)
2097
1733
  ], Subscription.prototype, "payment", void 0);
2098
1734
 
2099
- class SubscriptionMaterialization extends BaseModel {
1735
+ class Filter extends BaseModel {
1736
+ static get identifiersFields() {
1737
+ return ['id'];
1738
+ }
1739
+ }
1740
+
1741
+ class CategoryBase extends BaseModel {
2100
1742
  static get identifiersFields() {
2101
1743
  return ['id'];
2102
1744
  }
2103
1745
  }
2104
1746
  __decorate([
2105
- Type(() => User),
2106
- __metadata("design:type", User)
2107
- ], SubscriptionMaterialization.prototype, "user", void 0);
2108
- __decorate([
2109
- Type(() => SubscriptionPlan),
2110
- __metadata("design:type", SubscriptionPlan)
2111
- ], SubscriptionMaterialization.prototype, "subscriptionPlan", void 0);
2112
- __decorate([
2113
- Type(() => UserAddress),
2114
- __metadata("design:type", UserAddress)
2115
- ], SubscriptionMaterialization.prototype, "shippingAddress", void 0);
1747
+ Type(() => CategoryBase),
1748
+ __metadata("design:type", CategoryBase)
1749
+ ], CategoryBase.prototype, "parent", void 0);
2116
1750
  __decorate([
2117
- Type(() => UserAddress),
2118
- __metadata("design:type", UserAddress)
2119
- ], SubscriptionMaterialization.prototype, "billingAddress", void 0);
2120
- __decorate([
2121
- Type(() => Coupon),
2122
- __metadata("design:type", Coupon)
2123
- ], SubscriptionMaterialization.prototype, "coupon", void 0);
2124
- __decorate([
2125
- Type(() => Edition),
1751
+ Type(() => Filter),
2126
1752
  __metadata("design:type", Array)
2127
- ], SubscriptionMaterialization.prototype, "editions", void 0);
2128
- __decorate([
2129
- Type(() => SubscriptionPayment),
2130
- __metadata("design:type", SubscriptionPayment)
2131
- ], SubscriptionMaterialization.prototype, "payment", void 0);
1753
+ ], CategoryBase.prototype, "filters", void 0);
2132
1754
 
2133
- class SubscriptionSummary extends BaseModel {
1755
+ class CategoryForProduct extends CategoryBase {
2134
1756
  static get identifiersFields() {
2135
1757
  return ['id'];
2136
1758
  }
2137
1759
  }
2138
1760
 
2139
- class UserPaymentMethod extends BaseModel {
1761
+ class ProductBase extends BaseModel {
1762
+ get evaluation() {
1763
+ return {
1764
+ reviews: this.reviews,
1765
+ count: this.reviewsTotal,
1766
+ rating: this.rate,
1767
+ };
1768
+ }
1769
+ set evaluation(evaluation) {
1770
+ if (!evaluation) {
1771
+ this.reviews = null;
1772
+ this.reviewsTotal = null;
1773
+ this.rate = null;
1774
+ return;
1775
+ }
1776
+ this.reviews = evaluation.reviews || this.reviews;
1777
+ this.reviewsTotal = evaluation.count || this.reviewsTotal;
1778
+ this.rate = evaluation.rating || this.rate;
1779
+ }
2140
1780
  static get identifiersFields() {
2141
- return ['id', 'userId'];
1781
+ return ['id'];
2142
1782
  }
2143
1783
  }
2144
1784
 
2145
- class Lead extends BaseModel {
1785
+ class ProductForKit extends ProductBase {
2146
1786
  static get identifiersFields() {
2147
1787
  return ['id'];
2148
1788
  }
2149
- }
1789
+ }
1790
+ __decorate([
1791
+ Type(() => CategoryForProduct),
1792
+ __metadata("design:type", CategoryForProduct)
1793
+ ], ProductForKit.prototype, "category", void 0);
2150
1794
 
2151
- class UnauthorizedError extends CustomError {
2152
- constructor(message) {
2153
- super(message);
1795
+ class KitProduct extends BaseModel {
1796
+ static get identifiersFields() {
1797
+ return ['productId', 'kitProductId'];
2154
1798
  }
2155
- }
1799
+ }
1800
+ __decorate([
1801
+ Type(() => ProductForKit),
1802
+ __metadata("design:type", ProductForKit)
1803
+ ], KitProduct.prototype, "kit", void 0);
1804
+ __decorate([
1805
+ Type(() => ProductForKit),
1806
+ __metadata("design:type", ProductForKit)
1807
+ ], KitProduct.prototype, "product", void 0);
2156
1808
 
2157
- var SignInMethods;
2158
- (function (SignInMethods) {
2159
- SignInMethods["EMAIL_PASSWORD"] = "email_password";
2160
- SignInMethods["GOOGLE"] = "google";
2161
- })(SignInMethods || (SignInMethods = {}));
2162
- class Authentication {
2163
- constructor(authService, userRepository) {
2164
- this.authService = authService;
2165
- this.userRepository = userRepository;
1809
+ class ProductForCategory extends ProductBase {
1810
+ static get identifiersFields() {
1811
+ return ['id'];
2166
1812
  }
2167
- async signIn({ email, password }, signInMethod) {
2168
- const method = this.getServiceByMethod(signInMethod);
2169
- const userAuth = await this.authService[method]({ email, password });
2170
- const user = this.userRepository.get({ id: userAuth.id });
2171
- if (!isNil(user))
2172
- return user;
2173
- if (/^.+@b4a.com.br$/.test(userAuth.email))
2174
- return this.createsUserByCredential(userAuth);
2175
- throw new UnauthorizedError('Invalid credentials');
1813
+ }
1814
+ __decorate([
1815
+ Type(() => KitProduct),
1816
+ __metadata("design:type", Array)
1817
+ ], ProductForCategory.prototype, "kitProducts", void 0);
1818
+
1819
+ class Category extends CategoryBase {
1820
+ static get identifiersFields() {
1821
+ return ['id'];
2176
1822
  }
2177
- getServiceByMethod(signInMethod) {
2178
- return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
1823
+ }
1824
+ __decorate([
1825
+ Type(() => ProductForCategory),
1826
+ __metadata("design:type", Array)
1827
+ ], Category.prototype, "childrenProducts", void 0);
1828
+
1829
+ class CategoryCollectionChildren extends BaseModel {
1830
+ static get identifiersFields() {
1831
+ return ['collectionId', 'categoryId'];
2179
1832
  }
2180
- async createsUserByCredential(user) {
2181
- var _a;
2182
- const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
2183
- const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
2184
- lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
2185
- return this.userRepository.create(person);
1833
+ }
1834
+ __decorate([
1835
+ Type(() => CategoryCollectionChildren),
1836
+ __metadata("design:type", CategoryCollectionChildren)
1837
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
1838
+
1839
+ class CategoryFilter extends BaseModel {
1840
+ static get identifiersFields() {
1841
+ return ['id'];
2186
1842
  }
2187
- }
1843
+ }
1844
+ __decorate([
1845
+ Type(() => Filter),
1846
+ __metadata("design:type", Filter)
1847
+ ], CategoryFilter.prototype, "filter", void 0);
1848
+ __decorate([
1849
+ Type(() => Category),
1850
+ __metadata("design:type", Category)
1851
+ ], CategoryFilter.prototype, "category", void 0);
2188
1852
 
2189
- class UserAlreadyRegisteredError extends CustomError {
2190
- constructor(message) {
2191
- super(message);
1853
+ var GenderDestination;
1854
+ (function (GenderDestination) {
1855
+ GenderDestination["FEMALE"] = "female";
1856
+ GenderDestination["MALE"] = "male";
1857
+ GenderDestination["UNISEX"] = "unisex";
1858
+ })(GenderDestination || (GenderDestination = {}));
1859
+
1860
+ var Shops;
1861
+ (function (Shops) {
1862
+ Shops["MENSMARKET"] = "mensmarket";
1863
+ Shops["GLAMSHOP"] = "Glamshop";
1864
+ Shops["GLAMPOINTS"] = "Glampoints";
1865
+ Shops["ALL"] = "ALL";
1866
+ })(Shops || (Shops = {}));
1867
+
1868
+ class FilterOption extends BaseModel {
1869
+ static get identifiersFields() {
1870
+ return ['id'];
2192
1871
  }
2193
1872
  }
2194
1873
 
2195
- class WeakPasswordError extends CustomError {
2196
- constructor(message = 'Weak password') {
2197
- super(message);
1874
+ class Product extends ProductBase {
1875
+ static get identifiersFields() {
1876
+ return ['id'];
1877
+ }
1878
+ }
1879
+ __decorate([
1880
+ Type(() => CategoryForProduct),
1881
+ __metadata("design:type", CategoryForProduct)
1882
+ ], Product.prototype, "category", void 0);
1883
+ __decorate([
1884
+ Type(() => KitProduct),
1885
+ __metadata("design:type", Array)
1886
+ ], Product.prototype, "kitProducts", void 0);
1887
+
1888
+ class ProductReviews extends BaseModel {
1889
+ static get identifiersFields() {
1890
+ return ['id'];
2198
1891
  }
2199
1892
  }
2200
1893
 
2201
- class Register {
2202
- constructor(registerService, userRepository) {
2203
- this.registerService = registerService;
2204
- this.userRepository = userRepository;
1894
+ class Variant extends BaseModel {
1895
+ static get identifiersFields() {
1896
+ return ['id', 'productId'];
2205
1897
  }
2206
- async register(params) {
2207
- const email = params.email.toLocaleLowerCase();
2208
- const displayName = `${params.firstName} ${params.lastName}`;
2209
- if (await this.userRepository.checkIfExistsByField('cpf', params.cpf))
2210
- throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} já registrado.`);
2211
- if (await this.userRepository.checkIfExistsByField('email', params.email))
2212
- throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} já registrado.`);
2213
- const auth = await this.registerService.register({
2214
- birthday: params.birthday,
2215
- email,
2216
- firstName: params.firstName,
2217
- lastName: params.lastName,
2218
- cpf: params.cpf,
2219
- displayName,
2220
- phone: params.phone,
2221
- password: params.password,
2222
- });
2223
- delete params.password;
2224
- const user = await this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
2225
- displayName, type: UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
2226
- return user;
1898
+ }
1899
+
1900
+ class Wishlist extends Category {
1901
+ static get identifiersFields() {
1902
+ return ['id'];
2227
1903
  }
2228
1904
  }
2229
1905
 
2230
- class SignOut {
2231
- constructor(authService) {
2232
- this.authService = authService;
1906
+ class Buy2Win extends BaseModel {
1907
+ static get identifiersFields() {
1908
+ return ['id'];
2233
1909
  }
2234
- async signOut() {
2235
- await this.authService.signOut();
1910
+ }
1911
+ __decorate([
1912
+ Type(() => Category),
1913
+ __metadata("design:type", Array)
1914
+ ], Buy2Win.prototype, "categories", void 0);
1915
+
1916
+ class CampaignDashboard extends BaseModel {
1917
+ static get identifiersFields() {
1918
+ return ['id'];
2236
1919
  }
2237
1920
  }
2238
1921
 
2239
- class RecoveryPassword {
2240
- constructor(authService) {
2241
- this.authService = authService;
2242
- }
2243
- async sendEmail(email) {
2244
- await this.authService.sendPasswordResetEmail(email);
1922
+ class CampaignHashtag extends BaseModel {
1923
+ static get identifiersFields() {
1924
+ return ['id'];
2245
1925
  }
2246
1926
  }
2247
1927
 
@@ -2299,16 +1979,10 @@ var OrderStatus;
2299
1979
  class Order extends Checkout {
2300
1980
  }
2301
1981
  __decorate([
2302
- Type(() => PaymentTransaction),
2303
- __metadata("design:type", PaymentTransaction)
1982
+ Type(() => Payment),
1983
+ __metadata("design:type", Payment)
2304
1984
  ], Order.prototype, "payment", void 0);
2305
1985
 
2306
- class OrderBlocked extends BaseModel {
2307
- static get identifiersFields() {
2308
- return ['id'];
2309
- }
2310
- }
2311
-
2312
1986
  class CheckoutSubscription extends BaseModel {
2313
1987
  static get identifiersFields() {
2314
1988
  return ['id'];
@@ -2331,484 +2005,152 @@ __decorate([
2331
2005
  __metadata("design:type", Coupon)
2332
2006
  ], CheckoutSubscription.prototype, "coupon", void 0);
2333
2007
 
2334
- class AdyenCardService {
2335
- constructor(credentials) {
2336
- this.credentials = credentials;
2337
- }
2338
- async pay(checkout, card) {
2339
- try {
2340
- const result = await axios({
2341
- method: 'POST',
2342
- url: this.credentials.URL_TRANSACTION,
2343
- headers: {
2344
- 'x-api-key': this.credentials.API_KEY,
2345
- 'content-type': 'application/json',
2346
- },
2347
- data: this.createCardPayment(checkout, card),
2348
- });
2349
- if (result.data.resultCode !== 'Authorised') {
2350
- this.checkoutAntiFraudService.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2351
- 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`));
2352
- }
2353
- const payment = {
2354
- createdAt: new Date(),
2355
- updatedAt: new Date(),
2356
- userId: checkout.user.id,
2357
- checkoutId: checkout.id,
2358
- totalPrice: checkout.totalPrice,
2359
- transaction: Object.assign(Object.assign({}, result.data), { status: 'paid' }),
2360
- };
2361
- return payment;
2362
- }
2363
- catch (error) { }
2364
- }
2365
- createCardPayment(checkout, card) {
2366
- return {
2367
- amount: {
2368
- currency: 'BRL',
2369
- value: ((checkout === null || checkout === void 0 ? void 0 : checkout.totalPrice) || 0) * 100,
2370
- },
2371
- paymentMethod: {
2372
- type: 'scheme',
2373
- storedPaymentMethodId: card.cardId,
2374
- },
2375
- reference: checkout.id,
2376
- shopperInteraction: 'Ecommerce',
2377
- merchantAccount: this.credentials.MERCHANT_ACCOUNT,
2378
- shopperReference: checkout.user.id,
2379
- recurringProcessingModel: 'CardOnFile',
2380
- returnUrl: this.credentials.URL_POSTBACK,
2381
- installments: {
2382
- value: card.installments,
2383
- },
2384
- };
2008
+ class SubscriptionMaterialization extends BaseModel {
2009
+ static get identifiersFields() {
2010
+ return ['id'];
2385
2011
  }
2386
- addCard() {
2387
- throw new Error('Method not implemented.');
2012
+ }
2013
+ __decorate([
2014
+ Type(() => User),
2015
+ __metadata("design:type", User)
2016
+ ], SubscriptionMaterialization.prototype, "user", void 0);
2017
+ __decorate([
2018
+ Type(() => SubscriptionPlan),
2019
+ __metadata("design:type", SubscriptionPlan)
2020
+ ], SubscriptionMaterialization.prototype, "subscriptionPlan", void 0);
2021
+ __decorate([
2022
+ Type(() => UserAddress),
2023
+ __metadata("design:type", UserAddress)
2024
+ ], SubscriptionMaterialization.prototype, "shippingAddress", void 0);
2025
+ __decorate([
2026
+ Type(() => UserAddress),
2027
+ __metadata("design:type", UserAddress)
2028
+ ], SubscriptionMaterialization.prototype, "billingAddress", void 0);
2029
+ __decorate([
2030
+ Type(() => Coupon),
2031
+ __metadata("design:type", Coupon)
2032
+ ], SubscriptionMaterialization.prototype, "coupon", void 0);
2033
+ __decorate([
2034
+ Type(() => Edition),
2035
+ __metadata("design:type", Array)
2036
+ ], SubscriptionMaterialization.prototype, "editions", void 0);
2037
+ __decorate([
2038
+ Type(() => SubscriptionPayment),
2039
+ __metadata("design:type", SubscriptionPayment)
2040
+ ], SubscriptionMaterialization.prototype, "payment", void 0);
2041
+
2042
+ class SubscriptionSummary extends BaseModel {
2043
+ static get identifiersFields() {
2044
+ return ['id'];
2388
2045
  }
2389
2046
  }
2390
2047
 
2391
- class CheckoutAntiFraudService {
2392
- constructor(orderRepository, orderBlockedRepository) {
2393
- this.orderRepository = orderRepository;
2394
- this.orderBlockedRepository = orderBlockedRepository;
2395
- this.LIMIT_ORDERS_DAY = 2;
2396
- this.LIMIT_ORDERS_WEEK = 7;
2397
- this.LIMIT_BLOCKED_ORDERS_DAY = 5;
2048
+ class UserPaymentMethod extends BaseModel {
2049
+ static get identifiersFields() {
2050
+ return ['id', 'userId'];
2398
2051
  }
2399
- async validAntiFraud(checkout, boleto, pix, card) {
2400
- if (this.couponValidation(checkout))
2401
- return false;
2402
- if (pix)
2403
- return true;
2404
- if (boleto && !this.verifyBoletoOrder(checkout))
2405
- return false;
2406
- if (card && !(await this.verifyBlockedOrderAttempts(checkout, card)))
2407
- return false;
2408
- if (card && !(await this.verifyDayAndWeekOrders(checkout, card)))
2409
- return false;
2410
- return true;
2052
+ }
2053
+
2054
+ class Lead extends BaseModel {
2055
+ static get identifiersFields() {
2056
+ return ['id'];
2411
2057
  }
2412
- couponValidation(checkout) {
2413
- var _a, _b;
2414
- if (((_a = checkout.coupon) === null || _a === void 0 ? void 0 : _a.nickname) === 'FALHADEPAGAMENTO') {
2415
- console.error(`Falha de pagamento com cupom. CheckoutId: ${JSON.stringify({
2416
- checkoutId: checkout.id,
2417
- user: checkout.user.id,
2418
- coupon: (_b = checkout.coupon) === null || _b === void 0 ? void 0 : _b.nickname,
2419
- })}`);
2420
- return false;
2421
- }
2422
- return true;
2058
+ }
2059
+
2060
+ class UnauthorizedError extends CustomError {
2061
+ constructor(message) {
2062
+ super(message);
2423
2063
  }
2424
- async verifyDayAndWeekOrders(checkout, card) {
2425
- var _a, _b, _c, _d, _e, _f, _g, _h;
2426
- 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'));
2427
- for (const key in ordersPerDay) {
2428
- if (ordersPerDay[key] > this.LIMIT_ORDERS_DAY) {
2429
- await this.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'day');
2430
- return false;
2431
- }
2432
- }
2433
- 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'));
2434
- for (const key in ordersPerWeek) {
2435
- if (ordersPerDay[key] > this.LIMIT_ORDERS_WEEK) {
2436
- await this.createBlockedOrderOrPayment(checkout, 'Order limit', key, 'week');
2437
- return false;
2438
- }
2439
- }
2440
- return true;
2064
+ }
2065
+
2066
+ var SignInMethods;
2067
+ (function (SignInMethods) {
2068
+ SignInMethods["EMAIL_PASSWORD"] = "email_password";
2069
+ SignInMethods["GOOGLE"] = "google";
2070
+ })(SignInMethods || (SignInMethods = {}));
2071
+ class Authentication {
2072
+ constructor(authService, userRepository) {
2073
+ this.authService = authService;
2074
+ this.userRepository = userRepository;
2441
2075
  }
2442
- async validateOrdersByRange(cpf, email, phone, zip, card, range) {
2443
- const ordersCpf = await this.countOrdersByField('user', 'cpf', cpf, range);
2444
- const ordersByEmail = await this.countOrdersByField('user', 'email', email, range);
2445
- const ordersByPhone = await this.countOrdersByField('user', 'phone', phone, range);
2446
- const ordersByZip = await this.countOrdersByField('shippingAddress', 'zip', zip, range);
2447
- return {
2448
- cpf: ordersCpf,
2449
- email: ordersByEmail,
2450
- phone: ordersByPhone,
2451
- zip: ordersByZip,
2452
- };
2076
+ async signIn({ email, password }, signInMethod) {
2077
+ const method = this.getServiceByMethod(signInMethod);
2078
+ const userAuth = await this.authService[method]({ email, password });
2079
+ const user = this.userRepository.get({ id: userAuth.id });
2080
+ if (!isNil(user))
2081
+ return user;
2082
+ if (/^.+@b4a.com.br$/.test(userAuth.email))
2083
+ return this.createsUserByCredential(userAuth);
2084
+ throw new UnauthorizedError('Invalid credentials');
2453
2085
  }
2454
- async countOrdersByField(property, field, value, range) {
2455
- const filters = {
2456
- [property]: {
2457
- [field]: value,
2458
- },
2459
- ['createdAt']: [
2460
- { operator: Where.GTE, value: range.firstDate },
2461
- { operator: Where.LTE, value: range.lastDate },
2462
- ],
2463
- };
2464
- const docs = await (await this.orderRepository.find({ filters })).count;
2465
- return docs;
2086
+ getServiceByMethod(signInMethod) {
2087
+ return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
2466
2088
  }
2467
- async verifyBoletoOrder(checkout) {
2089
+ async createsUserByCredential(user) {
2468
2090
  var _a;
2469
- const maxOrderValue = 5000;
2470
- if (checkout.totalPrice && checkout.totalPrice > maxOrderValue && !((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber)) {
2471
- await this.createBlockedOrderOrPayment(checkout, 'Boleto not authorized', 'Boleto', 'day');
2472
- return false;
2473
- }
2474
- return true;
2475
- }
2476
- async verifyBlockedOrderAttempts(checkout, card) {
2477
- var _a, _b, _c, _d;
2478
- const day = `${format(new Date(), 'YYYY-MM-DD')}T00:00:00`;
2479
- const endOfDay = `${format(new Date(), 'YYYY-MM-DD')}T23:59:59`;
2480
- const ordersBlockedWithCpf = await this.orderBlockedRepository
2481
- .find({
2482
- filters: {
2483
- customer: { cpf: { operator: Where.EQUALS, value: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf } },
2484
- date: [
2485
- { operator: Where.GTE, value: new Date(day) },
2486
- { operator: Where.LTE, value: new Date(endOfDay) },
2487
- ],
2488
- },
2489
- })
2490
- .then((data) => data.data);
2491
- const ordersBlockedWithEmail = await this.orderBlockedRepository
2492
- .find({
2493
- filters: {
2494
- customer: { email: { operator: Where.EQUALS, value: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email } },
2495
- date: [
2496
- { operator: Where.GTE, value: new Date(day) },
2497
- { operator: Where.LTE, value: new Date(endOfDay) },
2498
- ],
2499
- },
2500
- })
2501
- .then((data) => data.data);
2502
- const ordersBlockedWithCep = await this.orderBlockedRepository
2503
- .find({
2504
- filters: {
2505
- customer: { shippingAddress: { zip: { operator: Where.EQUALS, value: (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.zip } } },
2506
- date: [
2507
- { operator: Where.GTE, value: new Date(day) },
2508
- { operator: Where.LTE, value: new Date(endOfDay) },
2509
- ],
2510
- },
2511
- })
2512
- .then((data) => data.data);
2513
- const ordersBlockedWithPhone = await this.orderBlockedRepository
2514
- .find({
2515
- filters: {
2516
- customer: { phoneNumber: { operator: Where.EQUALS, value: (_d = checkout.user) === null || _d === void 0 ? void 0 : _d.phone } },
2517
- date: [
2518
- { operator: Where.GTE, value: new Date(day) },
2519
- { operator: Where.LTE, value: new Date(endOfDay) },
2520
- ],
2521
- },
2522
- })
2523
- .then((data) => data.data);
2524
- const blockedUniqueEmails = ordersBlockedWithEmail.filter((e) => {
2525
- var _a;
2526
- return e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf);
2527
- });
2528
- const blockedUniqueCeps = ordersBlockedWithCep.filter((e) => {
2529
- var _a, _b;
2530
- 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);
2531
- });
2532
- const blockedUniquePhone = ordersBlockedWithPhone.filter((e) => {
2533
- var _a, _b, _c, _d, _e, _f;
2534
- return (e.customer.cpf !== ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.cpf) &&
2535
- e.customer.email !== ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email) &&
2536
- ((_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()));
2537
- });
2538
- const blockedAttempts = ordersBlockedWithCpf
2539
- .concat(blockedUniqueEmails)
2540
- .concat(blockedUniqueCeps)
2541
- .concat(blockedUniquePhone);
2542
- if (blockedAttempts.length >= this.LIMIT_BLOCKED_ORDERS_DAY) {
2543
- await this.createBlockedOrderOrPayment(checkout, 'More than 5 attempts have failed', 'Failed attempts', 'day', card || null);
2544
- return false;
2545
- }
2546
- return true;
2547
- }
2548
- async createBlockedOrderOrPayment(checkout, blockType, type, limiteRange, card = null) {
2549
- var _a, _b, _c, _d, _e, _f, _g, _h;
2550
- const paymentBlocked = {
2551
- customer: {
2552
- name: ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.displayName) || '',
2553
- cpf: ((_b = checkout.user) === null || _b === void 0 ? void 0 : _b.cpf) || '',
2554
- id: (_c = checkout.user) === null || _c === void 0 ? void 0 : _c.id,
2555
- email: ((_d = checkout.user) === null || _d === void 0 ? void 0 : _d.email) || '',
2556
- phoneNumber: '+55' + ((_e = checkout.user) === null || _e === void 0 ? void 0 : _e.phone),
2557
- isSubscriber: (_f = checkout.user) === null || _f === void 0 ? void 0 : _f.isSubscriber,
2558
- subscriptionPlan: ((_g = checkout.user) === null || _g === void 0 ? void 0 : _g.subscriptionPlan) || '',
2559
- shippingAddress: Object.assign(Object.assign({}, checkout.shippingAddress), { zip: this.formatZip((_h = checkout.shippingAddress) === null || _h === void 0 ? void 0 : _h.zip) }),
2560
- },
2561
- blockType,
2562
- limiteRange,
2563
- type,
2564
- card,
2565
- checkout: {
2566
- id: checkout.id,
2567
- shop: checkout.shop,
2568
- total: checkout.totalPrice,
2569
- },
2570
- date: new Date(),
2571
- };
2572
- await this.orderBlockedRepository.create(paymentBlocked);
2573
- }
2574
- getDateRange(range = 'day') {
2575
- switch (range) {
2576
- case 'day':
2577
- return {
2578
- firstDate: startOfDay(new Date()).getTime(),
2579
- lastDate: endOfDay(new Date()).getTime(),
2580
- };
2581
- case 'week':
2582
- return {
2583
- firstDate: startOfDay(subDays(new Date(), 7)).getTime(),
2584
- lastDate: endOfDay(new Date()).getTime(),
2585
- };
2586
- default:
2587
- return {
2588
- firstDate: startOfDay(new Date()).getTime(),
2589
- lastDate: endOfDay(new Date()).getTime(),
2590
- };
2591
- }
2592
- }
2593
- formatZip(zip) {
2594
- if (zip.length === 8)
2595
- return zip.substring(0, 5) + '-' + zip.substring(5, 8);
2596
- return zip;
2091
+ const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
2092
+ const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
2093
+ lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
2094
+ return this.userRepository.create(person);
2597
2095
  }
2598
2096
  }
2599
2097
 
2600
- class GlampointsPaymentService {
2601
- pay(checkout) {
2602
- const payment = {
2603
- createdAt: new Date(),
2604
- updatedAt: new Date(),
2605
- userId: checkout.user.id,
2606
- checkoutId: checkout.id,
2607
- totalPrice: checkout.totalPrice,
2608
- transaction: {
2609
- amount: 0,
2610
- acquirerResponseCode: '0000',
2611
- acquirerName: 'glampoints',
2612
- authorizedAmount: 0,
2613
- captureMethod: 'ecommerce',
2614
- installments: 1,
2615
- cost: 0,
2616
- paidAmount: 0,
2617
- paymentMethod: 'glampoints',
2618
- referer: 'api_key',
2619
- refundedAmount: 0,
2620
- status: 'paid',
2621
- statusReason: 'acquirer',
2622
- },
2623
- };
2624
- return Promise.resolve(payment);
2098
+ class UserAlreadyRegisteredError extends CustomError {
2099
+ constructor(message) {
2100
+ super(message);
2625
2101
  }
2626
2102
  }
2627
2103
 
2628
- class PagarmeBankSlipService {
2629
- constructor(credentials) {
2630
- this.credentials = credentials;
2631
- }
2632
- async pay(checkout) {
2633
- try {
2634
- const result = await axios({
2635
- method: 'POST',
2636
- url: this.credentials.URL_TRANSACTION,
2637
- data: this.createBoletoPayment(checkout),
2638
- });
2639
- if (result.data.status !== 'processing') {
2640
- console.log('Erro ao gerar o boleto para o checkout: ');
2641
- return Promise.reject(new Error(`Erro ao gerar o boleto para o checkout: ${checkout.id}`));
2642
- }
2643
- const payment = {
2644
- createdAt: new Date(),
2645
- updatedAt: new Date(),
2646
- userId: checkout.user.id,
2647
- checkoutId: checkout.id,
2648
- totalPrice: checkout.totalPrice,
2649
- transaction: result.data,
2650
- };
2651
- return payment;
2652
- }
2653
- catch (error) {
2654
- console.log(error);
2655
- }
2656
- }
2657
- createBoletoPayment(checkout) {
2658
- return {
2659
- api_key: this.credentials.API_KEY,
2660
- amount: Math.floor(checkout.totalPrice * 100),
2661
- boleto_rules: ['strict_expiration_date'],
2662
- boleto_instructions: 'Sr. Caixa, NÃO aceitar o pagamento após o vencimento.',
2663
- boleto_expiration_date: format(addDays(new Date(), 3), 'yyyy-MM-dd'),
2664
- payment_method: 'boleto',
2665
- postback_url: this.credentials.URL_POSTBACK,
2666
- customer: {
2667
- external_id: checkout.user.id,
2668
- type: 'individual',
2669
- country: 'br',
2670
- name: checkout.user.displayName,
2671
- documents: [
2672
- {
2673
- type: 'cpf',
2674
- number: checkout.user.cpf,
2675
- },
2676
- ],
2677
- },
2678
- };
2104
+ class WeakPasswordError extends CustomError {
2105
+ constructor(message = 'Weak password') {
2106
+ super(message);
2679
2107
  }
2680
2108
  }
2681
2109
 
2682
- class PagarmeCardService {
2683
- constructor(credentials) {
2684
- this.credentials = credentials;
2685
- }
2686
- async pay(checkout, card) {
2687
- var _a;
2688
- try {
2689
- const result = await axios({
2690
- method: 'POST',
2691
- url: this.credentials.URL_TRANSACTION,
2692
- data: this.createCardPayment(checkout, card),
2693
- });
2694
- if (result.data.status !== 'paid') {
2695
- this.checkoutAntiFraudService.createBlockedOrderOrPayment(checkout, 'Card not authorized', 'Card', 'day', card);
2696
- 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`));
2697
- }
2698
- const payment = {
2699
- createdAt: new Date(),
2700
- updatedAt: new Date(),
2701
- userId: checkout.user.id,
2702
- checkoutId: checkout.id,
2703
- totalPrice: checkout.totalPrice,
2704
- transaction: result.data,
2705
- };
2706
- return payment;
2707
- }
2708
- catch (error) {
2709
- console.log('Error Pagarme card request', JSON.stringify((_a = error.response) === null || _a === void 0 ? void 0 : _a.data));
2710
- }
2711
- }
2712
- addCard() {
2713
- throw new Error('Method not implemented.');
2110
+ class Register {
2111
+ constructor(registerService, userRepository) {
2112
+ this.registerService = registerService;
2113
+ this.userRepository = userRepository;
2714
2114
  }
2715
- createCardPayment(checkout, card) {
2716
- var _a, _b, _c, _d, _e, _f;
2717
- return {
2718
- api_key: this.credentials.API_KEY,
2719
- amount: Math.floor(checkout.totalPrice * 100),
2720
- card_id: card.cardId,
2721
- payment_method: 'credit_card',
2722
- installments: card.installments,
2723
- soft_descriptor: checkout.shop,
2724
- customer: {
2725
- external_id: checkout.user.id,
2726
- name: checkout.user.displayName,
2727
- type: 'individual',
2728
- country: 'br',
2729
- email: checkout.user.email,
2730
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2731
- documents: [
2732
- {
2733
- type: 'cpf',
2734
- number: checkout.user.cpf,
2735
- },
2736
- ],
2737
- },
2738
- billing: {
2739
- name: checkout.user.displayName,
2740
- address: {
2741
- country: 'br',
2742
- state: checkout.billingAddress ? checkout.billingAddress.state : (_a = checkout.shippingAddress) === null || _a === void 0 ? void 0 : _a.state,
2743
- city: checkout.billingAddress ? checkout.billingAddress.city : (_b = checkout.shippingAddress) === null || _b === void 0 ? void 0 : _b.city,
2744
- neighborhood: checkout.billingAddress ? checkout.billingAddress.district : (_c = checkout.shippingAddress) === null || _c === void 0 ? void 0 : _c.district,
2745
- street: checkout.billingAddress ? checkout.billingAddress.street : (_d = checkout.shippingAddress) === null || _d === void 0 ? void 0 : _d.street,
2746
- street_number: checkout.billingAddress ? checkout.billingAddress.number : (_e = checkout.shippingAddress) === null || _e === void 0 ? void 0 : _e.number,
2747
- zipcode: checkout.billingAddress
2748
- ? checkout.billingAddress.zip.replace('-', '')
2749
- : (_f = checkout.shippingAddress) === null || _f === void 0 ? void 0 : _f.zip.replace('-', ''),
2750
- },
2751
- },
2752
- items: checkout.lineItems.map((item) => {
2753
- return {
2754
- id: item.id,
2755
- title: checkout.user.isSubscriber ? `${item.name} - ASSINANTE` : item.name,
2756
- unit_price: Math.floor(item.pricePaid * 100),
2757
- quantity: item.quantity,
2758
- tangible: true,
2759
- };
2760
- }),
2761
- };
2115
+ async register(params) {
2116
+ const email = params.email.toLocaleLowerCase();
2117
+ const displayName = `${params.firstName} ${params.lastName}`;
2118
+ if (await this.userRepository.checkIfExistsByField('cpf', params.cpf))
2119
+ throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} registrado.`);
2120
+ if (await this.userRepository.checkIfExistsByField('email', params.email))
2121
+ throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} já registrado.`);
2122
+ const auth = await this.registerService.register({
2123
+ birthday: params.birthday,
2124
+ email,
2125
+ firstName: params.firstName,
2126
+ lastName: params.lastName,
2127
+ cpf: params.cpf,
2128
+ displayName,
2129
+ phone: params.phone,
2130
+ password: params.password,
2131
+ });
2132
+ delete params.password;
2133
+ const user = await this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
2134
+ displayName, type: UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
2135
+ return user;
2762
2136
  }
2763
2137
  }
2764
2138
 
2765
- class PagarmePixService {
2766
- constructor(credentials) {
2767
- this.credentials = credentials;
2139
+ class SignOut {
2140
+ constructor(authService) {
2141
+ this.authService = authService;
2768
2142
  }
2769
- async pay(checkout) {
2770
- try {
2771
- const result = await axios({
2772
- method: 'POST',
2773
- url: this.credentials.URL_TRANSACTION,
2774
- data: this.createPixPayment(checkout),
2775
- });
2776
- const payment = {
2777
- createdAt: new Date(),
2778
- updatedAt: new Date(),
2779
- userId: checkout.user.id,
2780
- checkoutId: checkout.id,
2781
- totalPrice: checkout.totalPrice,
2782
- transaction: result.data,
2783
- };
2784
- return payment;
2785
- }
2786
- catch (error) {
2787
- console.log(error);
2788
- }
2143
+ async signOut() {
2144
+ await this.authService.signOut();
2789
2145
  }
2790
- createPixPayment(checkout) {
2791
- return {
2792
- payment_method: 'pix',
2793
- amount: Math.floor(checkout.totalPrice * 100),
2794
- api_key: this.credentials.API_KEY,
2795
- postback_url: this.credentials.URL_POSTBACK,
2796
- pix_expiration_date: format(addDays(new Date(), 1), 'yyyy-MM-dd'),
2797
- customer: {
2798
- external_id: checkout.user.id,
2799
- type: 'individual',
2800
- country: 'br',
2801
- name: checkout.user.displayName,
2802
- email: checkout.user.email.trim(),
2803
- phone_numbers: checkout.user.phone ? ['+55' + checkout.user.phone] : '',
2804
- documents: [
2805
- {
2806
- type: 'cpf',
2807
- number: checkout.user.cpf,
2808
- },
2809
- ],
2810
- },
2811
- };
2146
+ }
2147
+
2148
+ class RecoveryPassword {
2149
+ constructor(authService) {
2150
+ this.authService = authService;
2151
+ }
2152
+ async sendEmail(email) {
2153
+ await this.authService.sendPasswordResetEmail(email);
2812
2154
  }
2813
2155
  }
2814
2156
 
@@ -2826,12 +2168,6 @@ class RoundProductPricesHelper {
2826
2168
  }
2827
2169
  }
2828
2170
 
2829
- class Sequence extends BaseModel {
2830
- static get identifiersFields() {
2831
- return ['id'];
2832
- }
2833
- }
2834
-
2835
2171
  var FilterType;
2836
2172
  (function (FilterType) {
2837
2173
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -3178,7 +2514,7 @@ const withFirestore = (MixinBase) => {
3178
2514
  if (iteratee(v, k)) {
3179
2515
  unset(value, k);
3180
2516
  }
3181
- else if (isObject$1(v)) {
2517
+ else if (isObject(v)) {
3182
2518
  omitByRecursivelyInPlace(v, iteratee);
3183
2519
  }
3184
2520
  });
@@ -3308,7 +2644,7 @@ const withFindFirestore = (MixinBase) => {
3308
2644
  (this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
3309
2645
  !this.fields[firestoreFieldName]))
3310
2646
  return [where(firestoreFieldName, 'array-contains', options.value)];
3311
- if (isObject$1(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
2647
+ if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
3312
2648
  return Object.keys(options).reduce((queries, key) => [
3313
2649
  ...queries,
3314
2650
  ...this.buildWhereSentence(`${fieldName.toString()}.${key}`, is(options)[key]),
@@ -3491,6 +2827,161 @@ const withCrudFirestore = (MixinBase) => {
3491
2827
  };
3492
2828
  };
3493
2829
 
2830
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2831
+ constructor({ firestore, interceptors }) {
2832
+ super({
2833
+ firestore,
2834
+ collectionName: 'leads',
2835
+ model: Lead,
2836
+ interceptors,
2837
+ });
2838
+ }
2839
+ }
2840
+
2841
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2842
+ constructor({ firestore, interceptors }, parentRepository) {
2843
+ super({
2844
+ firestore,
2845
+ collectionName: 'editions',
2846
+ parentIdField: 'subscriptionId',
2847
+ model: Edition,
2848
+ interceptors,
2849
+ });
2850
+ this.parentRepository = parentRepository;
2851
+ }
2852
+ }
2853
+
2854
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2855
+ constructor({ firestore, interceptors, }) {
2856
+ super({
2857
+ firestore,
2858
+ collectionName: 'subscription',
2859
+ model: Subscription,
2860
+ interceptors,
2861
+ });
2862
+ }
2863
+ }
2864
+
2865
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2866
+ constructor({ firestore, interceptors }) {
2867
+ super({
2868
+ firestore,
2869
+ collectionName: 'subscriptionMaterialization',
2870
+ model: SubscriptionMaterialization,
2871
+ interceptors,
2872
+ });
2873
+ }
2874
+ }
2875
+
2876
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2877
+ constructor({ firestore, interceptors }, parentRepository) {
2878
+ super({
2879
+ firestore,
2880
+ collectionName: 'payments',
2881
+ parentIdField: 'subscriptionId',
2882
+ model: SubscriptionPayment,
2883
+ interceptors,
2884
+ });
2885
+ this.parentRepository = parentRepository;
2886
+ }
2887
+ }
2888
+
2889
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2890
+ constructor({ firestore, interceptors, }) {
2891
+ super({
2892
+ firestore,
2893
+ collectionName: 'subscriptionSummary',
2894
+ model: SubscriptionSummary,
2895
+ interceptors,
2896
+ });
2897
+ }
2898
+ }
2899
+
2900
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2901
+ constructor({ firestore, interceptors }, parentRepository) {
2902
+ super({
2903
+ firestore,
2904
+ collectionName: 'address',
2905
+ parentIdField: 'userId',
2906
+ model: UserAddress,
2907
+ interceptors,
2908
+ });
2909
+ this.parentRepository = parentRepository;
2910
+ }
2911
+ }
2912
+
2913
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2914
+ constructor({ firestore, interceptors }, parentRepository) {
2915
+ super({
2916
+ firestore,
2917
+ collectionName: 'CX',
2918
+ parentIdField: 'userId',
2919
+ model: BeautyProfile,
2920
+ interceptors,
2921
+ });
2922
+ this.parentRepository = parentRepository;
2923
+ }
2924
+ }
2925
+
2926
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2927
+ constructor({ firestore, interceptors }) {
2928
+ super({
2929
+ firestore,
2930
+ collectionName: 'users',
2931
+ model: User,
2932
+ interceptors,
2933
+ });
2934
+ }
2935
+ async get(identifiers) {
2936
+ const user = await super.get({ id: identifiers.id });
2937
+ user.beautyProfile = await this.getBeautyProfile(user.id);
2938
+ user.isSubscriber = await this.checkIfIsSubscriber(user.id);
2939
+ return user;
2940
+ }
2941
+ async checkIfExistsByField(field, value) {
2942
+ const result = await this.find({ filters: { [field]: value } });
2943
+ return result.count > 0;
2944
+ }
2945
+ buildModelInstance() {
2946
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
2947
+ return {
2948
+ toFirestore: (data) => {
2949
+ const plain = toFirestore(data);
2950
+ delete plain.isSubscriber;
2951
+ return plain;
2952
+ },
2953
+ fromFirestore,
2954
+ };
2955
+ }
2956
+ async getBeautyProfile(userId) {
2957
+ const beautyProfile = await getDoc(doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
2958
+ return beautyProfile.data();
2959
+ }
2960
+ async checkIfIsSubscriber(userId) {
2961
+ const docs = await getDocs(query(this.collection('subscription'), where('user.id', '==', userId), where('status', '==', 'active')));
2962
+ return !!docs && !!docs.size;
2963
+ }
2964
+ buildBeautyProfileModelInstance() {
2965
+ return {
2966
+ toFirestore: (data) => data.toPlain(),
2967
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
2968
+ };
2969
+ }
2970
+ }
2971
+
2972
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2973
+ constructor({ firestore, interceptors }, parentRepository) {
2974
+ super({
2975
+ firestore,
2976
+ collectionName: 'payment_method',
2977
+ parentIdField: 'userId',
2978
+ model: UserPaymentMethod,
2979
+ interceptors,
2980
+ });
2981
+ this.parentRepository = parentRepository;
2982
+ }
2983
+ }
2984
+
3494
2985
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3495
2986
  constructor({ firestore, interceptors }) {
3496
2987
  super({
@@ -3592,134 +3083,39 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
3592
3083
  if (review.status === false)
3593
3084
  return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
3594
3085
  if (!!review.status)
3595
- return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3596
- return review;
3597
- });
3598
- });
3599
- return this.reviews[status];
3600
- }
3601
- cleanShoppingCountFromIds() {
3602
- return;
3603
- }
3604
- findCatalog(params) {
3605
- return this.find(params);
3606
- }
3607
- }
3608
-
3609
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3610
- constructor({ firestore, interceptors }, parentRepository) {
3611
- super({
3612
- firestore,
3613
- collectionName: 'variants',
3614
- parentIdField: 'productId',
3615
- model: Variant,
3616
- interceptors,
3617
- });
3618
- this.parentRepository = parentRepository;
3619
- }
3620
- }
3621
-
3622
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3623
- constructor({ firestore, interceptors }) {
3624
- super({
3625
- firestore,
3626
- collectionName: 'subscriptionProducts',
3627
- model: Product,
3628
- interceptors,
3629
- });
3630
- }
3631
- }
3632
-
3633
- class SequenceFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3634
- constructor({ firestore, interceptors }) {
3635
- super({
3636
- firestore,
3637
- collectionName: 'sequences',
3638
- model: Sequence,
3639
- interceptors,
3640
- });
3641
- }
3642
- }
3643
-
3644
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3645
- constructor({ firestore, interceptors }) {
3646
- super({
3647
- firestore,
3648
- collectionName: 'dms',
3649
- model: Home,
3650
- interceptors,
3651
- });
3652
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3653
- var _a, _b, _c;
3654
- return ({
3655
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3656
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3657
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3658
- 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)) || [],
3659
- });
3660
- };
3661
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3662
- var _a;
3663
- return ({
3664
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3665
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3666
- });
3667
- };
3668
- }
3669
- buildModelInstance() {
3670
- const { fromFirestore, toFirestore } = super.buildModelInstance();
3671
- return {
3672
- toFirestore: (data) => {
3673
- const modifiedData = this.homeToFirestore(data);
3674
- return toFirestore(modifiedData);
3675
- },
3676
- fromFirestore: (snap) => {
3677
- const instance = fromFirestore(snap);
3678
- return this.homeFromFirestore(instance);
3679
- },
3680
- };
3086
+ return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
3087
+ return review;
3088
+ });
3089
+ });
3090
+ return this.reviews[status];
3681
3091
  }
3682
- homeToFirestore(home) {
3683
- var _a, _b, _c, _d;
3684
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3685
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3686
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3687
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3688
- }
3689
- return home;
3092
+ cleanShoppingCountFromIds() {
3093
+ return;
3690
3094
  }
3691
- homeFromFirestore(home) {
3692
- var _a;
3693
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3694
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3695
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3696
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3697
- home.data.createdAt =
3698
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3699
- home.data.expiresAt =
3700
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3701
- }
3702
- return home;
3095
+ findCatalog(params) {
3096
+ return this.find(params);
3703
3097
  }
3704
3098
  }
3705
3099
 
3706
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3707
- constructor({ firestore, interceptors }) {
3100
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3101
+ constructor({ firestore, interceptors }, parentRepository) {
3708
3102
  super({
3709
3103
  firestore,
3710
- collectionName: 'shopMenus',
3711
- model: ShopMenu,
3104
+ collectionName: 'variants',
3105
+ parentIdField: 'productId',
3106
+ model: Variant,
3712
3107
  interceptors,
3713
3108
  });
3109
+ this.parentRepository = parentRepository;
3714
3110
  }
3715
3111
  }
3716
3112
 
3717
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3718
- constructor({ firestore, interceptors, }) {
3113
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3114
+ constructor({ firestore, interceptors }) {
3719
3115
  super({
3720
3116
  firestore,
3721
- collectionName: 'shopSettings',
3722
- model: ShopSettings,
3117
+ collectionName: 'subscriptionProducts',
3118
+ model: Product,
3723
3119
  interceptors,
3724
3120
  });
3725
3121
  }
@@ -3855,17 +3251,6 @@ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
3855
3251
  }
3856
3252
  }
3857
3253
 
3858
- class OrderBlockedFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3859
- constructor({ firestore, interceptors, }) {
3860
- super({
3861
- firestore,
3862
- collectionName: 'paymentBlockedAttempts',
3863
- model: OrderBlocked,
3864
- interceptors,
3865
- });
3866
- }
3867
- }
3868
-
3869
3254
  class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3870
3255
  constructor({ firestore, interceptors }) {
3871
3256
  super({
@@ -3888,158 +3273,87 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
3888
3273
  }
3889
3274
  }
3890
3275
 
3891
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3892
- constructor({ firestore, interceptors }) {
3893
- super({
3894
- firestore,
3895
- collectionName: 'leads',
3896
- model: Lead,
3897
- interceptors,
3898
- });
3899
- }
3900
- }
3901
-
3902
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3903
- constructor({ firestore, interceptors }, parentRepository) {
3904
- super({
3905
- firestore,
3906
- collectionName: 'editions',
3907
- parentIdField: 'subscriptionId',
3908
- model: Edition,
3909
- interceptors,
3910
- });
3911
- this.parentRepository = parentRepository;
3912
- }
3913
- }
3914
-
3915
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3916
- constructor({ firestore, interceptors, }) {
3917
- super({
3918
- firestore,
3919
- collectionName: 'subscription',
3920
- model: Subscription,
3921
- interceptors,
3922
- });
3923
- }
3924
- }
3925
-
3926
- class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3276
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3927
3277
  constructor({ firestore, interceptors }) {
3928
3278
  super({
3929
3279
  firestore,
3930
- collectionName: 'subscriptionMaterialization',
3931
- model: SubscriptionMaterialization,
3932
- interceptors,
3933
- });
3934
- }
3935
- }
3936
-
3937
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3938
- constructor({ firestore, interceptors }, parentRepository) {
3939
- super({
3940
- firestore,
3941
- collectionName: 'payments',
3942
- parentIdField: 'subscriptionId',
3943
- model: SubscriptionPayment,
3280
+ collectionName: 'dms',
3281
+ model: Home,
3944
3282
  interceptors,
3945
3283
  });
3946
- this.parentRepository = parentRepository;
3284
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
3285
+ var _a, _b, _c;
3286
+ return ({
3287
+ category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
3288
+ ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
3289
+ : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
3290
+ 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)) || [],
3291
+ });
3292
+ };
3293
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
3294
+ var _a;
3295
+ return ({
3296
+ category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
3297
+ products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
3298
+ });
3299
+ };
3947
3300
  }
3948
- }
3949
-
3950
- class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3951
- constructor({ firestore, interceptors, }) {
3952
- super({
3953
- firestore,
3954
- collectionName: 'subscriptionSummary',
3955
- model: SubscriptionSummary,
3956
- interceptors,
3957
- });
3301
+ buildModelInstance() {
3302
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
3303
+ return {
3304
+ toFirestore: (data) => {
3305
+ const modifiedData = this.homeToFirestore(data);
3306
+ return toFirestore(modifiedData);
3307
+ },
3308
+ fromFirestore: (snap) => {
3309
+ const instance = fromFirestore(snap);
3310
+ return this.homeFromFirestore(instance);
3311
+ },
3312
+ };
3958
3313
  }
3959
- }
3960
-
3961
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3962
- constructor({ firestore, interceptors }, parentRepository) {
3963
- super({
3964
- firestore,
3965
- collectionName: 'address',
3966
- parentIdField: 'userId',
3967
- model: UserAddress,
3968
- interceptors,
3969
- });
3970
- this.parentRepository = parentRepository;
3314
+ homeToFirestore(home) {
3315
+ var _a, _b, _c, _d;
3316
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3317
+ home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
3318
+ home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
3319
+ home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
3320
+ }
3321
+ return home;
3971
3322
  }
3972
- }
3973
-
3974
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
3975
- constructor({ firestore, interceptors }, parentRepository) {
3976
- super({
3977
- firestore,
3978
- collectionName: 'CX',
3979
- parentIdField: 'userId',
3980
- model: BeautyProfile,
3981
- interceptors,
3982
- });
3983
- this.parentRepository = parentRepository;
3323
+ homeFromFirestore(home) {
3324
+ var _a;
3325
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
3326
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
3327
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
3328
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
3329
+ home.data.createdAt =
3330
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
3331
+ home.data.expiresAt =
3332
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
3333
+ }
3334
+ return home;
3984
3335
  }
3985
3336
  }
3986
3337
 
3987
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3338
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3988
3339
  constructor({ firestore, interceptors }) {
3989
3340
  super({
3990
3341
  firestore,
3991
- collectionName: 'users',
3992
- model: User,
3342
+ collectionName: 'shopMenus',
3343
+ model: ShopMenu,
3993
3344
  interceptors,
3994
3345
  });
3995
3346
  }
3996
- async get(identifiers) {
3997
- const user = await super.get({ id: identifiers.id });
3998
- user.beautyProfile = await this.getBeautyProfile(user.id);
3999
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
4000
- return user;
4001
- }
4002
- async checkIfExistsByField(field, value) {
4003
- const result = await this.find({ filters: { [field]: value } });
4004
- return result.count > 0;
4005
- }
4006
- buildModelInstance() {
4007
- const { fromFirestore, toFirestore } = super.buildModelInstance();
4008
- return {
4009
- toFirestore: (data) => {
4010
- const plain = toFirestore(data);
4011
- delete plain.isSubscriber;
4012
- return plain;
4013
- },
4014
- fromFirestore,
4015
- };
4016
- }
4017
- async getBeautyProfile(userId) {
4018
- const beautyProfile = await getDoc(doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
4019
- return beautyProfile.data();
4020
- }
4021
- async checkIfIsSubscriber(userId) {
4022
- const docs = await getDocs(query(this.collection('subscription'), where('user.id', '==', userId), where('status', '==', 'active')));
4023
- return !!docs && !!docs.size;
4024
- }
4025
- buildBeautyProfileModelInstance() {
4026
- return {
4027
- toFirestore: (data) => data.toPlain(),
4028
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
4029
- };
4030
- }
4031
3347
  }
4032
3348
 
4033
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
4034
- constructor({ firestore, interceptors }, parentRepository) {
3349
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3350
+ constructor({ firestore, interceptors, }) {
4035
3351
  super({
4036
3352
  firestore,
4037
- collectionName: 'payment_method',
4038
- parentIdField: 'userId',
4039
- model: UserPaymentMethod,
3353
+ collectionName: 'shopSettings',
3354
+ model: ShopSettings,
4040
3355
  interceptors,
4041
3356
  });
4042
- this.parentRepository = parentRepository;
4043
3357
  }
4044
3358
  }
4045
3359
 
@@ -4118,7 +3432,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
4118
3432
  var _a;
4119
3433
  if (fields.includes(attributeName))
4120
3434
  return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
4121
- const field = fields.find((columnOption) => isObject$1(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
3435
+ const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
4122
3436
  const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
4123
3437
  if (isNil(fieldOption))
4124
3438
  return { columnName: attributeName.toString(), attributeName };
@@ -4131,7 +3445,7 @@ AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
4131
3445
  if (fields.includes(columnName))
4132
3446
  return { columnName, attributeName: columnName };
4133
3447
  const field = is(fields.find((field) => {
4134
- if (!isObject$1(field))
3448
+ if (!isObject(field))
4135
3449
  return false;
4136
3450
  const columnOption = Object.values(field).find((option) => AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName ? option : {});
4137
3451
  return AttributeOptionHelper.CheckIsColumnOption(columnOption) && (columnOption === null || columnOption === void 0 ? void 0 : columnOption.columnName) === columnName;
@@ -4207,7 +3521,7 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
4207
3521
  BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
4208
3522
  const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
4209
3523
  const isNestedField = !Array.isArray(options) &&
4210
- isObject$1(options) &&
3524
+ isObject(options) &&
4211
3525
  isNil(options === null || options === void 0 ? void 0 : options.operator) &&
4212
3526
  isNil(options === null || options === void 0 ? void 0 : options.value) &&
4213
3527
  isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
@@ -4222,7 +3536,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
4222
3536
  return {
4223
3537
  [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
4224
3538
  };
4225
- if (!Array.isArray(options) && isObject$1(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
3539
+ if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
4226
3540
  options = Object.values(options)[0];
4227
3541
  return Array.isArray(options)
4228
3542
  ? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
@@ -4272,7 +3586,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
4272
3586
  return Object.assign(Object.assign({}, result), { [attributeName]: from
4273
3587
  ? from(data[columnName], data)
4274
3588
  : is(data[columnName]).map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(is(value), attributeFields)) });
4275
- if (isObject$1(data[columnName]))
3589
+ if (isObject(data[columnName]))
4276
3590
  return Object.assign(Object.assign({}, result), { [attributeName]: !!from
4277
3591
  ? from(data[columnName])
4278
3592
  : GraphQLFieldHelper.ConvertFieldValueFrom(is(data[columnName]), attributeFields) });
@@ -4299,13 +3613,13 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
4299
3613
  return Object.assign(Object.assign({}, object), { [foreignColumnName]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] });
4300
3614
  }, Object.assign({}, result));
4301
3615
  if (update &&
4302
- isObject$1(data[attributeName]) &&
3616
+ isObject(data[attributeName]) &&
4303
3617
  !isNil(attributeFields) &&
4304
3618
  !isDate(data[attributeName]))
4305
3619
  return result;
4306
3620
  if (!!columnName &&
4307
3621
  Array.isArray(attributeFields) &&
4308
- isObject$1(data[attributeName])) {
3622
+ isObject(data[attributeName])) {
4309
3623
  const converted = !isNil(columnName) && to
4310
3624
  ? to(instance[attributeName], instance)
4311
3625
  : data[attributeName];
@@ -4996,6 +4310,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4996
4310
  fields: ['id', 'name', 'reference', 'slug'],
4997
4311
  },
4998
4312
  },
4313
+ 'theme',
4314
+ { bannerUrl: { columnName: 'banner_url' } },
4999
4315
  ],
5000
4316
  });
5001
4317
  this.productRepository = productRepository;
@@ -5135,18 +4451,24 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5135
4451
  const plainData = this.paramsToPlain({ products });
5136
4452
  if (!plainData.products || plainData.products.length <= 0)
5137
4453
  return [];
4454
+ const category = await this.get({ id: categoryId.toString() });
5138
4455
  await this.mutation('delete_category_product', ['affected_rows'], {
5139
4456
  where: {
5140
4457
  type: 'category_product_bool_exp',
5141
4458
  required: true,
5142
- value: { category_id: { _eq: categoryId } },
4459
+ value: {
4460
+ category_id: { _eq: categoryId },
4461
+ product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
4462
+ },
5143
4463
  },
5144
4464
  });
5145
4465
  await this.mutation('insert_category_product', ['affected_rows'], {
5146
4466
  objects: {
5147
4467
  type: '[category_product_insert_input!]',
5148
4468
  required: true,
5149
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4469
+ value: plainData.products
4470
+ .filter((productId) => !category.products.includes(productId))
4471
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
5150
4472
  },
5151
4473
  });
5152
4474
  return plainData.products;
@@ -5184,15 +4506,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5184
4506
  },
5185
4507
  })
5186
4508
  .then((res) => res.data);
5187
- const currentFiltersId = currentFilters.map((f) => f.id);
4509
+ const currentFiltersId = currentFilters.map((f) => f.filterId);
5188
4510
  const filtersUpdatedId = filters.value.map((f) => f.id);
5189
4511
  const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
5190
4512
  const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
5191
4513
  for (const filter of filterToBeDeleted) {
5192
4514
  const index = currentFilters.findIndex((f) => f.id == filter);
5193
- if (index != -1) {
4515
+ if (index != -1)
5194
4516
  currentFilters.splice(index, 1);
5195
- }
5196
4517
  await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
5197
4518
  }
5198
4519
  for (const filter of filterToBeInserted) {
@@ -5647,11 +4968,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5647
4968
  const plainData = this.paramsToPlain({ categories });
5648
4969
  if (!plainData.categories || plainData.categories.length <= 0)
5649
4970
  return [];
4971
+ const product = await this.get({ id: productId.toString() });
5650
4972
  await this.mutation('delete_category_product', ['affected_rows'], {
5651
4973
  where: {
5652
4974
  type: 'category_product_bool_exp',
5653
4975
  required: true,
5654
- value: { product_id: { _eq: productId } },
4976
+ value: {
4977
+ product_id: { _eq: productId },
4978
+ category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
4979
+ },
5655
4980
  },
5656
4981
  });
5657
4982
  await this.mutation('insert_category_product', ['affected_rows'], {
@@ -6043,6 +5368,10 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6043
5368
  throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
6044
5369
  return data;
6045
5370
  }
5371
+ async find(params) {
5372
+ const { filters } = params, rest = __rest(params, ["filters"]);
5373
+ return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
5374
+ }
6046
5375
  async update(params) {
6047
5376
  const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
6048
5377
  const plainData = this.paramsToPlain({ id: checkId });
@@ -6101,19 +5430,25 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6101
5430
  const plainData = this.paramsToPlain({ products });
6102
5431
  if (!plainData.products || plainData.products.length <= 0)
6103
5432
  return [];
5433
+ const category = await this.get({ id: categoryId.toString() });
5434
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
6104
5435
  await this.mutation('delete_category_product', ['affected_rows'], {
6105
5436
  where: {
6106
5437
  type: 'category_product_bool_exp',
6107
5438
  required: true,
6108
- value: { category_id: { _eq: categoryId } },
5439
+ value: {
5440
+ category_id: { _eq: categoryId },
5441
+ product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
5442
+ },
6109
5443
  },
6110
5444
  });
6111
- await this.categoryFilterRepository.deleteByCategory(categoryId);
6112
5445
  await this.mutation('insert_category_product', ['affected_rows'], {
6113
5446
  objects: {
6114
5447
  type: '[category_product_insert_input!]',
6115
5448
  required: true,
6116
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
5449
+ value: plainData.products
5450
+ .filter((productId) => !category.products.includes(productId))
5451
+ .map((productId) => ({ category_id: categoryId, product_id: productId })),
6117
5452
  },
6118
5453
  });
6119
5454
  return plainData.products;
@@ -6168,4 +5503,4 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
6168
5503
  }
6169
5504
  }
6170
5505
 
6171
- 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, ProductReviews, ProductReviewsHasuraGraphQLRepository, 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, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, 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 };
5506
+ 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, ProductReviews, ProductReviewsHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopPageName, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionMaterialization, SubscriptionMaterializationFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionSummary, SubscriptionSummaryFirestoreRepository, 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 };