@infrab4a/connect 4.3.2-beta.0 → 4.3.2-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
@@ -4503,6 +4503,28 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4503
4503
  .map((productId) => ({ category_id: categoryId, product_id: productId })),
4504
4504
  },
4505
4505
  });
4506
+ const productsOrder = products.map((product, index) => {
4507
+ return {
4508
+ id: product,
4509
+ order: index,
4510
+ };
4511
+ });
4512
+ const updateQueries = productsOrder.map((product) => ({
4513
+ where: {
4514
+ category_id: { _eq: category.id },
4515
+ product_id: { _eq: product.id },
4516
+ },
4517
+ _set: {
4518
+ order: product.order,
4519
+ },
4520
+ }));
4521
+ await this.mutation('update_category_product_many', ['affected_rows'], {
4522
+ updates: {
4523
+ value: updateQueries,
4524
+ type: '[category_product_updates!]',
4525
+ required: true,
4526
+ },
4527
+ });
4506
4528
  return plainData.products;
4507
4529
  }
4508
4530
  async updateMetadata(categoryId, { metadata }) {
package/index.esm.js CHANGED
@@ -4497,6 +4497,28 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4497
4497
  .map((productId) => ({ category_id: categoryId, product_id: productId })),
4498
4498
  },
4499
4499
  });
4500
+ const productsOrder = products.map((product, index) => {
4501
+ return {
4502
+ id: product,
4503
+ order: index,
4504
+ };
4505
+ });
4506
+ const updateQueries = productsOrder.map((product) => ({
4507
+ where: {
4508
+ category_id: { _eq: category.id },
4509
+ product_id: { _eq: product.id },
4510
+ },
4511
+ _set: {
4512
+ order: product.order,
4513
+ },
4514
+ }));
4515
+ await this.mutation('update_category_product_many', ['affected_rows'], {
4516
+ updates: {
4517
+ value: updateQueries,
4518
+ type: '[category_product_updates!]',
4519
+ required: true,
4520
+ },
4521
+ });
4500
4522
  return plainData.products;
4501
4523
  }
4502
4524
  async updateMetadata(categoryId, { metadata }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.3.2-beta.0",
3
+ "version": "4.3.2-beta.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -13,7 +13,7 @@
13
13
  "class-transformer": "^0.5.1",
14
14
  "date-fns": "^2.28.0",
15
15
  "debug": "^4.3.4",
16
- "firebase": "^9.23.0",
16
+ "firebase": "^9.9.0",
17
17
  "gql-query-builder": "3.7.0",
18
18
  "lodash": "^4.17.21",
19
19
  "reflect-metadata": "^0.1.13",