@infrab4a/connect 4.16.1-beta.2 → 4.16.1-beta.4

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/index.cjs.js CHANGED
@@ -4932,7 +4932,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4932
4932
  }).then(({ data }) => data)));
4933
4933
  if (categoriesHasura.length)
4934
4934
  categories.push(...(await this.find({
4935
- filters: { id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
4935
+ filters: {
4936
+ id: { operator: exports.Where.IN, value: categoriesHasura.filter(Boolean) },
4937
+ published: true,
4938
+ },
4936
4939
  }).then(({ data }) => data)));
4937
4940
  if (!categories.length)
4938
4941
  return [];
@@ -4947,7 +4950,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4947
4950
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
4948
4951
  return [];
4949
4952
  const mostRelevants = category.getMostRelevantByShop(shop);
4950
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))].slice(0, options.limit);
4953
+ const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4951
4954
  const products = [];
4952
4955
  const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign({ id: { operator: exports.Where.IN, value: mostRelevantProductsIds }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
4953
4956
  'id',
@@ -4975,7 +4978,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4975
4978
  'shoppingCount',
4976
4979
  'gender',
4977
4980
  'createdAt',
4978
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4981
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false }, orderBy: {
4982
+ shoppingCount: 'desc',
4983
+ rate: 'desc',
4984
+ stock: 'desc',
4985
+ name: 'asc',
4986
+ } }));
4979
4987
  products.push(...productsData.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id)));
4980
4988
  return products;
4981
4989
  }
package/index.esm.js CHANGED
@@ -4926,7 +4926,10 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4926
4926
  }).then(({ data }) => data)));
4927
4927
  if (categoriesHasura.length)
4928
4928
  categories.push(...(await this.find({
4929
- filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
4929
+ filters: {
4930
+ id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) },
4931
+ published: true,
4932
+ },
4930
4933
  }).then(({ data }) => data)));
4931
4934
  if (!categories.length)
4932
4935
  return [];
@@ -4941,7 +4944,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4941
4944
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
4942
4945
  return [];
4943
4946
  const mostRelevants = category.getMostRelevantByShop(shop);
4944
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))].slice(0, options.limit);
4947
+ const mostRelevantProductsIds = [...new Set(mostRelevants.concat(category.products))];
4945
4948
  const products = [];
4946
4949
  const { data: productsData } = await this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: mostRelevantProductsIds }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
4947
4950
  'id',
@@ -4969,7 +4972,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4969
4972
  'shoppingCount',
4970
4973
  'gender',
4971
4974
  'createdAt',
4972
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
4975
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false }, orderBy: {
4976
+ shoppingCount: 'desc',
4977
+ rate: 'desc',
4978
+ stock: 'desc',
4979
+ name: 'asc',
4980
+ } }));
4973
4981
  products.push(...productsData.sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id)));
4974
4982
  return products;
4975
4983
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.16.1-beta.2",
3
+ "version": "4.16.1-beta.4",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },