@infrab4a/connect 3.4.0-beta.9 → 3.4.3-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 (67) hide show
  1. package/bundles/infrab4a-connect.umd.js +276 -565
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/models/category.d.ts +2 -3
  4. package/domain/catalog/models/index.d.ts +0 -3
  5. package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
  6. package/domain/catalog/models/types/index.d.ts +1 -0
  7. package/domain/catalog/repositories/index.d.ts +0 -3
  8. package/domain/generic/repository/find.repository.d.ts +3 -0
  9. package/domain/shopping/models/campaign-dashboard.d.ts +15 -0
  10. package/domain/shopping/models/campaign-hashtag.d.ts +18 -0
  11. package/domain/shopping/models/index.d.ts +5 -4
  12. package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +4 -0
  13. package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +4 -0
  14. package/domain/shopping/repositories/index.d.ts +4 -2
  15. package/esm2015/domain/catalog/models/category.js +1 -8
  16. package/esm2015/domain/catalog/models/index.js +1 -4
  17. package/esm2015/domain/catalog/models/types/category-filter.type.js +2 -0
  18. package/esm2015/domain/catalog/models/types/index.js +2 -1
  19. package/esm2015/domain/catalog/repositories/index.js +1 -4
  20. package/esm2015/domain/generic/repository/find.repository.js +1 -1
  21. package/esm2015/domain/shopping/models/campaign-dashboard.js +7 -0
  22. package/esm2015/domain/shopping/models/campaign-hashtag.js +7 -0
  23. package/esm2015/domain/shopping/models/index.js +6 -5
  24. package/esm2015/domain/shopping/repositories/campaign-dashboard.repository.js +2 -0
  25. package/esm2015/domain/shopping/repositories/campaign-hashtag.repository.js +2 -0
  26. package/esm2015/domain/shopping/repositories/index.js +5 -3
  27. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +5 -3
  28. package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.js +12 -0
  29. package/esm2015/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.js +12 -0
  30. package/esm2015/infra/firebase/firestore/repositories/shopping/index.js +6 -4
  31. package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +2 -2
  32. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +17 -12
  33. package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +5 -5
  34. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +12 -84
  35. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +1 -4
  36. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +7 -4
  37. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +2 -2
  38. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +1 -1
  39. package/fesm2015/infrab4a-connect.js +118 -331
  40. package/fesm2015/infrab4a-connect.js.map +1 -1
  41. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
  42. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +9 -0
  43. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +9 -0
  44. package/infra/firebase/firestore/repositories/shopping/index.d.ts +5 -3
  45. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +4 -9
  46. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +1 -4
  47. package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -3
  48. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
  49. package/package.json +2 -2
  50. package/domain/catalog/models/category-filter.d.ts +0 -8
  51. package/domain/catalog/models/filter-option.d.ts +0 -10
  52. package/domain/catalog/models/filter.d.ts +0 -13
  53. package/domain/catalog/repositories/category-filter.repository.d.ts +0 -4
  54. package/domain/catalog/repositories/filter-option.repository.d.ts +0 -4
  55. package/domain/catalog/repositories/filter.repository.d.ts +0 -4
  56. package/esm2015/domain/catalog/models/category-filter.js +0 -10
  57. package/esm2015/domain/catalog/models/filter-option.js +0 -10
  58. package/esm2015/domain/catalog/models/filter.js +0 -10
  59. package/esm2015/domain/catalog/repositories/category-filter.repository.js +0 -2
  60. package/esm2015/domain/catalog/repositories/filter-option.repository.js +0 -2
  61. package/esm2015/domain/catalog/repositories/filter.repository.js +0 -2
  62. package/esm2015/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.js +0 -15
  63. package/esm2015/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.js +0 -123
  64. package/esm2015/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.js +0 -21
  65. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -10
  66. package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +0 -18
  67. package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +0 -10
@@ -9,7 +9,6 @@ import { CustomError } from 'ts-custom-error';
9
9
  import axios from 'axios';
10
10
  import firebase from 'firebase';
11
11
  import { mutation, query } from 'gql-query-builder';
12
- import fetch from 'node-fetch';
13
12
 
14
13
  class BaseModel {
15
14
  get identifier() {
@@ -751,15 +750,6 @@ class RecoveryPassword {
751
750
  }
752
751
  }
753
752
 
754
- class Filter extends BaseModel {
755
- identifierFields() {
756
- return ['id'];
757
- }
758
- static get identifiersFields() {
759
- return ['id'];
760
- }
761
- }
762
-
763
753
  class Category extends BaseModel {
764
754
  identifierFields() {
765
755
  return ['id'];
@@ -767,19 +757,6 @@ class Category extends BaseModel {
767
757
  static get identifiersFields() {
768
758
  return ['id'];
769
759
  }
770
- }
771
- __decorate([
772
- Type(() => Filter),
773
- __metadata("design:type", Array)
774
- ], Category.prototype, "filters", void 0);
775
-
776
- class CategoryFilter extends BaseModel {
777
- identifierFields() {
778
- return ['id'];
779
- }
780
- static get identifiersFields() {
781
- return ['id'];
782
- }
783
760
  }
784
761
 
785
762
  var GenderDestination;
@@ -797,15 +774,6 @@ var Shops;
797
774
  Shops["ALL"] = "ALL";
798
775
  })(Shops || (Shops = {}));
799
776
 
800
- class FilterOption extends BaseModel {
801
- identifierFields() {
802
- return ['id'];
803
- }
804
- static get identifiersFields() {
805
- return ['id'];
806
- }
807
- }
808
-
809
777
  class Product extends BaseModel {
810
778
  identifierFields() {
811
779
  return ['id'];
@@ -842,17 +810,27 @@ class Variant extends BaseModel {
842
810
  }
843
811
  }
844
812
 
845
- var OrderStatus;
846
- (function (OrderStatus) {
847
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
848
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
849
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
850
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
851
- OrderStatus["ENVIADO"] = "Enviado";
852
- OrderStatus["ENTREGUE"] = "Entregue";
853
- OrderStatus["CANCELADO"] = "Cancelado";
854
- OrderStatus["CREDIT_CARD"] = "credit_card";
855
- })(OrderStatus || (OrderStatus = {}));
813
+ class Buy2Win extends BaseModel {
814
+ static get identifiersFields() {
815
+ return ['id'];
816
+ }
817
+ }
818
+ __decorate([
819
+ Type(() => Category),
820
+ __metadata("design:type", Array)
821
+ ], Buy2Win.prototype, "categories", void 0);
822
+
823
+ class CampaignDashboard extends BaseModel {
824
+ static get identifiersFields() {
825
+ return ['id'];
826
+ }
827
+ }
828
+
829
+ class CampaignHashtag extends BaseModel {
830
+ static get identifiersFields() {
831
+ return ['id'];
832
+ }
833
+ }
856
834
 
857
835
  class LineItem extends Product {
858
836
  }
@@ -893,6 +871,18 @@ __decorate([
893
871
  __metadata("design:type", Coupon)
894
872
  ], Checkout.prototype, "coupon", void 0);
895
873
 
874
+ var OrderStatus;
875
+ (function (OrderStatus) {
876
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
877
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
878
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
879
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
880
+ OrderStatus["ENVIADO"] = "Enviado";
881
+ OrderStatus["ENTREGUE"] = "Entregue";
882
+ OrderStatus["CANCELADO"] = "Cancelado";
883
+ OrderStatus["CREDIT_CARD"] = "credit_card";
884
+ })(OrderStatus || (OrderStatus = {}));
885
+
896
886
  class Order extends Checkout {
897
887
  }
898
888
  __decorate([
@@ -922,16 +912,6 @@ __decorate([
922
912
  __metadata("design:type", Coupon)
923
913
  ], CheckoutSubscription.prototype, "coupon", void 0);
924
914
 
925
- class Buy2Win extends BaseModel {
926
- static get identifiersFields() {
927
- return ['id'];
928
- }
929
- }
930
- __decorate([
931
- Type(() => Category),
932
- __metadata("design:type", Array)
933
- ], Buy2Win.prototype, "categories", void 0);
934
-
935
915
  var FilterType;
936
916
  (function (FilterType) {
937
917
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -1340,9 +1320,11 @@ const withFindFirestore = (MixinBase) => {
1340
1320
  return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1341
1321
  };
1342
1322
  }
1343
- find({ filters, limits, orderBy, } = {}) {
1323
+ find({ filters, limits, orderBy, options } = {}) {
1324
+ var _a;
1344
1325
  return __awaiter(this, void 0, void 0, function* () {
1345
1326
  const orderByKeys = Object.keys(orderBy || {});
1327
+ const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
1346
1328
  let query = this.collection(this.buildCollectionPathForFind(filters || {}));
1347
1329
  query = this.makeFirestoreWhere(query, filters || {});
1348
1330
  if (orderByKeys.length) {
@@ -1356,7 +1338,7 @@ const withFindFirestore = (MixinBase) => {
1356
1338
  const data = docs.docs.map((doc) => doc.data());
1357
1339
  return {
1358
1340
  data,
1359
- count: this.calculateCount(data, limits),
1341
+ count: enableCount ? this.calculateCount(data, limits) : Infinity,
1360
1342
  };
1361
1343
  });
1362
1344
  }
@@ -1766,6 +1748,33 @@ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpe
1766
1748
  }
1767
1749
  }
1768
1750
 
1751
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1752
+ constructor(firestore) {
1753
+ super();
1754
+ this.firestore = firestore;
1755
+ this.collectionName = 'buy2win';
1756
+ this.model = Buy2Win;
1757
+ }
1758
+ }
1759
+
1760
+ class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1761
+ constructor(firestore) {
1762
+ super();
1763
+ this.firestore = firestore;
1764
+ this.collectionName = 'dashboardCampaignsAuto';
1765
+ this.model = CampaignDashboard;
1766
+ }
1767
+ }
1768
+
1769
+ class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1770
+ constructor(firestore) {
1771
+ super();
1772
+ this.firestore = firestore;
1773
+ this.collectionName = 'hashtagCampaignsAuto';
1774
+ this.model = CampaignHashtag;
1775
+ }
1776
+ }
1777
+
1769
1778
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1770
1779
  constructor(firestore) {
1771
1780
  super();
@@ -1775,6 +1784,15 @@ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1775
1784
  }
1776
1785
  }
1777
1786
 
1787
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1788
+ constructor(firestore) {
1789
+ super();
1790
+ this.firestore = firestore;
1791
+ this.collectionName = 'checkoutsSubscription';
1792
+ this.model = CheckoutSubscription;
1793
+ }
1794
+ }
1795
+
1778
1796
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1779
1797
  constructor(firestore) {
1780
1798
  super();
@@ -1837,21 +1855,20 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1837
1855
  }
1838
1856
  }
1839
1857
 
1840
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1858
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1841
1859
  constructor(firestore) {
1842
- super();
1860
+ super(firestore);
1843
1861
  this.firestore = firestore;
1844
- this.collectionName = 'payments';
1845
- this.model = Payment;
1862
+ this.collectionName = 'legacyOrders';
1846
1863
  }
1847
1864
  }
1848
1865
 
1849
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1866
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1850
1867
  constructor(firestore) {
1851
1868
  super();
1852
1869
  this.firestore = firestore;
1853
- this.collectionName = 'checkoutsSubscription';
1854
- this.model = CheckoutSubscription;
1870
+ this.collectionName = 'payments';
1871
+ this.model = Payment;
1855
1872
  }
1856
1873
  }
1857
1874
 
@@ -1864,23 +1881,6 @@ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(
1864
1881
  }
1865
1882
  }
1866
1883
 
1867
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1868
- constructor(firestore) {
1869
- super();
1870
- this.firestore = firestore;
1871
- this.collectionName = 'buy2win';
1872
- this.model = Buy2Win;
1873
- }
1874
- }
1875
-
1876
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1877
- constructor(firestore) {
1878
- super(firestore);
1879
- this.firestore = firestore;
1880
- this.collectionName = 'legacyOrders';
1881
- }
1882
- }
1883
-
1884
1884
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1885
1885
  constructor(firestore) {
1886
1886
  super();
@@ -2020,7 +2020,7 @@ class AttributeOptionHelper {
2020
2020
  }
2021
2021
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2022
2022
  if (fields.includes(attributeName))
2023
- return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
2023
+ return { columnName: attributeName.toString(), attributeName };
2024
2024
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2025
2025
  const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
2026
2026
  if (isNil(fieldOption))
@@ -2338,12 +2338,12 @@ const withHasuraGraphQL = (MixinBase) => {
2338
2338
  fetch(params) {
2339
2339
  return __awaiter(this, void 0, void 0, function* () {
2340
2340
  const headers = this.headers;
2341
- const response = yield fetch(`${this.endpoint}`, {
2341
+ const { data: result } = yield axios({
2342
+ url: `${this.endpoint}`,
2342
2343
  method: 'POST',
2343
- body: JSON.stringify(params),
2344
+ data: params,
2344
2345
  headers,
2345
2346
  });
2346
- const result = yield response.json();
2347
2347
  if (!isNil(result.errors))
2348
2348
  throw new Error(JSON.stringify(result.errors));
2349
2349
  return result.data;
@@ -2467,9 +2467,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
2467
2467
 
2468
2468
  const withFindHasuraGraphQL = (MixinBase) => {
2469
2469
  return class FindHasuraGraphQLMixin extends MixinBase {
2470
- find(options) {
2470
+ find(params) {
2471
+ var _a;
2471
2472
  return __awaiter(this, void 0, void 0, function* () {
2472
- const { filters, limits, orderBy } = options || {};
2473
+ const { filters, limits, orderBy, options } = params || {};
2474
+ const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
2473
2475
  const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
2474
2476
  ? {}
2475
2477
  : {
@@ -2483,8 +2485,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
2483
2485
  const result = yield this.query([
2484
2486
  {
2485
2487
  operation: this.tableName,
2486
- fields: options.fields
2487
- ? options.fields
2488
+ fields: params.fields
2489
+ ? params.fields
2488
2490
  .map((fieldName) => {
2489
2491
  var _a;
2490
2492
  return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
@@ -2493,15 +2495,18 @@ const withFindHasuraGraphQL = (MixinBase) => {
2493
2495
  : this.fields,
2494
2496
  variables,
2495
2497
  },
2496
- {
2497
- operation: `${this.tableName}_aggregate`,
2498
- fields: [{ aggregate: ['count'] }],
2499
- variables: variablesCount,
2500
- },
2498
+ ...(enableCount
2499
+ ? [
2500
+ {
2501
+ operation: `${this.tableName}_aggregate`,
2502
+ fields: [{ aggregate: ['count'] }],
2503
+ variables: variablesCount,
2504
+ },
2505
+ ]
2506
+ : []),
2501
2507
  ]);
2502
2508
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
2503
- const count = result[`${this.tableName}_aggregate`].aggregate.count;
2504
- return { count, data };
2509
+ return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
2505
2510
  });
2506
2511
  }
2507
2512
  };
@@ -2541,20 +2546,8 @@ class VariantHasuraGraphQL extends Variant {
2541
2546
  }
2542
2547
  }
2543
2548
 
2544
- class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2545
- constructor(endpoint, authOptions) {
2546
- super({
2547
- tableName: 'category_filter',
2548
- model: CategoryFilter,
2549
- endpoint,
2550
- authOptions,
2551
- fields: ['id', { filterId: { columnName: 'filter_id' } }, { categoryId: { columnName: 'category_id' } }],
2552
- });
2553
- }
2554
- }
2555
-
2556
2549
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2557
- constructor(endpoint, authOptions, productRepository, categoryFilterRepository) {
2550
+ constructor(endpoint, authOptions, productRepository) {
2558
2551
  super({
2559
2552
  tableName: 'category',
2560
2553
  model: Category,
@@ -2590,17 +2583,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2590
2583
  },
2591
2584
  },
2592
2585
  },
2593
- {
2594
- filters: {
2595
- columnName: 'filters',
2596
- foreignKeyColumn: { filter_id: 'id' },
2597
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
2598
- bindPersistData: (value) => ({
2599
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
2600
- }),
2601
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
2602
- },
2603
- },
2586
+ 'filters',
2604
2587
  { createdAt: { columnName: 'created_at' } },
2605
2588
  { updatedAt: { columnName: 'updated_at' } },
2606
2589
  {
@@ -2625,7 +2608,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2625
2608
  ],
2626
2609
  });
2627
2610
  this.productRepository = productRepository;
2628
- this.categoryFilterRepository = categoryFilterRepository;
2629
2611
  }
2630
2612
  create(params) {
2631
2613
  const _super = Object.create(null, {
@@ -2643,7 +2625,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2643
2625
  var _a;
2644
2626
  return __awaiter(this, void 0, void 0, function* () {
2645
2627
  return Number.isNaN(+identifiers.id)
2646
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2628
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2647
2629
  : _super.get.call(this, identifiers);
2648
2630
  });
2649
2631
  }
@@ -2652,13 +2634,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2652
2634
  update: { get: () => super.update }
2653
2635
  });
2654
2636
  return __awaiter(this, void 0, void 0, function* () {
2655
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
2637
+ const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
2656
2638
  const plainData = this.paramsToPlain({ id: checkId });
2657
2639
  const id = yield this.getId(plainData.id);
2658
2640
  const category = yield _super.update.call(this, Object.assign({ id }, data));
2659
2641
  category.products = products && (yield this.updateProducts(+id, { products }));
2660
2642
  category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
2661
- category.filters = filters && (yield this.updateFilters(+id, { filters }));
2662
2643
  return category;
2663
2644
  });
2664
2645
  }
@@ -2666,11 +2647,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2666
2647
  return __awaiter(this, void 0, void 0, function* () {
2667
2648
  if (!slug)
2668
2649
  return;
2669
- const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
2670
- if (count > 1)
2671
- throw new DuplicatedResultsError('Query returned duplicated values');
2672
- if (!count)
2650
+ const { data } = yield this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
2651
+ if (!data.length)
2673
2652
  throw new NotFoundError(`Category with slug ${slug} not found`);
2653
+ if (data.length > 1)
2654
+ throw new DuplicatedResultsError('Query returned duplicated values');
2674
2655
  return data.shift();
2675
2656
  });
2676
2657
  }
@@ -2706,7 +2687,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2706
2687
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
2707
2688
  return [];
2708
2689
  const products = [];
2709
- const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
2690
+ const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
2710
2691
  'id',
2711
2692
  'name',
2712
2693
  'slug',
@@ -2730,7 +2711,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2730
2711
  'tags',
2731
2712
  'type',
2732
2713
  'shoppingCount',
2733
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
2714
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
2734
2715
  products.push(...productsData);
2735
2716
  return products;
2736
2717
  });
@@ -2740,7 +2721,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2740
2721
  return __awaiter(this, void 0, void 0, function* () {
2741
2722
  if (!Number.isNaN(+id))
2742
2723
  return id;
2743
- const { data } = yield this.find({ filters: { firestoreId: id } });
2724
+ const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
2744
2725
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
2745
2726
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
2746
2727
  throw new NotFoundError(`Category with id ${id} not found`);
@@ -2798,203 +2779,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2798
2779
  return plainData.metadata;
2799
2780
  });
2800
2781
  }
2801
- updateFilters(categoryId, { filters }) {
2802
- return __awaiter(this, void 0, void 0, function* () {
2803
- if ('action' in filters && filters.action === 'remove' && filters.value.length) {
2804
- for (let i = 0; i < filters.value.length; i++) {
2805
- yield this.categoryFilterRepository.delete({ id: filters.value[i].id });
2806
- }
2807
- return [];
2808
- }
2809
- if ('action' in filters && filters.action === 'merge' && filters.value.length) {
2810
- let filtersList = [];
2811
- for (let i = 0; i < filters.value.length; i++) {
2812
- try {
2813
- const hasFilter = yield this.categoryFilterRepository
2814
- .find({
2815
- filters: {
2816
- categoryId,
2817
- filterId: filters[i].id,
2818
- },
2819
- })
2820
- .then((data) => data.data.shift());
2821
- if (hasFilter)
2822
- filtersList.push(hasFilter);
2823
- }
2824
- catch (error) {
2825
- const newCategoryFilter = yield this.categoryFilterRepository.create({
2826
- filterId: filters.value[i].id,
2827
- categoryId,
2828
- });
2829
- filtersList.push(newCategoryFilter);
2830
- }
2831
- }
2832
- return filtersList;
2833
- }
2834
- if (Array.isArray(filters) && filters.length) {
2835
- let filtersList = [];
2836
- for (let i = 0; i < filters.length; i++) {
2837
- try {
2838
- const hasFilter = yield this.categoryFilterRepository
2839
- .find({
2840
- filters: {
2841
- categoryId,
2842
- filterId: filters[i].id,
2843
- },
2844
- })
2845
- .then((data) => data.data.shift());
2846
- if (hasFilter)
2847
- filtersList.push(hasFilter);
2848
- }
2849
- catch (error) {
2850
- const newCategoryFilter = yield this.categoryFilterRepository.create({
2851
- filterId: filters[i].id,
2852
- categoryId,
2853
- });
2854
- filtersList.push(newCategoryFilter);
2855
- }
2856
- }
2857
- return filtersList;
2858
- }
2859
- });
2860
- }
2861
- }
2862
-
2863
- class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2864
- constructor(endpoint, authOptions, filterOptionRepository, categoryFilterRepository) {
2865
- super({
2866
- tableName: 'filter',
2867
- model: Filter,
2868
- endpoint,
2869
- authOptions,
2870
- fields: [
2871
- 'id',
2872
- 'description',
2873
- 'slug',
2874
- 'enabled',
2875
- { createdAt: { columnName: 'created_at' } },
2876
- { updatedAt: { columnName: 'updated_at' } },
2877
- {
2878
- options: {
2879
- columnName: 'options',
2880
- foreignKeyColumn: { filterId: 'id' },
2881
- fields: [
2882
- 'id',
2883
- { filterId: { columnName: 'filter_id' } },
2884
- 'description',
2885
- { createdAt: { columnName: 'created_at' } },
2886
- { updatedAt: { columnName: 'updated_at' } },
2887
- ],
2888
- },
2889
- },
2890
- ],
2891
- });
2892
- this.filterOptionRepository = filterOptionRepository;
2893
- this.categoryFilterRepository = categoryFilterRepository;
2894
- }
2895
- update(params) {
2896
- const _super = Object.create(null, {
2897
- update: { get: () => super.update }
2898
- });
2899
- return __awaiter(this, void 0, void 0, function* () {
2900
- const { options } = params, data = __rest(params, ["options"]);
2901
- const filter = yield _super.update.call(this, data);
2902
- filter.options = yield this.updateOptions(+data.id, { options });
2903
- return filter;
2904
- });
2905
- }
2906
- updateOptions(filterId, { options }) {
2907
- return __awaiter(this, void 0, void 0, function* () {
2908
- if (!options)
2909
- return [];
2910
- if ('action' in options && options.action === 'remove' && options.value.length) {
2911
- for (let i = 0; i < options.value.length; i++) {
2912
- yield this.filterOptionRepository.delete({ id: options.value[i].id });
2913
- }
2914
- return [];
2915
- }
2916
- if ('action' in options && options.action === 'merge' && options.value.length) {
2917
- let filterOptions = [];
2918
- for (let i = 0; i < options.value.length; i++) {
2919
- try {
2920
- const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
2921
- if (hasFilter)
2922
- filterOptions.push(hasFilter);
2923
- }
2924
- catch (error) {
2925
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
2926
- filterOptions.push(newOption);
2927
- }
2928
- }
2929
- return filterOptions;
2930
- }
2931
- if (Array.isArray(options) && options.length) {
2932
- let filterOptions = [];
2933
- for (let i = 0; i < options.length; i++) {
2934
- try {
2935
- const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
2936
- if (hasFilter)
2937
- filterOptions.push(hasFilter);
2938
- }
2939
- catch (error) {
2940
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
2941
- filterOptions.push(newOption);
2942
- }
2943
- }
2944
- }
2945
- return [];
2946
- });
2947
- }
2948
- delete(params) {
2949
- const _super = Object.create(null, {
2950
- delete: { get: () => super.delete }
2951
- });
2952
- return __awaiter(this, void 0, void 0, function* () {
2953
- const { options } = params, data = __rest(params, ["options"]);
2954
- const categoryFilters = yield this.categoryFilterRepository
2955
- .find({
2956
- filters: {
2957
- filterId: +data.id,
2958
- },
2959
- })
2960
- .then((result) => result.data);
2961
- if (categoryFilters.length)
2962
- throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
2963
- yield this.deleteOptions(options);
2964
- yield _super.delete.call(this, { id: +data.id });
2965
- return;
2966
- });
2967
- }
2968
- deleteOptions(options) {
2969
- return __awaiter(this, void 0, void 0, function* () {
2970
- for (let i = 0; i < options.length; i++) {
2971
- try {
2972
- yield this.filterOptionRepository.delete({ id: options[i].id });
2973
- }
2974
- catch (error) {
2975
- console.log(error);
2976
- }
2977
- }
2978
- });
2979
- }
2980
- }
2981
-
2982
- class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2983
- constructor(endpoint, authOptions) {
2984
- super({
2985
- tableName: 'filter_option',
2986
- model: FilterOption,
2987
- endpoint,
2988
- authOptions,
2989
- fields: [
2990
- 'id',
2991
- 'description',
2992
- { filterId: { columnName: 'filter_id' } },
2993
- { createdAt: { columnName: 'created_at' } },
2994
- { updatedAt: { columnName: 'updated_at' } },
2995
- ],
2996
- });
2997
- }
2998
2782
  }
2999
2783
 
3000
2784
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
@@ -3201,7 +2985,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3201
2985
  var _a;
3202
2986
  return __awaiter(this, void 0, void 0, function* () {
3203
2987
  const product = Number.isNaN(+identifiers.id)
3204
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2988
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
3205
2989
  : yield _super.get.call(this, identifiers);
3206
2990
  if (product.productId)
3207
2991
  throw new NotFoundError('Product not found, it is a variant');
@@ -3229,9 +3013,12 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3229
3013
  filters: {
3230
3014
  slug,
3231
3015
  },
3016
+ fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
3017
+ options: {
3018
+ enableCount: false,
3019
+ },
3232
3020
  });
3233
3021
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3234
- product.reviews = yield this.findReviewsByProduct(+product.id);
3235
3022
  return product;
3236
3023
  });
3237
3024
  }
@@ -3394,7 +3181,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3394
3181
  return __awaiter(this, void 0, void 0, function* () {
3395
3182
  if (!Number.isNaN(+id))
3396
3183
  return id;
3397
- const { data } = yield this.find({ filters: { firestoreId: id } });
3184
+ const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3398
3185
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3399
3186
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3400
3187
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3553,7 +3340,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3553
3340
  return __awaiter(this, void 0, void 0, function* () {
3554
3341
  if (!Number.isNaN(+id))
3555
3342
  return id;
3556
- const { data } = yield this.find({ filters: { firestoreId: id } });
3343
+ const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3557
3344
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3558
3345
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3559
3346
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3565,5 +3352,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3565
3352
  * Generated bundle index. Do not edit.
3566
3353
  */
3567
3354
 
3568
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, 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 };
3355
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, 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 };
3569
3356
  //# sourceMappingURL=infrab4a-connect.js.map