@infrab4a/connect 0.16.10 → 0.17.0-beta.1

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 (86) hide show
  1. package/bundles/infrab4a-connect.umd.js +145 -225
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/users/models/subscription/edition.d.ts +0 -2
  4. package/domain/users/models/user-payment-method.d.ts +0 -1
  5. package/domain/users/models/user.d.ts +0 -3
  6. package/esm2015/domain/users/models/subscription/edition.js +1 -1
  7. package/esm2015/domain/users/models/user-payment-method.js +1 -1
  8. package/esm2015/domain/users/models/user.js +1 -1
  9. package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +6 -6
  10. package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +4 -3
  11. package/esm2015/infra/firebase/auth/types/firebase-user-with-id.type.js +1 -1
  12. package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +7 -5
  13. package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +3 -4
  14. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +31 -25
  15. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +4 -4
  16. package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +4 -5
  17. package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
  18. package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +1 -1
  19. package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +9 -10
  20. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +19 -39
  21. package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +2 -2
  22. package/esm2015/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +1 -1
  23. package/esm2015/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +1 -1
  24. package/esm2015/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +4 -4
  25. package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +1 -1
  26. package/esm2015/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +1 -1
  27. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +1 -1
  28. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +1 -1
  29. package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +1 -1
  30. package/esm2015/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +1 -1
  31. package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +1 -1
  32. package/esm2015/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +1 -1
  33. package/esm2015/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +1 -1
  34. package/esm2015/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +1 -1
  35. package/esm2015/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +1 -1
  36. package/esm2015/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +1 -1
  37. package/esm2015/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +1 -1
  38. package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +1 -1
  39. package/esm2015/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +1 -1
  40. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +4 -12
  41. package/esm2015/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +1 -1
  42. package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +1 -1
  43. package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +1 -1
  44. package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
  45. package/esm2015/utils/index.js +3 -2
  46. package/fesm2015/infrab4a-connect.js +77 -105
  47. package/fesm2015/infrab4a-connect.js.map +1 -1
  48. package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +2 -2
  49. package/infra/firebase/auth/register-firebase-auth.service.d.ts +2 -2
  50. package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +2 -1
  51. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +4 -4
  52. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +8 -8
  53. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +3 -3
  54. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +7 -7
  55. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +2 -2
  56. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +3 -3
  57. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  58. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +2 -2
  59. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
  60. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +18 -16
  61. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +16 -16
  62. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +18 -18
  63. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +16 -16
  64. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +14 -14
  65. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +16 -16
  66. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +16 -16
  67. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +16 -16
  68. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +16 -16
  69. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +14 -14
  70. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +3 -3
  71. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +16 -16
  72. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +16 -16
  73. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +16 -16
  74. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +16 -16
  75. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +18 -18
  76. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +16 -16
  77. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +18 -18
  78. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +18 -18
  79. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +18 -18
  80. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +14 -14
  81. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +18 -18
  82. package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +16 -16
  83. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +1 -1
  84. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +2 -2
  85. package/package.json +2 -2
  86. package/utils/index.d.ts +1 -1
@@ -1,14 +1,13 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-md5'), require('axios'), require('firebase'), require('firebase/app')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-md5', 'axios', 'firebase', 'firebase/app'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global.tsMd5, global.axios, global.firebase, global.firebase$1));
5
- })(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsMd5, axios, firebase, firebase$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-md5'), require('axios'), require('firebase/firestore'), require('firebase/auth')) :
3
+ typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-md5', 'axios', 'firebase/firestore', 'firebase/auth'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global.tsMd5, global.axios, global.firestore, global.auth));
5
+ })(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsMd5, axios, firestore, auth) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
+ var lodash__default = /*#__PURE__*/_interopDefaultLegacy(lodash);
9
10
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
- var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
11
- var firebase__default$1 = /*#__PURE__*/_interopDefaultLegacy(firebase$1);
12
11
 
13
12
  var BaseModel = /** @class */ (function () {
14
13
  function BaseModel(args) {
@@ -798,6 +797,8 @@
798
797
  return Base;
799
798
  }());
800
799
 
800
+ var chunk = lodash__default["default"].chunk, get = lodash__default["default"].get, isDate = lodash__default["default"].isDate, isEmpty = lodash__default["default"].isEmpty, isNil = lodash__default["default"].isNil, isNumber = lodash__default["default"].isNumber, isObject = lodash__default["default"].isObject, isString = lodash__default["default"].isString, pick = lodash__default["default"].pick, set = lodash__default["default"].set;
801
+
801
802
  var Coupon = /** @class */ (function (_super) {
802
803
  __extends(Coupon, _super);
803
804
  function Coupon() {
@@ -805,7 +806,7 @@
805
806
  }
806
807
  Object.defineProperty(Coupon.prototype, "isInfluencer", {
807
808
  get: function () {
808
- return !lodash.isNil(this.influencerEmail);
809
+ return !isNil(this.influencerEmail);
809
810
  },
810
811
  enumerable: false,
811
812
  configurable: true
@@ -858,8 +859,8 @@
858
859
  }
859
860
  User.toInstance = function (data) {
860
861
  var instance = _super.toInstance.call(this, data);
861
- if (!lodash.isNil(data.firstName))
862
- instance.displayName = "" + data.firstName + (!lodash.isNil(data.lastName) ? " " + data.lastName : '');
862
+ if (!isNil(data.firstName))
863
+ instance.displayName = "" + data.firstName + (!isNil(data.lastName) ? " " + data.lastName : '');
863
864
  return instance;
864
865
  };
865
866
  User.prototype.identifierFields = function () {
@@ -981,7 +982,7 @@
981
982
  case 1:
982
983
  userAuth = _b.sent();
983
984
  user = this.userRepository.get(userAuth);
984
- if (!lodash.isNil(user))
985
+ if (!isNil(user))
985
986
  return [2 /*return*/, user];
986
987
  if (/^.+@b4a.com.br$/.test(userAuth.email))
987
988
  return [2 /*return*/, this.createsUserByCredential(userAuth)];
@@ -1588,7 +1589,7 @@
1588
1589
  return _super.call(this, args) || this;
1589
1590
  }
1590
1591
  class_1.prototype.collection = function (path) {
1591
- return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
1592
+ return firestore.collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
1592
1593
  };
1593
1594
  class_1.prototype.buildModelInstance = function () {
1594
1595
  var _this = this;
@@ -1597,7 +1598,7 @@
1597
1598
  fromFirestore: function (snap) {
1598
1599
  var data = snap.data();
1599
1600
  Object.keys(data).forEach(function (key) {
1600
- if (data[key] instanceof firebase__default["default"].firestore.Timestamp) {
1601
+ if (data[key] instanceof firestore.Timestamp) {
1601
1602
  data[key] = data[key].toDate();
1602
1603
  }
1603
1604
  });
@@ -1624,7 +1625,7 @@
1624
1625
  }
1625
1626
  };
1626
1627
  class_1.prototype.isSubCollection = function (repository) {
1627
- return !lodash.isNil(Object.keys(this).find(function (key) { return key === 'parentRepository'; }));
1628
+ return !isNil(Object.keys(this).find(function (key) { return key === 'parentRepository'; }));
1628
1629
  };
1629
1630
  return class_1;
1630
1631
  }(MixinBase));
@@ -1638,16 +1639,18 @@
1638
1639
  }
1639
1640
  GetFirestore.prototype.get = function (identifiers) {
1640
1641
  return __awaiter(this, void 0, void 0, function () {
1641
- var doc, data;
1642
- return __generator(this, function (_a) {
1643
- switch (_a.label) {
1644
- case 0: return [4 /*yield*/, this.collection(this.buildCollectionPathForGet(identifiers))
1645
- .doc(Object.values(identifiers).shift().toString())
1646
- .get()];
1647
- case 1:
1648
- doc = _a.sent();
1649
- data = doc.data();
1650
- if (lodash.isNil(data))
1642
+ var docRef, _a, _b, data;
1643
+ return __generator(this, function (_c) {
1644
+ switch (_c.label) {
1645
+ case 0:
1646
+ _a = firestore.getDoc;
1647
+ _b = firestore.doc;
1648
+ return [4 /*yield*/, this.collection(this.buildCollectionPathForGet(identifiers))];
1649
+ case 1: return [4 /*yield*/, _a.apply(void 0, [_b.apply(void 0, [_c.sent(), Object.values(identifiers).shift().toString()])])];
1650
+ case 2:
1651
+ docRef = _c.sent();
1652
+ data = docRef.data();
1653
+ if (isNil(data))
1651
1654
  throw new NotFoundError("Document " + JSON.stringify(identifiers) + " not found");
1652
1655
  return [2 /*return*/, data];
1653
1656
  }
@@ -1664,64 +1667,64 @@
1664
1667
  };
1665
1668
 
1666
1669
  var withFindFirestore = function (MixinBase) {
1667
- var checkIfIsFilterOption = function (filter) { return !lodash.isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
1670
+ var checkIfIsFilterOption = function (filter) { return !isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
1668
1671
  var getValueFromFilter = function (filter) {
1669
1672
  return checkIfIsFilterOption(filter) ? filter.value : filter;
1670
1673
  };
1671
- var getFinalValueFrom = function (value) { return lodash.isNumber(value) || lodash.isString(value) || lodash.isDate(value) || Array.isArray(value)
1674
+ var getFinalValueFrom = function (value) { return isNumber(value) || isString(value) || isDate(value) || Array.isArray(value)
1672
1675
  ? value
1673
1676
  : Object.values(getFinalValueFrom); };
1674
1677
  return /** @class */ (function (_super) {
1675
1678
  __extends(FindFirestore, _super);
1676
1679
  function FindFirestore() {
1677
1680
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1678
- _this.makeFirestoreWhere = function (queryReference, filter) { return Object.keys(filter).reduce(function (query, fieldName) { return _this.buildWhereSentence(query, fieldName, filter[fieldName]); }, queryReference); };
1679
- _this.buildWhereSentence = function (queryReference, fieldName, options) {
1681
+ _this.makeFirestoreWhere = function (filter) { return Object.keys(filter).reduce(function (queries, fieldName) { return __spreadArray(__spreadArray([], __read(queries)), __read(_this.buildWhereSentence(fieldName, filter[fieldName]))); }, []); };
1682
+ _this.buildWhereSentence = function (fieldName, options) {
1680
1683
  if (_this.isSubCollection(_this) && fieldName === _this.parentIdField)
1681
- return queryReference;
1684
+ [];
1682
1685
  var value = (options === null || options === void 0 ? void 0 : options.value) || options;
1683
1686
  var object = {};
1684
- lodash.set(object, fieldName, value);
1687
+ set(object, fieldName, value);
1685
1688
  var plainInstance = new _this.model(object).toPlain();
1686
1689
  var firestoreFieldName = fieldName.toString().indexOf('.') > -1
1687
1690
  ? fieldName.toString()
1688
1691
  : Object.keys(plainInstance).find(function (key) { return plainInstance[key]; });
1689
1692
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.LIKE) {
1690
1693
  if (Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1691
- return queryReference.where(firestoreFieldName, 'array-contains-any', options.value);
1692
- queryReference = queryReference.where(firestoreFieldName, '>=', options.value);
1693
- queryReference = queryReference.where(firestoreFieldName, '<=', options.value + "~");
1694
- return queryReference;
1694
+ return [firestore.where(firestoreFieldName, 'array-contains-any', options.value)];
1695
+ return [firestore.where(firestoreFieldName, '>=', options.value), firestore.where(firestoreFieldName, '<=', options.value + "~")];
1695
1696
  }
1696
1697
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1697
- return queryReference.where(firestoreFieldName, 'array-contains', options.value);
1698
- if (lodash.isObject(options) && lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) && lodash.isNil(options === null || options === void 0 ? void 0 : options.value)) {
1699
- return Object.keys(options).reduce(function (queryReferenceWithWhere, key) { return _this.buildWhereSentence(queryReferenceWithWhere, fieldName + "." + key, options[key]); }, queryReference);
1698
+ return [firestore.where(firestoreFieldName, 'array-contains', options.value)];
1699
+ if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
1700
+ return Object.keys(options).reduce(function (queries, key) { return __spreadArray(__spreadArray([], __read(queries)), __read(_this.buildWhereSentence(fieldName.toString() + "." + key, options[key]))); }, []);
1700
1701
  }
1701
- return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1702
+ return [firestore.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options)];
1702
1703
  };
1703
1704
  return _this;
1704
1705
  }
1705
- FindFirestore.prototype.find = function (filters, limits, orderBy) {
1706
+ FindFirestore.prototype.find = function (filters, limitList, orderByList) {
1706
1707
  return __awaiter(this, void 0, void 0, function () {
1707
- var query, docs, data;
1708
+ var collection, queries, ordination, limits, queryArgumments, docs, data;
1708
1709
  var _this = this;
1709
1710
  return __generator(this, function (_b) {
1710
1711
  switch (_b.label) {
1711
1712
  case 0:
1712
- query = this.collection(this.buildCollectionPathForFind(filters));
1713
- filters === null || filters === void 0 ? void 0 : filters.forEach(function (filterer) { return (query = _this.makeFirestoreWhere(query, filterer)); });
1714
- orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach(function (orderer) { return Object.keys(orderer).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderer[fieldName])); }); });
1715
- return [4 /*yield*/, this.defineLimits(query, filters, limits)];
1713
+ collection = this.collection(this.buildCollectionPathForFind(filters));
1714
+ queries = (filters === null || filters === void 0 ? void 0 : filters.reduce(function (queriesBuilded, filterer) { return __spreadArray(__spreadArray([], __read(queriesBuilded)), __read(_this.makeFirestoreWhere(filterer))); }, [])) ||
1715
+ [];
1716
+ ordination = (orderByList === null || orderByList === void 0 ? void 0 : orderByList.reduce(function (ordinationBuilded, sort) { return __spreadArray(__spreadArray([], __read(ordinationBuilded)), __read(Object.keys(sort).map(function (fieldName) { return firestore.orderBy(fieldName, sort[fieldName]); }))); }, [])) || [];
1717
+ return [4 /*yield*/, this.defineLimits(filters, limitList)];
1716
1718
  case 1:
1717
- query = _b.sent();
1718
- return [4 /*yield*/, query.get()];
1719
+ limits = _b.sent();
1720
+ queryArgumments = __spreadArray(__spreadArray(__spreadArray([], __read(queries)), __read(ordination)), __read(limits));
1721
+ return [4 /*yield*/, firestore.getDocs(firestore.query.apply(void 0, __spreadArray([collection], __read(queryArgumments))))];
1719
1722
  case 2:
1720
1723
  docs = _b.sent();
1721
1724
  data = docs.docs.map(function (doc) { return doc.data(); });
1722
1725
  return [2 /*return*/, {
1723
1726
  data: data,
1724
- count: this.calculateCount(data, limits),
1727
+ count: this.calculateCount(data, limitList),
1725
1728
  }];
1726
1729
  }
1727
1730
  });
@@ -1735,29 +1738,29 @@
1735
1738
  var parentId = getValueFromFilter((_a = filters.find(function (groupFilter) { return Boolean(getValueFromFilter(groupFilter[parentIdField])); })) === null || _a === void 0 ? void 0 : _a[parentIdField]);
1736
1739
  return this.parentRepository.collectionName + "/" + parentId + "/" + this.collectionName;
1737
1740
  };
1738
- FindFirestore.prototype.defineLimits = function (query, filters, limits) {
1741
+ FindFirestore.prototype.defineLimits = function (filters, limits) {
1739
1742
  return __awaiter(this, void 0, void 0, function () {
1740
- var _b, _c;
1741
- return __generator(this, function (_d) {
1742
- switch (_d.label) {
1743
+ var queries, _b, _c, _d;
1744
+ return __generator(this, function (_e) {
1745
+ switch (_e.label) {
1743
1746
  case 0:
1747
+ queries = [];
1744
1748
  if (!(limits === null || limits === void 0 ? void 0 : limits.offset)) return [3 /*break*/, 3];
1745
1749
  if (!(limits.offset instanceof this.model)) return [3 /*break*/, 2];
1746
- _c = (_b = query).startAfter;
1747
- return [4 /*yield*/, this.collection(this.buildCollectionPathForFind(filters))
1748
- .doc(limits.offset[limits.offset.identifierFields().shift()])
1749
- .get()];
1750
+ _c = (_b = queries).push;
1751
+ _d = firestore.startAfter;
1752
+ return [4 /*yield*/, firestore.getDoc(firestore.doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset[limits.offset.identifierFields().shift()]))];
1750
1753
  case 1:
1751
- query = _c.apply(_b, [_d.sent()]);
1754
+ _c.apply(_b, [_d.apply(void 0, [_e.sent()])]);
1752
1755
  return [3 /*break*/, 3];
1753
1756
  case 2:
1754
- if (lodash.isNumber(limits.offset) || lodash.isString(limits.offset))
1755
- query = query.startAt(limits.offset);
1756
- _d.label = 3;
1757
+ if (isNumber(limits.offset) || isString(limits.offset))
1758
+ queries.push(firestore.startAt(limits.offset));
1759
+ _e.label = 3;
1757
1760
  case 3:
1758
1761
  if (limits === null || limits === void 0 ? void 0 : limits.limit)
1759
- query = query.limit(limits.limit);
1760
- return [2 /*return*/, query];
1762
+ queries.push(firestore.limit(limits.limit));
1763
+ return [2 /*return*/, queries];
1761
1764
  }
1762
1765
  });
1763
1766
  });
@@ -1787,7 +1790,7 @@
1787
1790
  case 0: return [4 /*yield*/, this.save(this.model.toInstance(data))];
1788
1791
  case 1:
1789
1792
  docRef = _b.sent();
1790
- return [4 /*yield*/, docRef.get()];
1793
+ return [4 /*yield*/, firestore.getDoc(docRef)];
1791
1794
  case 2:
1792
1795
  doc = _b.sent();
1793
1796
  return [2 /*return*/, doc.data()];
@@ -1798,16 +1801,17 @@
1798
1801
  CreateFirestore.prototype.save = function (data) {
1799
1802
  var _a;
1800
1803
  return __awaiter(this, void 0, void 0, function () {
1801
- var id, collectionPath, docRef;
1804
+ var id, collectionPath, collection, docRef;
1802
1805
  return __generator(this, function (_b) {
1803
1806
  switch (_b.label) {
1804
1807
  case 0:
1805
1808
  id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
1806
1809
  collectionPath = this.buildCollectionPathForAdd(data);
1807
- if (lodash.isEmpty(id))
1808
- return [2 /*return*/, this.collection(collectionPath).add(data)];
1809
- docRef = this.collection(collectionPath).doc(id);
1810
- return [4 /*yield*/, docRef.set(data)];
1810
+ collection = this.collection(collectionPath);
1811
+ if (isEmpty(id))
1812
+ return [2 /*return*/, firestore.addDoc(collection, data)];
1813
+ docRef = firestore.doc(collection, id);
1814
+ return [4 /*yield*/, firestore.setDoc(docRef, data)];
1811
1815
  case 1:
1812
1816
  _b.sent();
1813
1817
  return [2 /*return*/, docRef];
@@ -1825,18 +1829,17 @@
1825
1829
  };
1826
1830
 
1827
1831
  var withUpdateFirestore = function (MixinBase) {
1828
- var getValueFromParams = function (params, field) { var _a; return (lodash.isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
1832
+ var getValueFromParams = function (params, field) { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
1829
1833
  var getValueByAction = function (options) {
1830
- var fieldValues = firebase__default["default"].firestore.FieldValue;
1831
- if (lodash.isNil(options.action))
1834
+ if (isNil(options.action))
1832
1835
  return options;
1833
1836
  if (options.action === exports.UpdateOptionActions.REMOVE_FIELD)
1834
- return fieldValues.delete();
1837
+ return firestore.deleteField();
1835
1838
  if (Array.isArray(options.value)) {
1836
1839
  if (options.action === exports.UpdateOptionActions.MERGE)
1837
- return fieldValues.arrayUnion.apply(fieldValues, __spreadArray([], __read(options.value)));
1840
+ return firestore.arrayUnion.apply(void 0, __spreadArray([], __read(options.value)));
1838
1841
  if (options.action === exports.UpdateOptionActions.REMOVE)
1839
- return fieldValues.arrayRemove.apply(fieldValues, __spreadArray([], __read(options.value)));
1842
+ return firestore.arrayRemove.apply(void 0, __spreadArray([], __read(options.value)));
1840
1843
  }
1841
1844
  return options.value;
1842
1845
  };
@@ -1847,20 +1850,20 @@
1847
1850
  }
1848
1851
  UpdateFirestore.prototype.update = function (data) {
1849
1852
  return __awaiter(this, void 0, void 0, function () {
1850
- var model, keyField, docRef, doc;
1853
+ var model, keyField, docRef, docData;
1851
1854
  return __generator(this, function (_b) {
1852
1855
  switch (_b.label) {
1853
1856
  case 0:
1854
1857
  model = new this.model();
1855
1858
  keyField = model.identifierFields().shift();
1856
- docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
1857
- return [4 /*yield*/, docRef.set(this.paramsToPlain(data), { merge: true })];
1859
+ docRef = firestore.doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
1860
+ return [4 /*yield*/, firestore.setDoc(docRef, this.paramsToPlain(data), { merge: true })];
1858
1861
  case 1:
1859
1862
  _b.sent();
1860
- return [4 /*yield*/, docRef.get()];
1863
+ return [4 /*yield*/, firestore.getDoc(docRef)];
1861
1864
  case 2:
1862
- doc = _b.sent();
1863
- return [2 /*return*/, doc.data()];
1865
+ docData = _b.sent();
1866
+ return [2 /*return*/, docData.data()];
1864
1867
  }
1865
1868
  });
1866
1869
  });
@@ -1893,9 +1896,7 @@
1893
1896
  return __awaiter(this, void 0, void 0, function () {
1894
1897
  return __generator(this, function (_a) {
1895
1898
  switch (_a.label) {
1896
- case 0: return [4 /*yield*/, this.collection(this.buildCollectionPathForRemove(identifiers))
1897
- .doc(Object.values(identifiers).shift().toString())
1898
- .delete()];
1899
+ case 0: return [4 /*yield*/, firestore.deleteDoc(firestore.doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()))];
1899
1900
  case 1:
1900
1901
  _a.sent();
1901
1902
  return [2 /*return*/];
@@ -2039,12 +2040,7 @@
2039
2040
  var beautyProfile;
2040
2041
  return __generator(this, function (_a) {
2041
2042
  switch (_a.label) {
2042
- case 0: return [4 /*yield*/, this.collection()
2043
- .doc(userId)
2044
- .collection('CX')
2045
- .withConverter(this.buildBeautyProfileModelInstance())
2046
- .doc('beautyProfile')
2047
- .get()];
2043
+ case 0: return [4 /*yield*/, firestore.getDoc(firestore.doc(this.collection(this.collectionName + "/" + userId + "/CX").withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'))];
2048
2044
  case 1:
2049
2045
  beautyProfile = _a.sent();
2050
2046
  return [2 /*return*/, beautyProfile.data()];
@@ -2057,11 +2053,7 @@
2057
2053
  var docs;
2058
2054
  return __generator(this, function (_a) {
2059
2055
  switch (_a.label) {
2060
- case 0: return [4 /*yield*/, this.firestore
2061
- .collection('subscription')
2062
- .where('user.id', '==', userId)
2063
- .where('status', '==', 'active')
2064
- .get()];
2056
+ case 0: return [4 /*yield*/, firestore.getDocs(firestore.query(this.collection('subscription'), firestore.where('user.id', '==', userId), firestore.where('status', '==', 'active')))];
2065
2057
  case 1:
2066
2058
  docs = _a.sent();
2067
2059
  return [2 /*return*/, !!docs && !!docs.size];
@@ -2162,27 +2154,30 @@
2162
2154
 
2163
2155
  var CategoryFirestoreRepository = /** @class */ (function (_super) {
2164
2156
  __extends(CategoryFirestoreRepository, _super);
2165
- function CategoryFirestoreRepository(firestore) {
2157
+ function CategoryFirestoreRepository(firestore, productsIndex) {
2166
2158
  var _this = _super.call(this) || this;
2167
2159
  _this.firestore = firestore;
2160
+ _this.productsIndex = productsIndex;
2168
2161
  _this.collectionName = 'categories';
2169
2162
  _this.model = Category;
2170
2163
  return _this;
2171
2164
  }
2172
2165
  CategoryFirestoreRepository.prototype.getCategoryBySlug = function (slug, shop) {
2173
- return this.collection(this.collectionName)
2174
- .where('slug', '==', slug)
2175
- .where('shop', '==', shop)
2176
- .where('published', '==', true)
2177
- .get()
2178
- .then(function (snap) {
2179
- if (snap.size > 1)
2180
- throw new DuplicatedResultsError('Query returned duplicated values');
2181
- if (snap.empty)
2182
- throw new NotFoundError("Document with slug " + slug + " not found");
2183
- return snap.docs[0].data();
2184
- })
2185
- .catch(function (error) { return error; });
2166
+ return __awaiter(this, void 0, void 0, function () {
2167
+ var categoryDocs;
2168
+ return __generator(this, function (_a) {
2169
+ switch (_a.label) {
2170
+ case 0: return [4 /*yield*/, firestore.getDocs(firestore.query(this.collection(this.collectionName), firestore.where('slug', '==', slug), firestore.where('shop', '==', shop), firestore.where('published', '==', true)))];
2171
+ case 1:
2172
+ categoryDocs = _a.sent();
2173
+ if (categoryDocs.size > 1)
2174
+ throw new DuplicatedResultsError('Query returned duplicated values');
2175
+ if (categoryDocs.empty)
2176
+ throw new NotFoundError("Document with slug " + slug + " not found");
2177
+ return [2 /*return*/, categoryDocs.docs[0].data()];
2178
+ }
2179
+ });
2180
+ });
2186
2181
  };
2187
2182
  CategoryFirestoreRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
2188
2183
  if (limit === void 0) { limit = 4; }
@@ -2191,10 +2186,7 @@
2191
2186
  var _this = this;
2192
2187
  return __generator(this, function (_a) {
2193
2188
  switch (_a.label) {
2194
- case 0: return [4 /*yield*/, this.collection(this.collectionName)
2195
- .where('id', 'in', categoryIds.filter(Boolean))
2196
- .where('published', '==', true)
2197
- .get()];
2189
+ case 0: return [4 /*yield*/, firestore.getDocs(firestore.query(this.collection(this.collectionName), firestore.where('id', 'in', categoryIds.filter(Boolean)), firestore.where('published', '==', true)))];
2198
2190
  case 1:
2199
2191
  categorySnap = _a.sent();
2200
2192
  if (categorySnap.empty)
@@ -2223,58 +2215,14 @@
2223
2215
  };
2224
2216
  CategoryFirestoreRepository.prototype.mountCategory = function (category, options) {
2225
2217
  return __awaiter(this, void 0, void 0, function () {
2226
- var chunks, products, publishedField, chunks_1, chunks_1_1, productIds, query, productSnap, e_1_1;
2227
- var e_1, _a;
2228
- return __generator(this, function (_b) {
2229
- switch (_b.label) {
2230
- case 0:
2231
- if (!category.products)
2232
- throw new RequiredArgumentError(['Category products is empty']);
2233
- chunks = lodash.chunk(category.products, 10);
2234
- products = [];
2235
- publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
2236
- _b.label = 1;
2237
- case 1:
2238
- _b.trys.push([1, 7, 8, 9]);
2239
- chunks_1 = __values(chunks), chunks_1_1 = chunks_1.next();
2240
- _b.label = 2;
2241
- case 2:
2242
- if (!!chunks_1_1.done) return [3 /*break*/, 6];
2243
- productIds = chunks_1_1.value;
2244
- if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
2245
- return [3 /*break*/, 6];
2246
- return [4 /*yield*/, this.collection('productsErpVitrine')
2247
- .where(publishedField, '==', true)
2248
- .where('id', 'in', productIds)];
2249
- case 3:
2250
- query = _b.sent();
2251
- if (options === null || options === void 0 ? void 0 : options.hasStock)
2252
- query = query.where('stock.quantity', '>', 0);
2253
- if (options === null || options === void 0 ? void 0 : options.limit)
2254
- query = query.limit(options === null || options === void 0 ? void 0 : options.limit);
2255
- return [4 /*yield*/, query.get()];
2256
- case 4:
2257
- productSnap = _b.sent();
2258
- if (productSnap.empty)
2259
- return [3 /*break*/, 5];
2260
- products.push.apply(products, __spreadArray([], __read(productSnap.docs.map(function (doc) { return doc.data(); }))));
2261
- _b.label = 5;
2262
- case 5:
2263
- chunks_1_1 = chunks_1.next();
2264
- return [3 /*break*/, 2];
2265
- case 6: return [3 /*break*/, 9];
2266
- case 7:
2267
- e_1_1 = _b.sent();
2268
- e_1 = { error: e_1_1 };
2269
- return [3 /*break*/, 9];
2270
- case 8:
2271
- try {
2272
- if (chunks_1_1 && !chunks_1_1.done && (_a = chunks_1.return)) _a.call(chunks_1);
2273
- }
2274
- finally { if (e_1) throw e_1.error; }
2275
- return [7 /*endfinally*/];
2276
- case 9: return [2 /*return*/, products];
2277
- }
2218
+ return __generator(this, function (_a) {
2219
+ if (!category.products)
2220
+ throw new RequiredArgumentError(['Category products is empty']);
2221
+ return [2 /*return*/, this.productsIndex.findById(category.products, {
2222
+ hasStock: options === null || options === void 0 ? void 0 : options.hasStock,
2223
+ size: options === null || options === void 0 ? void 0 : options.limit,
2224
+ shop: category.shop,
2225
+ })];
2278
2226
  });
2279
2227
  });
2280
2228
  };
@@ -2286,7 +2234,7 @@
2286
2234
  function ProductFirestoreRepository(firestore) {
2287
2235
  var _this = _super.call(this) || this;
2288
2236
  _this.firestore = firestore;
2289
- _this.collectionName = 'productsErpVitrine';
2237
+ _this.collectionName = 'products';
2290
2238
  _this.model = Product;
2291
2239
  return _this;
2292
2240
  }
@@ -2368,7 +2316,7 @@
2368
2316
  },
2369
2317
  fromFirestore: function (snap) {
2370
2318
  var instance = fromFirestore(snap);
2371
- if (!lodash.isNil(instance.expiresIn))
2319
+ if (!isNil(instance.expiresIn))
2372
2320
  instance.expiresIn = new Date(snap.data().expiresIn);
2373
2321
  return instance;
2374
2322
  },
@@ -2450,9 +2398,9 @@
2450
2398
 
2451
2399
  var HomeFirestoreRepository = /** @class */ (function (_super) {
2452
2400
  __extends(HomeFirestoreRepository, _super);
2453
- function HomeFirestoreRepository(firestore) {
2401
+ function HomeFirestoreRepository(firestore$1) {
2454
2402
  var _this = _super.call(this) || this;
2455
- _this.firestore = firestore;
2403
+ _this.firestore = firestore$1;
2456
2404
  _this.homeToFirestore = function (home) {
2457
2405
  var _a;
2458
2406
  if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
@@ -2473,9 +2421,9 @@
2473
2421
  home.data.data.featuredProducts = home.data.data.featuredProducts.map(_this.plainToHomeCategoryGroup);
2474
2422
  home.data.data.verticalProducts = home.data.data.verticalProducts.map(_this.plainToHomeCategoryGroup);
2475
2423
  home.data.createdAt =
2476
- home.data.createdAt instanceof firebase__default["default"].firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
2424
+ home.data.createdAt instanceof firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
2477
2425
  home.data.expiresAt =
2478
- home.data.expiresAt instanceof firebase__default["default"].firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
2426
+ home.data.expiresAt instanceof firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
2479
2427
  }
2480
2428
  return home;
2481
2429
  };
@@ -2525,7 +2473,7 @@
2525
2473
  var credentials, user;
2526
2474
  return __generator(this, function (_a) {
2527
2475
  switch (_a.label) {
2528
- case 0: return [4 /*yield*/, this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password)];
2476
+ case 0: return [4 /*yield*/, auth.signInWithEmailAndPassword(this.firebaseAuth, data.email, data.password)];
2529
2477
  case 1:
2530
2478
  credentials = _a.sent();
2531
2479
  user = credentials.user;
@@ -2545,7 +2493,7 @@
2545
2493
  var credentials, user;
2546
2494
  return __generator(this, function (_a) {
2547
2495
  switch (_a.label) {
2548
- case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default$1["default"].auth.GoogleAuthProvider())];
2496
+ case 0: return [4 /*yield*/, auth.signInWithPopup(this.firebaseAuth, new auth.GoogleAuthProvider())];
2549
2497
  case 1:
2550
2498
  credentials = _a.sent();
2551
2499
  user = credentials.user;
@@ -2570,14 +2518,14 @@
2570
2518
  };
2571
2519
  AuthenticationFirebaseAuthService.prototype.signInAnonymously = function () {
2572
2520
  return __awaiter(this, void 0, void 0, function () {
2573
- var auth, user;
2521
+ var auth$1, user;
2574
2522
  return __generator(this, function (_a) {
2575
2523
  switch (_a.label) {
2576
- case 0: return [4 /*yield*/, this.firebaseAuth.signInAnonymously()];
2524
+ case 0: return [4 /*yield*/, auth.signInAnonymously(this.firebaseAuth)];
2577
2525
  case 1:
2578
- auth = _a.sent();
2579
- user = auth.user;
2580
- user.id = auth.user.uid;
2526
+ auth$1 = _a.sent();
2527
+ user = auth$1.user;
2528
+ user.id = auth$1.user.uid;
2581
2529
  return [2 /*return*/, user];
2582
2530
  }
2583
2531
  });
@@ -2586,7 +2534,7 @@
2586
2534
  AuthenticationFirebaseAuthService.prototype.sendPasswordResetEmail = function (email) {
2587
2535
  return __awaiter(this, void 0, void 0, function () {
2588
2536
  return __generator(this, function (_a) {
2589
- return [2 /*return*/, this.firebaseAuth.sendPasswordResetEmail(email)];
2537
+ return [2 /*return*/, auth.sendPasswordResetEmail(this.firebaseAuth, email)];
2590
2538
  });
2591
2539
  });
2592
2540
  };
@@ -2599,26 +2547,28 @@
2599
2547
  }
2600
2548
  RegisterFirebaseAuthService.prototype.register = function (params) {
2601
2549
  return __awaiter(this, void 0, void 0, function () {
2602
- var auth, user, error_1;
2550
+ var auth$1, user, error_1;
2603
2551
  return __generator(this, function (_a) {
2604
2552
  switch (_a.label) {
2605
2553
  case 0:
2606
- _a.trys.push([0, 2, , 3]);
2607
- return [4 /*yield*/, this.firebaseAuth.createUserWithEmailAndPassword(params.email, params.password)];
2554
+ _a.trys.push([0, 3, , 4]);
2555
+ return [4 /*yield*/, auth.createUserWithEmailAndPassword(this.firebaseAuth, params.email, params.password)];
2608
2556
  case 1:
2609
- auth = _a.sent();
2610
- user = auth.user;
2611
- user.sendEmailVerification();
2612
- user.id = auth.user.uid;
2613
- return [2 /*return*/, user];
2557
+ auth$1 = _a.sent();
2558
+ user = auth$1.user;
2559
+ return [4 /*yield*/, auth.sendEmailVerification(user)];
2614
2560
  case 2:
2561
+ _a.sent();
2562
+ user.id = auth$1.user.uid;
2563
+ return [2 /*return*/, user];
2564
+ case 3:
2615
2565
  error_1 = _a.sent();
2616
2566
  if (error_1.code === 'auth/email-already-in-use')
2617
2567
  throw new UserAlreadyRegisteredError('Email already registered');
2618
2568
  if (error_1.code === 'auth/weak-password')
2619
2569
  throw new WeakPasswordError();
2620
2570
  throw error_1;
2621
- case 3: return [2 /*return*/];
2571
+ case 4: return [2 /*return*/];
2622
2572
  }
2623
2573
  });
2624
2574
  });
@@ -2638,46 +2588,6 @@
2638
2588
  enumerable: true,
2639
2589
  get: function () { return dateFns.sub; }
2640
2590
  });
2641
- Object.defineProperty(exports, 'chunk', {
2642
- enumerable: true,
2643
- get: function () { return lodash.chunk; }
2644
- });
2645
- Object.defineProperty(exports, 'get', {
2646
- enumerable: true,
2647
- get: function () { return lodash.get; }
2648
- });
2649
- Object.defineProperty(exports, 'isDate', {
2650
- enumerable: true,
2651
- get: function () { return lodash.isDate; }
2652
- });
2653
- Object.defineProperty(exports, 'isEmpty', {
2654
- enumerable: true,
2655
- get: function () { return lodash.isEmpty; }
2656
- });
2657
- Object.defineProperty(exports, 'isNil', {
2658
- enumerable: true,
2659
- get: function () { return lodash.isNil; }
2660
- });
2661
- Object.defineProperty(exports, 'isNumber', {
2662
- enumerable: true,
2663
- get: function () { return lodash.isNumber; }
2664
- });
2665
- Object.defineProperty(exports, 'isObject', {
2666
- enumerable: true,
2667
- get: function () { return lodash.isObject; }
2668
- });
2669
- Object.defineProperty(exports, 'isString', {
2670
- enumerable: true,
2671
- get: function () { return lodash.isString; }
2672
- });
2673
- Object.defineProperty(exports, 'pick', {
2674
- enumerable: true,
2675
- get: function () { return lodash.pick; }
2676
- });
2677
- Object.defineProperty(exports, 'set', {
2678
- enumerable: true,
2679
- get: function () { return lodash.set; }
2680
- });
2681
2591
  exports.Address = Address;
2682
2592
  exports.Authentication = Authentication;
2683
2593
  exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;
@@ -2743,6 +2653,16 @@
2743
2653
  exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
2744
2654
  exports.Variant = Variant;
2745
2655
  exports.WeakPasswordError = WeakPasswordError;
2656
+ exports.chunk = chunk;
2657
+ exports.get = get;
2658
+ exports.isDate = isDate;
2659
+ exports.isEmpty = isEmpty;
2660
+ exports.isNil = isNil;
2661
+ exports.isNumber = isNumber;
2662
+ exports.isObject = isObject;
2663
+ exports.isString = isString;
2664
+ exports.pick = pick;
2665
+ exports.set = set;
2746
2666
  exports.withCreateFirestore = withCreateFirestore;
2747
2667
  exports.withCrudFirestore = withCrudFirestore;
2748
2668
  exports.withDeleteFirestore = withDeleteFirestore;