@infrab4a/connect 0.17.0-beta.0 → 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 (84) hide show
  1. package/bundles/infrab4a-connect.umd.js +139 -187
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/repositories/category.repository.d.ts +1 -6
  4. package/esm2015/domain/catalog/repositories/category.repository.js +1 -1
  5. package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -13
  6. package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +6 -6
  7. package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +4 -3
  8. package/esm2015/infra/firebase/auth/types/firebase-user-with-id.type.js +1 -1
  9. package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +7 -5
  10. package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +3 -4
  11. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +31 -25
  12. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +4 -4
  13. package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +4 -5
  14. package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
  15. package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +1 -1
  16. package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +9 -10
  17. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +11 -19
  18. package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +1 -1
  19. package/esm2015/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +1 -1
  20. package/esm2015/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +1 -1
  21. package/esm2015/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +4 -4
  22. package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +1 -1
  23. package/esm2015/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +1 -1
  24. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +1 -1
  25. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +1 -1
  26. package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +1 -1
  27. package/esm2015/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +1 -1
  28. package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +1 -1
  29. package/esm2015/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +1 -1
  30. package/esm2015/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +1 -1
  31. package/esm2015/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +1 -1
  32. package/esm2015/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +1 -1
  33. package/esm2015/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +1 -1
  34. package/esm2015/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +1 -1
  35. package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +1 -1
  36. package/esm2015/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +1 -1
  37. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +4 -12
  38. package/esm2015/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +1 -1
  39. package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +1 -1
  40. package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +1 -1
  41. package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
  42. package/esm2015/utils/index.js +3 -2
  43. package/fesm2015/infrab4a-connect.js +72 -99
  44. package/fesm2015/infrab4a-connect.js.map +1 -1
  45. package/infra/elasticsearch/indexes/products-index.d.ts +0 -1
  46. package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +2 -2
  47. package/infra/firebase/auth/register-firebase-auth.service.d.ts +2 -2
  48. package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +2 -1
  49. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +4 -4
  50. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +8 -8
  51. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +3 -3
  52. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +7 -7
  53. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +2 -2
  54. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +3 -3
  55. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +1 -1
  56. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +2 -2
  57. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
  58. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +17 -22
  59. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +16 -16
  60. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +18 -18
  61. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +16 -16
  62. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +14 -14
  63. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +16 -16
  64. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +16 -16
  65. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +16 -16
  66. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +16 -16
  67. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +14 -14
  68. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +3 -3
  69. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +16 -16
  70. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +16 -16
  71. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +16 -16
  72. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +16 -16
  73. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +18 -18
  74. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +16 -16
  75. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +18 -18
  76. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +18 -18
  77. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +18 -18
  78. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +14 -14
  79. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +18 -18
  80. package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +16 -16
  81. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +1 -1
  82. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +2 -2
  83. package/package.json +2 -2
  84. 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)];
@@ -1543,7 +1544,7 @@
1543
1544
  ];
1544
1545
  return [4 /*yield*/, this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
1545
1546
  bool: {
1546
- filter: __spreadArray(__spreadArray([
1547
+ filter: __spreadArray([
1547
1548
  {
1548
1549
  terms: {
1549
1550
  _id: ids,
@@ -1554,7 +1555,7 @@
1554
1555
  _a[publishedField] = true,
1555
1556
  _a),
1556
1557
  }
1557
- ], __read((options.hasStock && !options.stock
1558
+ ], __read((options.hasStock
1558
1559
  ? [
1559
1560
  {
1560
1561
  range: {
@@ -1564,16 +1565,6 @@
1564
1565
  },
1565
1566
  },
1566
1567
  ]
1567
- : []))), __read((options.stock
1568
- ? [
1569
- {
1570
- range: {
1571
- 'stock.quantity': {
1572
- gte: options.stock,
1573
- },
1574
- },
1575
- },
1576
- ]
1577
1568
  : []))),
1578
1569
  },
1579
1570
  } }, (options.size ? { size: options.size } : {})))];
@@ -1598,7 +1589,7 @@
1598
1589
  return _super.call(this, args) || this;
1599
1590
  }
1600
1591
  class_1.prototype.collection = function (path) {
1601
- return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
1592
+ return firestore.collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
1602
1593
  };
1603
1594
  class_1.prototype.buildModelInstance = function () {
1604
1595
  var _this = this;
@@ -1607,7 +1598,7 @@
1607
1598
  fromFirestore: function (snap) {
1608
1599
  var data = snap.data();
1609
1600
  Object.keys(data).forEach(function (key) {
1610
- if (data[key] instanceof firebase__default["default"].firestore.Timestamp) {
1601
+ if (data[key] instanceof firestore.Timestamp) {
1611
1602
  data[key] = data[key].toDate();
1612
1603
  }
1613
1604
  });
@@ -1634,7 +1625,7 @@
1634
1625
  }
1635
1626
  };
1636
1627
  class_1.prototype.isSubCollection = function (repository) {
1637
- return !lodash.isNil(Object.keys(this).find(function (key) { return key === 'parentRepository'; }));
1628
+ return !isNil(Object.keys(this).find(function (key) { return key === 'parentRepository'; }));
1638
1629
  };
1639
1630
  return class_1;
1640
1631
  }(MixinBase));
@@ -1648,16 +1639,18 @@
1648
1639
  }
1649
1640
  GetFirestore.prototype.get = function (identifiers) {
1650
1641
  return __awaiter(this, void 0, void 0, function () {
1651
- var doc, data;
1652
- return __generator(this, function (_a) {
1653
- switch (_a.label) {
1654
- case 0: return [4 /*yield*/, this.collection(this.buildCollectionPathForGet(identifiers))
1655
- .doc(Object.values(identifiers).shift().toString())
1656
- .get()];
1657
- case 1:
1658
- doc = _a.sent();
1659
- data = doc.data();
1660
- 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))
1661
1654
  throw new NotFoundError("Document " + JSON.stringify(identifiers) + " not found");
1662
1655
  return [2 /*return*/, data];
1663
1656
  }
@@ -1674,64 +1667,64 @@
1674
1667
  };
1675
1668
 
1676
1669
  var withFindFirestore = function (MixinBase) {
1677
- 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); };
1678
1671
  var getValueFromFilter = function (filter) {
1679
1672
  return checkIfIsFilterOption(filter) ? filter.value : filter;
1680
1673
  };
1681
- 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)
1682
1675
  ? value
1683
1676
  : Object.values(getFinalValueFrom); };
1684
1677
  return /** @class */ (function (_super) {
1685
1678
  __extends(FindFirestore, _super);
1686
1679
  function FindFirestore() {
1687
1680
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1688
- _this.makeFirestoreWhere = function (queryReference, filter) { return Object.keys(filter).reduce(function (query, fieldName) { return _this.buildWhereSentence(query, fieldName, filter[fieldName]); }, queryReference); };
1689
- _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) {
1690
1683
  if (_this.isSubCollection(_this) && fieldName === _this.parentIdField)
1691
- return queryReference;
1684
+ [];
1692
1685
  var value = (options === null || options === void 0 ? void 0 : options.value) || options;
1693
1686
  var object = {};
1694
- lodash.set(object, fieldName, value);
1687
+ set(object, fieldName, value);
1695
1688
  var plainInstance = new _this.model(object).toPlain();
1696
1689
  var firestoreFieldName = fieldName.toString().indexOf('.') > -1
1697
1690
  ? fieldName.toString()
1698
1691
  : Object.keys(plainInstance).find(function (key) { return plainInstance[key]; });
1699
1692
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.LIKE) {
1700
1693
  if (Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1701
- return queryReference.where(firestoreFieldName, 'array-contains-any', options.value);
1702
- queryReference = queryReference.where(firestoreFieldName, '>=', options.value);
1703
- queryReference = queryReference.where(firestoreFieldName, '<=', options.value + "~");
1704
- return queryReference;
1694
+ return [firestore.where(firestoreFieldName, 'array-contains-any', options.value)];
1695
+ return [firestore.where(firestoreFieldName, '>=', options.value), firestore.where(firestoreFieldName, '<=', options.value + "~")];
1705
1696
  }
1706
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))
1707
- return queryReference.where(firestoreFieldName, 'array-contains', options.value);
1708
- 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)) {
1709
- 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]))); }, []);
1710
1701
  }
1711
- 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)];
1712
1703
  };
1713
1704
  return _this;
1714
1705
  }
1715
- FindFirestore.prototype.find = function (filters, limits, orderBy) {
1706
+ FindFirestore.prototype.find = function (filters, limitList, orderByList) {
1716
1707
  return __awaiter(this, void 0, void 0, function () {
1717
- var query, docs, data;
1708
+ var collection, queries, ordination, limits, queryArgumments, docs, data;
1718
1709
  var _this = this;
1719
1710
  return __generator(this, function (_b) {
1720
1711
  switch (_b.label) {
1721
1712
  case 0:
1722
- query = this.collection(this.buildCollectionPathForFind(filters));
1723
- filters === null || filters === void 0 ? void 0 : filters.forEach(function (filterer) { return (query = _this.makeFirestoreWhere(query, filterer)); });
1724
- 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])); }); });
1725
- 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)];
1726
1718
  case 1:
1727
- query = _b.sent();
1728
- 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))))];
1729
1722
  case 2:
1730
1723
  docs = _b.sent();
1731
1724
  data = docs.docs.map(function (doc) { return doc.data(); });
1732
1725
  return [2 /*return*/, {
1733
1726
  data: data,
1734
- count: this.calculateCount(data, limits),
1727
+ count: this.calculateCount(data, limitList),
1735
1728
  }];
1736
1729
  }
1737
1730
  });
@@ -1745,29 +1738,29 @@
1745
1738
  var parentId = getValueFromFilter((_a = filters.find(function (groupFilter) { return Boolean(getValueFromFilter(groupFilter[parentIdField])); })) === null || _a === void 0 ? void 0 : _a[parentIdField]);
1746
1739
  return this.parentRepository.collectionName + "/" + parentId + "/" + this.collectionName;
1747
1740
  };
1748
- FindFirestore.prototype.defineLimits = function (query, filters, limits) {
1741
+ FindFirestore.prototype.defineLimits = function (filters, limits) {
1749
1742
  return __awaiter(this, void 0, void 0, function () {
1750
- var _b, _c;
1751
- return __generator(this, function (_d) {
1752
- switch (_d.label) {
1743
+ var queries, _b, _c, _d;
1744
+ return __generator(this, function (_e) {
1745
+ switch (_e.label) {
1753
1746
  case 0:
1747
+ queries = [];
1754
1748
  if (!(limits === null || limits === void 0 ? void 0 : limits.offset)) return [3 /*break*/, 3];
1755
1749
  if (!(limits.offset instanceof this.model)) return [3 /*break*/, 2];
1756
- _c = (_b = query).startAfter;
1757
- return [4 /*yield*/, this.collection(this.buildCollectionPathForFind(filters))
1758
- .doc(limits.offset[limits.offset.identifierFields().shift()])
1759
- .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()]))];
1760
1753
  case 1:
1761
- query = _c.apply(_b, [_d.sent()]);
1754
+ _c.apply(_b, [_d.apply(void 0, [_e.sent()])]);
1762
1755
  return [3 /*break*/, 3];
1763
1756
  case 2:
1764
- if (lodash.isNumber(limits.offset) || lodash.isString(limits.offset))
1765
- query = query.startAt(limits.offset);
1766
- _d.label = 3;
1757
+ if (isNumber(limits.offset) || isString(limits.offset))
1758
+ queries.push(firestore.startAt(limits.offset));
1759
+ _e.label = 3;
1767
1760
  case 3:
1768
1761
  if (limits === null || limits === void 0 ? void 0 : limits.limit)
1769
- query = query.limit(limits.limit);
1770
- return [2 /*return*/, query];
1762
+ queries.push(firestore.limit(limits.limit));
1763
+ return [2 /*return*/, queries];
1771
1764
  }
1772
1765
  });
1773
1766
  });
@@ -1797,7 +1790,7 @@
1797
1790
  case 0: return [4 /*yield*/, this.save(this.model.toInstance(data))];
1798
1791
  case 1:
1799
1792
  docRef = _b.sent();
1800
- return [4 /*yield*/, docRef.get()];
1793
+ return [4 /*yield*/, firestore.getDoc(docRef)];
1801
1794
  case 2:
1802
1795
  doc = _b.sent();
1803
1796
  return [2 /*return*/, doc.data()];
@@ -1808,16 +1801,17 @@
1808
1801
  CreateFirestore.prototype.save = function (data) {
1809
1802
  var _a;
1810
1803
  return __awaiter(this, void 0, void 0, function () {
1811
- var id, collectionPath, docRef;
1804
+ var id, collectionPath, collection, docRef;
1812
1805
  return __generator(this, function (_b) {
1813
1806
  switch (_b.label) {
1814
1807
  case 0:
1815
1808
  id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
1816
1809
  collectionPath = this.buildCollectionPathForAdd(data);
1817
- if (lodash.isEmpty(id))
1818
- return [2 /*return*/, this.collection(collectionPath).add(data)];
1819
- docRef = this.collection(collectionPath).doc(id);
1820
- 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)];
1821
1815
  case 1:
1822
1816
  _b.sent();
1823
1817
  return [2 /*return*/, docRef];
@@ -1835,18 +1829,17 @@
1835
1829
  };
1836
1830
 
1837
1831
  var withUpdateFirestore = function (MixinBase) {
1838
- 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; };
1839
1833
  var getValueByAction = function (options) {
1840
- var fieldValues = firebase__default["default"].firestore.FieldValue;
1841
- if (lodash.isNil(options.action))
1834
+ if (isNil(options.action))
1842
1835
  return options;
1843
1836
  if (options.action === exports.UpdateOptionActions.REMOVE_FIELD)
1844
- return fieldValues.delete();
1837
+ return firestore.deleteField();
1845
1838
  if (Array.isArray(options.value)) {
1846
1839
  if (options.action === exports.UpdateOptionActions.MERGE)
1847
- return fieldValues.arrayUnion.apply(fieldValues, __spreadArray([], __read(options.value)));
1840
+ return firestore.arrayUnion.apply(void 0, __spreadArray([], __read(options.value)));
1848
1841
  if (options.action === exports.UpdateOptionActions.REMOVE)
1849
- return fieldValues.arrayRemove.apply(fieldValues, __spreadArray([], __read(options.value)));
1842
+ return firestore.arrayRemove.apply(void 0, __spreadArray([], __read(options.value)));
1850
1843
  }
1851
1844
  return options.value;
1852
1845
  };
@@ -1857,20 +1850,20 @@
1857
1850
  }
1858
1851
  UpdateFirestore.prototype.update = function (data) {
1859
1852
  return __awaiter(this, void 0, void 0, function () {
1860
- var model, keyField, docRef, doc;
1853
+ var model, keyField, docRef, docData;
1861
1854
  return __generator(this, function (_b) {
1862
1855
  switch (_b.label) {
1863
1856
  case 0:
1864
1857
  model = new this.model();
1865
1858
  keyField = model.identifierFields().shift();
1866
- docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
1867
- 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 })];
1868
1861
  case 1:
1869
1862
  _b.sent();
1870
- return [4 /*yield*/, docRef.get()];
1863
+ return [4 /*yield*/, firestore.getDoc(docRef)];
1871
1864
  case 2:
1872
- doc = _b.sent();
1873
- return [2 /*return*/, doc.data()];
1865
+ docData = _b.sent();
1866
+ return [2 /*return*/, docData.data()];
1874
1867
  }
1875
1868
  });
1876
1869
  });
@@ -1903,9 +1896,7 @@
1903
1896
  return __awaiter(this, void 0, void 0, function () {
1904
1897
  return __generator(this, function (_a) {
1905
1898
  switch (_a.label) {
1906
- case 0: return [4 /*yield*/, this.collection(this.buildCollectionPathForRemove(identifiers))
1907
- .doc(Object.values(identifiers).shift().toString())
1908
- .delete()];
1899
+ case 0: return [4 /*yield*/, firestore.deleteDoc(firestore.doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()))];
1909
1900
  case 1:
1910
1901
  _a.sent();
1911
1902
  return [2 /*return*/];
@@ -2049,12 +2040,7 @@
2049
2040
  var beautyProfile;
2050
2041
  return __generator(this, function (_a) {
2051
2042
  switch (_a.label) {
2052
- case 0: return [4 /*yield*/, this.collection()
2053
- .doc(userId)
2054
- .collection('CX')
2055
- .withConverter(this.buildBeautyProfileModelInstance())
2056
- .doc('beautyProfile')
2057
- .get()];
2043
+ case 0: return [4 /*yield*/, firestore.getDoc(firestore.doc(this.collection(this.collectionName + "/" + userId + "/CX").withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'))];
2058
2044
  case 1:
2059
2045
  beautyProfile = _a.sent();
2060
2046
  return [2 /*return*/, beautyProfile.data()];
@@ -2067,11 +2053,7 @@
2067
2053
  var docs;
2068
2054
  return __generator(this, function (_a) {
2069
2055
  switch (_a.label) {
2070
- case 0: return [4 /*yield*/, this.firestore
2071
- .collection('subscription')
2072
- .where('user.id', '==', userId)
2073
- .where('status', '==', 'active')
2074
- .get()];
2056
+ case 0: return [4 /*yield*/, firestore.getDocs(firestore.query(this.collection('subscription'), firestore.where('user.id', '==', userId), firestore.where('status', '==', 'active')))];
2075
2057
  case 1:
2076
2058
  docs = _a.sent();
2077
2059
  return [2 /*return*/, !!docs && !!docs.size];
@@ -2181,31 +2163,30 @@
2181
2163
  return _this;
2182
2164
  }
2183
2165
  CategoryFirestoreRepository.prototype.getCategoryBySlug = function (slug, shop) {
2184
- return this.collection(this.collectionName)
2185
- .where('slug', '==', slug)
2186
- .where('shop', '==', shop)
2187
- .where('published', '==', true)
2188
- .get()
2189
- .then(function (snap) {
2190
- if (snap.size > 1)
2191
- throw new DuplicatedResultsError('Query returned duplicated values');
2192
- if (snap.empty)
2193
- throw new NotFoundError("Document with slug " + slug + " not found");
2194
- return snap.docs[0].data();
2195
- })
2196
- .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
+ });
2197
2181
  };
2198
- CategoryFirestoreRepository.prototype.getCategoriesForHome = function (categoryIds, _a) {
2199
- var _b = _a === void 0 ? {} : _a, limit = _b.limit, stock = _b.stock;
2182
+ CategoryFirestoreRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
2183
+ if (limit === void 0) { limit = 4; }
2200
2184
  return __awaiter(this, void 0, void 0, function () {
2201
2185
  var categorySnap, categories, homeSections;
2202
2186
  var _this = this;
2203
2187
  return __generator(this, function (_a) {
2204
2188
  switch (_a.label) {
2205
- case 0: return [4 /*yield*/, this.collection(this.collectionName)
2206
- .where('id', 'in', categoryIds.filter(Boolean))
2207
- .where('published', '==', true)
2208
- .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)))];
2209
2190
  case 1:
2210
2191
  categorySnap = _a.sent();
2211
2192
  if (categorySnap.empty)
@@ -2219,7 +2200,7 @@
2219
2200
  _a = {
2220
2201
  category: category
2221
2202
  };
2222
- return [4 /*yield*/, this.mountCategory(category, { limit: limit, stock: stock, hasStock: true })];
2203
+ return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
2223
2204
  case 1: return [2 /*return*/, (_a.products = _b.sent(),
2224
2205
  _a)];
2225
2206
  }
@@ -2240,7 +2221,6 @@
2240
2221
  return [2 /*return*/, this.productsIndex.findById(category.products, {
2241
2222
  hasStock: options === null || options === void 0 ? void 0 : options.hasStock,
2242
2223
  size: options === null || options === void 0 ? void 0 : options.limit,
2243
- stock: options.stock,
2244
2224
  shop: category.shop,
2245
2225
  })];
2246
2226
  });
@@ -2336,7 +2316,7 @@
2336
2316
  },
2337
2317
  fromFirestore: function (snap) {
2338
2318
  var instance = fromFirestore(snap);
2339
- if (!lodash.isNil(instance.expiresIn))
2319
+ if (!isNil(instance.expiresIn))
2340
2320
  instance.expiresIn = new Date(snap.data().expiresIn);
2341
2321
  return instance;
2342
2322
  },
@@ -2418,9 +2398,9 @@
2418
2398
 
2419
2399
  var HomeFirestoreRepository = /** @class */ (function (_super) {
2420
2400
  __extends(HomeFirestoreRepository, _super);
2421
- function HomeFirestoreRepository(firestore) {
2401
+ function HomeFirestoreRepository(firestore$1) {
2422
2402
  var _this = _super.call(this) || this;
2423
- _this.firestore = firestore;
2403
+ _this.firestore = firestore$1;
2424
2404
  _this.homeToFirestore = function (home) {
2425
2405
  var _a;
2426
2406
  if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
@@ -2441,9 +2421,9 @@
2441
2421
  home.data.data.featuredProducts = home.data.data.featuredProducts.map(_this.plainToHomeCategoryGroup);
2442
2422
  home.data.data.verticalProducts = home.data.data.verticalProducts.map(_this.plainToHomeCategoryGroup);
2443
2423
  home.data.createdAt =
2444
- 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;
2445
2425
  home.data.expiresAt =
2446
- 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;
2447
2427
  }
2448
2428
  return home;
2449
2429
  };
@@ -2493,7 +2473,7 @@
2493
2473
  var credentials, user;
2494
2474
  return __generator(this, function (_a) {
2495
2475
  switch (_a.label) {
2496
- 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)];
2497
2477
  case 1:
2498
2478
  credentials = _a.sent();
2499
2479
  user = credentials.user;
@@ -2513,7 +2493,7 @@
2513
2493
  var credentials, user;
2514
2494
  return __generator(this, function (_a) {
2515
2495
  switch (_a.label) {
2516
- 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())];
2517
2497
  case 1:
2518
2498
  credentials = _a.sent();
2519
2499
  user = credentials.user;
@@ -2538,14 +2518,14 @@
2538
2518
  };
2539
2519
  AuthenticationFirebaseAuthService.prototype.signInAnonymously = function () {
2540
2520
  return __awaiter(this, void 0, void 0, function () {
2541
- var auth, user;
2521
+ var auth$1, user;
2542
2522
  return __generator(this, function (_a) {
2543
2523
  switch (_a.label) {
2544
- case 0: return [4 /*yield*/, this.firebaseAuth.signInAnonymously()];
2524
+ case 0: return [4 /*yield*/, auth.signInAnonymously(this.firebaseAuth)];
2545
2525
  case 1:
2546
- auth = _a.sent();
2547
- user = auth.user;
2548
- user.id = auth.user.uid;
2526
+ auth$1 = _a.sent();
2527
+ user = auth$1.user;
2528
+ user.id = auth$1.user.uid;
2549
2529
  return [2 /*return*/, user];
2550
2530
  }
2551
2531
  });
@@ -2554,7 +2534,7 @@
2554
2534
  AuthenticationFirebaseAuthService.prototype.sendPasswordResetEmail = function (email) {
2555
2535
  return __awaiter(this, void 0, void 0, function () {
2556
2536
  return __generator(this, function (_a) {
2557
- return [2 /*return*/, this.firebaseAuth.sendPasswordResetEmail(email)];
2537
+ return [2 /*return*/, auth.sendPasswordResetEmail(this.firebaseAuth, email)];
2558
2538
  });
2559
2539
  });
2560
2540
  };
@@ -2567,26 +2547,28 @@
2567
2547
  }
2568
2548
  RegisterFirebaseAuthService.prototype.register = function (params) {
2569
2549
  return __awaiter(this, void 0, void 0, function () {
2570
- var auth, user, error_1;
2550
+ var auth$1, user, error_1;
2571
2551
  return __generator(this, function (_a) {
2572
2552
  switch (_a.label) {
2573
2553
  case 0:
2574
- _a.trys.push([0, 2, , 3]);
2575
- 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)];
2576
2556
  case 1:
2577
- auth = _a.sent();
2578
- user = auth.user;
2579
- user.sendEmailVerification();
2580
- user.id = auth.user.uid;
2581
- return [2 /*return*/, user];
2557
+ auth$1 = _a.sent();
2558
+ user = auth$1.user;
2559
+ return [4 /*yield*/, auth.sendEmailVerification(user)];
2582
2560
  case 2:
2561
+ _a.sent();
2562
+ user.id = auth$1.user.uid;
2563
+ return [2 /*return*/, user];
2564
+ case 3:
2583
2565
  error_1 = _a.sent();
2584
2566
  if (error_1.code === 'auth/email-already-in-use')
2585
2567
  throw new UserAlreadyRegisteredError('Email already registered');
2586
2568
  if (error_1.code === 'auth/weak-password')
2587
2569
  throw new WeakPasswordError();
2588
2570
  throw error_1;
2589
- case 3: return [2 /*return*/];
2571
+ case 4: return [2 /*return*/];
2590
2572
  }
2591
2573
  });
2592
2574
  });
@@ -2606,46 +2588,6 @@
2606
2588
  enumerable: true,
2607
2589
  get: function () { return dateFns.sub; }
2608
2590
  });
2609
- Object.defineProperty(exports, 'chunk', {
2610
- enumerable: true,
2611
- get: function () { return lodash.chunk; }
2612
- });
2613
- Object.defineProperty(exports, 'get', {
2614
- enumerable: true,
2615
- get: function () { return lodash.get; }
2616
- });
2617
- Object.defineProperty(exports, 'isDate', {
2618
- enumerable: true,
2619
- get: function () { return lodash.isDate; }
2620
- });
2621
- Object.defineProperty(exports, 'isEmpty', {
2622
- enumerable: true,
2623
- get: function () { return lodash.isEmpty; }
2624
- });
2625
- Object.defineProperty(exports, 'isNil', {
2626
- enumerable: true,
2627
- get: function () { return lodash.isNil; }
2628
- });
2629
- Object.defineProperty(exports, 'isNumber', {
2630
- enumerable: true,
2631
- get: function () { return lodash.isNumber; }
2632
- });
2633
- Object.defineProperty(exports, 'isObject', {
2634
- enumerable: true,
2635
- get: function () { return lodash.isObject; }
2636
- });
2637
- Object.defineProperty(exports, 'isString', {
2638
- enumerable: true,
2639
- get: function () { return lodash.isString; }
2640
- });
2641
- Object.defineProperty(exports, 'pick', {
2642
- enumerable: true,
2643
- get: function () { return lodash.pick; }
2644
- });
2645
- Object.defineProperty(exports, 'set', {
2646
- enumerable: true,
2647
- get: function () { return lodash.set; }
2648
- });
2649
2591
  exports.Address = Address;
2650
2592
  exports.Authentication = Authentication;
2651
2593
  exports.AuthenticationFirebaseAuthService = AuthenticationFirebaseAuthService;
@@ -2711,6 +2653,16 @@
2711
2653
  exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
2712
2654
  exports.Variant = Variant;
2713
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;
2714
2666
  exports.withCreateFirestore = withCreateFirestore;
2715
2667
  exports.withCrudFirestore = withCrudFirestore;
2716
2668
  exports.withDeleteFirestore = withDeleteFirestore;