@infrab4a/connect 1.0.1 → 1.0.2
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 +45 -37
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +2 -2
- package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +4 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +2 -3
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +3 -1
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +6 -3
- package/fesm2015/infrab4a-connect.js +12 -6
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/package.json +1 -1
|
@@ -2002,7 +2002,7 @@
|
|
|
2002
2002
|
if (filtersKeysWithUnordered.length)
|
|
2003
2003
|
filtersKeysWithUnordered.forEach(function (filterKey) {
|
|
2004
2004
|
var _a;
|
|
2005
|
-
return (orderBy = Object.assign((_a = {}, _a[filterKey] = 'asc', _a), orderBy));
|
|
2005
|
+
return (orderBy = Object.assign(Object.assign({}, (![exports.Where.EQUALS].includes(filters[filterKey].operator) ? (_a = {}, _a[filterKey] = 'asc', _a) : {})), orderBy));
|
|
2006
2006
|
});
|
|
2007
2007
|
Object.keys(orderBy).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderBy[fieldName])); });
|
|
2008
2008
|
}
|
|
@@ -3087,7 +3087,9 @@
|
|
|
3087
3087
|
return false;
|
|
3088
3088
|
var converter = fieldOption.to
|
|
3089
3089
|
? fieldOption.to
|
|
3090
|
-
: function (value) { return
|
|
3090
|
+
: function (value) { return filter.operator === exports.Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
|
|
3091
|
+
? "%" + value + "%"
|
|
3092
|
+
: value; };
|
|
3091
3093
|
return Array.isArray(filter.value) && !fieldOption.fields && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
|
|
3092
3094
|
? filter.value.map(function (fieldValue) { return converter(fieldValue); })
|
|
3093
3095
|
: converter(filter.value);
|
|
@@ -3668,10 +3670,9 @@
|
|
|
3668
3670
|
type: HasuraGraphQLColumnType.Jsonb,
|
|
3669
3671
|
from: function (tags, row) { return ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }); },
|
|
3670
3672
|
bindPersistData: function (value) {
|
|
3671
|
-
var _a, _b;
|
|
3672
3673
|
return {
|
|
3673
3674
|
brand_condition: value.brand,
|
|
3674
|
-
tag_condition:
|
|
3675
|
+
tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
|
|
3675
3676
|
};
|
|
3676
3677
|
},
|
|
3677
3678
|
bindFindFilter: function (sentence) {
|
|
@@ -3703,34 +3704,34 @@
|
|
|
3703
3704
|
});
|
|
3704
3705
|
var _a;
|
|
3705
3706
|
return __awaiter(this, void 0, void 0, function () {
|
|
3706
|
-
var
|
|
3707
|
-
return __generator(this, function (
|
|
3708
|
-
switch (
|
|
3707
|
+
var _b;
|
|
3708
|
+
return __generator(this, function (_c) {
|
|
3709
|
+
switch (_c.label) {
|
|
3709
3710
|
case 0:
|
|
3710
3711
|
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
3711
3712
|
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
3712
3713
|
case 1:
|
|
3713
|
-
|
|
3714
|
+
_b = (_a = (_c.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
3714
3715
|
return [3 /*break*/, 3];
|
|
3715
3716
|
case 2:
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
case 3: return [2 /*return*/,
|
|
3717
|
+
_b = _super.get.call(this, identifiers);
|
|
3718
|
+
_c.label = 3;
|
|
3719
|
+
case 3: return [2 /*return*/, _b];
|
|
3719
3720
|
}
|
|
3720
3721
|
});
|
|
3721
3722
|
});
|
|
3722
3723
|
};
|
|
3723
3724
|
CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
|
|
3724
3725
|
return __awaiter(this, void 0, void 0, function () {
|
|
3725
|
-
var
|
|
3726
|
-
return __generator(this, function (
|
|
3727
|
-
switch (
|
|
3726
|
+
var _b, data, count;
|
|
3727
|
+
return __generator(this, function (_c) {
|
|
3728
|
+
switch (_c.label) {
|
|
3728
3729
|
case 0:
|
|
3729
3730
|
if (!slug)
|
|
3730
3731
|
return [2 /*return*/];
|
|
3731
3732
|
return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
|
|
3732
3733
|
case 1:
|
|
3733
|
-
|
|
3734
|
+
_b = _c.sent(), data = _b.data, count = _b.count;
|
|
3734
3735
|
if (count > 1)
|
|
3735
3736
|
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
3736
3737
|
if (!count)
|
|
@@ -3743,33 +3744,33 @@
|
|
|
3743
3744
|
CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
|
|
3744
3745
|
if (limit === void 0) { limit = 4; }
|
|
3745
3746
|
return __awaiter(this, void 0, void 0, function () {
|
|
3746
|
-
var
|
|
3747
|
+
var _b, categories, count, homeSections;
|
|
3747
3748
|
var _this = this;
|
|
3748
|
-
return __generator(this, function (
|
|
3749
|
-
switch (
|
|
3749
|
+
return __generator(this, function (_c) {
|
|
3750
|
+
switch (_c.label) {
|
|
3750
3751
|
case 0: return [4 /*yield*/, this.find({
|
|
3751
3752
|
filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
|
|
3752
3753
|
})];
|
|
3753
3754
|
case 1:
|
|
3754
|
-
|
|
3755
|
+
_b = _c.sent(), categories = _b.data, count = _b.count;
|
|
3755
3756
|
if (!count)
|
|
3756
3757
|
throw new NotFoundError('Categories not found');
|
|
3757
3758
|
return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
|
|
3758
|
-
var
|
|
3759
|
-
return __generator(this, function (
|
|
3760
|
-
switch (
|
|
3759
|
+
var _b;
|
|
3760
|
+
return __generator(this, function (_c) {
|
|
3761
|
+
switch (_c.label) {
|
|
3761
3762
|
case 0:
|
|
3762
|
-
|
|
3763
|
+
_b = {
|
|
3763
3764
|
category: category
|
|
3764
3765
|
};
|
|
3765
3766
|
return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
|
|
3766
|
-
case 1: return [2 /*return*/, (
|
|
3767
|
-
|
|
3767
|
+
case 1: return [2 /*return*/, (_b.products = _c.sent(),
|
|
3768
|
+
_b)];
|
|
3768
3769
|
}
|
|
3769
3770
|
});
|
|
3770
3771
|
}); }))];
|
|
3771
3772
|
case 2:
|
|
3772
|
-
homeSections =
|
|
3773
|
+
homeSections = _c.sent();
|
|
3773
3774
|
return [2 /*return*/, homeSections];
|
|
3774
3775
|
}
|
|
3775
3776
|
});
|
|
@@ -3778,15 +3779,15 @@
|
|
|
3778
3779
|
CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
|
|
3779
3780
|
return __awaiter(this, void 0, void 0, function () {
|
|
3780
3781
|
var products, publishedField, productsData;
|
|
3781
|
-
var
|
|
3782
|
-
return __generator(this, function (
|
|
3783
|
-
switch (
|
|
3782
|
+
var _b;
|
|
3783
|
+
return __generator(this, function (_c) {
|
|
3784
|
+
switch (_c.label) {
|
|
3784
3785
|
case 0:
|
|
3785
3786
|
if (!category.products)
|
|
3786
3787
|
throw new RequiredArgumentError(['Category products is empty']);
|
|
3787
3788
|
products = [];
|
|
3788
3789
|
publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
|
|
3789
|
-
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((
|
|
3790
|
+
return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_b = { id: { operator: exports.Where.IN, value: category.products } }, _b[publishedField] = true, _b), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
|
|
3790
3791
|
'id',
|
|
3791
3792
|
'name',
|
|
3792
3793
|
'slug',
|
|
@@ -3811,7 +3812,7 @@
|
|
|
3811
3812
|
'rate',
|
|
3812
3813
|
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
|
|
3813
3814
|
case 1:
|
|
3814
|
-
productsData = (
|
|
3815
|
+
productsData = (_c.sent()).data;
|
|
3815
3816
|
products.push.apply(products, __spreadArray([], __read(productsData)));
|
|
3816
3817
|
return [2 /*return*/, products];
|
|
3817
3818
|
}
|
|
@@ -4021,6 +4022,8 @@
|
|
|
4021
4022
|
_e.label = 4;
|
|
4022
4023
|
case 4:
|
|
4023
4024
|
product = _c;
|
|
4025
|
+
if (product.productId)
|
|
4026
|
+
throw new NotFoundError('Product not found, it is a variant');
|
|
4024
4027
|
_d = product;
|
|
4025
4028
|
return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
|
|
4026
4029
|
case 5:
|
|
@@ -4463,7 +4466,7 @@
|
|
|
4463
4466
|
});
|
|
4464
4467
|
var _a;
|
|
4465
4468
|
return __awaiter(this, void 0, void 0, function () {
|
|
4466
|
-
var _c;
|
|
4469
|
+
var variant, _c;
|
|
4467
4470
|
return __generator(this, function (_d) {
|
|
4468
4471
|
switch (_d.label) {
|
|
4469
4472
|
case 0:
|
|
@@ -4471,11 +4474,16 @@
|
|
|
4471
4474
|
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
4472
4475
|
case 1:
|
|
4473
4476
|
_c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
4474
|
-
return [3 /*break*/,
|
|
4475
|
-
case 2:
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4477
|
+
return [3 /*break*/, 4];
|
|
4478
|
+
case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
|
|
4479
|
+
case 3:
|
|
4480
|
+
_c = _d.sent();
|
|
4481
|
+
_d.label = 4;
|
|
4482
|
+
case 4:
|
|
4483
|
+
variant = _c;
|
|
4484
|
+
if (!variant.productId)
|
|
4485
|
+
throw new NotFoundError("Variant not found, it is a product");
|
|
4486
|
+
return [2 /*return*/, variant];
|
|
4479
4487
|
}
|
|
4480
4488
|
});
|
|
4481
4489
|
});
|