@infrab4a/connect 4.2.6 → 4.3.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
@@ -4316,8 +4316,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4316
4316
  fields: ['id', 'name', 'reference', 'slug'],
4317
4317
  },
4318
4318
  },
4319
- 'theme',
4320
- { bannerUrl: { columnName: 'banner_url' } },
4321
4319
  ],
4322
4320
  });
4323
4321
  this.productRepository = productRepository;
@@ -4457,24 +4455,18 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4457
4455
  const plainData = this.paramsToPlain({ products });
4458
4456
  if (!plainData.products || plainData.products.length <= 0)
4459
4457
  return [];
4460
- const category = await this.get({ id: categoryId.toString() });
4461
4458
  await this.mutation('delete_category_product', ['affected_rows'], {
4462
4459
  where: {
4463
4460
  type: 'category_product_bool_exp',
4464
4461
  required: true,
4465
- value: {
4466
- category_id: { _eq: categoryId },
4467
- product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
4468
- },
4462
+ value: { category_id: { _eq: categoryId } },
4469
4463
  },
4470
4464
  });
4471
4465
  await this.mutation('insert_category_product', ['affected_rows'], {
4472
4466
  objects: {
4473
4467
  type: '[category_product_insert_input!]',
4474
4468
  required: true,
4475
- value: plainData.products
4476
- .filter((productId) => !category.products.includes(productId))
4477
- .map((productId) => ({ category_id: categoryId, product_id: productId })),
4469
+ value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4478
4470
  },
4479
4471
  });
4480
4472
  return plainData.products;
@@ -4512,14 +4504,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4512
4504
  },
4513
4505
  })
4514
4506
  .then((res) => res.data);
4515
- const currentFiltersId = currentFilters.map((f) => f.filterId);
4507
+ const currentFiltersId = currentFilters.map((f) => f.id);
4516
4508
  const filtersUpdatedId = filters.value.map((f) => f.id);
4517
4509
  const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
4518
4510
  const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
4519
4511
  for (const filter of filterToBeDeleted) {
4520
4512
  const index = currentFilters.findIndex((f) => f.id == filter);
4521
- if (index != -1)
4513
+ if (index != -1) {
4522
4514
  currentFilters.splice(index, 1);
4515
+ }
4523
4516
  await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
4524
4517
  }
4525
4518
  for (const filter of filterToBeInserted) {
@@ -4974,24 +4967,18 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4974
4967
  const plainData = this.paramsToPlain({ categories });
4975
4968
  if (!plainData.categories || plainData.categories.length <= 0)
4976
4969
  return [];
4977
- const product = await this.get({ id: productId.toString() });
4978
4970
  await this.mutation('delete_category_product', ['affected_rows'], {
4979
4971
  where: {
4980
4972
  type: 'category_product_bool_exp',
4981
4973
  required: true,
4982
- value: {
4983
- product_id: { _eq: productId },
4984
- category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
4985
- },
4974
+ value: { product_id: { _eq: productId } },
4986
4975
  },
4987
4976
  });
4988
4977
  await this.mutation('insert_category_product', ['affected_rows'], {
4989
4978
  objects: {
4990
4979
  type: '[category_product_insert_input!]',
4991
4980
  required: true,
4992
- value: plainData.categories
4993
- .filter((categoryId) => !product.categories.includes(categoryId))
4994
- .map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4981
+ value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4995
4982
  },
4996
4983
  });
4997
4984
  return plainData.categories;
@@ -5362,8 +5349,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5362
5349
  { personId: { columnName: 'person_id' } },
5363
5350
  { personName: { columnName: 'person_name' } },
5364
5351
  { personPhoto: { columnName: 'person_photo' } },
5365
- 'theme',
5366
- { bannerUrl: { columnName: 'banner_url' } },
5367
5352
  ],
5368
5353
  });
5369
5354
  this.categoryFilterRepository = categoryFilterRepository;
@@ -5378,10 +5363,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5378
5363
  throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
5379
5364
  return data;
5380
5365
  }
5381
- async find(params) {
5382
- const { filters } = params, rest = tslib.__rest(params, ["filters"]);
5383
- return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: exports.Where.EQUALS, value: true } }) }));
5384
- }
5385
5366
  async update(params) {
5386
5367
  const { products, id: checkId, metadata, filters } = params, data = tslib.__rest(params, ["products", "id", "metadata", "filters"]);
5387
5368
  const plainData = this.paramsToPlain({ id: checkId });
@@ -5440,25 +5421,19 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5440
5421
  const plainData = this.paramsToPlain({ products });
5441
5422
  if (!plainData.products || plainData.products.length <= 0)
5442
5423
  return [];
5443
- const category = await this.get({ id: categoryId.toString() });
5444
- await this.categoryFilterRepository.deleteByCategory(categoryId);
5445
5424
  await this.mutation('delete_category_product', ['affected_rows'], {
5446
5425
  where: {
5447
5426
  type: 'category_product_bool_exp',
5448
5427
  required: true,
5449
- value: {
5450
- category_id: { _eq: categoryId },
5451
- product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
5452
- },
5428
+ value: { category_id: { _eq: categoryId } },
5453
5429
  },
5454
5430
  });
5431
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
5455
5432
  await this.mutation('insert_category_product', ['affected_rows'], {
5456
5433
  objects: {
5457
5434
  type: '[category_product_insert_input!]',
5458
5435
  required: true,
5459
- value: plainData.products
5460
- .filter((productId) => !category.products.includes(productId))
5461
- .map((productId) => ({ category_id: categoryId, product_id: productId })),
5436
+ value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
5462
5437
  },
5463
5438
  });
5464
5439
  return plainData.products;
package/index.esm.js CHANGED
@@ -4310,8 +4310,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4310
4310
  fields: ['id', 'name', 'reference', 'slug'],
4311
4311
  },
4312
4312
  },
4313
- 'theme',
4314
- { bannerUrl: { columnName: 'banner_url' } },
4315
4313
  ],
4316
4314
  });
4317
4315
  this.productRepository = productRepository;
@@ -4451,24 +4449,18 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4451
4449
  const plainData = this.paramsToPlain({ products });
4452
4450
  if (!plainData.products || plainData.products.length <= 0)
4453
4451
  return [];
4454
- const category = await this.get({ id: categoryId.toString() });
4455
4452
  await this.mutation('delete_category_product', ['affected_rows'], {
4456
4453
  where: {
4457
4454
  type: 'category_product_bool_exp',
4458
4455
  required: true,
4459
- value: {
4460
- category_id: { _eq: categoryId },
4461
- product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
4462
- },
4456
+ value: { category_id: { _eq: categoryId } },
4463
4457
  },
4464
4458
  });
4465
4459
  await this.mutation('insert_category_product', ['affected_rows'], {
4466
4460
  objects: {
4467
4461
  type: '[category_product_insert_input!]',
4468
4462
  required: true,
4469
- value: plainData.products
4470
- .filter((productId) => !category.products.includes(productId))
4471
- .map((productId) => ({ category_id: categoryId, product_id: productId })),
4463
+ value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4472
4464
  },
4473
4465
  });
4474
4466
  return plainData.products;
@@ -4506,14 +4498,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
4506
4498
  },
4507
4499
  })
4508
4500
  .then((res) => res.data);
4509
- const currentFiltersId = currentFilters.map((f) => f.filterId);
4501
+ const currentFiltersId = currentFilters.map((f) => f.id);
4510
4502
  const filtersUpdatedId = filters.value.map((f) => f.id);
4511
4503
  const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
4512
4504
  const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
4513
4505
  for (const filter of filterToBeDeleted) {
4514
4506
  const index = currentFilters.findIndex((f) => f.id == filter);
4515
- if (index != -1)
4507
+ if (index != -1) {
4516
4508
  currentFilters.splice(index, 1);
4509
+ }
4517
4510
  await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
4518
4511
  }
4519
4512
  for (const filter of filterToBeInserted) {
@@ -4968,24 +4961,18 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4968
4961
  const plainData = this.paramsToPlain({ categories });
4969
4962
  if (!plainData.categories || plainData.categories.length <= 0)
4970
4963
  return [];
4971
- const product = await this.get({ id: productId.toString() });
4972
4964
  await this.mutation('delete_category_product', ['affected_rows'], {
4973
4965
  where: {
4974
4966
  type: 'category_product_bool_exp',
4975
4967
  required: true,
4976
- value: {
4977
- product_id: { _eq: productId },
4978
- category_id: { _in: product.categories.filter((categoryId) => !plainData.categories.includes(categoryId)) },
4979
- },
4968
+ value: { product_id: { _eq: productId } },
4980
4969
  },
4981
4970
  });
4982
4971
  await this.mutation('insert_category_product', ['affected_rows'], {
4983
4972
  objects: {
4984
4973
  type: '[category_product_insert_input!]',
4985
4974
  required: true,
4986
- value: plainData.categories
4987
- .filter((categoryId) => !product.categories.includes(categoryId))
4988
- .map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4975
+ value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4989
4976
  },
4990
4977
  });
4991
4978
  return plainData.categories;
@@ -5356,8 +5343,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5356
5343
  { personId: { columnName: 'person_id' } },
5357
5344
  { personName: { columnName: 'person_name' } },
5358
5345
  { personPhoto: { columnName: 'person_photo' } },
5359
- 'theme',
5360
- { bannerUrl: { columnName: 'banner_url' } },
5361
5346
  ],
5362
5347
  });
5363
5348
  this.categoryFilterRepository = categoryFilterRepository;
@@ -5372,10 +5357,6 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5372
5357
  throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
5373
5358
  return data;
5374
5359
  }
5375
- async find(params) {
5376
- const { filters } = params, rest = __rest(params, ["filters"]);
5377
- return await super.find(Object.assign(Object.assign({}, rest), { filters: Object.assign(Object.assign({}, filters), { isWishlist: { operator: Where.EQUALS, value: true } }) }));
5378
- }
5379
5360
  async update(params) {
5380
5361
  const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
5381
5362
  const plainData = this.paramsToPlain({ id: checkId });
@@ -5434,25 +5415,19 @@ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
5434
5415
  const plainData = this.paramsToPlain({ products });
5435
5416
  if (!plainData.products || plainData.products.length <= 0)
5436
5417
  return [];
5437
- const category = await this.get({ id: categoryId.toString() });
5438
- await this.categoryFilterRepository.deleteByCategory(categoryId);
5439
5418
  await this.mutation('delete_category_product', ['affected_rows'], {
5440
5419
  where: {
5441
5420
  type: 'category_product_bool_exp',
5442
5421
  required: true,
5443
- value: {
5444
- category_id: { _eq: categoryId },
5445
- product_id: { _in: category.products.filter((productId) => !plainData.products.includes(productId)) },
5446
- },
5422
+ value: { category_id: { _eq: categoryId } },
5447
5423
  },
5448
5424
  });
5425
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
5449
5426
  await this.mutation('insert_category_product', ['affected_rows'], {
5450
5427
  objects: {
5451
5428
  type: '[category_product_insert_input!]',
5452
5429
  required: true,
5453
- value: plainData.products
5454
- .filter((productId) => !category.products.includes(productId))
5455
- .map((productId) => ({ category_id: categoryId, product_id: productId })),
5430
+ value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
5456
5431
  },
5457
5432
  });
5458
5433
  return plainData.products;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infrab4a/connect",
3
- "version": "4.2.6",
3
+ "version": "4.3.0-beta.0",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org"
6
6
  },
@@ -24,8 +24,6 @@ export declare class CategoryBase<ChildCategory extends ModelBaseStructure<Child
24
24
  isWishlist?: boolean;
25
25
  reference?: string;
26
26
  parentId?: number;
27
- theme?: string;
28
- bannerUrl?: string;
29
27
  parent?: CategoryBase;
30
28
  filters?: Filter[];
31
29
  static get identifiersFields(): GenericIdentifier[];
@@ -1,4 +1,4 @@
1
- import { Category, CreateRepositoryParams, FindRepositoryParams, GetRepositoryParams, Product, RepositoryFindResult, Shops, UpdateRepositoryParams, Wishlist, WishlistRepository } from '../../../../domain';
1
+ import { Category, CreateRepositoryParams, GetRepositoryParams, Product, Shops, UpdateRepositoryParams, Wishlist, WishlistRepository } from '../../../../domain';
2
2
  import { HasuraConstructorParams } from '../../mixins';
3
3
  import { CategoryFilterHasuraGraphQLRepository } from './category-filter-hasura-graphql.repository';
4
4
  declare const WishlistHasuraGraphQLRepository_base: import("../../../../utils").MixinCtor<import("../..").GraphQLRepository<Wishlist> & import("../../../../domain").CrudRepository<Wishlist, import("../../../../domain").CrudParams<Wishlist>> & import("../../../../domain").UpdateRepository<Wishlist, import("../../../../domain").RepositoryUpdateParams<Wishlist>> & {
@@ -9,7 +9,6 @@ export declare class WishlistHasuraGraphQLRepository extends WishlistHasuraGraph
9
9
  constructor({ endpoint, authOptions, interceptors, }: Pick<HasuraConstructorParams<Wishlist>, 'endpoint' | 'authOptions' | 'interceptors'>, categoryFilterRepository: CategoryFilterHasuraGraphQLRepository);
10
10
  create(params: CreateRepositoryParams<Wishlist>): Promise<Wishlist>;
11
11
  get(identifiers: GetRepositoryParams<Wishlist>): Promise<Wishlist>;
12
- find(params?: FindRepositoryParams<Wishlist>): Promise<RepositoryFindResult<Wishlist>>;
13
12
  update(params: UpdateRepositoryParams<Wishlist>): Promise<Wishlist>;
14
13
  getWishlistBySlug(slug: string): Promise<Wishlist>;
15
14
  getWishlistByPerson(personId: string): Promise<Wishlist[]>;