@infrab4a/connect 4.27.0-beta.0 → 4.27.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
@@ -6028,6 +6028,18 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
6028
6028
  },
6029
6029
  });
6030
6030
  }
6031
+ async removeProductFromCategories(productId, categoryIds) {
6032
+ await this.mutation('delete_category_product', ['affected_rows'], {
6033
+ where: {
6034
+ type: 'category_product_bool_exp',
6035
+ required: true,
6036
+ value: {
6037
+ product_id: { _eq: productId },
6038
+ category_id: { _in: categoryIds },
6039
+ },
6040
+ },
6041
+ });
6042
+ }
6031
6043
  async addProductsToCategory(categoryId, productIds) {
6032
6044
  await this.mutation('insert_category_product', ['affected_rows'], {
6033
6045
  objects: {
@@ -6039,6 +6051,29 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
6039
6051
  order,
6040
6052
  })),
6041
6053
  },
6054
+ on_conflict: {
6055
+ type: 'category_product_on_conflict',
6056
+ required: true,
6057
+ value: { constraint: 'category_product_pkey', update_columns: ['order'] },
6058
+ },
6059
+ });
6060
+ }
6061
+ async addProductToCategories(productId, categoryIds) {
6062
+ await this.mutation('insert_category_product', ['affected_rows'], {
6063
+ objects: {
6064
+ type: '[category_product_insert_input!]',
6065
+ required: true,
6066
+ value: categoryIds.map((categoryId) => ({
6067
+ category_id: categoryId,
6068
+ product_id: productId,
6069
+ order: 0,
6070
+ })),
6071
+ },
6072
+ on_conflict: {
6073
+ type: 'category_product_on_conflict',
6074
+ required: true,
6075
+ value: { constraint: 'category_product_pkey' },
6076
+ },
6042
6077
  });
6043
6078
  }
6044
6079
  }
package/index.esm.js CHANGED
@@ -6003,6 +6003,18 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
6003
6003
  },
6004
6004
  });
6005
6005
  }
6006
+ async removeProductFromCategories(productId, categoryIds) {
6007
+ await this.mutation('delete_category_product', ['affected_rows'], {
6008
+ where: {
6009
+ type: 'category_product_bool_exp',
6010
+ required: true,
6011
+ value: {
6012
+ product_id: { _eq: productId },
6013
+ category_id: { _in: categoryIds },
6014
+ },
6015
+ },
6016
+ });
6017
+ }
6006
6018
  async addProductsToCategory(categoryId, productIds) {
6007
6019
  await this.mutation('insert_category_product', ['affected_rows'], {
6008
6020
  objects: {
@@ -6014,6 +6026,29 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
6014
6026
  order,
6015
6027
  })),
6016
6028
  },
6029
+ on_conflict: {
6030
+ type: 'category_product_on_conflict',
6031
+ required: true,
6032
+ value: { constraint: 'category_product_pkey', update_columns: ['order'] },
6033
+ },
6034
+ });
6035
+ }
6036
+ async addProductToCategories(productId, categoryIds) {
6037
+ await this.mutation('insert_category_product', ['affected_rows'], {
6038
+ objects: {
6039
+ type: '[category_product_insert_input!]',
6040
+ required: true,
6041
+ value: categoryIds.map((categoryId) => ({
6042
+ category_id: categoryId,
6043
+ product_id: productId,
6044
+ order: 0,
6045
+ })),
6046
+ },
6047
+ on_conflict: {
6048
+ type: 'category_product_on_conflict',
6049
+ required: true,
6050
+ value: { constraint: 'category_product_pkey' },
6051
+ },
6017
6052
  });
6018
6053
  }
6019
6054
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.27.0-beta.0",
3
+ "version": "4.27.1",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -2,8 +2,10 @@ import { CrudRepository } from '../../generic/repository/crud.repository';
2
2
  import { CategoryProduct } from '../models';
3
3
  export interface CategoryProductRepository extends CrudRepository<CategoryProduct> {
4
4
  removeProductsFromCategory(categoryId: string, productIds: string[]): Promise<void>;
5
+ removeProductFromCategories(productId: string, categoryIds: string[]): Promise<void>;
5
6
  addProductsToCategory(categoryId: string, productIds: {
6
7
  productId: string;
7
8
  order: number;
8
9
  }[]): Promise<void>;
10
+ addProductToCategories(productId: string, categoryIds: string[]): Promise<void>;
9
11
  }
@@ -6,9 +6,11 @@ declare const CategoryProductHasuraGraphQLRepository_base: import("../../../../u
6
6
  export declare class CategoryProductHasuraGraphQLRepository extends CategoryProductHasuraGraphQLRepository_base implements CategoryProductRepository {
7
7
  constructor({ endpoint, authOptions, interceptors, cache, }: Pick<HasuraConstructorParams<CategoryProduct>, 'endpoint' | 'authOptions' | 'interceptors' | 'cache'>);
8
8
  removeProductsFromCategory(categoryId: string, productIds: string[]): Promise<void>;
9
+ removeProductFromCategories(productId: string, categoryIds: string[]): Promise<void>;
9
10
  addProductsToCategory(categoryId: string, productIds: {
10
11
  productId: string;
11
12
  order: number;
12
13
  }[]): Promise<void>;
14
+ addProductToCategories(productId: string, categoryIds: string[]): Promise<void>;
13
15
  }
14
16
  export {};