@infrab4a/connect 4.0.0-beta.19 → 4.0.0-beta.2

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 (170) hide show
  1. package/domain/catalog/models/category.d.ts +2 -3
  2. package/domain/catalog/models/index.d.ts +0 -3
  3. package/domain/catalog/models/product.d.ts +0 -1
  4. package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
  5. package/domain/catalog/models/types/index.d.ts +1 -0
  6. package/domain/catalog/repositories/category.repository.d.ts +3 -3
  7. package/domain/catalog/repositories/index.d.ts +0 -3
  8. package/domain/catalog/repositories/product.repository.d.ts +0 -1
  9. package/domain/generic/repository/find.repository.d.ts +0 -3
  10. package/domain/shop-settings/models/index.d.ts +0 -1
  11. package/domain/shop-settings/models/types/index.d.ts +1 -6
  12. package/domain/shop-settings/repositories/index.d.ts +0 -1
  13. package/domain/shopping/models/buy-2-win.d.ts +1 -3
  14. package/domain/shopping/models/index.d.ts +4 -5
  15. package/domain/shopping/repositories/index.d.ts +2 -4
  16. package/esm2020/domain/catalog/models/category.mjs +1 -8
  17. package/esm2020/domain/catalog/models/index.mjs +1 -4
  18. package/esm2020/domain/catalog/models/product.mjs +1 -1
  19. package/esm2020/domain/catalog/models/types/category-filter.type.mjs +2 -0
  20. package/esm2020/domain/catalog/models/types/index.mjs +2 -1
  21. package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
  22. package/esm2020/domain/catalog/repositories/index.mjs +1 -4
  23. package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
  24. package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
  25. package/esm2020/domain/shop-settings/models/index.mjs +1 -2
  26. package/esm2020/domain/shop-settings/models/types/index.mjs +2 -7
  27. package/esm2020/domain/shop-settings/repositories/index.mjs +1 -2
  28. package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
  29. package/esm2020/domain/shopping/models/index.mjs +5 -6
  30. package/esm2020/domain/shopping/repositories/index.mjs +3 -5
  31. package/esm2020/domain/users/models/subscription/edition.mjs +1 -1
  32. package/esm2020/domain/users/models/subscription/payment.mjs +1 -1
  33. package/esm2020/domain/users/models/user-payment-method.mjs +1 -1
  34. package/esm2020/infra/elasticsearch/indexes/products-index.mjs +1 -2
  35. package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +3 -7
  36. package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
  37. package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +2 -6
  38. package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +6 -9
  39. package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +3 -11
  40. package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +3 -6
  41. package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +3 -5
  42. package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +4 -7
  43. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +8 -12
  44. package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +6 -11
  45. package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +8 -10
  46. package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +6 -8
  47. package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +6 -8
  48. package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +1 -2
  49. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +6 -8
  50. package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +6 -8
  51. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +6 -8
  52. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +6 -8
  53. package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +6 -8
  54. package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +4 -6
  55. package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +4 -6
  56. package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +9 -11
  57. package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +6 -8
  58. package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +6 -8
  59. package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +6 -8
  60. package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +8 -10
  61. package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +6 -8
  62. package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +8 -10
  63. package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +8 -10
  64. package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +8 -10
  65. package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +6 -8
  66. package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +8 -10
  67. package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
  68. package/esm2020/infra/firebase/firestore/types/index.mjs +3 -4
  69. package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +2 -2
  70. package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +2 -5
  71. package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
  72. package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +12 -16
  73. package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +21 -30
  74. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +12 -95
  75. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +1 -4
  76. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +5 -23
  77. package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +7 -8
  78. package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
  79. package/esm2020/utils/index.mjs +3 -2
  80. package/fesm2015/infrab4a-connect.mjs +227 -695
  81. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  82. package/fesm2020/infrab4a-connect.mjs +229 -675
  83. package/fesm2020/infrab4a-connect.mjs.map +1 -1
  84. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +1 -2
  85. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +4 -13
  86. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +2 -6
  87. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +5 -5
  88. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +4 -4
  89. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +4 -3
  90. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +4 -3
  91. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
  92. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +0 -1
  93. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +4 -3
  94. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +4 -3
  95. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +4 -3
  96. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +4 -3
  97. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
  98. package/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -5
  99. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +4 -3
  100. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
  101. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +4 -3
  102. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +4 -3
  103. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +4 -3
  104. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +4 -3
  105. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +4 -3
  106. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +4 -3
  107. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +4 -3
  108. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +4 -3
  109. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
  110. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +4 -3
  111. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +0 -2
  112. package/infra/firebase/firestore/types/index.d.ts +2 -3
  113. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +2 -2
  114. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +9 -4
  115. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +3 -14
  116. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +5 -9
  117. package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -3
  118. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +3 -4
  119. package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
  120. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +1 -1
  121. package/package.json +2 -1
  122. package/utils/index.d.ts +21 -1
  123. package/domain/catalog/models/category-filter.d.ts +0 -11
  124. package/domain/catalog/models/filter-option.d.ts +0 -10
  125. package/domain/catalog/models/filter.d.ts +0 -13
  126. package/domain/catalog/repositories/category-filter.repository.d.ts +0 -5
  127. package/domain/catalog/repositories/filter-option.repository.d.ts +0 -4
  128. package/domain/catalog/repositories/filter.repository.d.ts +0 -4
  129. package/domain/shop-settings/models/shop-settings.d.ts +0 -9
  130. package/domain/shop-settings/models/types/shop-banner.type.d.ts +0 -12
  131. package/domain/shop-settings/models/types/shop-brands.type.d.ts +0 -10
  132. package/domain/shop-settings/models/types/shop-carousel.type.d.ts +0 -5
  133. package/domain/shop-settings/models/types/shop-collection.type.d.ts +0 -9
  134. package/domain/shop-settings/models/types/shop-section.type.d.ts +0 -9
  135. package/domain/shop-settings/repositories/shop-settings.repository.d.ts +0 -4
  136. package/domain/shopping/models/campaign-dashboard.d.ts +0 -15
  137. package/domain/shopping/models/campaign-hashtag.d.ts +0 -18
  138. package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +0 -4
  139. package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +0 -4
  140. package/esm2020/domain/catalog/models/category-filter.mjs +0 -14
  141. package/esm2020/domain/catalog/models/filter-option.mjs +0 -10
  142. package/esm2020/domain/catalog/models/filter.mjs +0 -10
  143. package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +0 -2
  144. package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +0 -2
  145. package/esm2020/domain/catalog/repositories/filter.repository.mjs +0 -2
  146. package/esm2020/domain/shop-settings/models/shop-settings.mjs +0 -7
  147. package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +0 -2
  148. package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +0 -2
  149. package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +0 -2
  150. package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +0 -2
  151. package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +0 -2
  152. package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +0 -2
  153. package/esm2020/domain/shopping/models/campaign-dashboard.mjs +0 -7
  154. package/esm2020/domain/shopping/models/campaign-hashtag.mjs +0 -7
  155. package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +0 -2
  156. package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +0 -2
  157. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +0 -14
  158. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +0 -14
  159. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +0 -14
  160. package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +0 -2
  161. package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +0 -55
  162. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +0 -104
  163. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +0 -21
  164. package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +0 -7
  165. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -8
  166. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -8
  167. package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +0 -14
  168. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -11
  169. package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +0 -18
  170. package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +0 -10
@@ -3,13 +3,14 @@ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transforme
3
3
  import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
4
4
  import { parseISO } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
- import { get as get$1, isString, isNil, isNumber, isDate, set, isObject, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
7
- export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
6
+ import * as lodash from 'lodash';
7
+ import { get as get$1, isString as isString$1 } from 'lodash';
8
8
  import { CustomError } from 'ts-custom-error';
9
9
  import axios from 'axios';
10
10
  import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
11
11
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
12
12
  import { mutation, query as query$1 } from 'gql-query-builder';
13
+ import fetch from 'node-fetch';
13
14
 
14
15
  class BaseModel {
15
16
  get identifier() {
@@ -472,7 +473,7 @@ function is(value) {
472
473
  return value;
473
474
  }
474
475
 
475
- const isUUID = (value) => isString(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
476
+ const isUUID = (value) => isString$1(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
476
477
 
477
478
  class Base {
478
479
  constructor(...args) {
@@ -481,7 +482,7 @@ class Base {
481
482
  }
482
483
 
483
484
  const parseDateTime = (value) => {
484
- if (!isString(value))
485
+ if (!isString$1(value))
485
486
  return value;
486
487
  if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
487
488
  !/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T\d{2}:\d{2}:\d{2}/.test(value))
@@ -492,6 +493,8 @@ const parseDateTime = (value) => {
492
493
  return date;
493
494
  };
494
495
 
496
+ const { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
497
+
495
498
  var CheckoutTypes;
496
499
  (function (CheckoutTypes) {
497
500
  CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
@@ -754,15 +757,6 @@ class RecoveryPassword {
754
757
  }
755
758
  }
756
759
 
757
- class Filter extends BaseModel {
758
- identifierFields() {
759
- return ['id'];
760
- }
761
- static get identifiersFields() {
762
- return ['id'];
763
- }
764
- }
765
-
766
760
  class Category extends BaseModel {
767
761
  identifierFields() {
768
762
  return ['id'];
@@ -771,20 +765,6 @@ class Category extends BaseModel {
771
765
  return ['id'];
772
766
  }
773
767
  }
774
- __decorate([
775
- Type(() => Filter),
776
- __metadata("design:type", Array)
777
- ], Category.prototype, "filters", void 0);
778
-
779
- class CategoryFilter extends BaseModel {
780
- static get identifiersFields() {
781
- return ['id'];
782
- }
783
- }
784
- __decorate([
785
- Type(() => Filter),
786
- __metadata("design:type", Filter)
787
- ], CategoryFilter.prototype, "filter", void 0);
788
768
 
789
769
  var GenderDestination;
790
770
  (function (GenderDestination) {
@@ -801,15 +781,6 @@ var Shops;
801
781
  Shops["ALL"] = "ALL";
802
782
  })(Shops || (Shops = {}));
803
783
 
804
- class FilterOption extends BaseModel {
805
- identifierFields() {
806
- return ['id'];
807
- }
808
- static get identifiersFields() {
809
- return ['id'];
810
- }
811
- }
812
-
813
784
  class Product extends BaseModel {
814
785
  identifierFields() {
815
786
  return ['id'];
@@ -846,27 +817,17 @@ class Variant extends BaseModel {
846
817
  }
847
818
  }
848
819
 
849
- class Buy2Win extends BaseModel {
850
- static get identifiersFields() {
851
- return ['id'];
852
- }
853
- }
854
- __decorate([
855
- Type(() => Category),
856
- __metadata("design:type", Array)
857
- ], Buy2Win.prototype, "categories", void 0);
858
-
859
- class CampaignDashboard extends BaseModel {
860
- static get identifiersFields() {
861
- return ['id'];
862
- }
863
- }
864
-
865
- class CampaignHashtag extends BaseModel {
866
- static get identifiersFields() {
867
- return ['id'];
868
- }
869
- }
820
+ var OrderStatus;
821
+ (function (OrderStatus) {
822
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
823
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
824
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
825
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
826
+ OrderStatus["ENVIADO"] = "Enviado";
827
+ OrderStatus["ENTREGUE"] = "Entregue";
828
+ OrderStatus["CANCELADO"] = "Cancelado";
829
+ OrderStatus["CREDIT_CARD"] = "credit_card";
830
+ })(OrderStatus || (OrderStatus = {}));
870
831
 
871
832
  class LineItem extends Product {
872
833
  }
@@ -907,18 +868,6 @@ __decorate([
907
868
  __metadata("design:type", Coupon)
908
869
  ], Checkout.prototype, "coupon", void 0);
909
870
 
910
- var OrderStatus;
911
- (function (OrderStatus) {
912
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
913
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
914
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
915
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
916
- OrderStatus["ENVIADO"] = "Enviado";
917
- OrderStatus["ENTREGUE"] = "Entregue";
918
- OrderStatus["CANCELADO"] = "Cancelado";
919
- OrderStatus["CREDIT_CARD"] = "credit_card";
920
- })(OrderStatus || (OrderStatus = {}));
921
-
922
871
  class Order extends Checkout {
923
872
  }
924
873
  __decorate([
@@ -948,6 +897,16 @@ __decorate([
948
897
  __metadata("design:type", Coupon)
949
898
  ], CheckoutSubscription.prototype, "coupon", void 0);
950
899
 
900
+ class Buy2Win extends BaseModel {
901
+ static get identifiersFields() {
902
+ return ['id'];
903
+ }
904
+ }
905
+ __decorate([
906
+ Type(() => Category),
907
+ __metadata("design:type", Array)
908
+ ], Buy2Win.prototype, "categories", void 0);
909
+
951
910
  var FilterType;
952
911
  (function (FilterType) {
953
912
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -1047,12 +1006,6 @@ class ShopMenu extends BaseModel {
1047
1006
  }
1048
1007
  }
1049
1008
 
1050
- class ShopSettings extends BaseModel {
1051
- static get identifiersFields() {
1052
- return ['id'];
1053
- }
1054
- }
1055
-
1056
1009
  class InvalidArgumentError extends CustomError {
1057
1010
  constructor(message) {
1058
1011
  super(message);
@@ -1163,7 +1116,6 @@ class ProductsIndex {
1163
1116
  'stock',
1164
1117
  'weight',
1165
1118
  'tags',
1166
- 'filters',
1167
1119
  'hasVariants',
1168
1120
  'type',
1169
1121
  ];
@@ -1254,17 +1206,9 @@ const withFirestore = (MixinBase) => {
1254
1206
  : bindDate(data[key], key) })), {});
1255
1207
  };
1256
1208
  return class extends MixinBase {
1257
- constructor(...params) {
1258
- const options = params[0];
1259
- super(...params);
1260
- this.fields = {};
1261
- this.interceptors = {};
1209
+ constructor() {
1210
+ super(...arguments);
1262
1211
  this.collectionName = '';
1263
- this.firestore = options.firestore;
1264
- this.collectionName = options.collectionName;
1265
- this.model = options.model;
1266
- this.fields = options.fields;
1267
- this.interceptors = options.interceptors;
1268
1212
  }
1269
1213
  collection(path) {
1270
1214
  return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
@@ -1311,16 +1255,12 @@ const withHelpers = (MixinBase) => {
1311
1255
  const withGetFirestore = (MixinBase) => {
1312
1256
  return class GetFirestore extends MixinBase {
1313
1257
  get(identifiers) {
1314
- var _a, _b, _c, _d;
1315
1258
  return __awaiter(this, void 0, void 0, function* () {
1316
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
1317
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
1318
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
1319
- const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
1259
+ const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
1320
1260
  const data = docRef.data();
1321
1261
  if (isNil(data))
1322
1262
  throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1323
- return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted)) || data;
1263
+ return data;
1324
1264
  });
1325
1265
  }
1326
1266
  buildCollectionPathForGet(identifiers) {
@@ -1399,13 +1339,9 @@ const withFindFirestore = (MixinBase) => {
1399
1339
  return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
1400
1340
  };
1401
1341
  }
1402
- find(find = {}) {
1403
- var _a, _b, _c, _d, _e, _f;
1342
+ find({ filters, limits, orderBy, } = {}) {
1404
1343
  return __awaiter(this, void 0, void 0, function* () {
1405
- const collection = this.collection(this.buildCollectionPathForFind(find.filters));
1406
- const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
1407
- const intercepted = yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
1408
- const { filters, limits, orderBy } = intercepted.find || find;
1344
+ const collection = this.collection(this.buildCollectionPathForFind(filters));
1409
1345
  const queries = this.makeFirestoreWhere(filters || {});
1410
1346
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
1411
1347
  const offsets = yield this.defineLimits(filters, limits);
@@ -1413,8 +1349,8 @@ const withFindFirestore = (MixinBase) => {
1413
1349
  const docs = yield getDocs(query(collection, ...queryArgumments));
1414
1350
  const data = docs.docs.map((doc) => doc.data());
1415
1351
  return {
1416
- data: (yield ((_f = (_e = this.interceptors) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.call(_e, data, intercepted))) || data,
1417
- count: enableCount ? this.calculateCount(data, limits) : Infinity,
1352
+ data,
1353
+ count: this.calculateCount(data, limits),
1418
1354
  };
1419
1355
  });
1420
1356
  }
@@ -1426,12 +1362,11 @@ const withFindFirestore = (MixinBase) => {
1426
1362
  return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
1427
1363
  }
1428
1364
  defineLimits(filters, limits) {
1429
- var _a;
1430
1365
  return __awaiter(this, void 0, void 0, function* () {
1431
1366
  const queries = [];
1432
1367
  if (limits === null || limits === void 0 ? void 0 : limits.offset) {
1433
1368
  if (this.model.isModel(limits.offset))
1434
- queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier[(_a = limits.offset.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]))));
1369
+ queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
1435
1370
  else if (isNumber(limits.offset) || isString(limits.offset))
1436
1371
  queries.push(startAt(limits.offset));
1437
1372
  }
@@ -1453,15 +1388,10 @@ const withFindFirestore = (MixinBase) => {
1453
1388
  const withCreateFirestore = (MixinBase) => {
1454
1389
  return class CreateFirestore extends MixinBase {
1455
1390
  create(data) {
1456
- var _a, _b, _c, _d;
1457
1391
  return __awaiter(this, void 0, void 0, function* () {
1458
- const instance = this.model.toInstance(data);
1459
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
1460
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
1461
- const docRef = yield this.save(builded);
1392
+ const docRef = yield this.save(this.model.toInstance(data));
1462
1393
  const doc = yield getDoc(docRef);
1463
- const docBuilded = (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, doc.data(), intercepted))) || doc.data();
1464
- return docBuilded;
1394
+ return doc.data();
1465
1395
  });
1466
1396
  }
1467
1397
  save(data) {
@@ -1509,17 +1439,13 @@ const withUpdateFirestore = (MixinBase) => {
1509
1439
  };
1510
1440
  return class UpdateFirestore extends MixinBase {
1511
1441
  update(data) {
1512
- var _a, _b, _c, _d;
1513
1442
  return __awaiter(this, void 0, void 0, function* () {
1514
1443
  const model = new this.model();
1515
1444
  const keyField = model.identifiersFields.shift();
1516
1445
  const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
1517
- const plainFromData = this.model.toInstance(this.paramsToPlain(data));
1518
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance: plainFromData }));
1519
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
1520
- yield setDoc(docRef, builded.toPlain(), { merge: true });
1521
- const docData = yield getDoc(docRef).then((doc) => doc.data());
1522
- return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, docData, intercepted)) || docData;
1446
+ yield setDoc(docRef, this.paramsToPlain(data), { merge: true });
1447
+ const docData = yield getDoc(docRef);
1448
+ return docData.data();
1523
1449
  });
1524
1450
  }
1525
1451
  buildCollectionPathForUpdate(identifiers) {
@@ -1539,13 +1465,8 @@ const withUpdateFirestore = (MixinBase) => {
1539
1465
  const withDeleteFirestore = (MixinBase) => {
1540
1466
  return class DeleteFirestore extends MixinBase {
1541
1467
  delete(identifiers) {
1542
- var _a, _b, _c, _d;
1543
1468
  return __awaiter(this, void 0, void 0, function* () {
1544
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
1545
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
1546
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
1547
- yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
1548
- yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
1469
+ yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
1549
1470
  });
1550
1471
  }
1551
1472
  buildCollectionPathForRemove(identifiers) {
@@ -1558,10 +1479,8 @@ const withDeleteFirestore = (MixinBase) => {
1558
1479
 
1559
1480
  const withSubCollection = (MixinBase, ParentModel) => {
1560
1481
  return class SubCollectionMix extends MixinBase {
1561
- constructor(...params) {
1562
- const options = params[0];
1563
- super(...params);
1564
- this.parentIdField = options.parentIdField;
1482
+ constructor(...args) {
1483
+ super(args);
1565
1484
  }
1566
1485
  collection(path) {
1567
1486
  return super.collection(path);
@@ -1575,87 +1494,73 @@ const withCrudFirestore = (MixinBase) => {
1575
1494
  };
1576
1495
 
1577
1496
  class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1578
- constructor({ firestore, interceptors }) {
1579
- super({
1580
- firestore,
1581
- collectionName: 'leads',
1582
- model: Lead,
1583
- interceptors,
1584
- });
1497
+ constructor(firestore) {
1498
+ super();
1499
+ this.firestore = firestore;
1500
+ this.collectionName = 'leads';
1501
+ this.model = Lead;
1585
1502
  }
1586
1503
  }
1587
1504
 
1588
1505
  class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1589
- constructor({ firestore, interceptors }, parentRepository) {
1590
- super({
1591
- firestore,
1592
- collectionName: 'editions',
1593
- parentIdField: 'subscriptionId',
1594
- model: Edition,
1595
- interceptors,
1596
- });
1506
+ constructor(firestore, parentRepository) {
1507
+ super();
1508
+ this.firestore = firestore;
1597
1509
  this.parentRepository = parentRepository;
1510
+ this.collectionName = 'editions';
1511
+ this.parentIdField = 'subscriptionId';
1512
+ this.model = Edition;
1598
1513
  }
1599
1514
  }
1600
1515
 
1601
1516
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1602
- constructor({ firestore, interceptors, }) {
1603
- super({
1604
- firestore,
1605
- collectionName: 'subscription',
1606
- model: Subscription,
1607
- interceptors,
1608
- });
1517
+ constructor(firestore) {
1518
+ super();
1519
+ this.firestore = firestore;
1520
+ this.collectionName = 'subscription';
1521
+ this.model = Subscription;
1609
1522
  }
1610
1523
  }
1611
1524
 
1612
1525
  class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1613
- constructor({ firestore, interceptors }, parentRepository) {
1614
- super({
1615
- firestore,
1616
- collectionName: 'payments',
1617
- parentIdField: 'subscriptionId',
1618
- model: SubscriptionPayment,
1619
- interceptors,
1620
- });
1526
+ constructor(firestore, parentRepository) {
1527
+ super();
1528
+ this.firestore = firestore;
1621
1529
  this.parentRepository = parentRepository;
1530
+ this.collectionName = 'payments';
1531
+ this.parentIdField = 'subscriptionId';
1532
+ this.model = SubscriptionPayment;
1622
1533
  }
1623
1534
  }
1624
1535
 
1625
1536
  class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1626
- constructor({ firestore, interceptors }, parentRepository) {
1627
- super({
1628
- firestore,
1629
- collectionName: 'address',
1630
- parentIdField: 'userId',
1631
- model: UserAddress,
1632
- interceptors,
1633
- });
1537
+ constructor(firestore, parentRepository) {
1538
+ super();
1539
+ this.firestore = firestore;
1634
1540
  this.parentRepository = parentRepository;
1541
+ this.collectionName = 'address';
1542
+ this.parentIdField = 'userId';
1543
+ this.model = UserAddress;
1635
1544
  }
1636
1545
  }
1637
1546
 
1638
1547
  class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1639
- constructor({ firestore, interceptors }, parentRepository) {
1640
- super({
1641
- firestore,
1642
- collectionName: 'CX',
1643
- parentIdField: 'userId',
1644
- model: BeautyProfile,
1645
- interceptors,
1646
- });
1548
+ constructor(firestore, parentRepository) {
1549
+ super();
1550
+ this.firestore = firestore;
1647
1551
  this.parentRepository = parentRepository;
1552
+ this.collectionName = 'CX';
1553
+ this.parentIdField = 'userId';
1554
+ this.model = BeautyProfile;
1648
1555
  }
1649
1556
  }
1650
1557
 
1651
1558
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1652
- constructor({ firestore, interceptors }) {
1653
- super({
1654
- firestore,
1655
- collectionName: 'users',
1656
- model: User,
1657
- interceptors,
1658
- });
1559
+ constructor(firestore) {
1560
+ super();
1561
+ this.firestore = firestore;
1562
+ this.collectionName = 'users';
1563
+ this.model = User;
1659
1564
  }
1660
1565
  get(identifiers) {
1661
1566
  const _super = Object.create(null, {
@@ -1706,26 +1611,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1706
1611
  }
1707
1612
 
1708
1613
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1709
- constructor({ firestore, interceptors }, parentRepository) {
1710
- super({
1711
- firestore,
1712
- collectionName: 'payment_method',
1713
- parentIdField: 'userId',
1714
- model: UserPaymentMethod,
1715
- interceptors,
1716
- });
1614
+ constructor(firestore, parentRepository) {
1615
+ super();
1616
+ this.firestore = firestore;
1717
1617
  this.parentRepository = parentRepository;
1618
+ this.collectionName = 'payment_method';
1619
+ this.parentIdField = 'userId';
1620
+ this.model = UserPaymentMethod;
1718
1621
  }
1719
1622
  }
1720
1623
 
1721
1624
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1722
- constructor({ firestore, interceptors }) {
1723
- super({
1724
- firestore,
1725
- collectionName: 'categories',
1726
- model: Category,
1727
- interceptors,
1728
- });
1625
+ constructor(firestore) {
1626
+ super();
1627
+ this.firestore = firestore;
1628
+ this.collectionName = 'categories';
1629
+ this.model = Category;
1729
1630
  }
1730
1631
  getCategoryBySlug(slug, shop) {
1731
1632
  return __awaiter(this, void 0, void 0, function* () {
@@ -1737,7 +1638,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1737
1638
  return categoryDocs.docs[0].data();
1738
1639
  });
1739
1640
  }
1740
- getCategoriesForHome(categoryIds, limit = 4, gender) {
1641
+ getCategoriesForHome(categoryIds, limit = 4) {
1741
1642
  return __awaiter(this, void 0, void 0, function* () {
1742
1643
  const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
1743
1644
  if (categorySnap.empty)
@@ -1746,7 +1647,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1746
1647
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
1747
1648
  return ({
1748
1649
  category,
1749
- products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
1650
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
1750
1651
  });
1751
1652
  })));
1752
1653
  return homeSections;
@@ -1765,8 +1666,6 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1765
1666
  wheres.push(where('published', '==', true), where('id', 'in', productIds));
1766
1667
  if (options === null || options === void 0 ? void 0 : options.hasStock)
1767
1668
  wheres.push(where('stock.quantity', '>', 0));
1768
- if (options === null || options === void 0 ? void 0 : options.gender)
1769
- wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
1770
1669
  if (options === null || options === void 0 ? void 0 : options.limit)
1771
1670
  wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
1772
1671
  const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
@@ -1780,14 +1679,12 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1780
1679
  }
1781
1680
 
1782
1681
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1783
- constructor({ firestore, interceptors }) {
1784
- super({
1785
- firestore,
1786
- collectionName: 'productsErpVitrine',
1787
- model: Product,
1788
- interceptors,
1789
- });
1682
+ constructor(firestore) {
1683
+ super();
1684
+ this.firestore = firestore;
1790
1685
  this.reviews = {};
1686
+ this.collectionName = 'productsErpVitrine';
1687
+ this.model = Product;
1791
1688
  }
1792
1689
  getBySlug(slug) {
1793
1690
  var _a;
@@ -1828,98 +1725,43 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
1828
1725
  return this.reviews[status];
1829
1726
  });
1830
1727
  }
1831
- cleanShoppingCountFromIds() {
1832
- return;
1833
- }
1834
1728
  }
1835
1729
 
1836
1730
  class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
1837
- constructor({ firestore, interceptors }, parentRepository) {
1838
- super({
1839
- firestore,
1840
- collectionName: 'variants',
1841
- parentIdField: 'productId',
1842
- model: Variant,
1843
- interceptors,
1844
- });
1731
+ constructor(firestore, parentRepository) {
1732
+ super();
1733
+ this.firestore = firestore;
1845
1734
  this.parentRepository = parentRepository;
1735
+ this.collectionName = 'variants';
1736
+ this.parentIdField = 'productId';
1737
+ this.model = Variant;
1846
1738
  }
1847
1739
  }
1848
1740
 
1849
1741
  class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1850
- constructor({ firestore, interceptors }) {
1851
- super({
1852
- firestore,
1853
- collectionName: 'subscriptionProducts',
1854
- model: Product,
1855
- interceptors,
1856
- });
1857
- }
1858
- }
1859
-
1860
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1861
- constructor({ firestore, interceptors }) {
1862
- super({
1863
- firestore,
1864
- collectionName: 'buy2win',
1865
- model: Buy2Win,
1866
- interceptors,
1867
- });
1868
- }
1869
- }
1870
-
1871
- class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1872
- constructor({ firestore, interceptors, }) {
1873
- super({
1874
- firestore,
1875
- collectionName: 'dashboardCampaignsAuto',
1876
- model: CampaignDashboard,
1877
- interceptors,
1878
- });
1879
- }
1880
- }
1881
-
1882
- class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1883
- constructor({ firestore, interceptors, }) {
1884
- super({
1885
- firestore,
1886
- collectionName: 'hashtagCampaignsAuto',
1887
- model: CampaignHashtag,
1888
- interceptors,
1889
- });
1742
+ constructor(firestore) {
1743
+ super();
1744
+ this.firestore = firestore;
1745
+ this.collectionName = 'subscriptionProducts';
1746
+ this.model = Product;
1890
1747
  }
1891
1748
  }
1892
1749
 
1893
1750
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1894
- constructor({ firestore, interceptors }) {
1895
- super({
1896
- firestore,
1897
- collectionName: 'checkouts',
1898
- model: Checkout,
1899
- interceptors,
1900
- });
1901
- }
1902
- }
1903
-
1904
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1905
- constructor({ firestore, interceptors, }) {
1906
- super({
1907
- firestore,
1908
- collectionName: 'checkoutsSubscription',
1909
- model: CheckoutSubscription,
1910
- interceptors,
1911
- });
1751
+ constructor(firestore) {
1752
+ super();
1753
+ this.firestore = firestore;
1754
+ this.collectionName = 'checkouts';
1755
+ this.model = Checkout;
1912
1756
  }
1913
1757
  }
1914
1758
 
1915
1759
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1916
- constructor({ firestore, interceptors }) {
1917
- super({
1918
- firestore,
1919
- collectionName: 'coupons',
1920
- model: Coupon,
1921
- interceptors,
1922
- });
1760
+ constructor(firestore) {
1761
+ super();
1762
+ this.firestore = firestore;
1763
+ this.collectionName = 'coupons';
1764
+ this.model = Coupon;
1923
1765
  }
1924
1766
  buildModelInstance() {
1925
1767
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1941,16 +1783,9 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
1941
1783
  }
1942
1784
 
1943
1785
  class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1944
- constructor({ firestore, interceptors }) {
1945
- super({
1946
- firestore,
1947
- collectionName: 'orders',
1948
- model: Order,
1949
- interceptors,
1950
- fields: {
1951
- status: FirestoreFieldType.String,
1952
- },
1953
- });
1786
+ constructor(firestore) {
1787
+ super();
1788
+ this.firestore = firestore;
1954
1789
  this.orderFromFirestore = (order) => {
1955
1790
  var _a;
1956
1791
  if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
@@ -1964,6 +1799,11 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1964
1799
  }
1965
1800
  return order;
1966
1801
  };
1802
+ this.collectionName = 'orders';
1803
+ this.model = Order;
1804
+ this.fields = {
1805
+ status: FirestoreFieldType.String,
1806
+ };
1967
1807
  }
1968
1808
  buildModelInstance() {
1969
1809
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1977,46 +1817,54 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1977
1817
  }
1978
1818
  }
1979
1819
 
1980
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1981
- constructor({ firestore, interceptors }) {
1982
- super({
1983
- firestore,
1984
- interceptors,
1985
- });
1986
- this.collectionName = 'legacyOrders';
1820
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1821
+ constructor(firestore) {
1822
+ super();
1823
+ this.firestore = firestore;
1824
+ this.collectionName = 'payments';
1825
+ this.model = Payment;
1987
1826
  }
1988
1827
  }
1989
1828
 
1990
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1991
- constructor({ firestore, interceptors }) {
1992
- super({
1993
- firestore,
1994
- collectionName: 'payments',
1995
- model: Payment,
1996
- interceptors,
1997
- });
1829
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1830
+ constructor(firestore) {
1831
+ super();
1832
+ this.firestore = firestore;
1833
+ this.collectionName = 'checkoutsSubscription';
1834
+ this.model = CheckoutSubscription;
1998
1835
  }
1999
1836
  }
2000
1837
 
2001
1838
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2002
- constructor({ firestore, interceptors, }) {
2003
- super({
2004
- firestore,
2005
- collectionName: 'subscriptionPlans',
2006
- model: SubscriptionPlan,
2007
- interceptors,
2008
- });
1839
+ constructor(firestore) {
1840
+ super();
1841
+ this.firestore = firestore;
1842
+ this.collectionName = 'subscriptionPlans';
1843
+ this.model = SubscriptionPlan;
1844
+ }
1845
+ }
1846
+
1847
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1848
+ constructor(firestore) {
1849
+ super();
1850
+ this.firestore = firestore;
1851
+ this.collectionName = 'buy2win';
1852
+ this.model = Buy2Win;
1853
+ }
1854
+ }
1855
+
1856
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1857
+ constructor(firestore) {
1858
+ super(firestore);
1859
+ this.firestore = firestore;
1860
+ this.collectionName = 'legacyOrders';
2009
1861
  }
2010
1862
  }
2011
1863
 
2012
1864
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2013
- constructor({ firestore, interceptors }) {
2014
- super({
2015
- firestore,
2016
- collectionName: 'dms',
2017
- model: Home,
2018
- interceptors,
2019
- });
1865
+ constructor(firestore) {
1866
+ super();
1867
+ this.firestore = firestore;
2020
1868
  this.homeToFirestore = (home) => {
2021
1869
  var _a;
2022
1870
  if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
@@ -2047,6 +1895,8 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2047
1895
  category: Category.toInstance(homeCategoryGroup.category),
2048
1896
  products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
2049
1897
  });
1898
+ this.collectionName = 'dms';
1899
+ this.model = Home;
2050
1900
  }
2051
1901
  buildModelInstance() {
2052
1902
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2064,24 +1914,11 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2064
1914
  }
2065
1915
 
2066
1916
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2067
- constructor({ firestore, interceptors }) {
2068
- super({
2069
- firestore,
2070
- collectionName: 'shopMenus',
2071
- model: ShopMenu,
2072
- interceptors,
2073
- });
2074
- }
2075
- }
2076
-
2077
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2078
- constructor({ firestore, interceptors, }) {
2079
- super({
2080
- firestore,
2081
- collectionName: 'shopSettings',
2082
- model: ShopSettings,
2083
- interceptors,
2084
- });
1917
+ constructor(firestore) {
1918
+ super();
1919
+ this.firestore = firestore;
1920
+ this.collectionName = 'shopMenus';
1921
+ this.model = ShopMenu;
2085
1922
  }
2086
1923
  }
2087
1924
 
@@ -2171,7 +2008,7 @@ class AttributeOptionHelper {
2171
2008
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2172
2009
  var _a;
2173
2010
  if (fields.includes(attributeName))
2174
- return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
2011
+ return { columnName: attributeName.toString(), attributeName };
2175
2012
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2176
2013
  const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
2177
2014
  if (isNil(fieldOption))
@@ -2346,7 +2183,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
2346
2183
  }
2347
2184
  if (!!from)
2348
2185
  return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
2349
- return Object.assign(Object.assign({}, result), { [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName] });
2186
+ return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
2350
2187
  }, {});
2351
2188
  GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2352
2189
  var _a;
@@ -2472,13 +2309,9 @@ const withHasuraGraphQL = (MixinBase) => {
2472
2309
  this.fields = options.fields || this.model.identifiersFields;
2473
2310
  }
2474
2311
  get headers() {
2475
- var _a, _b, _c, _d, _e, _f, _g;
2476
- return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil((_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.authToken) ? {} : { Authorization: (_b = this.authOptions) === null || _b === void 0 ? void 0 : _b.authToken })), (isNil((_c = this.authOptions) === null || _c === void 0 ? void 0 : _c.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': (_d = this.authOptions) === null || _d === void 0 ? void 0 : _d.adminSecret })), (isNil((_e = this.authOptions) === null || _e === void 0 ? void 0 : _e.authRole)
2312
+ return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
2477
2313
  ? {}
2478
- : {
2479
- 'X-Hasura-Role': this.authOptions.authRole.role,
2480
- 'X-Hasura-User-Id': (_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.authRole) === null || _g === void 0 ? void 0 : _g.userId,
2481
- }));
2314
+ : { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }));
2482
2315
  }
2483
2316
  mutation(operation, fields, variables) {
2484
2317
  return __awaiter(this, void 0, void 0, function* () {
@@ -2491,24 +2324,30 @@ const withHasuraGraphQL = (MixinBase) => {
2491
2324
  });
2492
2325
  }
2493
2326
  query(operation, fields, variables) {
2494
- var _a, _b, _c, _d;
2495
2327
  return __awaiter(this, void 0, void 0, function* () {
2496
- const builded = this.buildHasuraQueryFields({ operation, fields, variables });
2497
- const interpected = (yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, builded))) || builded;
2498
- const resultQuery = query$1(interpected);
2499
- const result = yield this.fetch(resultQuery);
2500
- return (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, result, interpected))) || result;
2328
+ const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2329
+ ? query$1(operation.map((option) => ({
2330
+ operation: option.operation,
2331
+ variables: option.variables,
2332
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2333
+ })))
2334
+ : query$1({
2335
+ operation,
2336
+ variables,
2337
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2338
+ });
2339
+ return this.fetch(resultQuery);
2501
2340
  });
2502
2341
  }
2503
2342
  fetch(params) {
2504
2343
  return __awaiter(this, void 0, void 0, function* () {
2505
2344
  const headers = this.headers;
2506
- const { data: result } = yield axios({
2507
- url: `${this.endpoint}`,
2345
+ const response = yield fetch(`${this.endpoint}`, {
2508
2346
  method: 'POST',
2509
- data: params,
2347
+ body: JSON.stringify(params),
2510
2348
  headers,
2511
2349
  });
2350
+ const result = yield response.json();
2512
2351
  if (!isNil(result.errors))
2513
2352
  throw new Error(JSON.stringify(result.errors));
2514
2353
  return result.data;
@@ -2544,19 +2383,6 @@ const withHasuraGraphQL = (MixinBase) => {
2544
2383
  convertDataToHasura(instance, update = false) {
2545
2384
  return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
2546
2385
  }
2547
- buildHasuraQueryFields({ operation, fields, variables, }) {
2548
- return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2549
- ? operation.map((option) => ({
2550
- operation: option.operation,
2551
- variables: option.variables,
2552
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2553
- }))
2554
- : {
2555
- operation,
2556
- variables,
2557
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2558
- };
2559
- }
2560
2386
  };
2561
2387
  };
2562
2388
 
@@ -2648,11 +2474,9 @@ const withGetHasuraGraphQL = (MixinBase) => {
2648
2474
 
2649
2475
  const withFindHasuraGraphQL = (MixinBase) => {
2650
2476
  return class FindHasuraGraphQLMixin extends MixinBase {
2651
- find(params) {
2652
- var _a;
2477
+ find(options) {
2653
2478
  return __awaiter(this, void 0, void 0, function* () {
2654
- const { filters, limits, orderBy, options } = params || {};
2655
- const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
2479
+ const { filters, limits, orderBy } = options || {};
2656
2480
  const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
2657
2481
  ? {}
2658
2482
  : {
@@ -2666,8 +2490,8 @@ const withFindHasuraGraphQL = (MixinBase) => {
2666
2490
  const result = yield this.query([
2667
2491
  {
2668
2492
  operation: this.tableName,
2669
- fields: params.fields
2670
- ? params.fields
2493
+ fields: options.fields
2494
+ ? options.fields
2671
2495
  .map((fieldName) => {
2672
2496
  var _a;
2673
2497
  return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
@@ -2676,18 +2500,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
2676
2500
  : this.fields,
2677
2501
  variables,
2678
2502
  },
2679
- ...(enableCount
2680
- ? [
2681
- {
2682
- operation: `${this.tableName}_aggregate`,
2683
- fields: [{ aggregate: ['count'] }],
2684
- variables: variablesCount,
2685
- },
2686
- ]
2687
- : []),
2503
+ {
2504
+ operation: `${this.tableName}_aggregate`,
2505
+ fields: [{ aggregate: ['count'] }],
2506
+ variables: variablesCount,
2507
+ },
2688
2508
  ]);
2689
2509
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
2690
- return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
2510
+ const count = result[`${this.tableName}_aggregate`].aggregate.count;
2511
+ return { count, data };
2691
2512
  });
2692
2513
  }
2693
2514
  };
@@ -2727,66 +2548,13 @@ class VariantHasuraGraphQL extends Variant {
2727
2548
  }
2728
2549
  }
2729
2550
 
2730
- class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2731
- constructor({ endpoint, authOptions, interceptors, }) {
2732
- super({
2733
- tableName: 'category_filter',
2734
- model: CategoryFilter,
2735
- endpoint,
2736
- authOptions,
2737
- fields: [
2738
- 'id',
2739
- { filterId: { columnName: 'filter_id' } },
2740
- { categoryId: { columnName: 'category_id' } },
2741
- {
2742
- filter: {
2743
- columnName: 'filter',
2744
- foreignKeyColumn: { id: 'filterId' },
2745
- fields: [
2746
- 'id',
2747
- 'description',
2748
- 'slug',
2749
- 'enabled',
2750
- { createdAt: { columnName: 'created_at' } },
2751
- { updatedAt: { columnName: 'updated_at' } },
2752
- {
2753
- options: {
2754
- columnName: 'options',
2755
- foreignKeyColumn: { filterId: 'id' },
2756
- fields: [
2757
- 'id',
2758
- { filterId: { columnName: 'filter_id' } },
2759
- 'description',
2760
- { createdAt: { columnName: 'created_at' } },
2761
- { updatedAt: { columnName: 'updated_at' } },
2762
- ],
2763
- },
2764
- },
2765
- ],
2766
- },
2767
- },
2768
- ],
2769
- });
2770
- }
2771
- deleteByCategoryAndFilter(categoryId, filterId) {
2772
- return this.mutation('delete_category_filter', ['affected_rows'], {
2773
- where: {
2774
- type: 'category_filter_bool_exp',
2775
- required: true,
2776
- value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
2777
- },
2778
- });
2779
- }
2780
- }
2781
-
2782
2551
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2783
- constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
2552
+ constructor(endpoint, authOptions, productRepository) {
2784
2553
  super({
2785
2554
  tableName: 'category',
2786
2555
  model: Category,
2787
2556
  endpoint,
2788
2557
  authOptions,
2789
- interceptors,
2790
2558
  fields: [
2791
2559
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
2792
2560
  { firestoreId: { columnName: 'firestore_id' } },
@@ -2820,17 +2588,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2820
2588
  },
2821
2589
  },
2822
2590
  },
2823
- {
2824
- filters: {
2825
- columnName: 'filters',
2826
- foreignKeyColumn: { filter_id: 'id' },
2827
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
2828
- bindPersistData: (value) => ({
2829
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
2830
- }),
2831
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
2832
- },
2833
- },
2591
+ 'filters',
2834
2592
  { createdAt: { columnName: 'created_at' } },
2835
2593
  { updatedAt: { columnName: 'updated_at' } },
2836
2594
  {
@@ -2855,7 +2613,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2855
2613
  ],
2856
2614
  });
2857
2615
  this.productRepository = productRepository;
2858
- this.categoryFilterRepository = categoryFilterRepository;
2859
2616
  }
2860
2617
  create(params) {
2861
2618
  const _super = Object.create(null, {
@@ -2873,7 +2630,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2873
2630
  var _a;
2874
2631
  return __awaiter(this, void 0, void 0, function* () {
2875
2632
  return Number.isNaN(+identifiers.id)
2876
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2633
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2877
2634
  : _super.get.call(this, identifiers);
2878
2635
  });
2879
2636
  }
@@ -2882,13 +2639,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2882
2639
  update: { get: () => super.update }
2883
2640
  });
2884
2641
  return __awaiter(this, void 0, void 0, function* () {
2885
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
2642
+ const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
2886
2643
  const plainData = this.paramsToPlain({ id: checkId });
2887
2644
  const id = yield this.getId(plainData.id);
2888
2645
  const category = yield _super.update.call(this, Object.assign({ id }, data));
2889
2646
  category.products = products && (yield this.updateProducts(+id, { products }));
2890
2647
  category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
2891
- category.filters = filters && (yield this.updateFilters(+id, { filters }));
2892
2648
  return category;
2893
2649
  });
2894
2650
  }
@@ -2896,15 +2652,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2896
2652
  return __awaiter(this, void 0, void 0, function* () {
2897
2653
  if (!slug)
2898
2654
  return null;
2899
- const { data } = yield this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
2900
- if (!data.length)
2901
- throw new NotFoundError(`Category with slug ${slug} not found`);
2902
- if (data.length > 1)
2655
+ const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
2656
+ if (count > 1)
2903
2657
  throw new DuplicatedResultsError('Query returned duplicated values');
2658
+ if (!count)
2659
+ throw new NotFoundError(`Category with slug ${slug} not found`);
2904
2660
  return data.shift();
2905
2661
  });
2906
2662
  }
2907
- getCategoriesForHome(categoryIds, limit = 4, gender) {
2663
+ getCategoriesForHome(categoryIds, limit = 4) {
2908
2664
  return __awaiter(this, void 0, void 0, function* () {
2909
2665
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
2910
2666
  return [];
@@ -2924,7 +2680,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2924
2680
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
2925
2681
  return ({
2926
2682
  category,
2927
- products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
2683
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
2928
2684
  });
2929
2685
  })));
2930
2686
  return homeSections;
@@ -2936,7 +2692,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2936
2692
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
2937
2693
  return [];
2938
2694
  const products = [];
2939
- const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(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 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
2695
+ 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: [
2940
2696
  'id',
2941
2697
  'name',
2942
2698
  'slug',
@@ -2960,8 +2716,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2960
2716
  'tags',
2961
2717
  'type',
2962
2718
  'shoppingCount',
2963
- 'gender',
2964
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
2719
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
2965
2720
  products.push(...productsData);
2966
2721
  return products;
2967
2722
  });
@@ -2971,7 +2726,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2971
2726
  return __awaiter(this, void 0, void 0, function* () {
2972
2727
  if (!Number.isNaN(+id))
2973
2728
  return id;
2974
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
2729
+ const { data } = yield this.find({ filters: { firestoreId: id } });
2975
2730
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
2976
2731
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
2977
2732
  throw new NotFoundError(`Category with id ${id} not found`);
@@ -3029,218 +2784,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3029
2784
  return plainData.metadata;
3030
2785
  });
3031
2786
  }
3032
- updateFilters(categoryId, { filters }) {
3033
- return __awaiter(this, void 0, void 0, function* () {
3034
- if ('action' in filters && filters.action === 'remove' && filters.value.length) {
3035
- for (let i = 0; i < filters.value.length; i++) {
3036
- yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
3037
- }
3038
- return [];
3039
- }
3040
- if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3041
- let filtersList = [];
3042
- for (let i = 0; i < filters.value.length; i++) {
3043
- try {
3044
- const hasFilter = yield this.categoryFilterRepository
3045
- .find({
3046
- filters: {
3047
- categoryId,
3048
- filterId: filters.value[i].id,
3049
- },
3050
- })
3051
- .then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
3052
- if (hasFilter) {
3053
- filtersList.push(hasFilter);
3054
- }
3055
- else {
3056
- yield this.categoryFilterRepository.create({
3057
- filterId: filters.value[i].id,
3058
- categoryId,
3059
- });
3060
- filtersList.push(filters.value[i]);
3061
- }
3062
- }
3063
- catch (error) {
3064
- console.log('catch error: ', error);
3065
- }
3066
- }
3067
- return filtersList;
3068
- }
3069
- if (Array.isArray(filters) && filters.length) {
3070
- let filtersList = [];
3071
- for (let i = 0; i < filters.length; i++) {
3072
- try {
3073
- const hasFilter = yield this.categoryFilterRepository
3074
- .find({
3075
- filters: {
3076
- categoryId,
3077
- filterId: filters[i].id,
3078
- },
3079
- })
3080
- .then((data) => { var _a; return (_a = data.data.shift()) === null || _a === void 0 ? void 0 : _a.filter; });
3081
- if (hasFilter) {
3082
- filtersList.push(hasFilter);
3083
- }
3084
- else {
3085
- yield this.categoryFilterRepository.create({
3086
- filterId: filters[i].id,
3087
- categoryId,
3088
- });
3089
- filtersList.push(filters[i]);
3090
- }
3091
- }
3092
- catch (error) {
3093
- console.log('catch error: ', error);
3094
- }
3095
- }
3096
- return filtersList;
3097
- }
3098
- return [];
3099
- });
3100
- }
3101
- }
3102
-
3103
- class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3104
- constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
3105
- super({
3106
- tableName: 'filter',
3107
- model: Filter,
3108
- endpoint,
3109
- authOptions,
3110
- fields: [
3111
- 'id',
3112
- 'description',
3113
- 'slug',
3114
- 'enabled',
3115
- { createdAt: { columnName: 'created_at' } },
3116
- { updatedAt: { columnName: 'updated_at' } },
3117
- {
3118
- options: {
3119
- columnName: 'options',
3120
- foreignKeyColumn: { filterId: 'id' },
3121
- fields: [
3122
- 'id',
3123
- { filterId: { columnName: 'filter_id' } },
3124
- 'description',
3125
- { createdAt: { columnName: 'created_at' } },
3126
- { updatedAt: { columnName: 'updated_at' } },
3127
- ],
3128
- },
3129
- },
3130
- ],
3131
- });
3132
- this.filterOptionRepository = filterOptionRepository;
3133
- this.categoryFilterRepository = categoryFilterRepository;
3134
- }
3135
- update(params) {
3136
- const _super = Object.create(null, {
3137
- update: { get: () => super.update }
3138
- });
3139
- return __awaiter(this, void 0, void 0, function* () {
3140
- const { options } = params, data = __rest(params, ["options"]);
3141
- const filter = yield _super.update.call(this, data);
3142
- filter.options = yield this.updateOptions(+data.id, { options });
3143
- return filter;
3144
- });
3145
- }
3146
- updateOptions(filterId, { options }) {
3147
- return __awaiter(this, void 0, void 0, function* () {
3148
- if (!options)
3149
- return [];
3150
- if ('action' in options && options.action === 'remove' && options.value.length) {
3151
- for (let i = 0; i < options.value.length; i++) {
3152
- yield this.filterOptionRepository.delete({ id: options.value[i].id });
3153
- }
3154
- return [];
3155
- }
3156
- if ('action' in options && options.action === 'merge' && options.value.length) {
3157
- let filterOptions = [];
3158
- for (let i = 0; i < options.value.length; i++) {
3159
- try {
3160
- const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
3161
- if (hasFilter)
3162
- filterOptions.push(hasFilter);
3163
- }
3164
- catch (error) {
3165
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
3166
- filterOptions.push(newOption);
3167
- }
3168
- }
3169
- return filterOptions;
3170
- }
3171
- if (Array.isArray(options) && options.length) {
3172
- let filterOptions = [];
3173
- for (let i = 0; i < options.length; i++) {
3174
- try {
3175
- const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
3176
- if (hasFilter)
3177
- filterOptions.push(hasFilter);
3178
- }
3179
- catch (error) {
3180
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
3181
- filterOptions.push(newOption);
3182
- }
3183
- }
3184
- }
3185
- return [];
3186
- });
3187
- }
3188
- delete(params) {
3189
- const _super = Object.create(null, {
3190
- delete: { get: () => super.delete }
3191
- });
3192
- return __awaiter(this, void 0, void 0, function* () {
3193
- const { data: categoryFilters } = yield this.categoryFilterRepository.find({
3194
- filters: {
3195
- filterId: params.id,
3196
- },
3197
- });
3198
- if (categoryFilters.length)
3199
- throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
3200
- yield this.deleteOptions(+params.id);
3201
- yield _super.delete.call(this, { id: +params.id });
3202
- return;
3203
- });
3204
- }
3205
- deleteOptions(filterId) {
3206
- return __awaiter(this, void 0, void 0, function* () {
3207
- yield this.mutation('delete_filter_option', ['affected_rows'], {
3208
- where: {
3209
- type: 'filter_option_bool_exp',
3210
- required: true,
3211
- value: { filter_id: { _eq: filterId } },
3212
- },
3213
- });
3214
- });
3215
- }
3216
- }
3217
-
3218
- class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3219
- constructor({ endpoint, authOptions, interceptors, }) {
3220
- super({
3221
- tableName: 'filter_option',
3222
- model: FilterOption,
3223
- endpoint,
3224
- authOptions,
3225
- fields: [
3226
- 'id',
3227
- 'description',
3228
- { filterId: { columnName: 'filter_id' } },
3229
- { createdAt: { columnName: 'created_at' } },
3230
- { updatedAt: { columnName: 'updated_at' } },
3231
- ],
3232
- });
3233
- }
3234
2787
  }
3235
2788
 
3236
2789
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3237
- constructor({ endpoint, authOptions, interceptors, }) {
2790
+ constructor(endpoint, authOptions) {
3238
2791
  super({
3239
2792
  tableName: 'product',
3240
2793
  model: ProductHasuraGraphQL,
3241
2794
  endpoint,
3242
2795
  authOptions,
3243
- interceptors,
3244
2796
  fields: [],
3245
2797
  });
3246
2798
  this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id']))), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
@@ -3337,7 +2889,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3337
2889
  'weight',
3338
2890
  'gender',
3339
2891
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
3340
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
3341
2892
  { isKit: { columnName: 'is_kit' } },
3342
2893
  { createdAt: { columnName: 'created_at' } },
3343
2894
  { updatedAt: { columnName: 'updated_at' } },
@@ -3439,7 +2990,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3439
2990
  var _a;
3440
2991
  return __awaiter(this, void 0, void 0, function* () {
3441
2992
  const product = Number.isNaN(+identifiers.id)
3442
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2993
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
3443
2994
  : yield _super.get.call(this, identifiers);
3444
2995
  if (product.productId)
3445
2996
  throw new NotFoundError('Product not found, it is a variant');
@@ -3467,12 +3018,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3467
3018
  filters: {
3468
3019
  slug,
3469
3020
  },
3470
- fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
3471
- options: {
3472
- enableCount: false,
3473
- },
3474
3021
  });
3475
3022
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
3023
+ product.reviews = yield this.findReviewsByProduct(+product.id);
3476
3024
  return product;
3477
3025
  });
3478
3026
  }
@@ -3635,7 +3183,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3635
3183
  return __awaiter(this, void 0, void 0, function* () {
3636
3184
  if (!Number.isNaN(+id))
3637
3185
  return id;
3638
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3186
+ const { data } = yield this.find({ filters: { firestoreId: id } });
3639
3187
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3640
3188
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3641
3189
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3691,31 +3239,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3691
3239
  return data && data[0] && this.bindReviewToModel(data[0]);
3692
3240
  });
3693
3241
  }
3694
- cleanShoppingCountFromIds(ids) {
3695
- return __awaiter(this, void 0, void 0, function* () {
3696
- return yield this.mutation('update_product', ['affected_rows'], {
3697
- where: {
3698
- value: { id: { _nin: ids } },
3699
- type: 'product_bool_exp',
3700
- required: true,
3701
- },
3702
- _set: {
3703
- value: { shopping_count: 0 },
3704
- type: 'product_set_input',
3705
- },
3706
- });
3707
- });
3708
- }
3709
3242
  }
3710
3243
 
3711
3244
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3712
- constructor({ endpoint, authOptions, interceptors, }) {
3245
+ constructor(endpoint, authOptions) {
3713
3246
  super({
3714
3247
  tableName: 'product',
3715
3248
  model: VariantHasuraGraphQL,
3716
3249
  endpoint,
3717
3250
  authOptions,
3718
- interceptors,
3719
3251
  fields: [
3720
3252
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
3721
3253
  { firestoreId: { columnName: 'firestore_id' } },
@@ -3745,9 +3277,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3745
3277
  subscriber_price: filters.subscriberPrice,
3746
3278
  }));
3747
3279
  },
3748
- bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (((priceData === null || priceData === void 0 ? void 0 : priceData.price) || 0) >= 0 && { price: priceData.price })), (((priceData === null || priceData === void 0 ? void 0 : priceData.fullPrice) || 0) >= 0 && { full_price: priceData.fullPrice })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberDiscountPercentage) || 0) >= 0 && {
3280
+ 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 && {
3749
3281
  subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
3750
- })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberPrice) || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }))),
3282
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
3751
3283
  },
3752
3284
  },
3753
3285
  { fullPrice: { columnName: 'full_price' } },
@@ -3816,7 +3348,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3816
3348
  return __awaiter(this, void 0, void 0, function* () {
3817
3349
  if (!Number.isNaN(+id))
3818
3350
  return id;
3819
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3351
+ const { data } = yield this.find({ filters: { firestoreId: id } });
3820
3352
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3821
3353
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3822
3354
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3828,5 +3360,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3828
3360
  * Generated bundle index. Do not edit.
3829
3361
  */
3830
3362
 
3831
- 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, 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, ShopSettings, ShopSettingsFirestoreRepository, 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, get, is, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3363
+ 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, chunk, get, is, isBoolean, isDate, isEmpty, isInteger, isNaN$1 as isNaN, isNil, isNumber, isObject, isString, isUUID, now, omit, parseDateTime, pick, set, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3832
3364
  //# sourceMappingURL=infrab4a-connect.mjs.map