@infrab4a/connect 2.0.9-beta.0 → 2.0.9
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 +19 -12
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +7 -5
- package/fesm2015/infrab4a-connect.js +7 -5
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/package.json +1 -1
|
@@ -1831,7 +1831,7 @@
|
|
|
1831
1831
|
return [3 /*break*/, 6];
|
|
1832
1832
|
case 4:
|
|
1833
1833
|
error_1 = _a.sent();
|
|
1834
|
-
console.
|
|
1834
|
+
console.error(error_1.message);
|
|
1835
1835
|
return [4 /*yield*/, this.adapter.save("products/_doc/" + product.id, product.toPlain())];
|
|
1836
1836
|
case 5:
|
|
1837
1837
|
_a.sent();
|
|
@@ -4114,27 +4114,32 @@
|
|
|
4114
4114
|
});
|
|
4115
4115
|
var _a;
|
|
4116
4116
|
return __awaiter(this, void 0, void 0, function () {
|
|
4117
|
-
var product, _c, _d;
|
|
4118
|
-
return __generator(this, function (
|
|
4119
|
-
switch (
|
|
4117
|
+
var product, _c, _d, _e;
|
|
4118
|
+
return __generator(this, function (_f) {
|
|
4119
|
+
switch (_f.label) {
|
|
4120
4120
|
case 0:
|
|
4121
4121
|
if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
|
|
4122
4122
|
return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
|
|
4123
4123
|
case 1:
|
|
4124
|
-
_c = (_a = (
|
|
4124
|
+
_c = (_a = (_f.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
|
|
4125
4125
|
return [3 /*break*/, 4];
|
|
4126
4126
|
case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
|
|
4127
4127
|
case 3:
|
|
4128
|
-
_c =
|
|
4129
|
-
|
|
4128
|
+
_c = _f.sent();
|
|
4129
|
+
_f.label = 4;
|
|
4130
4130
|
case 4:
|
|
4131
4131
|
product = _c;
|
|
4132
4132
|
if (product.productId)
|
|
4133
4133
|
throw new NotFoundError('Product not found, it is a variant');
|
|
4134
4134
|
_d = product;
|
|
4135
|
+
_e = product.reviews;
|
|
4136
|
+
if (_e) return [3 /*break*/, 6];
|
|
4135
4137
|
return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
|
|
4136
4138
|
case 5:
|
|
4137
|
-
|
|
4139
|
+
_e = (_f.sent());
|
|
4140
|
+
_f.label = 6;
|
|
4141
|
+
case 6:
|
|
4142
|
+
_d.reviews = _e;
|
|
4138
4143
|
return [2 /*return*/, product];
|
|
4139
4144
|
}
|
|
4140
4145
|
});
|
|
@@ -4149,7 +4154,9 @@
|
|
|
4149
4154
|
return __generator(this, function (_c) {
|
|
4150
4155
|
_a = params || {}, filters = _a.filters, fields = _a.fields, options = __rest(_a, ["filters", "fields"]);
|
|
4151
4156
|
bindFields = fields ||
|
|
4152
|
-
this.fields
|
|
4157
|
+
this.fields
|
|
4158
|
+
.map(function (field) { return (typeof field === 'string' ? field : Object.keys(field).shift()); })
|
|
4159
|
+
.filter(function (field) { return field !== 'reviews'; });
|
|
4153
4160
|
return [2 /*return*/, _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: exports.Where.ISNULL } }), fields: bindFields }))];
|
|
4154
4161
|
});
|
|
4155
4162
|
});
|
|
@@ -4228,18 +4235,18 @@
|
|
|
4228
4235
|
};
|
|
4229
4236
|
ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
|
|
4230
4237
|
return __awaiter(this, void 0, void 0, function () {
|
|
4231
|
-
var
|
|
4238
|
+
var reviewsExpression, data;
|
|
4232
4239
|
var _c, _d;
|
|
4233
4240
|
var _this = this;
|
|
4234
4241
|
return __generator(this, function (_e) {
|
|
4235
4242
|
switch (_e.label) {
|
|
4236
4243
|
case 0:
|
|
4237
|
-
|
|
4244
|
+
reviewsExpression = {
|
|
4238
4245
|
status: status === 'pending'
|
|
4239
4246
|
? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
|
|
4240
4247
|
};
|
|
4241
4248
|
return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
|
|
4242
|
-
where: { value: { reviews:
|
|
4249
|
+
where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
|
|
4243
4250
|
})];
|
|
4244
4251
|
case 1:
|
|
4245
4252
|
data = (_e.sent()).product;
|