@infrab4a/connect 4.2.0-beta.6 → 4.2.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 (25) hide show
  1. package/index.cjs.js +1026 -773
  2. package/index.esm.js +865 -636
  3. package/package.json +1 -1
  4. package/src/domain/catalog/models/index.d.ts +1 -0
  5. package/src/domain/catalog/models/product-reviews.d.ts +20 -0
  6. package/src/domain/catalog/models/types/shop-description.type.d.ts +1 -0
  7. package/src/domain/catalog/repositories/index.d.ts +1 -0
  8. package/src/domain/catalog/repositories/product-reviews.repository.d.ts +6 -0
  9. package/src/domain/shop-settings/models/types/index.d.ts +0 -3
  10. package/src/domain/shop-settings/models/types/sections.type.d.ts +0 -6
  11. package/src/domain/users/models/subscription/index.d.ts +3 -1
  12. package/src/domain/users/models/subscription/subscription-materialization.d.ts +31 -0
  13. package/src/domain/users/models/subscription/subscription-summary.d.ts +11 -0
  14. package/src/domain/users/models/subscription/subscription.d.ts +1 -0
  15. package/src/domain/users/repositories/index.d.ts +7 -5
  16. package/src/domain/users/repositories/subscription-materialization.repository.d.ts +4 -0
  17. package/src/domain/users/repositories/subscription-summary.repository.d.ts +4 -0
  18. package/src/infra/firebase/firestore/repositories/users/index.d.ts +2 -0
  19. package/src/infra/firebase/firestore/repositories/users/subscription-materialization-firestore.repository.d.ts +7 -0
  20. package/src/infra/firebase/firestore/repositories/users/subscription-summary-firestore.repository.d.ts +7 -0
  21. package/src/infra/hasura-graphql/repositories/catalog/index.d.ts +1 -0
  22. package/src/infra/hasura-graphql/repositories/catalog/product-review-hasura-graphql.repository.d.ts +12 -0
  23. package/src/domain/shop-settings/models/types/brands-carousel.type.d.ts +0 -3
  24. package/src/domain/shop-settings/models/types/landing-page.d.ts +0 -8
  25. package/src/domain/shop-settings/models/types/promotion-page.d.ts +0 -10
package/index.cjs.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('reflect-metadata');
6
6
  var classTransformer = require('class-transformer');
7
- var tslib = require('tslib');
7
+ var tslib_1 = require('tslib');
8
8
  var dateFns = require('date-fns');
9
9
  var lodash = require('lodash');
10
10
  var debug = require('debug');
@@ -16,6 +16,25 @@ var gqlQueryBuilder = require('gql-query-builder');
16
16
 
17
17
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
18
 
19
+ function _interopNamespace(e) {
20
+ if (e && e.__esModule) return e;
21
+ var n = Object.create(null);
22
+ if (e) {
23
+ Object.keys(e).forEach(function (k) {
24
+ if (k !== 'default') {
25
+ var d = Object.getOwnPropertyDescriptor(e, k);
26
+ Object.defineProperty(n, k, d.get ? d : {
27
+ enumerable: true,
28
+ get: function () { return e[k]; }
29
+ });
30
+ }
31
+ });
32
+ }
33
+ n["default"] = e;
34
+ return Object.freeze(n);
35
+ }
36
+
37
+ var tslib_1__namespace = /*#__PURE__*/_interopNamespace(tslib_1);
19
38
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
20
39
 
21
40
  class BaseModel {
@@ -262,6 +281,12 @@ exports.UserType = void 0;
262
281
  UserType["Influencer"] = "Influencer";
263
282
  })(exports.UserType || (exports.UserType = {}));
264
283
 
284
+ class Edition extends BaseModel {
285
+ static get identifiersFields() {
286
+ return ['id', 'subscriptionId'];
287
+ }
288
+ }
289
+
265
290
  exports.BillingStatus = void 0;
266
291
  (function (BillingStatus) {
267
292
  BillingStatus["PAYED"] = "PAGO";
@@ -286,176 +311,170 @@ exports.Status = void 0;
286
311
  Status["CANCELLED"] = "Cancelado";
287
312
  })(exports.Status || (exports.Status = {}));
288
313
 
289
- class Edition extends BaseModel {
290
- static get identifiersFields() {
291
- return ['id', 'subscriptionId'];
292
- }
293
- }
294
-
295
314
  class Payment extends BaseModel {
296
315
  static get identifiersFields() {
297
316
  return ['id'];
298
317
  }
299
318
  }
300
- tslib.__decorate([
319
+ tslib_1.__decorate([
301
320
  classTransformer.Expose({ name: 'refuse_reason' }),
302
- tslib.__metadata("design:type", String)
321
+ tslib_1.__metadata("design:type", String)
303
322
  ], Payment.prototype, "refuseReason", void 0);
304
- tslib.__decorate([
323
+ tslib_1.__decorate([
305
324
  classTransformer.Expose({ name: 'status_reason' }),
306
- tslib.__metadata("design:type", String)
325
+ tslib_1.__metadata("design:type", String)
307
326
  ], Payment.prototype, "statusReason", void 0);
308
- tslib.__decorate([
327
+ tslib_1.__decorate([
309
328
  classTransformer.Expose({ name: 'acquirer_response_code' }),
310
- tslib.__metadata("design:type", String)
329
+ tslib_1.__metadata("design:type", String)
311
330
  ], Payment.prototype, "acquirerResponseCode", void 0);
312
- tslib.__decorate([
331
+ tslib_1.__decorate([
313
332
  classTransformer.Expose({ name: 'acquirer_name' }),
314
- tslib.__metadata("design:type", String)
333
+ tslib_1.__metadata("design:type", String)
315
334
  ], Payment.prototype, "acquirerName", void 0);
316
- tslib.__decorate([
335
+ tslib_1.__decorate([
317
336
  classTransformer.Expose({ name: 'acquirer_id' }),
318
- tslib.__metadata("design:type", String)
337
+ tslib_1.__metadata("design:type", String)
319
338
  ], Payment.prototype, "acquirerId", void 0);
320
- tslib.__decorate([
339
+ tslib_1.__decorate([
321
340
  classTransformer.Expose({ name: 'authorization_code' }),
322
- tslib.__metadata("design:type", String)
341
+ tslib_1.__metadata("design:type", String)
323
342
  ], Payment.prototype, "authorizationCode", void 0);
324
- tslib.__decorate([
343
+ tslib_1.__decorate([
325
344
  classTransformer.Expose({ name: 'soft_descriptor' }),
326
- tslib.__metadata("design:type", String)
345
+ tslib_1.__metadata("design:type", String)
327
346
  ], Payment.prototype, "softDescriptor", void 0);
328
- tslib.__decorate([
347
+ tslib_1.__decorate([
329
348
  classTransformer.Expose({ name: 'date_created' }),
330
- tslib.__metadata("design:type", String)
349
+ tslib_1.__metadata("design:type", String)
331
350
  ], Payment.prototype, "dateCreated", void 0);
332
- tslib.__decorate([
351
+ tslib_1.__decorate([
333
352
  classTransformer.Expose({ name: 'date_updated' }),
334
- tslib.__metadata("design:type", String)
353
+ tslib_1.__metadata("design:type", String)
335
354
  ], Payment.prototype, "dateUpdated", void 0);
336
- tslib.__decorate([
355
+ tslib_1.__decorate([
337
356
  classTransformer.Expose({ name: 'authorized_amount' }),
338
- tslib.__metadata("design:type", Number)
357
+ tslib_1.__metadata("design:type", Number)
339
358
  ], Payment.prototype, "authorizedAmount", void 0);
340
- tslib.__decorate([
359
+ tslib_1.__decorate([
341
360
  classTransformer.Expose({ name: 'paid_amount' }),
342
- tslib.__metadata("design:type", Number)
361
+ tslib_1.__metadata("design:type", Number)
343
362
  ], Payment.prototype, "paidAmount", void 0);
344
- tslib.__decorate([
363
+ tslib_1.__decorate([
345
364
  classTransformer.Expose({ name: 'refunded_amount' }),
346
- tslib.__metadata("design:type", Number)
365
+ tslib_1.__metadata("design:type", Number)
347
366
  ], Payment.prototype, "refundedAmount", void 0);
348
- tslib.__decorate([
367
+ tslib_1.__decorate([
349
368
  classTransformer.Expose({ name: 'card_holder_name' }),
350
- tslib.__metadata("design:type", String)
369
+ tslib_1.__metadata("design:type", String)
351
370
  ], Payment.prototype, "cardHolderName", void 0);
352
- tslib.__decorate([
371
+ tslib_1.__decorate([
353
372
  classTransformer.Expose({ name: 'card_last_digits' }),
354
- tslib.__metadata("design:type", String)
373
+ tslib_1.__metadata("design:type", String)
355
374
  ], Payment.prototype, "cardLastDigits", void 0);
356
- tslib.__decorate([
375
+ tslib_1.__decorate([
357
376
  classTransformer.Expose({ name: 'card_first_digits' }),
358
- tslib.__metadata("design:type", String)
377
+ tslib_1.__metadata("design:type", String)
359
378
  ], Payment.prototype, "cardFirstDigits", void 0);
360
- tslib.__decorate([
379
+ tslib_1.__decorate([
361
380
  classTransformer.Expose({ name: 'card_brand' }),
362
- tslib.__metadata("design:type", String)
381
+ tslib_1.__metadata("design:type", String)
363
382
  ], Payment.prototype, "cardBrand", void 0);
364
- tslib.__decorate([
383
+ tslib_1.__decorate([
365
384
  classTransformer.Expose({ name: 'card_pin_mode' }),
366
- tslib.__metadata("design:type", String)
385
+ tslib_1.__metadata("design:type", String)
367
386
  ], Payment.prototype, "cardPinMode", void 0);
368
- tslib.__decorate([
387
+ tslib_1.__decorate([
369
388
  classTransformer.Expose({ name: 'card_magstripe_fallback' }),
370
- tslib.__metadata("design:type", Boolean)
389
+ tslib_1.__metadata("design:type", Boolean)
371
390
  ], Payment.prototype, "cardMagstripeFallback", void 0);
372
- tslib.__decorate([
391
+ tslib_1.__decorate([
373
392
  classTransformer.Expose({ name: 'cvm_pin' }),
374
- tslib.__metadata("design:type", Boolean)
393
+ tslib_1.__metadata("design:type", Boolean)
375
394
  ], Payment.prototype, "cvmPin", void 0);
376
- tslib.__decorate([
395
+ tslib_1.__decorate([
377
396
  classTransformer.Expose({ name: 'postback_url' }),
378
- tslib.__metadata("design:type", String)
397
+ tslib_1.__metadata("design:type", String)
379
398
  ], Payment.prototype, "postbackUrl", void 0);
380
- tslib.__decorate([
399
+ tslib_1.__decorate([
381
400
  classTransformer.Expose({ name: 'payment_method' }),
382
- tslib.__metadata("design:type", String)
401
+ tslib_1.__metadata("design:type", String)
383
402
  ], Payment.prototype, "paymentMethod", void 0);
384
- tslib.__decorate([
403
+ tslib_1.__decorate([
385
404
  classTransformer.Expose({ name: 'capture_method' }),
386
- tslib.__metadata("design:type", String)
405
+ tslib_1.__metadata("design:type", String)
387
406
  ], Payment.prototype, "captureMethod", void 0);
388
- tslib.__decorate([
407
+ tslib_1.__decorate([
389
408
  classTransformer.Expose({ name: 'antifraud_score' }),
390
- tslib.__metadata("design:type", String)
409
+ tslib_1.__metadata("design:type", String)
391
410
  ], Payment.prototype, "antifraudScore", void 0);
392
- tslib.__decorate([
411
+ tslib_1.__decorate([
393
412
  classTransformer.Expose({ name: 'boleto_url' }),
394
- tslib.__metadata("design:type", String)
413
+ tslib_1.__metadata("design:type", String)
395
414
  ], Payment.prototype, "boletoUrl", void 0);
396
- tslib.__decorate([
415
+ tslib_1.__decorate([
397
416
  classTransformer.Expose({ name: 'boleto_barcode' }),
398
- tslib.__metadata("design:type", String)
417
+ tslib_1.__metadata("design:type", String)
399
418
  ], Payment.prototype, "boletoBarcode", void 0);
400
- tslib.__decorate([
419
+ tslib_1.__decorate([
401
420
  classTransformer.Expose({ name: 'boleto_expiration_date' }),
402
- tslib.__metadata("design:type", String)
421
+ tslib_1.__metadata("design:type", String)
403
422
  ], Payment.prototype, "boletoExpirationDate", void 0);
404
- tslib.__decorate([
423
+ tslib_1.__decorate([
405
424
  classTransformer.Expose({ name: 'subscription_id' }),
406
- tslib.__metadata("design:type", String)
425
+ tslib_1.__metadata("design:type", String)
407
426
  ], Payment.prototype, "subscriptionId", void 0);
408
- tslib.__decorate([
427
+ tslib_1.__decorate([
409
428
  classTransformer.Expose({ name: 'split_rules' }),
410
- tslib.__metadata("design:type", String)
429
+ tslib_1.__metadata("design:type", String)
411
430
  ], Payment.prototype, "splitRules", void 0);
412
- tslib.__decorate([
431
+ tslib_1.__decorate([
413
432
  classTransformer.Expose({ name: 'antifraud_metadata' }),
414
- tslib.__metadata("design:type", Object)
433
+ tslib_1.__metadata("design:type", Object)
415
434
  ], Payment.prototype, "antifraudMetadata", void 0);
416
- tslib.__decorate([
435
+ tslib_1.__decorate([
417
436
  classTransformer.Expose({ name: 'reference_key' }),
418
- tslib.__metadata("design:type", String)
437
+ tslib_1.__metadata("design:type", String)
419
438
  ], Payment.prototype, "referenceKey", void 0);
420
- tslib.__decorate([
439
+ tslib_1.__decorate([
421
440
  classTransformer.Expose({ name: 'local_transaction_id' }),
422
- tslib.__metadata("design:type", String)
441
+ tslib_1.__metadata("design:type", String)
423
442
  ], Payment.prototype, "localTransactionId", void 0);
424
- tslib.__decorate([
443
+ tslib_1.__decorate([
425
444
  classTransformer.Expose({ name: 'local_time' }),
426
- tslib.__metadata("design:type", String)
445
+ tslib_1.__metadata("design:type", String)
427
446
  ], Payment.prototype, "localTime", void 0);
428
- tslib.__decorate([
447
+ tslib_1.__decorate([
429
448
  classTransformer.Expose({ name: 'fraud_covered' }),
430
- tslib.__metadata("design:type", Boolean)
449
+ tslib_1.__metadata("design:type", Boolean)
431
450
  ], Payment.prototype, "fraudCovered", void 0);
432
- tslib.__decorate([
451
+ tslib_1.__decorate([
433
452
  classTransformer.Expose({ name: 'fraud_reimbursed' }),
434
- tslib.__metadata("design:type", String)
453
+ tslib_1.__metadata("design:type", String)
435
454
  ], Payment.prototype, "fraudReimbursed", void 0);
436
- tslib.__decorate([
455
+ tslib_1.__decorate([
437
456
  classTransformer.Expose({ name: 'order_id' }),
438
- tslib.__metadata("design:type", String)
457
+ tslib_1.__metadata("design:type", String)
439
458
  ], Payment.prototype, "orderId", void 0);
440
- tslib.__decorate([
459
+ tslib_1.__decorate([
441
460
  classTransformer.Expose({ name: 'risk_level' }),
442
- tslib.__metadata("design:type", String)
461
+ tslib_1.__metadata("design:type", String)
443
462
  ], Payment.prototype, "riskLevel", void 0);
444
- tslib.__decorate([
463
+ tslib_1.__decorate([
445
464
  classTransformer.Expose({ name: 'receipt_url' }),
446
- tslib.__metadata("design:type", String)
465
+ tslib_1.__metadata("design:type", String)
447
466
  ], Payment.prototype, "receiptUrl", void 0);
448
- tslib.__decorate([
467
+ tslib_1.__decorate([
449
468
  classTransformer.Expose({ name: 'private_label' }),
450
- tslib.__metadata("design:type", String)
469
+ tslib_1.__metadata("design:type", String)
451
470
  ], Payment.prototype, "privateLabel", void 0);
452
- tslib.__decorate([
471
+ tslib_1.__decorate([
453
472
  classTransformer.Expose({ name: 'pix_qr_code' }),
454
- tslib.__metadata("design:type", String)
473
+ tslib_1.__metadata("design:type", String)
455
474
  ], Payment.prototype, "pixQrCode", void 0);
456
- tslib.__decorate([
475
+ tslib_1.__decorate([
457
476
  classTransformer.Expose({ name: 'pix_expiration_date' }),
458
- tslib.__metadata("design:type", String)
477
+ tslib_1.__metadata("design:type", String)
459
478
  ], Payment.prototype, "pixExpirationDate", void 0);
460
479
 
461
480
  class SubscriptionPayment extends BaseModel {
@@ -463,406 +482,483 @@ class SubscriptionPayment extends BaseModel {
463
482
  return ['id', 'subscriptionId'];
464
483
  }
465
484
  }
466
- tslib.__decorate([
485
+ tslib_1.__decorate([
467
486
  classTransformer.Type(() => Payment),
468
- tslib.__metadata("design:type", Payment)
487
+ tslib_1.__metadata("design:type", Payment)
469
488
  ], SubscriptionPayment.prototype, "payment", void 0);
470
489
 
471
- function isFunction(value) {
472
- return typeof value === 'function';
490
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
491
+ function isFunction(x) {
492
+ return typeof x === 'function';
473
493
  }
474
494
 
475
- function createErrorClass(createImpl) {
476
- var _super = function (instance) {
477
- Error.call(instance);
478
- instance.stack = new Error().stack;
479
- };
480
- var ctorFunc = createImpl(_super);
481
- ctorFunc.prototype = Object.create(Error.prototype);
482
- ctorFunc.prototype.constructor = ctorFunc;
483
- return ctorFunc;
495
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
496
+ var _enable_super_gross_mode_that_will_cause_bad_things = false;
497
+ var config = {
498
+ Promise: undefined,
499
+ set useDeprecatedSynchronousErrorHandling(value) {
500
+ if (value) {
501
+ var error = /*@__PURE__*/ new Error();
502
+ /*@__PURE__*/ console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
503
+ }
504
+ _enable_super_gross_mode_that_will_cause_bad_things = value;
505
+ },
506
+ get useDeprecatedSynchronousErrorHandling() {
507
+ return _enable_super_gross_mode_that_will_cause_bad_things;
508
+ },
509
+ };
510
+
511
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
512
+ function hostReportError(err) {
513
+ setTimeout(function () { throw err; }, 0);
484
514
  }
485
515
 
486
- var UnsubscriptionError = createErrorClass(function (_super) {
487
- return function UnsubscriptionErrorImpl(errors) {
488
- _super(this);
489
- this.message = errors
490
- ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
491
- : '';
492
- this.name = 'UnsubscriptionError';
493
- this.errors = errors;
494
- };
495
- });
516
+ /** PURE_IMPORTS_START _config,_util_hostReportError PURE_IMPORTS_END */
517
+ var empty = {
518
+ closed: true,
519
+ next: function (value) { },
520
+ error: function (err) {
521
+ if (config.useDeprecatedSynchronousErrorHandling) {
522
+ throw err;
523
+ }
524
+ else {
525
+ hostReportError(err);
526
+ }
527
+ },
528
+ complete: function () { }
529
+ };
496
530
 
497
- function arrRemove(arr, item) {
498
- if (arr) {
499
- var index = arr.indexOf(item);
500
- 0 <= index && arr.splice(index, 1);
501
- }
531
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
532
+ var isArray = /*@__PURE__*/ (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
533
+
534
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
535
+ function isObject(x) {
536
+ return x !== null && typeof x === 'object';
502
537
  }
503
538
 
504
- var Subscription$1 = (function () {
505
- function Subscription(initialTeardown) {
506
- this.initialTeardown = initialTeardown;
539
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
540
+ var UnsubscriptionErrorImpl = /*@__PURE__*/ (function () {
541
+ function UnsubscriptionErrorImpl(errors) {
542
+ Error.call(this);
543
+ this.message = errors ?
544
+ errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ') : '';
545
+ this.name = 'UnsubscriptionError';
546
+ this.errors = errors;
547
+ return this;
548
+ }
549
+ UnsubscriptionErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
550
+ return UnsubscriptionErrorImpl;
551
+ })();
552
+ var UnsubscriptionError = UnsubscriptionErrorImpl;
553
+
554
+ /** PURE_IMPORTS_START _util_isArray,_util_isObject,_util_isFunction,_util_UnsubscriptionError PURE_IMPORTS_END */
555
+ var Subscription$1 = /*@__PURE__*/ (function () {
556
+ function Subscription(unsubscribe) {
507
557
  this.closed = false;
508
- this._parentage = null;
509
- this._finalizers = null;
558
+ this._parentOrParents = null;
559
+ this._subscriptions = null;
560
+ if (unsubscribe) {
561
+ this._ctorUnsubscribe = true;
562
+ this._unsubscribe = unsubscribe;
563
+ }
510
564
  }
511
565
  Subscription.prototype.unsubscribe = function () {
512
- var e_1, _a, e_2, _b;
513
566
  var errors;
514
- if (!this.closed) {
515
- this.closed = true;
516
- var _parentage = this._parentage;
517
- if (_parentage) {
518
- this._parentage = null;
519
- if (Array.isArray(_parentage)) {
520
- try {
521
- for (var _parentage_1 = tslib.__values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
522
- var parent_1 = _parentage_1_1.value;
523
- parent_1.remove(this);
524
- }
525
- }
526
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
527
- finally {
528
- try {
529
- if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
530
- }
531
- finally { if (e_1) throw e_1.error; }
532
- }
533
- }
534
- else {
535
- _parentage.remove(this);
536
- }
567
+ if (this.closed) {
568
+ return;
569
+ }
570
+ var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
571
+ this.closed = true;
572
+ this._parentOrParents = null;
573
+ this._subscriptions = null;
574
+ if (_parentOrParents instanceof Subscription) {
575
+ _parentOrParents.remove(this);
576
+ }
577
+ else if (_parentOrParents !== null) {
578
+ for (var index = 0; index < _parentOrParents.length; ++index) {
579
+ var parent_1 = _parentOrParents[index];
580
+ parent_1.remove(this);
537
581
  }
538
- var initialFinalizer = this.initialTeardown;
539
- if (isFunction(initialFinalizer)) {
540
- try {
541
- initialFinalizer();
542
- }
543
- catch (e) {
544
- errors = e instanceof UnsubscriptionError ? e.errors : [e];
545
- }
582
+ }
583
+ if (isFunction(_unsubscribe)) {
584
+ if (_ctorUnsubscribe) {
585
+ this._unsubscribe = undefined;
546
586
  }
547
- var _finalizers = this._finalizers;
548
- if (_finalizers) {
549
- this._finalizers = null;
550
- try {
551
- for (var _finalizers_1 = tslib.__values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
552
- var finalizer = _finalizers_1_1.value;
553
- try {
554
- execFinalizer(finalizer);
587
+ try {
588
+ _unsubscribe.call(this);
589
+ }
590
+ catch (e) {
591
+ errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
592
+ }
593
+ }
594
+ if (isArray(_subscriptions)) {
595
+ var index = -1;
596
+ var len = _subscriptions.length;
597
+ while (++index < len) {
598
+ var sub = _subscriptions[index];
599
+ if (isObject(sub)) {
600
+ try {
601
+ sub.unsubscribe();
602
+ }
603
+ catch (e) {
604
+ errors = errors || [];
605
+ if (e instanceof UnsubscriptionError) {
606
+ errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
555
607
  }
556
- catch (err) {
557
- errors = errors !== null && errors !== void 0 ? errors : [];
558
- if (err instanceof UnsubscriptionError) {
559
- errors = tslib.__spreadArray(tslib.__spreadArray([], tslib.__read(errors)), tslib.__read(err.errors));
560
- }
561
- else {
562
- errors.push(err);
563
- }
608
+ else {
609
+ errors.push(e);
564
610
  }
565
611
  }
566
612
  }
567
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
568
- finally {
569
- try {
570
- if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
571
- }
572
- finally { if (e_2) throw e_2.error; }
573
- }
574
- }
575
- if (errors) {
576
- throw new UnsubscriptionError(errors);
577
613
  }
578
614
  }
615
+ if (errors) {
616
+ throw new UnsubscriptionError(errors);
617
+ }
579
618
  };
580
619
  Subscription.prototype.add = function (teardown) {
581
- var _a;
582
- if (teardown && teardown !== this) {
583
- if (this.closed) {
584
- execFinalizer(teardown);
585
- }
586
- else {
587
- if (teardown instanceof Subscription) {
588
- if (teardown.closed || teardown._hasParent(this)) {
589
- return;
590
- }
591
- teardown._addParent(this);
620
+ var subscription = teardown;
621
+ if (!teardown) {
622
+ return Subscription.EMPTY;
623
+ }
624
+ switch (typeof teardown) {
625
+ case 'function':
626
+ subscription = new Subscription(teardown);
627
+ case 'object':
628
+ if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
629
+ return subscription;
630
+ }
631
+ else if (this.closed) {
632
+ subscription.unsubscribe();
633
+ return subscription;
634
+ }
635
+ else if (!(subscription instanceof Subscription)) {
636
+ var tmp = subscription;
637
+ subscription = new Subscription();
638
+ subscription._subscriptions = [tmp];
592
639
  }
593
- (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
640
+ break;
641
+ default: {
642
+ throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
594
643
  }
595
644
  }
596
- };
597
- Subscription.prototype._hasParent = function (parent) {
598
- var _parentage = this._parentage;
599
- return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
600
- };
601
- Subscription.prototype._addParent = function (parent) {
602
- var _parentage = this._parentage;
603
- this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
604
- };
605
- Subscription.prototype._removeParent = function (parent) {
606
- var _parentage = this._parentage;
607
- if (_parentage === parent) {
608
- this._parentage = null;
645
+ var _parentOrParents = subscription._parentOrParents;
646
+ if (_parentOrParents === null) {
647
+ subscription._parentOrParents = this;
609
648
  }
610
- else if (Array.isArray(_parentage)) {
611
- arrRemove(_parentage, parent);
649
+ else if (_parentOrParents instanceof Subscription) {
650
+ if (_parentOrParents === this) {
651
+ return subscription;
652
+ }
653
+ subscription._parentOrParents = [_parentOrParents, this];
654
+ }
655
+ else if (_parentOrParents.indexOf(this) === -1) {
656
+ _parentOrParents.push(this);
657
+ }
658
+ else {
659
+ return subscription;
660
+ }
661
+ var subscriptions = this._subscriptions;
662
+ if (subscriptions === null) {
663
+ this._subscriptions = [subscription];
664
+ }
665
+ else {
666
+ subscriptions.push(subscription);
612
667
  }
668
+ return subscription;
613
669
  };
614
- Subscription.prototype.remove = function (teardown) {
615
- var _finalizers = this._finalizers;
616
- _finalizers && arrRemove(_finalizers, teardown);
617
- if (teardown instanceof Subscription) {
618
- teardown._removeParent(this);
670
+ Subscription.prototype.remove = function (subscription) {
671
+ var subscriptions = this._subscriptions;
672
+ if (subscriptions) {
673
+ var subscriptionIndex = subscriptions.indexOf(subscription);
674
+ if (subscriptionIndex !== -1) {
675
+ subscriptions.splice(subscriptionIndex, 1);
676
+ }
619
677
  }
620
678
  };
621
- Subscription.EMPTY = (function () {
622
- var empty = new Subscription();
679
+ Subscription.EMPTY = (function (empty) {
623
680
  empty.closed = true;
624
681
  return empty;
625
- })();
682
+ }(new Subscription()));
626
683
  return Subscription;
627
684
  }());
628
- var EMPTY_SUBSCRIPTION = Subscription$1.EMPTY;
629
- function isSubscription(value) {
630
- return (value instanceof Subscription$1 ||
631
- (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
632
- }
633
- function execFinalizer(finalizer) {
634
- if (isFunction(finalizer)) {
635
- finalizer();
636
- }
637
- else {
638
- finalizer.unsubscribe();
639
- }
640
- }
641
-
642
- var config = {
643
- onUnhandledError: null,
644
- onStoppedNotification: null,
645
- Promise: undefined,
646
- useDeprecatedSynchronousErrorHandling: false,
647
- useDeprecatedNextContext: false,
648
- };
649
-
650
- var timeoutProvider = {
651
- setTimeout: function (handler, timeout) {
652
- var args = [];
653
- for (var _i = 2; _i < arguments.length; _i++) {
654
- args[_i - 2] = arguments[_i];
655
- }
656
- var delegate = timeoutProvider.delegate;
657
- if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
658
- return delegate.setTimeout.apply(delegate, tslib.__spreadArray([handler, timeout], tslib.__read(args)));
659
- }
660
- return setTimeout.apply(void 0, tslib.__spreadArray([handler, timeout], tslib.__read(args)));
661
- },
662
- clearTimeout: function (handle) {
663
- var delegate = timeoutProvider.delegate;
664
- return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
665
- },
666
- delegate: undefined,
667
- };
668
-
669
- function reportUnhandledError(err) {
670
- timeoutProvider.setTimeout(function () {
671
- {
672
- throw err;
673
- }
674
- });
685
+ function flattenUnsubscriptionErrors(errors) {
686
+ return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
675
687
  }
676
688
 
677
- function noop() { }
678
-
679
- var context = null;
680
- function errorContext(cb) {
681
- if (config.useDeprecatedSynchronousErrorHandling) {
682
- var isRoot = !context;
683
- if (isRoot) {
684
- context = { errorThrown: false, error: null };
685
- }
686
- cb();
687
- if (isRoot) {
688
- var _a = context, errorThrown = _a.errorThrown, error = _a.error;
689
- context = null;
690
- if (errorThrown) {
691
- throw error;
692
- }
693
- }
694
- }
695
- else {
696
- cb();
697
- }
698
- }
699
-
700
- var Subscriber = (function (_super) {
701
- tslib.__extends(Subscriber, _super);
702
- function Subscriber(destination) {
689
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
690
+ var rxSubscriber = /*@__PURE__*/ (function () {
691
+ return typeof Symbol === 'function'
692
+ ? /*@__PURE__*/ Symbol('rxSubscriber')
693
+ : '@@rxSubscriber_' + /*@__PURE__*/ Math.random();
694
+ })();
695
+
696
+ /** PURE_IMPORTS_START tslib,_util_isFunction,_Observer,_Subscription,_internal_symbol_rxSubscriber,_config,_util_hostReportError PURE_IMPORTS_END */
697
+ var Subscriber = /*@__PURE__*/ (function (_super) {
698
+ tslib_1__namespace.__extends(Subscriber, _super);
699
+ function Subscriber(destinationOrNext, error, complete) {
703
700
  var _this = _super.call(this) || this;
701
+ _this.syncErrorValue = null;
702
+ _this.syncErrorThrown = false;
703
+ _this.syncErrorThrowable = false;
704
704
  _this.isStopped = false;
705
- if (destination) {
706
- _this.destination = destination;
707
- if (isSubscription(destination)) {
708
- destination.add(_this);
709
- }
710
- }
711
- else {
712
- _this.destination = EMPTY_OBSERVER;
705
+ switch (arguments.length) {
706
+ case 0:
707
+ _this.destination = empty;
708
+ break;
709
+ case 1:
710
+ if (!destinationOrNext) {
711
+ _this.destination = empty;
712
+ break;
713
+ }
714
+ if (typeof destinationOrNext === 'object') {
715
+ if (destinationOrNext instanceof Subscriber) {
716
+ _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
717
+ _this.destination = destinationOrNext;
718
+ destinationOrNext.add(_this);
719
+ }
720
+ else {
721
+ _this.syncErrorThrowable = true;
722
+ _this.destination = new SafeSubscriber(_this, destinationOrNext);
723
+ }
724
+ break;
725
+ }
726
+ default:
727
+ _this.syncErrorThrowable = true;
728
+ _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
729
+ break;
713
730
  }
714
731
  return _this;
715
732
  }
733
+ Subscriber.prototype[rxSubscriber] = function () { return this; };
716
734
  Subscriber.create = function (next, error, complete) {
717
- return new SafeSubscriber(next, error, complete);
735
+ var subscriber = new Subscriber(next, error, complete);
736
+ subscriber.syncErrorThrowable = false;
737
+ return subscriber;
718
738
  };
719
739
  Subscriber.prototype.next = function (value) {
720
- if (this.isStopped) ;
721
- else {
740
+ if (!this.isStopped) {
722
741
  this._next(value);
723
742
  }
724
743
  };
725
744
  Subscriber.prototype.error = function (err) {
726
- if (this.isStopped) ;
727
- else {
745
+ if (!this.isStopped) {
728
746
  this.isStopped = true;
729
747
  this._error(err);
730
748
  }
731
749
  };
732
750
  Subscriber.prototype.complete = function () {
733
- if (this.isStopped) ;
734
- else {
751
+ if (!this.isStopped) {
735
752
  this.isStopped = true;
736
753
  this._complete();
737
754
  }
738
755
  };
739
756
  Subscriber.prototype.unsubscribe = function () {
740
- if (!this.closed) {
741
- this.isStopped = true;
742
- _super.prototype.unsubscribe.call(this);
743
- this.destination = null;
757
+ if (this.closed) {
758
+ return;
744
759
  }
760
+ this.isStopped = true;
761
+ _super.prototype.unsubscribe.call(this);
745
762
  };
746
763
  Subscriber.prototype._next = function (value) {
747
764
  this.destination.next(value);
748
765
  };
749
766
  Subscriber.prototype._error = function (err) {
750
- try {
751
- this.destination.error(err);
752
- }
753
- finally {
754
- this.unsubscribe();
755
- }
767
+ this.destination.error(err);
768
+ this.unsubscribe();
756
769
  };
757
770
  Subscriber.prototype._complete = function () {
758
- try {
759
- this.destination.complete();
760
- }
761
- finally {
762
- this.unsubscribe();
763
- }
771
+ this.destination.complete();
772
+ this.unsubscribe();
773
+ };
774
+ Subscriber.prototype._unsubscribeAndRecycle = function () {
775
+ var _parentOrParents = this._parentOrParents;
776
+ this._parentOrParents = null;
777
+ this.unsubscribe();
778
+ this.closed = false;
779
+ this.isStopped = false;
780
+ this._parentOrParents = _parentOrParents;
781
+ return this;
764
782
  };
765
783
  return Subscriber;
766
784
  }(Subscription$1));
767
- var _bind = Function.prototype.bind;
768
- function bind(fn, thisArg) {
769
- return _bind.call(fn, thisArg);
770
- }
771
- var ConsumerObserver = (function () {
772
- function ConsumerObserver(partialObserver) {
773
- this.partialObserver = partialObserver;
785
+ var SafeSubscriber = /*@__PURE__*/ (function (_super) {
786
+ tslib_1__namespace.__extends(SafeSubscriber, _super);
787
+ function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
788
+ var _this = _super.call(this) || this;
789
+ _this._parentSubscriber = _parentSubscriber;
790
+ var next;
791
+ var context = _this;
792
+ if (isFunction(observerOrNext)) {
793
+ next = observerOrNext;
794
+ }
795
+ else if (observerOrNext) {
796
+ next = observerOrNext.next;
797
+ error = observerOrNext.error;
798
+ complete = observerOrNext.complete;
799
+ if (observerOrNext !== empty) {
800
+ context = Object.create(observerOrNext);
801
+ if (isFunction(context.unsubscribe)) {
802
+ _this.add(context.unsubscribe.bind(context));
803
+ }
804
+ context.unsubscribe = _this.unsubscribe.bind(_this);
805
+ }
806
+ }
807
+ _this._context = context;
808
+ _this._next = next;
809
+ _this._error = error;
810
+ _this._complete = complete;
811
+ return _this;
774
812
  }
775
- ConsumerObserver.prototype.next = function (value) {
776
- var partialObserver = this.partialObserver;
777
- if (partialObserver.next) {
778
- try {
779
- partialObserver.next(value);
813
+ SafeSubscriber.prototype.next = function (value) {
814
+ if (!this.isStopped && this._next) {
815
+ var _parentSubscriber = this._parentSubscriber;
816
+ if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
817
+ this.__tryOrUnsub(this._next, value);
780
818
  }
781
- catch (error) {
782
- handleUnhandledError(error);
819
+ else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
820
+ this.unsubscribe();
783
821
  }
784
822
  }
785
823
  };
786
- ConsumerObserver.prototype.error = function (err) {
787
- var partialObserver = this.partialObserver;
788
- if (partialObserver.error) {
789
- try {
790
- partialObserver.error(err);
824
+ SafeSubscriber.prototype.error = function (err) {
825
+ if (!this.isStopped) {
826
+ var _parentSubscriber = this._parentSubscriber;
827
+ var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
828
+ if (this._error) {
829
+ if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
830
+ this.__tryOrUnsub(this._error, err);
831
+ this.unsubscribe();
832
+ }
833
+ else {
834
+ this.__tryOrSetError(_parentSubscriber, this._error, err);
835
+ this.unsubscribe();
836
+ }
791
837
  }
792
- catch (error) {
793
- handleUnhandledError(error);
838
+ else if (!_parentSubscriber.syncErrorThrowable) {
839
+ this.unsubscribe();
840
+ if (useDeprecatedSynchronousErrorHandling) {
841
+ throw err;
842
+ }
843
+ hostReportError(err);
844
+ }
845
+ else {
846
+ if (useDeprecatedSynchronousErrorHandling) {
847
+ _parentSubscriber.syncErrorValue = err;
848
+ _parentSubscriber.syncErrorThrown = true;
849
+ }
850
+ else {
851
+ hostReportError(err);
852
+ }
853
+ this.unsubscribe();
794
854
  }
795
855
  }
796
- else {
797
- handleUnhandledError(err);
856
+ };
857
+ SafeSubscriber.prototype.complete = function () {
858
+ var _this = this;
859
+ if (!this.isStopped) {
860
+ var _parentSubscriber = this._parentSubscriber;
861
+ if (this._complete) {
862
+ var wrappedComplete = function () { return _this._complete.call(_this._context); };
863
+ if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
864
+ this.__tryOrUnsub(wrappedComplete);
865
+ this.unsubscribe();
866
+ }
867
+ else {
868
+ this.__tryOrSetError(_parentSubscriber, wrappedComplete);
869
+ this.unsubscribe();
870
+ }
871
+ }
872
+ else {
873
+ this.unsubscribe();
874
+ }
798
875
  }
799
876
  };
800
- ConsumerObserver.prototype.complete = function () {
801
- var partialObserver = this.partialObserver;
802
- if (partialObserver.complete) {
803
- try {
804
- partialObserver.complete();
877
+ SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
878
+ try {
879
+ fn.call(this._context, value);
880
+ }
881
+ catch (err) {
882
+ this.unsubscribe();
883
+ if (config.useDeprecatedSynchronousErrorHandling) {
884
+ throw err;
805
885
  }
806
- catch (error) {
807
- handleUnhandledError(error);
886
+ else {
887
+ hostReportError(err);
808
888
  }
809
889
  }
810
890
  };
811
- return ConsumerObserver;
812
- }());
813
- var SafeSubscriber = (function (_super) {
814
- tslib.__extends(SafeSubscriber, _super);
815
- function SafeSubscriber(observerOrNext, error, complete) {
816
- var _this = _super.call(this) || this;
817
- var partialObserver;
818
- if (isFunction(observerOrNext) || !observerOrNext) {
819
- partialObserver = {
820
- next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
821
- error: error !== null && error !== void 0 ? error : undefined,
822
- complete: complete !== null && complete !== void 0 ? complete : undefined,
823
- };
891
+ SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
892
+ if (!config.useDeprecatedSynchronousErrorHandling) {
893
+ throw new Error('bad call');
824
894
  }
825
- else {
826
- var context_1;
827
- if (_this && config.useDeprecatedNextContext) {
828
- context_1 = Object.create(observerOrNext);
829
- context_1.unsubscribe = function () { return _this.unsubscribe(); };
830
- partialObserver = {
831
- next: observerOrNext.next && bind(observerOrNext.next, context_1),
832
- error: observerOrNext.error && bind(observerOrNext.error, context_1),
833
- complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
834
- };
895
+ try {
896
+ fn.call(this._context, value);
897
+ }
898
+ catch (err) {
899
+ if (config.useDeprecatedSynchronousErrorHandling) {
900
+ parent.syncErrorValue = err;
901
+ parent.syncErrorThrown = true;
902
+ return true;
835
903
  }
836
904
  else {
837
- partialObserver = observerOrNext;
905
+ hostReportError(err);
906
+ return true;
838
907
  }
839
908
  }
840
- _this.destination = new ConsumerObserver(partialObserver);
841
- return _this;
842
- }
909
+ return false;
910
+ };
911
+ SafeSubscriber.prototype._unsubscribe = function () {
912
+ var _parentSubscriber = this._parentSubscriber;
913
+ this._context = null;
914
+ this._parentSubscriber = null;
915
+ _parentSubscriber.unsubscribe();
916
+ };
843
917
  return SafeSubscriber;
844
918
  }(Subscriber));
845
- function handleUnhandledError(error) {
846
- {
847
- reportUnhandledError(error);
919
+
920
+ /** PURE_IMPORTS_START _Subscriber PURE_IMPORTS_END */
921
+ function canReportError(observer) {
922
+ while (observer) {
923
+ var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
924
+ if (closed_1 || isStopped) {
925
+ return false;
926
+ }
927
+ else if (destination && destination instanceof Subscriber) {
928
+ observer = destination;
929
+ }
930
+ else {
931
+ observer = null;
932
+ }
848
933
  }
934
+ return true;
849
935
  }
850
- function defaultErrorHandler(err) {
851
- throw err;
936
+
937
+ /** PURE_IMPORTS_START _Subscriber,_symbol_rxSubscriber,_Observer PURE_IMPORTS_END */
938
+ function toSubscriber(nextOrObserver, error, complete) {
939
+ if (nextOrObserver) {
940
+ if (nextOrObserver instanceof Subscriber) {
941
+ return nextOrObserver;
942
+ }
943
+ if (nextOrObserver[rxSubscriber]) {
944
+ return nextOrObserver[rxSubscriber]();
945
+ }
946
+ }
947
+ if (!nextOrObserver && !error && !complete) {
948
+ return new Subscriber(empty);
949
+ }
950
+ return new Subscriber(nextOrObserver, error, complete);
852
951
  }
853
- var EMPTY_OBSERVER = {
854
- closed: true,
855
- next: noop,
856
- error: defaultErrorHandler,
857
- complete: noop,
858
- };
859
952
 
860
- var observable = (function () { return (typeof Symbol === 'function' && Symbol.observable) || '@@observable'; })();
953
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
954
+ var observable = /*@__PURE__*/ (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
861
955
 
956
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
862
957
  function identity(x) {
863
958
  return x;
864
959
  }
865
960
 
961
+ /** PURE_IMPORTS_START _identity PURE_IMPORTS_END */
866
962
  function pipeFromArray(fns) {
867
963
  if (fns.length === 0) {
868
964
  return identity;
@@ -875,8 +971,10 @@ function pipeFromArray(fns) {
875
971
  };
876
972
  }
877
973
 
878
- var Observable = (function () {
974
+ /** PURE_IMPORTS_START _util_canReportError,_util_toSubscriber,_symbol_observable,_util_pipe,_config PURE_IMPORTS_END */
975
+ var Observable = /*@__PURE__*/ (function () {
879
976
  function Observable(subscribe) {
977
+ this._isScalar = false;
880
978
  if (subscribe) {
881
979
  this._subscribe = subscribe;
882
980
  }
@@ -888,52 +986,64 @@ var Observable = (function () {
888
986
  return observable;
889
987
  };
890
988
  Observable.prototype.subscribe = function (observerOrNext, error, complete) {
891
- var _this = this;
892
- var subscriber = isSubscriber(observerOrNext) ? observerOrNext : new SafeSubscriber(observerOrNext, error, complete);
893
- errorContext(function () {
894
- var _a = _this, operator = _a.operator, source = _a.source;
895
- subscriber.add(operator
896
- ?
897
- operator.call(subscriber, source)
898
- : source
899
- ?
900
- _this._subscribe(subscriber)
901
- :
902
- _this._trySubscribe(subscriber));
903
- });
904
- return subscriber;
989
+ var operator = this.operator;
990
+ var sink = toSubscriber(observerOrNext, error, complete);
991
+ if (operator) {
992
+ sink.add(operator.call(sink, this.source));
993
+ }
994
+ else {
995
+ sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
996
+ this._subscribe(sink) :
997
+ this._trySubscribe(sink));
998
+ }
999
+ if (config.useDeprecatedSynchronousErrorHandling) {
1000
+ if (sink.syncErrorThrowable) {
1001
+ sink.syncErrorThrowable = false;
1002
+ if (sink.syncErrorThrown) {
1003
+ throw sink.syncErrorValue;
1004
+ }
1005
+ }
1006
+ }
1007
+ return sink;
905
1008
  };
906
1009
  Observable.prototype._trySubscribe = function (sink) {
907
1010
  try {
908
1011
  return this._subscribe(sink);
909
1012
  }
910
1013
  catch (err) {
911
- sink.error(err);
1014
+ if (config.useDeprecatedSynchronousErrorHandling) {
1015
+ sink.syncErrorThrown = true;
1016
+ sink.syncErrorValue = err;
1017
+ }
1018
+ if (canReportError(sink)) {
1019
+ sink.error(err);
1020
+ }
1021
+ else {
1022
+ console.warn(err);
1023
+ }
912
1024
  }
913
1025
  };
914
1026
  Observable.prototype.forEach = function (next, promiseCtor) {
915
1027
  var _this = this;
916
1028
  promiseCtor = getPromiseCtor(promiseCtor);
917
1029
  return new promiseCtor(function (resolve, reject) {
918
- var subscriber = new SafeSubscriber({
919
- next: function (value) {
920
- try {
921
- next(value);
922
- }
923
- catch (err) {
924
- reject(err);
925
- subscriber.unsubscribe();
1030
+ var subscription;
1031
+ subscription = _this.subscribe(function (value) {
1032
+ try {
1033
+ next(value);
1034
+ }
1035
+ catch (err) {
1036
+ reject(err);
1037
+ if (subscription) {
1038
+ subscription.unsubscribe();
926
1039
  }
927
- },
928
- error: reject,
929
- complete: resolve,
930
- });
931
- _this.subscribe(subscriber);
1040
+ }
1041
+ }, reject, resolve);
932
1042
  });
933
1043
  };
934
1044
  Observable.prototype._subscribe = function (subscriber) {
935
- var _a;
936
- return (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber);
1045
+ var source = this.source;
1046
+ return source && source.subscribe(subscriber);
937
1047
  };
938
1048
  Observable.prototype[observable] = function () {
939
1049
  return this;
@@ -943,6 +1053,9 @@ var Observable = (function () {
943
1053
  for (var _i = 0; _i < arguments.length; _i++) {
944
1054
  operations[_i] = arguments[_i];
945
1055
  }
1056
+ if (operations.length === 0) {
1057
+ return this;
1058
+ }
946
1059
  return pipeFromArray(operations)(this);
947
1060
  };
948
1061
  Observable.prototype.toPromise = function (promiseCtor) {
@@ -950,7 +1063,7 @@ var Observable = (function () {
950
1063
  promiseCtor = getPromiseCtor(promiseCtor);
951
1064
  return new promiseCtor(function (resolve, reject) {
952
1065
  var value;
953
- _this.subscribe(function (x) { return (value = x); }, function (err) { return reject(err); }, function () { return resolve(value); });
1066
+ _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
954
1067
  });
955
1068
  };
956
1069
  Observable.create = function (subscribe) {
@@ -959,139 +1072,155 @@ var Observable = (function () {
959
1072
  return Observable;
960
1073
  }());
961
1074
  function getPromiseCtor(promiseCtor) {
962
- var _a;
963
- return (_a = promiseCtor !== null && promiseCtor !== void 0 ? promiseCtor : config.Promise) !== null && _a !== void 0 ? _a : Promise;
964
- }
965
- function isObserver(value) {
966
- return value && isFunction(value.next) && isFunction(value.error) && isFunction(value.complete);
967
- }
968
- function isSubscriber(value) {
969
- return (value && value instanceof Subscriber) || (isObserver(value) && isSubscription(value));
1075
+ if (!promiseCtor) {
1076
+ promiseCtor = config.Promise || Promise;
1077
+ }
1078
+ if (!promiseCtor) {
1079
+ throw new Error('no Promise impl found');
1080
+ }
1081
+ return promiseCtor;
970
1082
  }
971
1083
 
972
- var ObjectUnsubscribedError = createErrorClass(function (_super) {
973
- return function ObjectUnsubscribedErrorImpl() {
974
- _super(this);
975
- this.name = 'ObjectUnsubscribedError';
1084
+ /** PURE_IMPORTS_START PURE_IMPORTS_END */
1085
+ var ObjectUnsubscribedErrorImpl = /*@__PURE__*/ (function () {
1086
+ function ObjectUnsubscribedErrorImpl() {
1087
+ Error.call(this);
976
1088
  this.message = 'object unsubscribed';
1089
+ this.name = 'ObjectUnsubscribedError';
1090
+ return this;
1091
+ }
1092
+ ObjectUnsubscribedErrorImpl.prototype = /*@__PURE__*/ Object.create(Error.prototype);
1093
+ return ObjectUnsubscribedErrorImpl;
1094
+ })();
1095
+ var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
1096
+
1097
+ /** PURE_IMPORTS_START tslib,_Subscription PURE_IMPORTS_END */
1098
+ var SubjectSubscription = /*@__PURE__*/ (function (_super) {
1099
+ tslib_1__namespace.__extends(SubjectSubscription, _super);
1100
+ function SubjectSubscription(subject, subscriber) {
1101
+ var _this = _super.call(this) || this;
1102
+ _this.subject = subject;
1103
+ _this.subscriber = subscriber;
1104
+ _this.closed = false;
1105
+ return _this;
1106
+ }
1107
+ SubjectSubscription.prototype.unsubscribe = function () {
1108
+ if (this.closed) {
1109
+ return;
1110
+ }
1111
+ this.closed = true;
1112
+ var subject = this.subject;
1113
+ var observers = subject.observers;
1114
+ this.subject = null;
1115
+ if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
1116
+ return;
1117
+ }
1118
+ var subscriberIndex = observers.indexOf(this.subscriber);
1119
+ if (subscriberIndex !== -1) {
1120
+ observers.splice(subscriberIndex, 1);
1121
+ }
977
1122
  };
978
- });
1123
+ return SubjectSubscription;
1124
+ }(Subscription$1));
979
1125
 
980
- var Subject = (function (_super) {
981
- tslib.__extends(Subject, _super);
1126
+ /** PURE_IMPORTS_START tslib,_Observable,_Subscriber,_Subscription,_util_ObjectUnsubscribedError,_SubjectSubscription,_internal_symbol_rxSubscriber PURE_IMPORTS_END */
1127
+ var SubjectSubscriber = /*@__PURE__*/ (function (_super) {
1128
+ tslib_1__namespace.__extends(SubjectSubscriber, _super);
1129
+ function SubjectSubscriber(destination) {
1130
+ var _this = _super.call(this, destination) || this;
1131
+ _this.destination = destination;
1132
+ return _this;
1133
+ }
1134
+ return SubjectSubscriber;
1135
+ }(Subscriber));
1136
+ var Subject = /*@__PURE__*/ (function (_super) {
1137
+ tslib_1__namespace.__extends(Subject, _super);
982
1138
  function Subject() {
983
1139
  var _this = _super.call(this) || this;
984
- _this.closed = false;
985
- _this.currentObservers = null;
986
1140
  _this.observers = [];
1141
+ _this.closed = false;
987
1142
  _this.isStopped = false;
988
1143
  _this.hasError = false;
989
1144
  _this.thrownError = null;
990
1145
  return _this;
991
1146
  }
1147
+ Subject.prototype[rxSubscriber] = function () {
1148
+ return new SubjectSubscriber(this);
1149
+ };
992
1150
  Subject.prototype.lift = function (operator) {
993
1151
  var subject = new AnonymousSubject(this, this);
994
1152
  subject.operator = operator;
995
1153
  return subject;
996
1154
  };
997
- Subject.prototype._throwIfClosed = function () {
1155
+ Subject.prototype.next = function (value) {
998
1156
  if (this.closed) {
999
1157
  throw new ObjectUnsubscribedError();
1000
1158
  }
1001
- };
1002
- Subject.prototype.next = function (value) {
1003
- var _this = this;
1004
- errorContext(function () {
1005
- var e_1, _a;
1006
- _this._throwIfClosed();
1007
- if (!_this.isStopped) {
1008
- if (!_this.currentObservers) {
1009
- _this.currentObservers = Array.from(_this.observers);
1010
- }
1011
- try {
1012
- for (var _b = tslib.__values(_this.currentObservers), _c = _b.next(); !_c.done; _c = _b.next()) {
1013
- var observer = _c.value;
1014
- observer.next(value);
1015
- }
1016
- }
1017
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1018
- finally {
1019
- try {
1020
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
1021
- }
1022
- finally { if (e_1) throw e_1.error; }
1023
- }
1159
+ if (!this.isStopped) {
1160
+ var observers = this.observers;
1161
+ var len = observers.length;
1162
+ var copy = observers.slice();
1163
+ for (var i = 0; i < len; i++) {
1164
+ copy[i].next(value);
1024
1165
  }
1025
- });
1166
+ }
1026
1167
  };
1027
1168
  Subject.prototype.error = function (err) {
1028
- var _this = this;
1029
- errorContext(function () {
1030
- _this._throwIfClosed();
1031
- if (!_this.isStopped) {
1032
- _this.hasError = _this.isStopped = true;
1033
- _this.thrownError = err;
1034
- var observers = _this.observers;
1035
- while (observers.length) {
1036
- observers.shift().error(err);
1037
- }
1038
- }
1039
- });
1169
+ if (this.closed) {
1170
+ throw new ObjectUnsubscribedError();
1171
+ }
1172
+ this.hasError = true;
1173
+ this.thrownError = err;
1174
+ this.isStopped = true;
1175
+ var observers = this.observers;
1176
+ var len = observers.length;
1177
+ var copy = observers.slice();
1178
+ for (var i = 0; i < len; i++) {
1179
+ copy[i].error(err);
1180
+ }
1181
+ this.observers.length = 0;
1040
1182
  };
1041
1183
  Subject.prototype.complete = function () {
1042
- var _this = this;
1043
- errorContext(function () {
1044
- _this._throwIfClosed();
1045
- if (!_this.isStopped) {
1046
- _this.isStopped = true;
1047
- var observers = _this.observers;
1048
- while (observers.length) {
1049
- observers.shift().complete();
1050
- }
1051
- }
1052
- });
1184
+ if (this.closed) {
1185
+ throw new ObjectUnsubscribedError();
1186
+ }
1187
+ this.isStopped = true;
1188
+ var observers = this.observers;
1189
+ var len = observers.length;
1190
+ var copy = observers.slice();
1191
+ for (var i = 0; i < len; i++) {
1192
+ copy[i].complete();
1193
+ }
1194
+ this.observers.length = 0;
1053
1195
  };
1054
1196
  Subject.prototype.unsubscribe = function () {
1055
- this.isStopped = this.closed = true;
1056
- this.observers = this.currentObservers = null;
1197
+ this.isStopped = true;
1198
+ this.closed = true;
1199
+ this.observers = null;
1057
1200
  };
1058
- Object.defineProperty(Subject.prototype, "observed", {
1059
- get: function () {
1060
- var _a;
1061
- return ((_a = this.observers) === null || _a === void 0 ? void 0 : _a.length) > 0;
1062
- },
1063
- enumerable: false,
1064
- configurable: true
1065
- });
1066
1201
  Subject.prototype._trySubscribe = function (subscriber) {
1067
- this._throwIfClosed();
1068
- return _super.prototype._trySubscribe.call(this, subscriber);
1202
+ if (this.closed) {
1203
+ throw new ObjectUnsubscribedError();
1204
+ }
1205
+ else {
1206
+ return _super.prototype._trySubscribe.call(this, subscriber);
1207
+ }
1069
1208
  };
1070
1209
  Subject.prototype._subscribe = function (subscriber) {
1071
- this._throwIfClosed();
1072
- this._checkFinalizedStatuses(subscriber);
1073
- return this._innerSubscribe(subscriber);
1074
- };
1075
- Subject.prototype._innerSubscribe = function (subscriber) {
1076
- var _this = this;
1077
- var _a = this, hasError = _a.hasError, isStopped = _a.isStopped, observers = _a.observers;
1078
- if (hasError || isStopped) {
1079
- return EMPTY_SUBSCRIPTION;
1210
+ if (this.closed) {
1211
+ throw new ObjectUnsubscribedError();
1080
1212
  }
1081
- this.currentObservers = null;
1082
- observers.push(subscriber);
1083
- return new Subscription$1(function () {
1084
- _this.currentObservers = null;
1085
- arrRemove(observers, subscriber);
1086
- });
1087
- };
1088
- Subject.prototype._checkFinalizedStatuses = function (subscriber) {
1089
- var _a = this, hasError = _a.hasError, thrownError = _a.thrownError, isStopped = _a.isStopped;
1090
- if (hasError) {
1091
- subscriber.error(thrownError);
1213
+ else if (this.hasError) {
1214
+ subscriber.error(this.thrownError);
1215
+ return Subscription$1.EMPTY;
1092
1216
  }
1093
- else if (isStopped) {
1217
+ else if (this.isStopped) {
1094
1218
  subscriber.complete();
1219
+ return Subscription$1.EMPTY;
1220
+ }
1221
+ else {
1222
+ this.observers.push(subscriber);
1223
+ return new SubjectSubscription(this, subscriber);
1095
1224
  }
1096
1225
  };
1097
1226
  Subject.prototype.asObservable = function () {
@@ -1104,8 +1233,8 @@ var Subject = (function (_super) {
1104
1233
  };
1105
1234
  return Subject;
1106
1235
  }(Observable));
1107
- var AnonymousSubject = (function (_super) {
1108
- tslib.__extends(AnonymousSubject, _super);
1236
+ var AnonymousSubject = /*@__PURE__*/ (function (_super) {
1237
+ tslib_1__namespace.__extends(AnonymousSubject, _super);
1109
1238
  function AnonymousSubject(destination, source) {
1110
1239
  var _this = _super.call(this) || this;
1111
1240
  _this.destination = destination;
@@ -1113,20 +1242,31 @@ var AnonymousSubject = (function (_super) {
1113
1242
  return _this;
1114
1243
  }
1115
1244
  AnonymousSubject.prototype.next = function (value) {
1116
- var _a, _b;
1117
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.next) === null || _b === void 0 ? void 0 : _b.call(_a, value);
1245
+ var destination = this.destination;
1246
+ if (destination && destination.next) {
1247
+ destination.next(value);
1248
+ }
1118
1249
  };
1119
1250
  AnonymousSubject.prototype.error = function (err) {
1120
- var _a, _b;
1121
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.call(_a, err);
1251
+ var destination = this.destination;
1252
+ if (destination && destination.error) {
1253
+ this.destination.error(err);
1254
+ }
1122
1255
  };
1123
1256
  AnonymousSubject.prototype.complete = function () {
1124
- var _a, _b;
1125
- (_b = (_a = this.destination) === null || _a === void 0 ? void 0 : _a.complete) === null || _b === void 0 ? void 0 : _b.call(_a);
1257
+ var destination = this.destination;
1258
+ if (destination && destination.complete) {
1259
+ this.destination.complete();
1260
+ }
1126
1261
  };
1127
1262
  AnonymousSubject.prototype._subscribe = function (subscriber) {
1128
- var _a, _b;
1129
- return (_b = (_a = this.source) === null || _a === void 0 ? void 0 : _a.subscribe(subscriber)) !== null && _b !== void 0 ? _b : EMPTY_SUBSCRIPTION;
1263
+ var source = this.source;
1264
+ if (source) {
1265
+ return this.source.subscribe(subscriber);
1266
+ }
1267
+ else {
1268
+ return Subscription$1.EMPTY;
1269
+ }
1130
1270
  };
1131
1271
  return AnonymousSubject;
1132
1272
  }(Subject));
@@ -1654,199 +1794,90 @@ class Coupon extends BaseModel {
1654
1794
  }
1655
1795
  }
1656
1796
 
1657
- class SubscriptionPlan extends BaseModel {
1658
- static get identifiersFields() {
1659
- return ['id'];
1660
- }
1661
- }
1662
-
1663
- class BeautyProfile extends BaseModel {
1664
- toPlain() {
1665
- const plain = super.toPlain();
1666
- delete plain.id;
1667
- return plain;
1668
- }
1669
- static get identifiersFields() {
1670
- return ['id', 'userId'];
1671
- }
1672
- }
1673
-
1674
- class User extends BaseModel {
1675
- static toInstance(data) {
1676
- const instance = super.toInstance(data);
1677
- if (!lodash.isNil(data.firstName))
1678
- instance.displayName = `${data.firstName}${!lodash.isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
1679
- return instance;
1680
- }
1681
- toPlain() {
1682
- const plain = super.toPlain();
1683
- delete plain.beautyProfile;
1684
- return plain;
1685
- }
1686
- static get identifiersFields() {
1687
- return ['id'];
1688
- }
1689
- }
1690
- tslib.__decorate([
1691
- classTransformer.Type(() => BeautyProfile),
1692
- tslib.__metadata("design:type", BeautyProfile)
1693
- ], User.prototype, "beautyProfile", void 0);
1694
-
1695
- class Address extends BaseModel {
1696
- static get identifiersFields() {
1697
- return ['id'];
1698
- }
1699
- }
1700
-
1701
- class UserAddress extends Address {
1702
- static get identifiersFields() {
1703
- return ['id', 'userId'];
1704
- }
1705
- }
1706
-
1707
- class Subscription extends BaseModel {
1708
- static get identifiersFields() {
1709
- return ['id'];
1710
- }
1711
- }
1712
- tslib.__decorate([
1713
- classTransformer.Type(() => User),
1714
- tslib.__metadata("design:type", User)
1715
- ], Subscription.prototype, "user", void 0);
1716
- tslib.__decorate([
1717
- classTransformer.Type(() => SubscriptionPlan),
1718
- tslib.__metadata("design:type", SubscriptionPlan)
1719
- ], Subscription.prototype, "subscriptionPlan", void 0);
1720
- tslib.__decorate([
1721
- classTransformer.Type(() => UserAddress),
1722
- tslib.__metadata("design:type", UserAddress)
1723
- ], Subscription.prototype, "shippingAddress", void 0);
1724
- tslib.__decorate([
1725
- classTransformer.Type(() => UserAddress),
1726
- tslib.__metadata("design:type", UserAddress)
1727
- ], Subscription.prototype, "billingAddress", void 0);
1728
- tslib.__decorate([
1729
- classTransformer.Type(() => Coupon),
1730
- tslib.__metadata("design:type", Coupon)
1731
- ], Subscription.prototype, "coupon", void 0);
1732
- tslib.__decorate([
1733
- classTransformer.Type(() => Edition),
1734
- tslib.__metadata("design:type", Array)
1735
- ], Subscription.prototype, "editions", void 0);
1736
- tslib.__decorate([
1737
- classTransformer.Type(() => SubscriptionPayment),
1738
- tslib.__metadata("design:type", Array)
1739
- ], Subscription.prototype, "payment", void 0);
1740
-
1741
- class UserPaymentMethod extends BaseModel {
1742
- static get identifiersFields() {
1743
- return ['id', 'userId'];
1744
- }
1745
- }
1746
-
1747
- class Lead extends BaseModel {
1748
- static get identifiersFields() {
1749
- return ['id'];
1750
- }
1751
- }
1752
-
1753
- class UnauthorizedError extends tsCustomError.CustomError {
1754
- constructor(message) {
1755
- super(message);
1756
- }
1757
- }
1758
-
1759
- exports.SignInMethods = void 0;
1760
- (function (SignInMethods) {
1761
- SignInMethods["EMAIL_PASSWORD"] = "email_password";
1762
- SignInMethods["GOOGLE"] = "google";
1763
- })(exports.SignInMethods || (exports.SignInMethods = {}));
1764
- class Authentication {
1765
- constructor(authService, userRepository) {
1766
- this.authService = authService;
1767
- this.userRepository = userRepository;
1768
- }
1769
- async signIn({ email, password }, signInMethod) {
1770
- const method = this.getServiceByMethod(signInMethod);
1771
- const userAuth = await this.authService[method]({ email, password });
1772
- const user = this.userRepository.get({ id: userAuth.id });
1773
- if (!lodash.isNil(user))
1774
- return user;
1775
- if (/^.+@b4a.com.br$/.test(userAuth.email))
1776
- return this.createsUserByCredential(userAuth);
1777
- throw new UnauthorizedError('Invalid credentials');
1778
- }
1779
- getServiceByMethod(signInMethod) {
1780
- return signInMethod === exports.SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
1781
- }
1782
- async createsUserByCredential(user) {
1783
- var _a;
1784
- const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
1785
- const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
1786
- lastName, acceptsNewsletter: false, area: exports.Area.Transactional, officePosition: exports.OfficePosition.Intern, type: exports.UserType.Collaborator }));
1787
- return this.userRepository.create(person);
1788
- }
1789
- }
1790
-
1791
- class UserAlreadyRegisteredError extends tsCustomError.CustomError {
1792
- constructor(message) {
1793
- super(message);
1794
- }
1795
- }
1796
-
1797
- class WeakPasswordError extends tsCustomError.CustomError {
1798
- constructor(message = 'Weak password') {
1799
- super(message);
1797
+ class SubscriptionPlan extends BaseModel {
1798
+ static get identifiersFields() {
1799
+ return ['id'];
1800
1800
  }
1801
1801
  }
1802
1802
 
1803
- class Register {
1804
- constructor(registerService, userRepository) {
1805
- this.registerService = registerService;
1806
- this.userRepository = userRepository;
1803
+ class BeautyProfile extends BaseModel {
1804
+ toPlain() {
1805
+ const plain = super.toPlain();
1806
+ delete plain.id;
1807
+ return plain;
1807
1808
  }
1808
- async register(params) {
1809
- const email = params.email.toLocaleLowerCase();
1810
- const displayName = `${params.firstName} ${params.lastName}`;
1811
- if (await this.userRepository.checkIfExistsByField('cpf', params.cpf))
1812
- throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} já registrado.`);
1813
- if (await this.userRepository.checkIfExistsByField('email', params.email))
1814
- throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} já registrado.`);
1815
- const auth = await this.registerService.register({
1816
- birthday: params.birthday,
1817
- email,
1818
- firstName: params.firstName,
1819
- lastName: params.lastName,
1820
- cpf: params.cpf,
1821
- displayName,
1822
- phone: params.phone,
1823
- password: params.password,
1824
- });
1825
- delete params.password;
1826
- const user = await this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
1827
- displayName, type: exports.UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
1828
- return user;
1809
+ static get identifiersFields() {
1810
+ return ['id', 'userId'];
1829
1811
  }
1830
1812
  }
1831
1813
 
1832
- class SignOut {
1833
- constructor(authService) {
1834
- this.authService = authService;
1814
+ class User extends BaseModel {
1815
+ static toInstance(data) {
1816
+ const instance = super.toInstance(data);
1817
+ if (!lodash.isNil(data.firstName))
1818
+ instance.displayName = `${data.firstName}${!lodash.isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
1819
+ return instance;
1835
1820
  }
1836
- async signOut() {
1837
- await this.authService.signOut();
1821
+ toPlain() {
1822
+ const plain = super.toPlain();
1823
+ delete plain.beautyProfile;
1824
+ return plain;
1838
1825
  }
1839
- }
1826
+ static get identifiersFields() {
1827
+ return ['id'];
1828
+ }
1829
+ }
1830
+ tslib_1.__decorate([
1831
+ classTransformer.Type(() => BeautyProfile),
1832
+ tslib_1.__metadata("design:type", BeautyProfile)
1833
+ ], User.prototype, "beautyProfile", void 0);
1840
1834
 
1841
- class RecoveryPassword {
1842
- constructor(authService) {
1843
- this.authService = authService;
1835
+ class Address extends BaseModel {
1836
+ static get identifiersFields() {
1837
+ return ['id'];
1844
1838
  }
1845
- async sendEmail(email) {
1846
- await this.authService.sendPasswordResetEmail(email);
1839
+ }
1840
+
1841
+ class UserAddress extends Address {
1842
+ static get identifiersFields() {
1843
+ return ['id', 'userId'];
1847
1844
  }
1848
1845
  }
1849
1846
 
1847
+ class Subscription extends BaseModel {
1848
+ static get identifiersFields() {
1849
+ return ['id'];
1850
+ }
1851
+ }
1852
+ tslib_1.__decorate([
1853
+ classTransformer.Type(() => User),
1854
+ tslib_1.__metadata("design:type", User)
1855
+ ], Subscription.prototype, "user", void 0);
1856
+ tslib_1.__decorate([
1857
+ classTransformer.Type(() => SubscriptionPlan),
1858
+ tslib_1.__metadata("design:type", SubscriptionPlan)
1859
+ ], Subscription.prototype, "subscriptionPlan", void 0);
1860
+ tslib_1.__decorate([
1861
+ classTransformer.Type(() => UserAddress),
1862
+ tslib_1.__metadata("design:type", UserAddress)
1863
+ ], Subscription.prototype, "shippingAddress", void 0);
1864
+ tslib_1.__decorate([
1865
+ classTransformer.Type(() => UserAddress),
1866
+ tslib_1.__metadata("design:type", UserAddress)
1867
+ ], Subscription.prototype, "billingAddress", void 0);
1868
+ tslib_1.__decorate([
1869
+ classTransformer.Type(() => Coupon),
1870
+ tslib_1.__metadata("design:type", Coupon)
1871
+ ], Subscription.prototype, "coupon", void 0);
1872
+ tslib_1.__decorate([
1873
+ classTransformer.Type(() => Edition),
1874
+ tslib_1.__metadata("design:type", Array)
1875
+ ], Subscription.prototype, "editions", void 0);
1876
+ tslib_1.__decorate([
1877
+ classTransformer.Type(() => SubscriptionPayment),
1878
+ tslib_1.__metadata("design:type", Array)
1879
+ ], Subscription.prototype, "payment", void 0);
1880
+
1850
1881
  class Filter extends BaseModel {
1851
1882
  static get identifiersFields() {
1852
1883
  return ['id'];
@@ -1858,13 +1889,13 @@ class CategoryBase extends BaseModel {
1858
1889
  return ['id'];
1859
1890
  }
1860
1891
  }
1861
- tslib.__decorate([
1892
+ tslib_1.__decorate([
1862
1893
  classTransformer.Type(() => CategoryBase),
1863
- tslib.__metadata("design:type", CategoryBase)
1894
+ tslib_1.__metadata("design:type", CategoryBase)
1864
1895
  ], CategoryBase.prototype, "parent", void 0);
1865
- tslib.__decorate([
1896
+ tslib_1.__decorate([
1866
1897
  classTransformer.Type(() => Filter),
1867
- tslib.__metadata("design:type", Array)
1898
+ tslib_1.__metadata("design:type", Array)
1868
1899
  ], CategoryBase.prototype, "filters", void 0);
1869
1900
 
1870
1901
  class CategoryForProduct extends CategoryBase {
@@ -1902,9 +1933,9 @@ class ProductForKit extends ProductBase {
1902
1933
  return ['id'];
1903
1934
  }
1904
1935
  }
1905
- tslib.__decorate([
1936
+ tslib_1.__decorate([
1906
1937
  classTransformer.Type(() => CategoryForProduct),
1907
- tslib.__metadata("design:type", CategoryForProduct)
1938
+ tslib_1.__metadata("design:type", CategoryForProduct)
1908
1939
  ], ProductForKit.prototype, "category", void 0);
1909
1940
 
1910
1941
  class KitProduct extends BaseModel {
@@ -1912,13 +1943,13 @@ class KitProduct extends BaseModel {
1912
1943
  return ['productId', 'kitProductId'];
1913
1944
  }
1914
1945
  }
1915
- tslib.__decorate([
1946
+ tslib_1.__decorate([
1916
1947
  classTransformer.Type(() => ProductForKit),
1917
- tslib.__metadata("design:type", ProductForKit)
1948
+ tslib_1.__metadata("design:type", ProductForKit)
1918
1949
  ], KitProduct.prototype, "kit", void 0);
1919
- tslib.__decorate([
1950
+ tslib_1.__decorate([
1920
1951
  classTransformer.Type(() => ProductForKit),
1921
- tslib.__metadata("design:type", ProductForKit)
1952
+ tslib_1.__metadata("design:type", ProductForKit)
1922
1953
  ], KitProduct.prototype, "product", void 0);
1923
1954
 
1924
1955
  class ProductForCategory extends ProductBase {
@@ -1926,9 +1957,9 @@ class ProductForCategory extends ProductBase {
1926
1957
  return ['id'];
1927
1958
  }
1928
1959
  }
1929
- tslib.__decorate([
1960
+ tslib_1.__decorate([
1930
1961
  classTransformer.Type(() => KitProduct),
1931
- tslib.__metadata("design:type", Array)
1962
+ tslib_1.__metadata("design:type", Array)
1932
1963
  ], ProductForCategory.prototype, "kitProducts", void 0);
1933
1964
 
1934
1965
  class Category extends CategoryBase {
@@ -1936,9 +1967,9 @@ class Category extends CategoryBase {
1936
1967
  return ['id'];
1937
1968
  }
1938
1969
  }
1939
- tslib.__decorate([
1970
+ tslib_1.__decorate([
1940
1971
  classTransformer.Type(() => ProductForCategory),
1941
- tslib.__metadata("design:type", Array)
1972
+ tslib_1.__metadata("design:type", Array)
1942
1973
  ], Category.prototype, "childrenProducts", void 0);
1943
1974
 
1944
1975
  class CategoryCollectionChildren extends BaseModel {
@@ -1946,9 +1977,9 @@ class CategoryCollectionChildren extends BaseModel {
1946
1977
  return ['collectionId', 'categoryId'];
1947
1978
  }
1948
1979
  }
1949
- tslib.__decorate([
1980
+ tslib_1.__decorate([
1950
1981
  classTransformer.Type(() => CategoryCollectionChildren),
1951
- tslib.__metadata("design:type", CategoryCollectionChildren)
1982
+ tslib_1.__metadata("design:type", CategoryCollectionChildren)
1952
1983
  ], CategoryCollectionChildren.prototype, "parent", void 0);
1953
1984
 
1954
1985
  class CategoryFilter extends BaseModel {
@@ -1956,13 +1987,13 @@ class CategoryFilter extends BaseModel {
1956
1987
  return ['id'];
1957
1988
  }
1958
1989
  }
1959
- tslib.__decorate([
1990
+ tslib_1.__decorate([
1960
1991
  classTransformer.Type(() => Filter),
1961
- tslib.__metadata("design:type", Filter)
1992
+ tslib_1.__metadata("design:type", Filter)
1962
1993
  ], CategoryFilter.prototype, "filter", void 0);
1963
- tslib.__decorate([
1994
+ tslib_1.__decorate([
1964
1995
  classTransformer.Type(() => Category),
1965
- tslib.__metadata("design:type", Category)
1996
+ tslib_1.__metadata("design:type", Category)
1966
1997
  ], CategoryFilter.prototype, "category", void 0);
1967
1998
 
1968
1999
  exports.GenderDestination = void 0;
@@ -1991,15 +2022,21 @@ class Product extends ProductBase {
1991
2022
  return ['id'];
1992
2023
  }
1993
2024
  }
1994
- tslib.__decorate([
2025
+ tslib_1.__decorate([
1995
2026
  classTransformer.Type(() => CategoryForProduct),
1996
- tslib.__metadata("design:type", CategoryForProduct)
2027
+ tslib_1.__metadata("design:type", CategoryForProduct)
1997
2028
  ], Product.prototype, "category", void 0);
1998
- tslib.__decorate([
2029
+ tslib_1.__decorate([
1999
2030
  classTransformer.Type(() => KitProduct),
2000
- tslib.__metadata("design:type", Array)
2031
+ tslib_1.__metadata("design:type", Array)
2001
2032
  ], Product.prototype, "kitProducts", void 0);
2002
2033
 
2034
+ class ProductReviews extends BaseModel {
2035
+ static get identifiersFields() {
2036
+ return ['id'];
2037
+ }
2038
+ }
2039
+
2003
2040
  class Variant extends BaseModel {
2004
2041
  static get identifiersFields() {
2005
2042
  return ['id', 'productId'];
@@ -2017,9 +2054,9 @@ class Buy2Win extends BaseModel {
2017
2054
  return ['id'];
2018
2055
  }
2019
2056
  }
2020
- tslib.__decorate([
2057
+ tslib_1.__decorate([
2021
2058
  classTransformer.Type(() => Category),
2022
- tslib.__metadata("design:type", Array)
2059
+ tslib_1.__metadata("design:type", Array)
2023
2060
  ], Buy2Win.prototype, "categories", void 0);
2024
2061
 
2025
2062
  class CampaignDashboard extends BaseModel {
@@ -2048,29 +2085,29 @@ class Checkout extends BaseModel {
2048
2085
  return ['id'];
2049
2086
  }
2050
2087
  }
2051
- tslib.__decorate([
2088
+ tslib_1.__decorate([
2052
2089
  classTransformer.Type(() => LineItem),
2053
- tslib.__metadata("design:type", Array)
2090
+ tslib_1.__metadata("design:type", Array)
2054
2091
  ], Checkout.prototype, "lineItems", void 0);
2055
- tslib.__decorate([
2092
+ tslib_1.__decorate([
2056
2093
  classTransformer.Type(() => User),
2057
- tslib.__metadata("design:type", User)
2094
+ tslib_1.__metadata("design:type", User)
2058
2095
  ], Checkout.prototype, "user", void 0);
2059
- tslib.__decorate([
2096
+ tslib_1.__decorate([
2060
2097
  classTransformer.Type(() => UserAddress),
2061
- tslib.__metadata("design:type", UserAddress)
2098
+ tslib_1.__metadata("design:type", UserAddress)
2062
2099
  ], Checkout.prototype, "shippingAddress", void 0);
2063
- tslib.__decorate([
2100
+ tslib_1.__decorate([
2064
2101
  classTransformer.Type(() => UserAddress),
2065
- tslib.__metadata("design:type", UserAddress)
2102
+ tslib_1.__metadata("design:type", UserAddress)
2066
2103
  ], Checkout.prototype, "billingAddress", void 0);
2067
- tslib.__decorate([
2104
+ tslib_1.__decorate([
2068
2105
  classTransformer.Type(() => ShippingMethod),
2069
- tslib.__metadata("design:type", ShippingMethod)
2106
+ tslib_1.__metadata("design:type", ShippingMethod)
2070
2107
  ], Checkout.prototype, "shipping", void 0);
2071
- tslib.__decorate([
2108
+ tslib_1.__decorate([
2072
2109
  classTransformer.Type(() => Coupon),
2073
- tslib.__metadata("design:type", Coupon)
2110
+ tslib_1.__metadata("design:type", Coupon)
2074
2111
  ], Checkout.prototype, "coupon", void 0);
2075
2112
 
2076
2113
  exports.OrderStatus = void 0;
@@ -2087,9 +2124,9 @@ exports.OrderStatus = void 0;
2087
2124
 
2088
2125
  class Order extends Checkout {
2089
2126
  }
2090
- tslib.__decorate([
2127
+ tslib_1.__decorate([
2091
2128
  classTransformer.Type(() => Payment),
2092
- tslib.__metadata("design:type", Payment)
2129
+ tslib_1.__metadata("design:type", Payment)
2093
2130
  ], Order.prototype, "payment", void 0);
2094
2131
 
2095
2132
  class CheckoutSubscription extends BaseModel {
@@ -2097,23 +2134,172 @@ class CheckoutSubscription extends BaseModel {
2097
2134
  return ['id'];
2098
2135
  }
2099
2136
  }
2100
- tslib.__decorate([
2137
+ tslib_1.__decorate([
2101
2138
  classTransformer.Type(() => UserAddress),
2102
- tslib.__metadata("design:type", UserAddress)
2139
+ tslib_1.__metadata("design:type", UserAddress)
2103
2140
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
2104
- tslib.__decorate([
2141
+ tslib_1.__decorate([
2105
2142
  classTransformer.Type(() => UserAddress),
2106
- tslib.__metadata("design:type", UserAddress)
2143
+ tslib_1.__metadata("design:type", UserAddress)
2107
2144
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
2108
- tslib.__decorate([
2145
+ tslib_1.__decorate([
2109
2146
  classTransformer.Type(() => SubscriptionPlan),
2110
- tslib.__metadata("design:type", SubscriptionPlan)
2147
+ tslib_1.__metadata("design:type", SubscriptionPlan)
2111
2148
  ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
2112
- tslib.__decorate([
2149
+ tslib_1.__decorate([
2113
2150
  classTransformer.Type(() => Coupon),
2114
- tslib.__metadata("design:type", Coupon)
2151
+ tslib_1.__metadata("design:type", Coupon)
2115
2152
  ], CheckoutSubscription.prototype, "coupon", void 0);
2116
2153
 
2154
+ class SubscriptionMaterialization extends BaseModel {
2155
+ static get identifiersFields() {
2156
+ return ['id'];
2157
+ }
2158
+ }
2159
+ tslib_1.__decorate([
2160
+ classTransformer.Type(() => User),
2161
+ tslib_1.__metadata("design:type", User)
2162
+ ], SubscriptionMaterialization.prototype, "user", void 0);
2163
+ tslib_1.__decorate([
2164
+ classTransformer.Type(() => SubscriptionPlan),
2165
+ tslib_1.__metadata("design:type", SubscriptionPlan)
2166
+ ], SubscriptionMaterialization.prototype, "subscriptionPlan", void 0);
2167
+ tslib_1.__decorate([
2168
+ classTransformer.Type(() => UserAddress),
2169
+ tslib_1.__metadata("design:type", UserAddress)
2170
+ ], SubscriptionMaterialization.prototype, "shippingAddress", void 0);
2171
+ tslib_1.__decorate([
2172
+ classTransformer.Type(() => UserAddress),
2173
+ tslib_1.__metadata("design:type", UserAddress)
2174
+ ], SubscriptionMaterialization.prototype, "billingAddress", void 0);
2175
+ tslib_1.__decorate([
2176
+ classTransformer.Type(() => Coupon),
2177
+ tslib_1.__metadata("design:type", Coupon)
2178
+ ], SubscriptionMaterialization.prototype, "coupon", void 0);
2179
+ tslib_1.__decorate([
2180
+ classTransformer.Type(() => Edition),
2181
+ tslib_1.__metadata("design:type", Array)
2182
+ ], SubscriptionMaterialization.prototype, "editions", void 0);
2183
+ tslib_1.__decorate([
2184
+ classTransformer.Type(() => SubscriptionPayment),
2185
+ tslib_1.__metadata("design:type", SubscriptionPayment)
2186
+ ], SubscriptionMaterialization.prototype, "payment", void 0);
2187
+
2188
+ class SubscriptionSummary extends BaseModel {
2189
+ static get identifiersFields() {
2190
+ return ['id'];
2191
+ }
2192
+ }
2193
+
2194
+ class UserPaymentMethod extends BaseModel {
2195
+ static get identifiersFields() {
2196
+ return ['id', 'userId'];
2197
+ }
2198
+ }
2199
+
2200
+ class Lead extends BaseModel {
2201
+ static get identifiersFields() {
2202
+ return ['id'];
2203
+ }
2204
+ }
2205
+
2206
+ class UnauthorizedError extends tsCustomError.CustomError {
2207
+ constructor(message) {
2208
+ super(message);
2209
+ }
2210
+ }
2211
+
2212
+ exports.SignInMethods = void 0;
2213
+ (function (SignInMethods) {
2214
+ SignInMethods["EMAIL_PASSWORD"] = "email_password";
2215
+ SignInMethods["GOOGLE"] = "google";
2216
+ })(exports.SignInMethods || (exports.SignInMethods = {}));
2217
+ class Authentication {
2218
+ constructor(authService, userRepository) {
2219
+ this.authService = authService;
2220
+ this.userRepository = userRepository;
2221
+ }
2222
+ async signIn({ email, password }, signInMethod) {
2223
+ const method = this.getServiceByMethod(signInMethod);
2224
+ const userAuth = await this.authService[method]({ email, password });
2225
+ const user = this.userRepository.get({ id: userAuth.id });
2226
+ if (!lodash.isNil(user))
2227
+ return user;
2228
+ if (/^.+@b4a.com.br$/.test(userAuth.email))
2229
+ return this.createsUserByCredential(userAuth);
2230
+ throw new UnauthorizedError('Invalid credentials');
2231
+ }
2232
+ getServiceByMethod(signInMethod) {
2233
+ return signInMethod === exports.SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
2234
+ }
2235
+ async createsUserByCredential(user) {
2236
+ var _a;
2237
+ const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
2238
+ const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
2239
+ lastName, acceptsNewsletter: false, area: exports.Area.Transactional, officePosition: exports.OfficePosition.Intern, type: exports.UserType.Collaborator }));
2240
+ return this.userRepository.create(person);
2241
+ }
2242
+ }
2243
+
2244
+ class UserAlreadyRegisteredError extends tsCustomError.CustomError {
2245
+ constructor(message) {
2246
+ super(message);
2247
+ }
2248
+ }
2249
+
2250
+ class WeakPasswordError extends tsCustomError.CustomError {
2251
+ constructor(message = 'Weak password') {
2252
+ super(message);
2253
+ }
2254
+ }
2255
+
2256
+ class Register {
2257
+ constructor(registerService, userRepository) {
2258
+ this.registerService = registerService;
2259
+ this.userRepository = userRepository;
2260
+ }
2261
+ async register(params) {
2262
+ const email = params.email.toLocaleLowerCase();
2263
+ const displayName = `${params.firstName} ${params.lastName}`;
2264
+ if (await this.userRepository.checkIfExistsByField('cpf', params.cpf))
2265
+ throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} já registrado.`);
2266
+ if (await this.userRepository.checkIfExistsByField('email', params.email))
2267
+ throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} já registrado.`);
2268
+ const auth = await this.registerService.register({
2269
+ birthday: params.birthday,
2270
+ email,
2271
+ firstName: params.firstName,
2272
+ lastName: params.lastName,
2273
+ cpf: params.cpf,
2274
+ displayName,
2275
+ phone: params.phone,
2276
+ password: params.password,
2277
+ });
2278
+ delete params.password;
2279
+ const user = await this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
2280
+ displayName, type: exports.UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
2281
+ return user;
2282
+ }
2283
+ }
2284
+
2285
+ class SignOut {
2286
+ constructor(authService) {
2287
+ this.authService = authService;
2288
+ }
2289
+ async signOut() {
2290
+ await this.authService.signOut();
2291
+ }
2292
+ }
2293
+
2294
+ class RecoveryPassword {
2295
+ constructor(authService) {
2296
+ this.authService = authService;
2297
+ }
2298
+ async sendEmail(email) {
2299
+ await this.authService.sendPasswordResetEmail(email);
2300
+ }
2301
+ }
2302
+
2117
2303
  class RoundProductPricesHelper {
2118
2304
  static roundProductPrices(product) {
2119
2305
  product.price.price = Number(product.price.price.toFixed(2));
@@ -2422,7 +2608,7 @@ class ProductsIndex {
2422
2608
  }
2423
2609
  async save(product) {
2424
2610
  try {
2425
- const { createdAt, updatedAt, kitProducts } = product, data = tslib.__rest(product, ["createdAt", "updatedAt", "kitProducts"]);
2611
+ const { createdAt, updatedAt, kitProducts } = product, data = tslib_1.__rest(product, ["createdAt", "updatedAt", "kitProducts"]);
2426
2612
  this.adapter.save(this.index, data);
2427
2613
  }
2428
2614
  catch (error) {
@@ -2822,6 +3008,17 @@ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(with
2822
3008
  }
2823
3009
  }
2824
3010
 
3011
+ class SubscriptionMaterializationFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3012
+ constructor({ firestore, interceptors }) {
3013
+ super({
3014
+ firestore,
3015
+ collectionName: 'subscriptionMaterialization',
3016
+ model: SubscriptionMaterialization,
3017
+ interceptors,
3018
+ });
3019
+ }
3020
+ }
3021
+
2825
3022
  class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2826
3023
  constructor({ firestore, interceptors }, parentRepository) {
2827
3024
  super({
@@ -2835,6 +3032,17 @@ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudF
2835
3032
  }
2836
3033
  }
2837
3034
 
3035
+ class SubscriptionSummaryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
3036
+ constructor({ firestore, interceptors, }) {
3037
+ super({
3038
+ firestore,
3039
+ collectionName: 'subscriptionSummary',
3040
+ model: SubscriptionSummary,
3041
+ interceptors,
3042
+ });
3043
+ }
3044
+ }
3045
+
2838
3046
  class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base)))) {
2839
3047
  constructor({ firestore, interceptors }, parentRepository) {
2840
3048
  super({
@@ -3999,20 +4207,20 @@ class CategoryHasuraGraphQL extends Category {
3999
4207
 
4000
4208
  class ProductHasuraGraphQL extends Product {
4001
4209
  }
4002
- tslib.__decorate([
4210
+ tslib_1.__decorate([
4003
4211
  classTransformer.Type(() => KitProductHasuraGraphQL),
4004
- tslib.__metadata("design:type", Array)
4212
+ tslib_1.__metadata("design:type", Array)
4005
4213
  ], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
4006
4214
 
4007
4215
  class KitProductHasuraGraphQL extends KitProduct {
4008
4216
  }
4009
- tslib.__decorate([
4217
+ tslib_1.__decorate([
4010
4218
  classTransformer.Type(() => ProductHasuraGraphQL),
4011
- tslib.__metadata("design:type", ProductHasuraGraphQL)
4219
+ tslib_1.__metadata("design:type", ProductHasuraGraphQL)
4012
4220
  ], KitProductHasuraGraphQL.prototype, "kit", void 0);
4013
- tslib.__decorate([
4221
+ tslib_1.__decorate([
4014
4222
  classTransformer.Type(() => ProductHasuraGraphQL),
4015
- tslib.__metadata("design:type", ProductHasuraGraphQL)
4223
+ tslib_1.__metadata("design:type", ProductHasuraGraphQL)
4016
4224
  ], KitProductHasuraGraphQL.prototype, "product", void 0);
4017
4225
 
4018
4226
  class VariantHasuraGraphQL extends Variant {
@@ -4254,7 +4462,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4254
4462
  this.categoryFilterRepository = categoryFilterRepository;
4255
4463
  }
4256
4464
  async create(params) {
4257
- const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
4465
+ const { metadata } = params, data = tslib_1.__rest(params, ["metadata"]);
4258
4466
  return super.create(Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
4259
4467
  }
4260
4468
  async get(identifiers) {
@@ -4264,7 +4472,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4264
4472
  : super.get(identifiers);
4265
4473
  }
4266
4474
  async update(params) {
4267
- const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
4475
+ const { products, id: checkId, metadata, filters } = params, data = tslib_1.__rest(params, ["products", "id", "metadata", "filters"]);
4268
4476
  const plainData = this.paramsToPlain({ id: checkId });
4269
4477
  const id = await this.getId(plainData.id);
4270
4478
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: false }));
@@ -4516,7 +4724,7 @@ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGrap
4516
4724
  this.categoryFilterRepository = categoryFilterRepository;
4517
4725
  }
4518
4726
  async update(params) {
4519
- const { options } = params, data = tslib.__rest(params, ["options"]);
4727
+ const { options } = params, data = tslib_1.__rest(params, ["options"]);
4520
4728
  const filter = await super.update(data);
4521
4729
  filter.options = await this.updateOptions(+data.id, { options });
4522
4730
  return filter;
@@ -4652,9 +4860,10 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4652
4860
  howToUse: data.how_to_use,
4653
4861
  brand: data.brand_description,
4654
4862
  ingredients: data.ingredients,
4863
+ purpose: data.purpose,
4655
4864
  }),
4656
4865
  bindFindFilter: (filters) => {
4657
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
4866
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
4658
4867
  who_must_use: filters.whoMustUse,
4659
4868
  })), (filters.howToUse && {
4660
4869
  how_to_use: filters.howToUse,
@@ -4662,11 +4871,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4662
4871
  brand_description: filters.brand,
4663
4872
  })), (filters.ingredients && {
4664
4873
  ingredients: filters.ingredients,
4874
+ })), (filters.purpose && {
4875
+ purpose: filters.purpose,
4665
4876
  }));
4666
4877
  },
4667
- bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
4878
+ bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
4668
4879
  who_must_use: descriptionData.whoMustUse,
4669
- })), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand })), (descriptionData.ingredients && { ingredients: descriptionData.ingredients }))),
4880
+ })), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand })), (descriptionData.ingredients && { ingredients: descriptionData.ingredients })), (descriptionData.purpose && { purpose: descriptionData.purpose }))),
4670
4881
  },
4671
4882
  },
4672
4883
  { differentials: { columnName: 'differentials' } },
@@ -4674,6 +4885,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4674
4885
  { howToUse: { columnName: 'how_to_use' } },
4675
4886
  { brandDescription: { columnName: 'brand_description' } },
4676
4887
  { ingredients: { columnName: 'ingredients' } },
4888
+ { purpose: { columnName: 'purpose' } },
4677
4889
  { hasVariants: { columnName: 'has_variants' } },
4678
4890
  {
4679
4891
  images: {
@@ -4789,7 +5001,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4789
5001
  ];
4790
5002
  }
4791
5003
  async create(params) {
4792
- const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
5004
+ const { metadata } = params, data = tslib_1.__rest(params, ["metadata"]);
4793
5005
  const product = await super.create(lodash.omit(Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }), ['reviews']));
4794
5006
  try {
4795
5007
  product.reviews = data.reviews && (await this.updateReviews(+product.id, data));
@@ -4812,7 +5024,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4812
5024
  }
4813
5025
  async find(params) {
4814
5026
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4815
- const _o = params || {}, { filters, fields } = _o, options = tslib.__rest(_o, ["filters", "fields"]);
5027
+ const _o = params || {}, { filters, fields } = _o, options = tslib_1.__rest(_o, ["filters", "fields"]);
4816
5028
  const bindFields = fields ||
4817
5029
  this.fields
4818
5030
  .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
@@ -4850,7 +5062,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4850
5062
  return product;
4851
5063
  }
4852
5064
  async update(params) {
4853
- const { categories, kitProducts, reviews, id: checkId, rate, metadata } = params, data = tslib.__rest(params, ["categories", "kitProducts", "reviews", "id", "rate", "metadata"]);
5065
+ const { categories, kitProducts, reviews, id: checkId, rate, metadata } = params, data = tslib_1.__rest(params, ["categories", "kitProducts", "reviews", "id", "rate", "metadata"]);
4854
5066
  const plainData = this.paramsToPlain({ id: checkId });
4855
5067
  const id = await this.getId(plainData.id);
4856
5068
  const product = await super.update(Object.assign({ id }, data));
@@ -5057,6 +5269,41 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5057
5269
  }
5058
5270
  }
5059
5271
 
5272
+ class ProductReviewsHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5273
+ constructor({ endpoint, authOptions, interceptors, }) {
5274
+ super({
5275
+ tableName: 'product_review',
5276
+ model: ProductReviews,
5277
+ endpoint,
5278
+ authOptions,
5279
+ interceptors,
5280
+ fields: [
5281
+ 'id',
5282
+ { productId: { columnName: 'product_id' } },
5283
+ 'shop',
5284
+ 'rate',
5285
+ 'author',
5286
+ 'email',
5287
+ 'location',
5288
+ 'review',
5289
+ 'status',
5290
+ 'title',
5291
+ { personId: { columnName: 'person_id' } },
5292
+ 'points',
5293
+ { orderId: { columnName: 'order_id' } },
5294
+ { createdAt: { columnName: 'created_at' } },
5295
+ { updatedAt: { columnName: 'updated_at' } },
5296
+ ],
5297
+ });
5298
+ }
5299
+ aproveReview(id) {
5300
+ return this.update({ id, status: true });
5301
+ }
5302
+ disaproveReview(id) {
5303
+ return this.update({ id, status: false });
5304
+ }
5305
+ }
5306
+
5060
5307
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
5061
5308
  constructor({ endpoint, authOptions, interceptors, }) {
5062
5309
  super({
@@ -5135,11 +5382,11 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
5135
5382
  return variant;
5136
5383
  }
5137
5384
  async find(params) {
5138
- const _a = params || {}, { filters } = _a, options = tslib.__rest(_a, ["filters"]);
5385
+ const _a = params || {}, { filters } = _a, options = tslib_1.__rest(_a, ["filters"]);
5139
5386
  return super.find(Object.assign(Object.assign({}, options), { filters: Object.assign({ productId: { operator: exports.Where.ISNOTNULL } }, filters) }));
5140
5387
  }
5141
5388
  async update(params) {
5142
- const { productId, id: checkId } = params, data = tslib.__rest(params, ["productId", "id"]);
5389
+ const { productId, id: checkId } = params, data = tslib_1.__rest(params, ["productId", "id"]);
5143
5390
  const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
5144
5391
  const id = await this.getId(dataWithProductId.id);
5145
5392
  const product = await super.update(Object.assign({ id }, data));
@@ -5247,7 +5494,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5247
5494
  this.categoryFilterRepository = categoryFilterRepository;
5248
5495
  }
5249
5496
  async create(params) {
5250
- const { metadata } = params, data = tslib.__rest(params, ["metadata"]);
5497
+ const { metadata } = params, data = tslib_1.__rest(params, ["metadata"]);
5251
5498
  return super.create(Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
5252
5499
  }
5253
5500
  async get(identifiers) {
@@ -5257,7 +5504,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5257
5504
  return data;
5258
5505
  }
5259
5506
  async update(params) {
5260
- const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
5507
+ const { products, id: checkId, metadata, filters } = params, data = tslib_1.__rest(params, ["products", "id", "metadata", "filters"]);
5261
5508
  const plainData = this.paramsToPlain({ id: checkId });
5262
5509
  const id = plainData.id;
5263
5510
  const category = await super.update(Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
@@ -5553,6 +5800,8 @@ exports.Product = Product;
5553
5800
  exports.ProductFirestoreRepository = ProductFirestoreRepository;
5554
5801
  exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
5555
5802
  exports.ProductHasuraGraphQLRepository = ProductHasuraGraphQLRepository;
5803
+ exports.ProductReviews = ProductReviews;
5804
+ exports.ProductReviewsHasuraGraphQLRepository = ProductReviewsHasuraGraphQLRepository;
5556
5805
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
5557
5806
  exports.ProductsIndex = ProductsIndex;
5558
5807
  exports.RecoveryPassword = RecoveryPassword;
@@ -5570,11 +5819,15 @@ exports.SignOut = SignOut;
5570
5819
  exports.Subscription = Subscription;
5571
5820
  exports.SubscriptionEditionFirestoreRepository = SubscriptionEditionFirestoreRepository;
5572
5821
  exports.SubscriptionFirestoreRepository = SubscriptionFirestoreRepository;
5822
+ exports.SubscriptionMaterialization = SubscriptionMaterialization;
5823
+ exports.SubscriptionMaterializationFirestoreRepository = SubscriptionMaterializationFirestoreRepository;
5573
5824
  exports.SubscriptionPayment = SubscriptionPayment;
5574
5825
  exports.SubscriptionPaymentFirestoreRepository = SubscriptionPaymentFirestoreRepository;
5575
5826
  exports.SubscriptionPlan = SubscriptionPlan;
5576
5827
  exports.SubscriptionPlanFirestoreRepository = SubscriptionPlanFirestoreRepository;
5577
5828
  exports.SubscriptionProductFirestoreRepository = SubscriptionProductFirestoreRepository;
5829
+ exports.SubscriptionSummary = SubscriptionSummary;
5830
+ exports.SubscriptionSummaryFirestoreRepository = SubscriptionSummaryFirestoreRepository;
5578
5831
  exports.Trace = Trace;
5579
5832
  exports.UnauthorizedError = UnauthorizedError;
5580
5833
  exports.User = User;