@infrab4a/connect 4.26.0 → 4.27.0-beta.0

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
@@ -4922,7 +4922,8 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
4922
4922
  if (lodash.isNil(instance.identifier[identifierBinded]))
4923
4923
  return ids;
4924
4924
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
4925
- const value = columnOption.to(identifiers[identifier], instance);
4925
+ const value = (columnOption === null || columnOption === void 0 ? void 0 : columnOption.to(identifiers[identifier], instance)) ||
4926
+ identifiers[identifier];
4926
4927
  return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
4927
4928
  type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
4928
4929
  value,
@@ -6015,24 +6016,28 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
6015
6016
  cache,
6016
6017
  });
6017
6018
  }
6018
- async removeProductFromCategory(categoryId, productId) {
6019
+ async removeProductsFromCategory(categoryId, productIds) {
6019
6020
  await this.mutation('delete_category_product', ['affected_rows'], {
6020
6021
  where: {
6021
6022
  type: 'category_product_bool_exp',
6022
6023
  required: true,
6023
6024
  value: {
6024
- product_id: { _eq: productId },
6025
+ product_id: { _in: productIds },
6025
6026
  category_id: { _eq: categoryId },
6026
6027
  },
6027
6028
  },
6028
6029
  });
6029
6030
  }
6030
- async addProductToCategory(categoryId, productId) {
6031
+ async addProductsToCategory(categoryId, productIds) {
6031
6032
  await this.mutation('insert_category_product', ['affected_rows'], {
6032
6033
  objects: {
6033
6034
  type: '[category_product_insert_input!]',
6034
6035
  required: true,
6035
- value: [{ category_id: categoryId, product_id: productId }],
6036
+ value: productIds.map(({ productId, order }) => ({
6037
+ category_id: categoryId,
6038
+ product_id: productId,
6039
+ order,
6040
+ })),
6036
6041
  },
6037
6042
  });
6038
6043
  }
@@ -7403,10 +7408,17 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
7403
7408
  }
7404
7409
  }
7405
7410
  async addProduct(wishlistId, productId) {
7406
- return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
7411
+ await this.categoryProductRepository.create({
7412
+ categoryId: +wishlistId,
7413
+ productId: +productId,
7414
+ order: 0,
7415
+ });
7407
7416
  }
7408
7417
  async removeProduct(wishlistId, productId) {
7409
- return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
7418
+ return this.categoryProductRepository.delete({
7419
+ categoryId: +wishlistId,
7420
+ productId: +productId,
7421
+ });
7410
7422
  }
7411
7423
  }
7412
7424
  tslib.__decorate([
package/index.esm.js CHANGED
@@ -4897,7 +4897,8 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
4897
4897
  if (isNil(instance.identifier[identifierBinded]))
4898
4898
  return ids;
4899
4899
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
4900
- const value = columnOption.to(identifiers[identifier], instance);
4900
+ const value = (columnOption === null || columnOption === void 0 ? void 0 : columnOption.to(identifiers[identifier], instance)) ||
4901
+ identifiers[identifier];
4901
4902
  return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
4902
4903
  type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
4903
4904
  value,
@@ -5990,24 +5991,28 @@ class CategoryProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withH
5990
5991
  cache,
5991
5992
  });
5992
5993
  }
5993
- async removeProductFromCategory(categoryId, productId) {
5994
+ async removeProductsFromCategory(categoryId, productIds) {
5994
5995
  await this.mutation('delete_category_product', ['affected_rows'], {
5995
5996
  where: {
5996
5997
  type: 'category_product_bool_exp',
5997
5998
  required: true,
5998
5999
  value: {
5999
- product_id: { _eq: productId },
6000
+ product_id: { _in: productIds },
6000
6001
  category_id: { _eq: categoryId },
6001
6002
  },
6002
6003
  },
6003
6004
  });
6004
6005
  }
6005
- async addProductToCategory(categoryId, productId) {
6006
+ async addProductsToCategory(categoryId, productIds) {
6006
6007
  await this.mutation('insert_category_product', ['affected_rows'], {
6007
6008
  objects: {
6008
6009
  type: '[category_product_insert_input!]',
6009
6010
  required: true,
6010
- value: [{ category_id: categoryId, product_id: productId }],
6011
+ value: productIds.map(({ productId, order }) => ({
6012
+ category_id: categoryId,
6013
+ product_id: productId,
6014
+ order,
6015
+ })),
6011
6016
  },
6012
6017
  });
6013
6018
  }
@@ -7378,10 +7383,17 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
7378
7383
  }
7379
7384
  }
7380
7385
  async addProduct(wishlistId, productId) {
7381
- return this.categoryProductRepository.addProductToCategory(wishlistId, productId);
7386
+ await this.categoryProductRepository.create({
7387
+ categoryId: +wishlistId,
7388
+ productId: +productId,
7389
+ order: 0,
7390
+ });
7382
7391
  }
7383
7392
  async removeProduct(wishlistId, productId) {
7384
- return this.categoryProductRepository.removeProductFromCategory(wishlistId, productId);
7393
+ return this.categoryProductRepository.delete({
7394
+ categoryId: +wishlistId,
7395
+ productId: +productId,
7396
+ });
7385
7397
  }
7386
7398
  }
7387
7399
  __decorate([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.26.0",
3
+ "version": "4.27.0-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -1,6 +1,9 @@
1
1
  import { CrudRepository } from '../../generic/repository/crud.repository';
2
2
  import { CategoryProduct } from '../models';
3
3
  export interface CategoryProductRepository extends CrudRepository<CategoryProduct> {
4
- removeProductFromCategory(categoryId: string, productId: string): Promise<void>;
5
- addProductToCategory(categoryId: string, productId: string): Promise<void>;
4
+ removeProductsFromCategory(categoryId: string, productIds: string[]): Promise<void>;
5
+ addProductsToCategory(categoryId: string, productIds: {
6
+ productId: string;
7
+ order: number;
8
+ }[]): Promise<void>;
6
9
  }
@@ -5,7 +5,7 @@ import { FirestoreRepository, FirestoreSubRepository } from '../types';
5
5
  export declare const withHelpers: <TMixinBase extends MixinCtor<any, any[]> = MixinCtor<any, any[]>>(MixinBase: MixinCtor<any, any[]> & TMixinBase) => {
6
6
  new (...args: any[]): {
7
7
  [x: string]: any;
8
- toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T> | QueryDocumentSnapshot<T>[]): T[];
8
+ toArray<T extends ModelBaseStructure<T, T["identifiersFields"][number]>>(snapShot: QuerySnapshot<T, import("firebase/firestore").DocumentData> | QueryDocumentSnapshot<T, import("firebase/firestore").DocumentData>[]): T[];
9
9
  isSubCollection<T_1 extends ModelBaseStructure<T_1, T_1["identifiersFields"][number]>, E extends ModelBaseStructure<E, E["identifiersFields"][number]>>(repository: FirestoreRepository<T_1> | FirestoreSubRepository<T_1, E>): repository is FirestoreSubRepository<T_1, E>;
10
10
  };
11
11
  } & TMixinBase;
@@ -5,7 +5,10 @@ declare const CategoryProductHasuraGraphQLRepository_base: import("../../../../u
5
5
  }, [HasuraConstructorParams<CategoryProduct> & import("../../mixins").CreateConstructorParams & import("../../mixins").DeleteConstructorParams & import("../../mixins").GetConstructorParams & import("../../mixins").UpdateConstructorParams, ...any[]]>;
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
- removeProductFromCategory(categoryId: string, productId: string): Promise<void>;
9
- addProductToCategory(categoryId: string, productId: string): Promise<void>;
8
+ removeProductsFromCategory(categoryId: string, productIds: string[]): Promise<void>;
9
+ addProductsToCategory(categoryId: string, productIds: {
10
+ productId: string;
11
+ order: number;
12
+ }[]): Promise<void>;
10
13
  }
11
14
  export {};