@infrab4a/connect 3.3.1-beta.1 → 3.3.1-beta.3
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 +20 -21
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +5 -6
- package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +9 -9
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +3 -3
- package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +2 -2
- package/fesm2015/infrab4a-connect.js +15 -16
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/package.json +1 -1
|
@@ -2467,18 +2467,17 @@ const withFindHasuraGraphQL = (MixinBase) => {
|
|
|
2467
2467
|
variables,
|
|
2468
2468
|
},
|
|
2469
2469
|
...(enableCount
|
|
2470
|
-
? [
|
|
2471
|
-
: [
|
|
2470
|
+
? [
|
|
2472
2471
|
{
|
|
2473
2472
|
operation: `${this.tableName}_aggregate`,
|
|
2474
2473
|
fields: [{ aggregate: ['count'] }],
|
|
2475
2474
|
variables: variablesCount,
|
|
2476
2475
|
},
|
|
2477
|
-
]
|
|
2476
|
+
]
|
|
2477
|
+
: []),
|
|
2478
2478
|
]);
|
|
2479
2479
|
const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
|
|
2480
|
-
|
|
2481
|
-
return { data, count: enableCount ? count : Infinity };
|
|
2480
|
+
return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
|
|
2482
2481
|
});
|
|
2483
2482
|
}
|
|
2484
2483
|
};
|
|
@@ -2597,7 +2596,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2597
2596
|
var _a;
|
|
2598
2597
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2599
2598
|
return Number.isNaN(+identifiers.id)
|
|
2600
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2599
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2601
2600
|
: _super.get.call(this, identifiers);
|
|
2602
2601
|
});
|
|
2603
2602
|
}
|
|
@@ -2619,11 +2618,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2619
2618
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2620
2619
|
if (!slug)
|
|
2621
2620
|
return;
|
|
2622
|
-
const { data
|
|
2623
|
-
if (
|
|
2624
|
-
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2625
|
-
if (!count)
|
|
2621
|
+
const { data } = yield this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
|
|
2622
|
+
if (!data.length)
|
|
2626
2623
|
throw new NotFoundError(`Category with slug ${slug} not found`);
|
|
2624
|
+
if (data.length > 1)
|
|
2625
|
+
throw new DuplicatedResultsError('Query returned duplicated values');
|
|
2627
2626
|
return data.shift();
|
|
2628
2627
|
});
|
|
2629
2628
|
}
|
|
@@ -2659,7 +2658,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2659
2658
|
if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
|
|
2660
2659
|
return [];
|
|
2661
2660
|
const products = [];
|
|
2662
|
-
const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
2661
|
+
const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
|
|
2663
2662
|
'id',
|
|
2664
2663
|
'name',
|
|
2665
2664
|
'slug',
|
|
@@ -2683,7 +2682,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2683
2682
|
'tags',
|
|
2684
2683
|
'type',
|
|
2685
2684
|
'shoppingCount',
|
|
2686
|
-
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
|
|
2685
|
+
] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
|
|
2687
2686
|
products.push(...productsData);
|
|
2688
2687
|
return products;
|
|
2689
2688
|
});
|
|
@@ -2693,7 +2692,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
|
|
|
2693
2692
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2694
2693
|
if (!Number.isNaN(+id))
|
|
2695
2694
|
return id;
|
|
2696
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
2695
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
2697
2696
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
2698
2697
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
2699
2698
|
throw new NotFoundError(`Category with id ${id} not found`);
|
|
@@ -2957,7 +2956,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
2957
2956
|
var _a;
|
|
2958
2957
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2959
2958
|
const product = Number.isNaN(+identifiers.id)
|
|
2960
|
-
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2959
|
+
? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
|
|
2961
2960
|
: yield _super.get.call(this, identifiers);
|
|
2962
2961
|
if (product.productId)
|
|
2963
2962
|
throw new NotFoundError('Product not found, it is a variant');
|
|
@@ -3153,7 +3152,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3153
3152
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3154
3153
|
if (!Number.isNaN(+id))
|
|
3155
3154
|
return id;
|
|
3156
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3155
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3157
3156
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3158
3157
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3159
3158
|
throw new NotFoundError(`Product with id ${id} not found`);
|
|
@@ -3312,7 +3311,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
|
|
|
3312
3311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3313
3312
|
if (!Number.isNaN(+id))
|
|
3314
3313
|
return id;
|
|
3315
|
-
const { data } = yield this.find({ filters: { firestoreId: id } });
|
|
3314
|
+
const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
|
|
3316
3315
|
if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
|
|
3317
3316
|
return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
|
|
3318
3317
|
throw new NotFoundError(`Product with id ${id} not found`);
|