@infrab4a/connect 1.0.0-beta.21 → 1.0.0-beta.23

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.
@@ -1114,7 +1114,7 @@ const withFirestore = (MixinBase) => {
1114
1114
  fromFirestore: (snap) => {
1115
1115
  const data = snap.data();
1116
1116
  Object.keys(data).forEach((key) => {
1117
- if (typeof data[key] === 'object' && '_seconds' in data[key]) {
1117
+ if (data[key] && typeof data[key] === 'object' && '_seconds' in data[key]) {
1118
1118
  data[key] = data[key].toDate();
1119
1119
  }
1120
1120
  });
@@ -1199,10 +1199,10 @@ const withFindFirestore = (MixinBase) => {
1199
1199
  return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1200
1200
  };
1201
1201
  }
1202
- find({ filters, limits, orderBy, }) {
1202
+ find({ filters, limits, orderBy, } = {}) {
1203
1203
  return __awaiter(this, void 0, void 0, function* () {
1204
- let query = this.collection(this.buildCollectionPathForFind(filters));
1205
- query = this.makeFirestoreWhere(query, filters);
1204
+ let query = this.collection(this.buildCollectionPathForFind(filters || {}));
1205
+ query = this.makeFirestoreWhere(query, filters || {});
1206
1206
  Object.keys(orderBy || {}).forEach((fieldName) => (query = query.orderBy(fieldName, orderBy[fieldName])));
1207
1207
  query = yield this.defineLimits(query, filters, limits);
1208
1208
  const docs = yield query.get();
@@ -1551,7 +1551,9 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1551
1551
  for (const productIds of chunks) {
1552
1552
  if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
1553
1553
  break;
1554
- let query = yield this.collection('products').where(publishedField, '==', true).where('id', 'in', productIds);
1554
+ let query = yield this.collection('productsErpVitrine')
1555
+ .where(publishedField, '==', true)
1556
+ .where('id', 'in', productIds);
1555
1557
  if (options === null || options === void 0 ? void 0 : options.hasStock)
1556
1558
  query = query.where('stock.quantity', '>', 0);
1557
1559
  if (options === null || options === void 0 ? void 0 : options.limit)
@@ -1571,7 +1573,7 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
1571
1573
  super();
1572
1574
  this.firestore = firestore;
1573
1575
  this.reviews = {};
1574
- this.collectionName = 'products';
1576
+ this.collectionName = 'productsErpVitrine';
1575
1577
  this.model = Product;
1576
1578
  }
1577
1579
  getBySlug(slug, shop) {
@@ -2714,6 +2716,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2714
2716
  }
2715
2717
  updateReviews(productId, { reviews }) {
2716
2718
  return __awaiter(this, void 0, void 0, function* () {
2719
+ if (!reviews)
2720
+ return [];
2717
2721
  if ('action' in reviews && reviews.action === 'remove') {
2718
2722
  const reviewIds = yield Promise.all(reviews.value.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
2719
2723
  const review = yield this.findReview(reviewData, productId);
@@ -2844,15 +2848,17 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2844
2848
  } })), {}),
2845
2849
  bindFindFilter: (sentence) => {
2846
2850
  const filters = Object.values(sentence).shift();
2847
- return Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.price) && { price: filters.price })), (filters.fullPrice && { full_price: filters.fullPrice })), (filters.subscriberDiscountPercentage && {
2851
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
2848
2852
  subscriber_discount_percentage: filters.subscriberDiscountPercentage,
2849
- })), (filters.subscriberPrice && { subscriber_price: filters.subscriberPrice }));
2853
+ })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
2854
+ subscriber_price: filters.subscriberPrice,
2855
+ }));
2850
2856
  },
2851
- bindPersistData: (value, instance) => {
2857
+ bindPersistData: (value) => {
2852
2858
  const priceData = Object.values(value).shift();
2853
- return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) && { price: priceData.price })), (priceData.fullPrice && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage && {
2859
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
2854
2860
  subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
2855
- })), (priceData.subscriberPrice && { subscriber_price: priceData.subscriberPrice }));
2861
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
2856
2862
  },
2857
2863
  },
2858
2864
  },