@infrab4a/connect 0.5.1 → 0.6.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.
- package/bundles/infrab4a-connect.umd.js +30 -31
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/lib/domain/catalog/repositories/category.repository.js +1 -1
- package/esm2015/lib/domain/users/models/user.js +4 -2
- package/esm2015/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +21 -23
- package/fesm2015/infrab4a-connect.js +28 -29
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/lib/domain/catalog/repositories/category.repository.d.ts +1 -1
- package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -1
- package/package.json +1 -1
|
@@ -666,6 +666,17 @@
|
|
|
666
666
|
return SubscriptionPlan;
|
|
667
667
|
}(BaseModel));
|
|
668
668
|
|
|
669
|
+
var Base = /** @class */ (function () {
|
|
670
|
+
function Base() {
|
|
671
|
+
var args = [];
|
|
672
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
673
|
+
args[_i] = arguments[_i];
|
|
674
|
+
}
|
|
675
|
+
Object.assign.apply(Object, __spreadArray([this], __read(args)));
|
|
676
|
+
}
|
|
677
|
+
return Base;
|
|
678
|
+
}());
|
|
679
|
+
|
|
669
680
|
var BeautyProfile = /** @class */ (function (_super) {
|
|
670
681
|
__extends(BeautyProfile, _super);
|
|
671
682
|
function BeautyProfile() {
|
|
@@ -689,7 +700,8 @@
|
|
|
689
700
|
}
|
|
690
701
|
User.toInstance = function (data) {
|
|
691
702
|
var instance = _super.toInstance.call(this, data);
|
|
692
|
-
|
|
703
|
+
if (!lodash.isNil(data.firstName))
|
|
704
|
+
instance.displayName = "" + data.firstName + (!lodash.isNil(data.lastName) ? " " + data.lastName : '');
|
|
693
705
|
return instance;
|
|
694
706
|
};
|
|
695
707
|
User.prototype.identifierFields = function () {
|
|
@@ -757,17 +769,6 @@
|
|
|
757
769
|
return UserAddress;
|
|
758
770
|
}(Address));
|
|
759
771
|
|
|
760
|
-
var Base = /** @class */ (function () {
|
|
761
|
-
function Base() {
|
|
762
|
-
var args = [];
|
|
763
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
764
|
-
args[_i] = arguments[_i];
|
|
765
|
-
}
|
|
766
|
-
Object.assign.apply(Object, __spreadArray([this], __read(args)));
|
|
767
|
-
}
|
|
768
|
-
return Base;
|
|
769
|
-
}());
|
|
770
|
-
|
|
771
772
|
var UnauthorizedError = /** @class */ (function (_super) {
|
|
772
773
|
__extends(UnauthorizedError, _super);
|
|
773
774
|
function UnauthorizedError(message) {
|
|
@@ -1617,16 +1618,18 @@
|
|
|
1617
1618
|
}
|
|
1618
1619
|
CategoryFirestoreRepository.prototype.getCategoryBySlug = function (slug, shop) {
|
|
1619
1620
|
return this.collection(this.collectionName)
|
|
1620
|
-
.where(
|
|
1621
|
-
.where(
|
|
1622
|
-
.where(
|
|
1623
|
-
.get()
|
|
1621
|
+
.where('slug', '==', slug)
|
|
1622
|
+
.where('shop', '==', shop)
|
|
1623
|
+
.where('published', '==', true)
|
|
1624
|
+
.get()
|
|
1625
|
+
.then(function (snap) {
|
|
1624
1626
|
if (snap.size > 1)
|
|
1625
|
-
throw new DuplicatedResultsError(
|
|
1627
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
1626
1628
|
if (snap.empty)
|
|
1627
1629
|
throw new NotFoundError("Document with slug " + slug + " not found");
|
|
1628
1630
|
return snap.docs[0].data();
|
|
1629
|
-
})
|
|
1631
|
+
})
|
|
1632
|
+
.catch(function (error) { return error; });
|
|
1630
1633
|
};
|
|
1631
1634
|
CategoryFirestoreRepository.prototype.getCategoriesForHome = function (categoryIds) {
|
|
1632
1635
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -1635,13 +1638,13 @@
|
|
|
1635
1638
|
return __generator(this, function (_b) {
|
|
1636
1639
|
switch (_b.label) {
|
|
1637
1640
|
case 0: return [4 /*yield*/, this.collection(this.collectionName)
|
|
1638
|
-
.where(
|
|
1639
|
-
.where(
|
|
1641
|
+
.where('id', 'in', categoryIds)
|
|
1642
|
+
.where('published', '==', true)
|
|
1640
1643
|
.get()];
|
|
1641
1644
|
case 1:
|
|
1642
1645
|
categorySnap = _b.sent();
|
|
1643
1646
|
if (categorySnap.empty)
|
|
1644
|
-
throw new NotFoundError(
|
|
1647
|
+
throw new NotFoundError('Categories not found');
|
|
1645
1648
|
categories = categorySnap.docs.map(function (doc) { return doc.data(); });
|
|
1646
1649
|
homeSections = [];
|
|
1647
1650
|
_b.label = 2;
|
|
@@ -1652,16 +1655,15 @@
|
|
|
1652
1655
|
case 3:
|
|
1653
1656
|
if (!!categories_1_1.done) return [3 /*break*/, 6];
|
|
1654
1657
|
category = categories_1_1.value;
|
|
1655
|
-
return [4 /*yield*/, this.collection(
|
|
1656
|
-
.where(
|
|
1657
|
-
|
|
1658
|
-
.where("stock.quantity", ">", 1)
|
|
1658
|
+
return [4 /*yield*/, this.collection('products')
|
|
1659
|
+
.where('categories', 'array-contains', category.id)
|
|
1660
|
+
.where('stock.quantity', '>', 1)
|
|
1659
1661
|
.limit(4)
|
|
1660
1662
|
.get()];
|
|
1661
1663
|
case 4:
|
|
1662
1664
|
productSnap = _b.sent();
|
|
1663
1665
|
products = productSnap.docs.map(function (doc) { return doc.data(); });
|
|
1664
|
-
homeSections.push({
|
|
1666
|
+
homeSections.push({ category: category, products: products });
|
|
1665
1667
|
_b.label = 5;
|
|
1666
1668
|
case 5:
|
|
1667
1669
|
categories_1_1 = categories_1.next();
|
|
@@ -1690,7 +1692,7 @@
|
|
|
1690
1692
|
switch (_b.label) {
|
|
1691
1693
|
case 0:
|
|
1692
1694
|
if (!category.products)
|
|
1693
|
-
throw new RequiredArgumentError([
|
|
1695
|
+
throw new RequiredArgumentError(['Category products is empty']);
|
|
1694
1696
|
chunks = category.products.reduce(function (resultArray, item, index) {
|
|
1695
1697
|
var chunkIndex = Math.floor(index / 10);
|
|
1696
1698
|
if (!resultArray[chunkIndex])
|
|
@@ -1707,10 +1709,7 @@
|
|
|
1707
1709
|
case 2:
|
|
1708
1710
|
if (!!chunks_1_1.done) return [3 /*break*/, 5];
|
|
1709
1711
|
productIds = chunks_1_1.value;
|
|
1710
|
-
return [4 /*yield*/, this.collection(
|
|
1711
|
-
.where("id", "in", productIds)
|
|
1712
|
-
// .where("published", "==", true)
|
|
1713
|
-
.get()];
|
|
1712
|
+
return [4 /*yield*/, this.collection('products').where('id', 'in', productIds).get()];
|
|
1714
1713
|
case 3:
|
|
1715
1714
|
productSnap = _b.sent();
|
|
1716
1715
|
if (productSnap.empty)
|