@infrab4a/connect 4.2.3 → 4.2.4-beta.1

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
@@ -4972,18 +4972,24 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4972
4972
  const plainData = this.paramsToPlain({ categories });
4973
4973
  if (!plainData.categories || plainData.categories.length <= 0)
4974
4974
  return [];
4975
+ const product = await this.get({ id: productId.toString() });
4975
4976
  await this.mutation('delete_category_product', ['affected_rows'], {
4976
4977
  where: {
4977
4978
  type: 'category_product_bool_exp',
4978
4979
  required: true,
4979
- value: { product_id: { _eq: productId } },
4980
+ value: {
4981
+ product_id: { _eq: productId },
4982
+ category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
4983
+ },
4980
4984
  },
4981
4985
  });
4982
4986
  await this.mutation('insert_category_product', ['affected_rows'], {
4983
4987
  objects: {
4984
4988
  type: '[category_product_insert_input!]',
4985
4989
  required: true,
4986
- value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4990
+ value: plainData.categories
4991
+ .filter((categoryId) => !product.categories.includes(categoryId))
4992
+ .map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4987
4993
  },
4988
4994
  });
4989
4995
  return plainData.categories;
@@ -5437,7 +5443,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5437
5443
  type: 'category_product_bool_exp',
5438
5444
  required: true,
5439
5445
  value: {
5440
- category_id: categoryId,
5446
+ category_id: { _eq: categoryId },
5441
5447
  product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
5442
5448
  },
5443
5449
  },
package/index.esm.js CHANGED
@@ -4966,18 +4966,24 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4966
4966
  const plainData = this.paramsToPlain({ categories });
4967
4967
  if (!plainData.categories || plainData.categories.length <= 0)
4968
4968
  return [];
4969
+ const product = await this.get({ id: productId.toString() });
4969
4970
  await this.mutation('delete_category_product', ['affected_rows'], {
4970
4971
  where: {
4971
4972
  type: 'category_product_bool_exp',
4972
4973
  required: true,
4973
- value: { product_id: { _eq: productId } },
4974
+ value: {
4975
+ product_id: { _eq: productId },
4976
+ category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
4977
+ },
4974
4978
  },
4975
4979
  });
4976
4980
  await this.mutation('insert_category_product', ['affected_rows'], {
4977
4981
  objects: {
4978
4982
  type: '[category_product_insert_input!]',
4979
4983
  required: true,
4980
- value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4984
+ value: plainData.categories
4985
+ .filter((categoryId) => !product.categories.includes(categoryId))
4986
+ .map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4981
4987
  },
4982
4988
  });
4983
4989
  return plainData.categories;
@@ -5431,7 +5437,7 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5431
5437
  type: 'category_product_bool_exp',
5432
5438
  required: true,
5433
5439
  value: {
5434
- category_id: categoryId,
5440
+ category_id: { _eq: categoryId },
5435
5441
  product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
5436
5442
  },
5437
5443
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.2.3",
3
+ "version": "4.2.4-beta.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },