@infrab4a/connect 2.0.13-beta.0 → 3.0.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.
Files changed (40) hide show
  1. package/bundles/infrab4a-connect.umd.js +168 -290
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/models/product.d.ts +4 -8
  4. package/domain/catalog/models/types/index.d.ts +3 -2
  5. package/domain/catalog/models/types/product-metadata.type.d.ts +4 -0
  6. package/domain/catalog/models/types/shop-description.type.d.ts +7 -0
  7. package/domain/catalog/models/types/{shops-price.type.d.ts → shop-price.type.d.ts} +0 -4
  8. package/domain/catalog/models/variant.d.ts +2 -2
  9. package/domain/generic/repository/enums/where.enum.d.ts +0 -1
  10. package/esm2015/domain/catalog/models/product.js +1 -5
  11. package/esm2015/domain/catalog/models/types/index.js +4 -3
  12. package/esm2015/domain/catalog/models/types/product-metadata.type.js +2 -0
  13. package/esm2015/domain/catalog/models/types/shop-description.type.js +2 -0
  14. package/esm2015/domain/catalog/models/types/shop-price.type.js +2 -0
  15. package/esm2015/domain/catalog/models/variant.js +1 -1
  16. package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
  17. package/esm2015/domain/generic/repository/enums/where.enum.js +1 -2
  18. package/esm2015/domain/shop-settings/models/home.js +1 -1
  19. package/esm2015/infra/elasticsearch/indexes/products-index.js +2 -3
  20. package/esm2015/infra/firebase/firestore/models/user-search.js +7 -0
  21. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +4 -5
  22. package/esm2015/infra/firebase/firestore/repositories/users/index.js +7 -6
  23. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +6 -4
  24. package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +12 -0
  25. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +3 -63
  26. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +27 -54
  27. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +11 -14
  28. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
  29. package/fesm2015/infrab4a-connect.js +100 -181
  30. package/fesm2015/infrab4a-connect.js.map +1 -1
  31. package/infra/firebase/firestore/models/user-search.d.ts +9 -0
  32. package/infra/firebase/firestore/repositories/users/index.d.ts +6 -5
  33. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +3 -1
  34. package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +9 -0
  35. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -4
  36. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/domain/catalog/models/types/shops-description.type.d.ts +0 -7
  39. package/esm2015/domain/catalog/models/types/shops-description.type.js +0 -2
  40. package/esm2015/domain/catalog/models/types/shops-price.type.js +0 -2
@@ -36,7 +36,6 @@ class BaseModel {
36
36
  var Where;
37
37
  (function (Where) {
38
38
  Where["EQUALS"] = "==";
39
- Where["NOTEQUALS"] = "!=";
40
39
  Where["GT"] = ">";
41
40
  Where["GTE"] = ">=";
42
41
  Where["IN"] = "in";
@@ -779,10 +778,6 @@ class Product extends BaseModel {
779
778
  identifierFields() {
780
779
  return ['id'];
781
780
  }
782
- getInfoByShop(shop) {
783
- var _a, _b, _c, _d, _e, _f;
784
- return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
785
- }
786
781
  static get identifiersFields() {
787
782
  return ['id'];
788
783
  }
@@ -1116,7 +1111,6 @@ class ProductsIndex {
1116
1111
  'weight',
1117
1112
  'tags',
1118
1113
  'hasVariants',
1119
- 'type'
1120
1114
  ];
1121
1115
  const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
1122
1116
  bool: {
@@ -1160,7 +1154,7 @@ class ProductsIndex {
1160
1154
  yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
1161
1155
  }
1162
1156
  catch (error) {
1163
- console.error(error.message);
1157
+ console.info(error.message);
1164
1158
  yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
1165
1159
  }
1166
1160
  });
@@ -1429,26 +1423,6 @@ const withCrudFirestore = (MixinBase) => {
1429
1423
  };
1430
1424
  };
1431
1425
 
1432
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1433
- constructor(firestore) {
1434
- super();
1435
- this.firestore = firestore;
1436
- this.collectionName = 'leads';
1437
- this.model = Lead;
1438
- }
1439
- }
1440
-
1441
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1442
- constructor(firestore, parentRepository) {
1443
- super();
1444
- this.firestore = firestore;
1445
- this.parentRepository = parentRepository;
1446
- this.collectionName = 'editions';
1447
- this.parentIdField = 'subscriptionId';
1448
- this.model = Edition;
1449
- }
1450
- }
1451
-
1452
1426
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1453
1427
  constructor(firestore) {
1454
1428
  super();
@@ -1458,43 +1432,26 @@ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(with
1458
1432
  }
1459
1433
  }
1460
1434
 
1461
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1462
- constructor(firestore, parentRepository) {
1463
- super();
1464
- this.firestore = firestore;
1465
- this.parentRepository = parentRepository;
1466
- this.collectionName = 'payments';
1467
- this.parentIdField = 'subscriptionId';
1468
- this.model = SubscriptionPayment;
1469
- }
1470
- }
1471
-
1472
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1473
- constructor(firestore, parentRepository) {
1474
- super();
1475
- this.firestore = firestore;
1476
- this.parentRepository = parentRepository;
1477
- this.collectionName = 'address';
1478
- this.parentIdField = 'userId';
1479
- this.model = UserAddress;
1435
+ class UserSearch extends BaseModel {
1436
+ static get identifiersFields() {
1437
+ return ['id'];
1480
1438
  }
1481
1439
  }
1482
1440
 
1483
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1484
- constructor(firestore, parentRepository) {
1441
+ class UserSearchFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1442
+ constructor(firestore) {
1485
1443
  super();
1486
1444
  this.firestore = firestore;
1487
- this.parentRepository = parentRepository;
1488
- this.collectionName = 'CX';
1489
- this.parentIdField = 'userId';
1490
- this.model = BeautyProfile;
1445
+ this.collectionName = 'userSearch';
1446
+ this.model = UserSearch;
1491
1447
  }
1492
1448
  }
1493
1449
 
1494
1450
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1495
- constructor(firestore) {
1451
+ constructor(firestore, userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore)) {
1496
1452
  super();
1497
1453
  this.firestore = firestore;
1454
+ this.userSearchFirestoreRepository = userSearchFirestoreRepository;
1498
1455
  this.collectionName = 'users';
1499
1456
  this.model = User;
1500
1457
  }
@@ -1511,7 +1468,7 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1511
1468
  }
1512
1469
  checkIfExistsByField(field, value) {
1513
1470
  return __awaiter(this, void 0, void 0, function* () {
1514
- const result = yield this.find({ filters: { [field]: value } });
1471
+ const result = yield this.userSearchFirestoreRepository.find({ [field]: { operator: Where.EQUALS, value } });
1515
1472
  return result.count > 0;
1516
1473
  });
1517
1474
  }
@@ -1555,6 +1512,39 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1555
1512
  }
1556
1513
  }
1557
1514
 
1515
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1516
+ constructor(firestore, parentRepository) {
1517
+ super();
1518
+ this.firestore = firestore;
1519
+ this.parentRepository = parentRepository;
1520
+ this.collectionName = 'editions';
1521
+ this.parentIdField = 'subscriptionId';
1522
+ this.model = Edition;
1523
+ }
1524
+ }
1525
+
1526
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1527
+ constructor(firestore, parentRepository) {
1528
+ super();
1529
+ this.firestore = firestore;
1530
+ this.parentRepository = parentRepository;
1531
+ this.collectionName = 'CX';
1532
+ this.parentIdField = 'userId';
1533
+ this.model = BeautyProfile;
1534
+ }
1535
+ }
1536
+
1537
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1538
+ constructor(firestore, parentRepository) {
1539
+ super();
1540
+ this.firestore = firestore;
1541
+ this.parentRepository = parentRepository;
1542
+ this.collectionName = 'address';
1543
+ this.parentIdField = 'userId';
1544
+ this.model = UserAddress;
1545
+ }
1546
+ }
1547
+
1558
1548
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1559
1549
  constructor(firestore, parentRepository) {
1560
1550
  super();
@@ -1566,6 +1556,26 @@ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFir
1566
1556
  }
1567
1557
  }
1568
1558
 
1559
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1560
+ constructor(firestore, parentRepository) {
1561
+ super();
1562
+ this.firestore = firestore;
1563
+ this.parentRepository = parentRepository;
1564
+ this.collectionName = 'payments';
1565
+ this.parentIdField = 'subscriptionId';
1566
+ this.model = SubscriptionPayment;
1567
+ }
1568
+ }
1569
+
1570
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1571
+ constructor(firestore) {
1572
+ super();
1573
+ this.firestore = firestore;
1574
+ this.collectionName = 'leads';
1575
+ this.model = Lead;
1576
+ }
1577
+ }
1578
+
1569
1579
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1570
1580
  constructor(firestore) {
1571
1581
  super();
@@ -1612,12 +1622,11 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1612
1622
  throw new RequiredArgumentError(['Category products is empty']);
1613
1623
  const chunks = chunk(category.products, 10);
1614
1624
  const products = [];
1615
- const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
1616
1625
  for (const productIds of chunks) {
1617
1626
  if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
1618
1627
  break;
1619
1628
  let query = yield this.collection('productsErpVitrine')
1620
- .where(publishedField, '==', true)
1629
+ .where('published', '==', true)
1621
1630
  .where('id', 'in', productIds);
1622
1631
  if (options === null || options === void 0 ? void 0 : options.hasStock)
1623
1632
  query = query.where('stock.quantity', '>', 0);
@@ -2499,19 +2508,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2499
2508
  : _super.get.call(this, identifiers);
2500
2509
  });
2501
2510
  }
2502
- update(params) {
2503
- const _super = Object.create(null, {
2504
- update: { get: () => super.update }
2505
- });
2506
- return __awaiter(this, void 0, void 0, function* () {
2507
- const { products, id: checkId } = params, data = __rest(params, ["products", "id"]);
2508
- const plainData = this.paramsToPlain({ id: checkId });
2509
- const id = yield this.getId(plainData.id);
2510
- const category = yield _super.update.call(this, Object.assign({ id }, data));
2511
- category.products = products && (yield this.updateProducts(+id, { products }));
2512
- return category;
2513
- });
2514
- }
2515
2511
  getCategoryBySlug(slug, shop) {
2516
2512
  return __awaiter(this, void 0, void 0, function* () {
2517
2513
  if (!slug)
@@ -2558,7 +2554,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2558
2554
  'subscriberPrice',
2559
2555
  'stock',
2560
2556
  'published',
2561
- 'publishedGlam',
2562
2557
  'CEST',
2563
2558
  'EAN',
2564
2559
  'NCM',
@@ -2566,60 +2561,14 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2566
2561
  'costPrice',
2567
2562
  'hasVariants',
2568
2563
  'isKit',
2569
- 'shopAvailability',
2570
2564
  'sku',
2571
2565
  'rate',
2572
2566
  'tags',
2573
- 'type',
2574
- 'shoppingCount',
2575
2567
  ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
2576
2568
  products.push(...productsData);
2577
2569
  return products;
2578
2570
  });
2579
2571
  }
2580
- getId(id) {
2581
- var _a, _b;
2582
- return __awaiter(this, void 0, void 0, function* () {
2583
- if (!Number.isNaN(+id))
2584
- return id;
2585
- const { data } = yield this.find({ filters: { firestoreId: id } });
2586
- if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
2587
- return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
2588
- throw new NotFoundError(`Category with id ${id} not found`);
2589
- });
2590
- }
2591
- updateProducts(categoryId, { products }) {
2592
- return __awaiter(this, void 0, void 0, function* () {
2593
- if ('action' in products && products.action === 'remove') {
2594
- yield this.mutation('delete_category_product', ['affected_rows'], {
2595
- where: {
2596
- type: 'category_product_bool_exp',
2597
- required: true,
2598
- value: { category_id: { _eq: categoryId } },
2599
- },
2600
- });
2601
- return [];
2602
- }
2603
- const plainData = this.paramsToPlain({ products });
2604
- if (!plainData.products || plainData.products.length <= 0)
2605
- return [];
2606
- yield this.mutation('delete_category_product', ['affected_rows'], {
2607
- where: {
2608
- type: 'category_product_bool_exp',
2609
- required: true,
2610
- value: { category_id: { _eq: categoryId } },
2611
- },
2612
- });
2613
- yield this.mutation('insert_category_product', ['affected_rows'], {
2614
- objects: {
2615
- type: '[category_product_insert_input!]',
2616
- required: true,
2617
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
2618
- },
2619
- });
2620
- return plainData.products;
2621
- });
2622
- }
2623
2572
  }
2624
2573
 
2625
2574
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -2645,8 +2594,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2645
2594
  {
2646
2595
  description: {
2647
2596
  columnName: 'description',
2648
- from: (description) => Object.values(Shops).reduce((shops, shop) => (Object.assign(Object.assign({}, shops), { [shop]: { description } })), {}),
2649
- to: (value) => Object.values(value).shift().description,
2597
+ from: (description) => ({ description }),
2598
+ to: (value) => value.description,
2650
2599
  },
2651
2600
  },
2652
2601
  { hasVariants: { columnName: 'has_variants' } },
@@ -2656,12 +2605,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2656
2605
  {
2657
2606
  price: {
2658
2607
  columnName: 'price',
2659
- from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
2660
- price,
2661
- fullPrice: data.full_price,
2662
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
2663
- subscriberPrice: data.subscriber_price,
2664
- } })), {}),
2608
+ from: (price, data) => ({
2609
+ price,
2610
+ fullPrice: data.full_price,
2611
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
2612
+ subscriberPrice: data.subscriber_price,
2613
+ }),
2665
2614
  bindFindFilter: (sentence) => {
2666
2615
  const filters = Object.values(sentence).shift();
2667
2616
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
@@ -2670,19 +2619,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2670
2619
  subscriber_price: filters.subscriberPrice,
2671
2620
  }));
2672
2621
  },
2673
- bindPersistData: (value) => {
2674
- const priceData = Object.values(value).shift();
2675
- return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
2676
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
2677
- })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
2678
- },
2622
+ bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
2623
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
2624
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
2679
2625
  },
2680
2626
  },
2681
2627
  { fullPrice: { columnName: 'full_price' } },
2682
2628
  { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
2683
2629
  { subscriberPrice: { columnName: 'subscriber_price' } },
2684
2630
  'published',
2685
- { publishedGlam: { columnName: 'published_glam' } },
2686
2631
  'sku',
2687
2632
  {
2688
2633
  stock: {
@@ -2696,14 +2641,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2696
2641
  'video',
2697
2642
  'weight',
2698
2643
  'gender',
2699
- {
2700
- shopAvailability: {
2701
- columnName: 'shop_availabilities',
2702
- fields: ['shop'],
2703
- from: (shop) => (Array.isArray(shop) ? shop.map((row) => row.shop) : []),
2704
- bindPersistData: (shops) => ({ shop_availabilities: { data: shops.map((shop) => ({ shop })) } }),
2705
- },
2706
- },
2707
2644
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
2708
2645
  { isKit: { columnName: 'is_kit' } },
2709
2646
  { createdAt: { columnName: 'created_at' } },
@@ -2715,7 +2652,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2715
2652
  from: (value) => value.aggregate.avg.rate,
2716
2653
  },
2717
2654
  },
2718
- { shoppingCount: { columnName: 'shopping_count' } },
2719
2655
  ];
2720
2656
  this.fields = [
2721
2657
  ...commonFields,
@@ -2743,10 +2679,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2743
2679
  },
2744
2680
  },
2745
2681
  {
2746
- reviews: {
2747
- columnName: 'reviews',
2748
- foreignKeyColumn: { product_id: 'id' },
2749
- fields: this.reviewsFields,
2682
+ metadata: {
2683
+ columnName: 'metadata',
2684
+ fields: ['title', 'description'],
2685
+ bindPersistData: (value) => ({
2686
+ metadata: { data: value },
2687
+ }),
2750
2688
  },
2751
2689
  },
2752
2690
  ];
@@ -2796,7 +2734,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2796
2734
  : yield _super.get.call(this, identifiers);
2797
2735
  if (product.productId)
2798
2736
  throw new NotFoundError('Product not found, it is a variant');
2799
- product.reviews = product.reviews || (yield this.findReviewsByProduct(+product.id));
2737
+ product.reviews = yield this.findReviewsByProduct(+product.id);
2800
2738
  return product;
2801
2739
  });
2802
2740
  }
@@ -2805,12 +2743,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2805
2743
  find: { get: () => super.find }
2806
2744
  });
2807
2745
  return __awaiter(this, void 0, void 0, function* () {
2808
- const _a = params || {}, { filters, fields } = _a, options = __rest(_a, ["filters", "fields"]);
2809
- const bindFields = fields ||
2810
- this.fields
2811
- .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
2812
- .filter((field) => field !== 'reviews');
2813
- return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: bindFields }));
2746
+ const _a = params || {}, { filters } = _a, options = __rest(_a, ["filters"]);
2747
+ return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }) }));
2814
2748
  });
2815
2749
  }
2816
2750
  getBySlug(slug) {
@@ -2831,7 +2765,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2831
2765
  update: { get: () => super.update }
2832
2766
  });
2833
2767
  return __awaiter(this, void 0, void 0, function* () {
2834
- const { categories, kitProducts, reviews, id: checkId, shopAvailability, rate } = params, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "shopAvailability", "rate"]);
2768
+ const { categories, kitProducts, reviews, id: checkId, rate } = params, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "rate"]);
2835
2769
  const plainData = this.paramsToPlain({ id: checkId });
2836
2770
  const id = yield this.getId(plainData.id);
2837
2771
  const product = yield _super.update.call(this, Object.assign({ id }, data));
@@ -2843,13 +2777,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2843
2777
  }
2844
2778
  fetchReviews(status) {
2845
2779
  return __awaiter(this, void 0, void 0, function* () {
2846
- const reviewsExpression = {
2780
+ const reviews = {
2847
2781
  status: status === 'pending'
2848
2782
  ? { [HasuraGraphQLWhere.ISNULL]: true }
2849
2783
  : { [HasuraGraphQLWhere.EQUALS]: status === 'approved' },
2850
2784
  };
2851
2785
  const { product: data } = yield this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
2852
- where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
2786
+ where: { value: { reviews }, type: 'product_bool_exp', required: true },
2853
2787
  });
2854
2788
  return data.reduce((reviews, product) => [
2855
2789
  ...reviews,
@@ -2863,19 +2797,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2863
2797
  }
2864
2798
  updateCategories(productId, { categories }) {
2865
2799
  return __awaiter(this, void 0, void 0, function* () {
2866
- if ('action' in categories && categories.action === 'remove') {
2867
- yield this.mutation('delete_category_product', ['affected_rows'], {
2868
- where: {
2869
- type: 'category_product_bool_exp',
2870
- required: true,
2871
- value: { product_id: { _eq: productId } },
2872
- },
2873
- });
2874
- return [];
2875
- }
2876
2800
  const plainData = this.paramsToPlain({ categories });
2877
- if (!plainData.categories || plainData.categories.length <= 0)
2878
- return [];
2879
2801
  yield this.mutation('delete_category_product', ['affected_rows'], {
2880
2802
  where: {
2881
2803
  type: 'category_product_bool_exp',
@@ -2919,6 +2841,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2919
2841
  }
2920
2842
  updateReviews(productId, { reviews }) {
2921
2843
  return __awaiter(this, void 0, void 0, function* () {
2844
+ if (!reviews)
2845
+ return [];
2922
2846
  if ('action' in reviews && reviews.action === 'remove') {
2923
2847
  const reviewIds = yield Promise.all(reviews.value.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
2924
2848
  const review = yield this.findReview(reviewData, productId);
@@ -2930,8 +2854,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2930
2854
  return reviews.value.map((review, index) => !reviewIds[index] && review).filter(Boolean);
2931
2855
  }
2932
2856
  const plainData = this.paramsToPlain({ reviews });
2933
- if (!plainData.reviews || plainData.reviews.length <= 0)
2934
- return [];
2935
2857
  return Promise.all(plainData.reviews.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
2936
2858
  const review = yield this.findReview(reviewData, productId);
2937
2859
  if (review.id)
@@ -3043,12 +2965,12 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3043
2965
  {
3044
2966
  price: {
3045
2967
  columnName: 'price',
3046
- from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
3047
- price,
3048
- fullPrice: data.full_price,
3049
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
3050
- subscriberPrice: data.subscriber_price,
3051
- } })), {}),
2968
+ from: (price, data) => ({
2969
+ price,
2970
+ fullPrice: data.full_price,
2971
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
2972
+ subscriberPrice: data.subscriber_price,
2973
+ }),
3052
2974
  bindFindFilter: (sentence) => {
3053
2975
  const filters = Object.values(sentence).shift();
3054
2976
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
@@ -3057,12 +2979,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3057
2979
  subscriber_price: filters.subscriberPrice,
3058
2980
  }));
3059
2981
  },
3060
- bindPersistData: (value) => {
3061
- const priceData = Object.values(value).shift();
3062
- return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
3063
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
3064
- })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
3065
- },
2982
+ bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
2983
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
2984
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
3066
2985
  },
3067
2986
  },
3068
2987
  { fullPrice: { columnName: 'full_price' } },
@@ -3143,5 +3062,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3143
3062
  * Generated bundle index. Do not edit.
3144
3063
  */
3145
3064
 
3146
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3065
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserSearchFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3147
3066
  //# sourceMappingURL=infrab4a-connect.js.map