@infrab4a/connect-angular 3.7.0-beta.1 → 3.7.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.
@@ -31,7 +31,7 @@
31
31
  var i1__namespace$2 = /*#__PURE__*/_interopNamespace(i1$2);
32
32
  var i1__namespace$3 = /*#__PURE__*/_interopNamespace(i1$3);
33
33
 
34
- /******************************************************************************
34
+ /*! *****************************************************************************
35
35
  Copyright (c) Microsoft Corporation.
36
36
 
37
37
  Permission to use, copy, modify, and/or distribute this software for any
@@ -98,64 +98,6 @@
98
98
  function __param(paramIndex, decorator) {
99
99
  return function (target, key) { decorator(target, key, paramIndex); };
100
100
  }
101
- function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
102
- function accept(f) { if (f !== void 0 && typeof f !== "function")
103
- throw new TypeError("Function expected"); return f; }
104
- var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
105
- var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
106
- var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
107
- var _, done = false;
108
- for (var i = decorators.length - 1; i >= 0; i--) {
109
- var context = {};
110
- for (var p in contextIn)
111
- context[p] = p === "access" ? {} : contextIn[p];
112
- for (var p in contextIn.access)
113
- context.access[p] = contextIn.access[p];
114
- context.addInitializer = function (f) { if (done)
115
- throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
116
- var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
117
- if (kind === "accessor") {
118
- if (result === void 0)
119
- continue;
120
- if (result === null || typeof result !== "object")
121
- throw new TypeError("Object expected");
122
- if (_ = accept(result.get))
123
- descriptor.get = _;
124
- if (_ = accept(result.set))
125
- descriptor.set = _;
126
- if (_ = accept(result.init))
127
- initializers.push(_);
128
- }
129
- else if (_ = accept(result)) {
130
- if (kind === "field")
131
- initializers.push(_);
132
- else
133
- descriptor[key] = _;
134
- }
135
- }
136
- if (target)
137
- Object.defineProperty(target, contextIn.name, descriptor);
138
- done = true;
139
- }
140
- ;
141
- function __runInitializers(thisArg, initializers, value) {
142
- var useValue = arguments.length > 2;
143
- for (var i = 0; i < initializers.length; i++) {
144
- value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
145
- }
146
- return useValue ? value : void 0;
147
- }
148
- ;
149
- function __propKey(x) {
150
- return typeof x === "symbol" ? x : "".concat(x);
151
- }
152
- ;
153
- function __setFunctionName(f, name, prefix) {
154
- if (typeof name === "symbol")
155
- name = name.description ? "[".concat(name.description, "]") : "";
156
- return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
157
- }
158
- ;
159
101
  function __metadata(metadataKey, metadataValue) {
160
102
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
161
103
  return Reflect.metadata(metadataKey, metadataValue);
@@ -187,7 +129,7 @@
187
129
  function step(op) {
188
130
  if (f)
189
131
  throw new TypeError("Generator is already executing.");
190
- while (g && (g = 0, op[0] && (_ = 0)), _)
132
+ while (_)
191
133
  try {
192
134
  if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
193
135
  return t;
@@ -251,11 +193,7 @@
251
193
  var __createBinding = Object.create ? (function (o, m, k, k2) {
252
194
  if (k2 === undefined)
253
195
  k2 = k;
254
- var desc = Object.getOwnPropertyDescriptor(m, k);
255
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
256
- desc = { enumerable: true, get: function () { return m[k]; } };
257
- }
258
- Object.defineProperty(o, k2, desc);
196
+ Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
259
197
  }) : (function (o, m, k, k2) {
260
198
  if (k2 === undefined)
261
199
  k2 = k;
@@ -355,7 +293,7 @@
355
293
  function __asyncDelegator(o) {
356
294
  var i, p;
357
295
  return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
358
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
296
+ function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
359
297
  }
360
298
  function __asyncValues(o) {
361
299
  if (!Symbol.asyncIterator)
@@ -409,11 +347,6 @@
409
347
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
410
348
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
411
349
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
412
- }
413
- function __classPrivateFieldIn(state, receiver) {
414
- if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
415
- throw new TypeError("Cannot use 'in' operator on non-object");
416
- return typeof state === "function" ? receiver === state : state.has(receiver);
417
350
  }
418
351
 
419
352
  var AuthService = /** @class */ (function () {
@@ -583,13 +516,11 @@
583
516
  // Verifica o limite de uso geral por usuario
584
517
  if (coupon.useLimit && orders.data.length >= coupon.useLimit)
585
518
  throw new InvalidCouponError('Limite de uso atingido.');
586
- return [4 /*yield*/, this.userValidationAndSubscriptionStatus(coupon, userEmail)];
587
- case 2:
588
- validUser = _d.sent();
519
+ validUser = this.userValidationAndSubscriptionStatus(coupon, checkout.user);
589
520
  if (!validUser)
590
521
  throw new InvalidCouponError('Usuário não elegível.');
591
522
  return [4 /*yield*/, this.hasProductCategories(coupon, checkout)];
592
- case 3:
523
+ case 2:
593
524
  hasProductCategories = _d.sent();
594
525
  if (!hasProductCategories)
595
526
  throw 'Seu carrinho não possui produtos elegíveis para desconto.';
@@ -652,7 +583,7 @@
652
583
  lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter(function (i) {
653
584
  var _a;
654
585
  if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
655
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); }); });
586
+ return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
656
587
  }
657
588
  return true;
658
589
  });
@@ -704,56 +635,31 @@
704
635
  var _a;
705
636
  if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
706
637
  return true;
707
- return i.categories.some(function (c) { return couponCategories.some(function (cat) { return (cat.id == c || cat.firestoreId == c); }); });
638
+ return i.categories.some(function (c) { return couponCategories.some(function (cat) { return cat.id == c || cat.firestoreId == c; }); });
708
639
  });
709
640
  return [2 /*return*/, hasCategories.length ? true : false];
710
641
  }
711
642
  });
712
643
  });
713
644
  };
714
- CouponService.prototype.userValidationAndSubscriptionStatus = function (coupon, userEmail) {
715
- return __awaiter(this, void 0, void 0, function () {
716
- var couponRuleSubscription, sub, activeSubs;
717
- return __generator(this, function (_d) {
718
- switch (_d.label) {
719
- case 0:
720
- // Verifica se o email do usuário é coorporativo
721
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i1$1.Exclusivities.COLLABORATORS)
722
- throw new InvalidCouponError('Você não é colaborador.');
723
- // Verifica se o email do usuário é associado ao cupom de uso por usuario
724
- if (coupon.exclusivityType === i1$1.Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
725
- throw new InvalidCouponError('Cupom não é válido para este usuário.');
726
- couponRuleSubscription = coupon.exclusivityType === i1$1.Exclusivities.ACTIVE_SUBSCRIBER ||
727
- coupon.exclusivityType === i1$1.Exclusivities.INACTIVE_SUBSCRIBER ||
728
- coupon.exclusivityType === i1$1.Exclusivities.NON_SUBSCRIBER;
729
- if (!(couponRuleSubscription && userEmail)) return [3 /*break*/, 2];
730
- return [4 /*yield*/, this.subscriptionRepository
731
- .find({
732
- filters: {
733
- user: {
734
- email: { operator: i1$1.Where.EQUALS, value: userEmail },
735
- },
736
- },
737
- })
738
- .then(function (sub) { return sub.data; })];
739
- case 1:
740
- sub = _d.sent();
741
- activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter(function (s) { return s.status === i1$1.Status.ACTIVE; });
742
- switch (coupon.exclusivityType) {
743
- case i1$1.Exclusivities.ACTIVE_SUBSCRIBER:
744
- return [2 /*return*/, activeSubs.length > 0];
745
- case i1$1.Exclusivities.INACTIVE_SUBSCRIBER:
746
- return [2 /*return*/, activeSubs.length === 0];
747
- case i1$1.Exclusivities.NON_SUBSCRIBER:
748
- return [2 /*return*/, sub.length === 0];
749
- default:
750
- return [2 /*return*/, false];
751
- }
752
- _d.label = 2;
753
- case 2: return [2 /*return*/, true];
754
- }
755
- });
756
- });
645
+ CouponService.prototype.userValidationAndSubscriptionStatus = function (coupon, user) {
646
+ if (coupon.exclusivityType === i1$1.Exclusivities.ALL_USERS)
647
+ return true;
648
+ // Verifica se o email do usuário é coorporativo
649
+ if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === i1$1.Exclusivities.COLLABORATORS)
650
+ throw new InvalidCouponError('Você não é colaborador.');
651
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
652
+ if (coupon.exclusivityType === i1$1.Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
653
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
654
+ switch (coupon.exclusivityType) {
655
+ case i1$1.Exclusivities.ACTIVE_SUBSCRIBER:
656
+ return user.isSubscriber ? true : false;
657
+ case i1$1.Exclusivities.INACTIVE_SUBSCRIBER:
658
+ return user.isSubscriber ? false : true;
659
+ case i1$1.Exclusivities.NON_SUBSCRIBER:
660
+ return user.isSubscriber ? false : true;
661
+ }
662
+ return true;
757
663
  };
758
664
  CouponService.prototype.getCouponCategoriesId = function (coupon) {
759
665
  return __awaiter(this, void 0, void 0, function () {
@@ -766,7 +672,9 @@
766
672
  _d.label = 1;
767
673
  case 1:
768
674
  if (!(index < coupon.productsCategories.length)) return [3 /*break*/, 4];
769
- return [4 /*yield*/, this.categoryRepository.get({ id: coupon.productsCategories[index] })];
675
+ return [4 /*yield*/, this.categoryRepository.get({
676
+ id: coupon.productsCategories[index],
677
+ })];
770
678
  case 2:
771
679
  c = _d.sent();
772
680
  couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
@@ -1590,6 +1498,20 @@
1590
1498
  },
1591
1499
  deps: [i1$2.AngularFirestore],
1592
1500
  },
1501
+ {
1502
+ provide: 'CampaignHashtagRepository',
1503
+ useFactory: function (firestore) {
1504
+ return new i1$1.CampaignHashtagFirestoreRepository(firestore.firestore);
1505
+ },
1506
+ deps: [i1$2.AngularFirestore],
1507
+ },
1508
+ {
1509
+ provide: 'CampaignDashboardRepository',
1510
+ useFactory: function (firestore) {
1511
+ return new i1$1.CampaignDashboardFirestoreRepository(firestore.firestore);
1512
+ },
1513
+ deps: [i1$2.AngularFirestore],
1514
+ },
1593
1515
  {
1594
1516
  provide: 'EditionRepository',
1595
1517
  useFactory: function (firestore, subscriptionRepository) {
@@ -1763,6 +1685,20 @@
1763
1685
  },
1764
1686
  deps: [i1$2.AngularFirestore],
1765
1687
  },
1688
+ {
1689
+ provide: 'CampaignHashtagRepository',
1690
+ useFactory: function (firestore) {
1691
+ return new i1$1.CampaignHashtagFirestoreRepository(firestore.firestore);
1692
+ },
1693
+ deps: [i1$2.AngularFirestore],
1694
+ },
1695
+ {
1696
+ provide: 'CampaignDashboardRepository',
1697
+ useFactory: function (firestore) {
1698
+ return new i1$1.CampaignDashboardFirestoreRepository(firestore.firestore);
1699
+ },
1700
+ deps: [i1$2.AngularFirestore],
1701
+ },
1766
1702
  {
1767
1703
  provide: 'EditionRepository',
1768
1704
  useFactory: function (firestore, subscriptionRepository) {