@infrab4a/connect 1.0.0-beta.20 → 1.0.0-beta.22
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 +68 -6
- package/bundles/infrab4a-connect.umd.js.map +1 -1
- package/domain/catalog/repositories/product.repository.d.ts +8 -1
- package/domain/generic/repository/types/repository-find-filters.type.d.ts +1 -1
- package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
- package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +1 -1
- package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +4 -4
- package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +2 -2
- package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +30 -2
- package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +2 -2
- package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +23 -3
- package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
- package/fesm2015/infrab4a-connect.js +54 -6
- package/fesm2015/infrab4a-connect.js.map +1 -1
- package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +3 -1
- package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +2 -1
- package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1755,7 +1755,7 @@
|
|
|
1755
1755
|
fromFirestore: function (snap) {
|
|
1756
1756
|
var data = snap.data();
|
|
1757
1757
|
Object.keys(data).forEach(function (key) {
|
|
1758
|
-
if (typeof data[key] === 'object' && '_seconds' in data[key]) {
|
|
1758
|
+
if (data[key] && typeof data[key] === 'object' && '_seconds' in data[key]) {
|
|
1759
1759
|
data[key] = data[key].toDate();
|
|
1760
1760
|
}
|
|
1761
1761
|
});
|
|
@@ -1861,14 +1861,14 @@
|
|
|
1861
1861
|
return _this;
|
|
1862
1862
|
}
|
|
1863
1863
|
FindFirestore.prototype.find = function (_a) {
|
|
1864
|
-
var filters =
|
|
1864
|
+
var _b = _a === void 0 ? {} : _a, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy;
|
|
1865
1865
|
return __awaiter(this, void 0, void 0, function () {
|
|
1866
1866
|
var query, docs, data;
|
|
1867
1867
|
return __generator(this, function (_a) {
|
|
1868
1868
|
switch (_a.label) {
|
|
1869
1869
|
case 0:
|
|
1870
|
-
query = this.collection(this.buildCollectionPathForFind(filters));
|
|
1871
|
-
query = this.makeFirestoreWhere(query, filters);
|
|
1870
|
+
query = this.collection(this.buildCollectionPathForFind(filters || {}));
|
|
1871
|
+
query = this.makeFirestoreWhere(query, filters || {});
|
|
1872
1872
|
Object.keys(orderBy || {}).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderBy[fieldName])); });
|
|
1873
1873
|
return [4 /*yield*/, this.defineLimits(query, filters, limits)];
|
|
1874
1874
|
case 1:
|
|
@@ -2445,6 +2445,7 @@
|
|
|
2445
2445
|
function ProductFirestoreRepository(firestore) {
|
|
2446
2446
|
var _this = _super.call(this) || this;
|
|
2447
2447
|
_this.firestore = firestore;
|
|
2448
|
+
_this.reviews = {};
|
|
2448
2449
|
_this.collectionName = 'products';
|
|
2449
2450
|
_this.model = Product;
|
|
2450
2451
|
return _this;
|
|
@@ -2468,6 +2469,41 @@
|
|
|
2468
2469
|
});
|
|
2469
2470
|
});
|
|
2470
2471
|
};
|
|
2472
|
+
ProductFirestoreRepository.prototype.fetchReviews = function (status) {
|
|
2473
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2474
|
+
var products;
|
|
2475
|
+
var _this = this;
|
|
2476
|
+
return __generator(this, function (_b) {
|
|
2477
|
+
switch (_b.label) {
|
|
2478
|
+
case 0: return [4 /*yield*/, this.find()];
|
|
2479
|
+
case 1:
|
|
2480
|
+
products = (_b.sent()).data;
|
|
2481
|
+
products.forEach(function (product) {
|
|
2482
|
+
var _a;
|
|
2483
|
+
if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
|
|
2484
|
+
return;
|
|
2485
|
+
var productInfo = {
|
|
2486
|
+
productId: product.id,
|
|
2487
|
+
productName: product.name,
|
|
2488
|
+
productSku: product.sku,
|
|
2489
|
+
};
|
|
2490
|
+
_this.reviews.pending = [];
|
|
2491
|
+
_this.reviews.approved = [];
|
|
2492
|
+
_this.reviews.rejected = [];
|
|
2493
|
+
product.reviews.forEach(function (review) {
|
|
2494
|
+
if ([null, undefined].includes(review.status))
|
|
2495
|
+
return _this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
|
|
2496
|
+
if (review.status === false)
|
|
2497
|
+
return _this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
|
|
2498
|
+
if (!!review.status)
|
|
2499
|
+
return _this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
|
|
2500
|
+
});
|
|
2501
|
+
});
|
|
2502
|
+
return [2 /*return*/, this.reviews[status]];
|
|
2503
|
+
}
|
|
2504
|
+
});
|
|
2505
|
+
});
|
|
2506
|
+
};
|
|
2471
2507
|
return ProductFirestoreRepository;
|
|
2472
2508
|
}(withCrudFirestore(withHelpers(withFirestore(Base)))));
|
|
2473
2509
|
|
|
@@ -3150,7 +3186,7 @@
|
|
|
3150
3186
|
var getValueByAction = function (options) {
|
|
3151
3187
|
if (options instanceof BaseModel)
|
|
3152
3188
|
return options.toPlain();
|
|
3153
|
-
if (lodash.isNil(options.action))
|
|
3189
|
+
if (lodash.isNil(options === null || options === void 0 ? void 0 : options.action))
|
|
3154
3190
|
return options;
|
|
3155
3191
|
if ([exports.UpdateOptionActions.REMOVE_FIELD.toString(), exports.UpdateOptionActions.NULL.toString()].includes(options.action))
|
|
3156
3192
|
return null;
|
|
@@ -3624,7 +3660,7 @@
|
|
|
3624
3660
|
authOptions: authOptions,
|
|
3625
3661
|
fields: [],
|
|
3626
3662
|
}) || this;
|
|
3627
|
-
_this.bindReviewToModel = function (plain) { return (Object.assign(Object.assign({}, lodash.omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])), { createdAt: plain.created_at, updatedAt: plain.updated_at, personId: plain.person_id, orderId: plain.order_id })); };
|
|
3663
|
+
_this.bindReviewToModel = function (plain) { return (Object.assign(Object.assign({}, lodash.omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id })); };
|
|
3628
3664
|
_this.bindReviewToHasura = function (review) { return (Object.assign(Object.assign({}, lodash.omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])), { person_id: review.personId, order_id: review.orderId })); };
|
|
3629
3665
|
var commonFields = [
|
|
3630
3666
|
{ id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
|
|
@@ -3883,6 +3919,32 @@
|
|
|
3883
3919
|
});
|
|
3884
3920
|
});
|
|
3885
3921
|
};
|
|
3922
|
+
ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
|
|
3923
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
3924
|
+
var reviews, data;
|
|
3925
|
+
var _c, _d;
|
|
3926
|
+
var _this = this;
|
|
3927
|
+
return __generator(this, function (_e) {
|
|
3928
|
+
switch (_e.label) {
|
|
3929
|
+
case 0:
|
|
3930
|
+
reviews = {
|
|
3931
|
+
status: status === 'pending'
|
|
3932
|
+
? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
|
|
3933
|
+
};
|
|
3934
|
+
return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
|
|
3935
|
+
where: { value: { reviews: reviews }, type: 'product_bool_exp', required: true },
|
|
3936
|
+
})];
|
|
3937
|
+
case 1:
|
|
3938
|
+
data = (_e.sent()).product;
|
|
3939
|
+
return [2 /*return*/, data.reduce(function (reviews, product) { return __spreadArray(__spreadArray([], __read(reviews)), __read(product.reviews
|
|
3940
|
+
.filter(function (review) { return (status === 'pending' && [undefined, null].includes(review.status)) ||
|
|
3941
|
+
(status === 'approved' && review.status === true) ||
|
|
3942
|
+
(status === 'rejected' && review.status === false); })
|
|
3943
|
+
.map(function (review) { return (Object.assign(Object.assign({}, _this.bindReviewToModel(review)), { productId: product.id, productName: product.name, productSku: product.sku })); }))); }, [])];
|
|
3944
|
+
}
|
|
3945
|
+
});
|
|
3946
|
+
});
|
|
3947
|
+
};
|
|
3886
3948
|
ProductHasuraGraphQLRepository.prototype.updateCategories = function (productId, _c) {
|
|
3887
3949
|
var categories = _c.categories;
|
|
3888
3950
|
return __awaiter(this, void 0, void 0, function () {
|