@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 } 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";
@@ -759,15 +762,6 @@ class RecoveryPassword {
759
762
  }
760
763
  }
761
764
 
762
- class Filter extends BaseModel {
763
- identifierFields() {
764
- return ['id'];
765
- }
766
- static get identifiersFields() {
767
- return ['id'];
768
- }
769
- }
770
-
771
765
  class Category extends BaseModel {
772
766
  identifierFields() {
773
767
  return ['id'];
@@ -776,20 +770,6 @@ class Category extends BaseModel {
776
770
  return ['id'];
777
771
  }
778
772
  }
779
- __decorate([
780
- Type(() => Filter),
781
- __metadata("design:type", Array)
782
- ], Category.prototype, "filters", void 0);
783
-
784
- class CategoryFilter extends BaseModel {
785
- static get identifiersFields() {
786
- return ['id'];
787
- }
788
- }
789
- __decorate([
790
- Type(() => Filter),
791
- __metadata("design:type", Filter)
792
- ], CategoryFilter.prototype, "filter", void 0);
793
773
 
794
774
  var GenderDestination;
795
775
  (function (GenderDestination) {
@@ -806,15 +786,6 @@ var Shops;
806
786
  Shops["ALL"] = "ALL";
807
787
  })(Shops || (Shops = {}));
808
788
 
809
- class FilterOption extends BaseModel {
810
- identifierFields() {
811
- return ['id'];
812
- }
813
- static get identifiersFields() {
814
- return ['id'];
815
- }
816
- }
817
-
818
789
  class Product extends BaseModel {
819
790
  identifierFields() {
820
791
  return ['id'];
@@ -851,27 +822,17 @@ class Variant extends BaseModel {
851
822
  }
852
823
  }
853
824
 
854
- class Buy2Win extends BaseModel {
855
- static get identifiersFields() {
856
- return ['id'];
857
- }
858
- }
859
- __decorate([
860
- Type(() => Category),
861
- __metadata("design:type", Array)
862
- ], Buy2Win.prototype, "categories", void 0);
863
-
864
- class CampaignDashboard extends BaseModel {
865
- static get identifiersFields() {
866
- return ['id'];
867
- }
868
- }
869
-
870
- class CampaignHashtag extends BaseModel {
871
- static get identifiersFields() {
872
- return ['id'];
873
- }
874
- }
825
+ var OrderStatus;
826
+ (function (OrderStatus) {
827
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
828
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
829
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
830
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
831
+ OrderStatus["ENVIADO"] = "Enviado";
832
+ OrderStatus["ENTREGUE"] = "Entregue";
833
+ OrderStatus["CANCELADO"] = "Cancelado";
834
+ OrderStatus["CREDIT_CARD"] = "credit_card";
835
+ })(OrderStatus || (OrderStatus = {}));
875
836
 
876
837
  class LineItem extends Product {
877
838
  }
@@ -912,18 +873,6 @@ __decorate([
912
873
  __metadata("design:type", Coupon)
913
874
  ], Checkout.prototype, "coupon", void 0);
914
875
 
915
- var OrderStatus;
916
- (function (OrderStatus) {
917
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
918
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
919
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
920
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
921
- OrderStatus["ENVIADO"] = "Enviado";
922
- OrderStatus["ENTREGUE"] = "Entregue";
923
- OrderStatus["CANCELADO"] = "Cancelado";
924
- OrderStatus["CREDIT_CARD"] = "credit_card";
925
- })(OrderStatus || (OrderStatus = {}));
926
-
927
876
  class Order extends Checkout {
928
877
  }
929
878
  __decorate([
@@ -953,6 +902,16 @@ __decorate([
953
902
  __metadata("design:type", Coupon)
954
903
  ], CheckoutSubscription.prototype, "coupon", void 0);
955
904
 
905
+ class Buy2Win extends BaseModel {
906
+ static get identifiersFields() {
907
+ return ['id'];
908
+ }
909
+ }
910
+ __decorate([
911
+ Type(() => Category),
912
+ __metadata("design:type", Array)
913
+ ], Buy2Win.prototype, "categories", void 0);
914
+
956
915
  var FilterType;
957
916
  (function (FilterType) {
958
917
  FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
@@ -1052,12 +1011,6 @@ class ShopMenu extends BaseModel {
1052
1011
  }
1053
1012
  }
1054
1013
 
1055
- class ShopSettings extends BaseModel {
1056
- static get identifiersFields() {
1057
- return ['id'];
1058
- }
1059
- }
1060
-
1061
1014
  class InvalidArgumentError extends CustomError {
1062
1015
  constructor(message) {
1063
1016
  super(message);
@@ -1157,7 +1110,6 @@ class ProductsIndex {
1157
1110
  'stock',
1158
1111
  'weight',
1159
1112
  'tags',
1160
- 'filters',
1161
1113
  'hasVariants',
1162
1114
  'type',
1163
1115
  ];
@@ -1250,17 +1202,9 @@ const withFirestore = (MixinBase) => {
1250
1202
  }), {});
1251
1203
  };
1252
1204
  return class extends MixinBase {
1253
- constructor(...params) {
1254
- const options = params[0];
1255
- super(...params);
1256
- this.fields = {};
1257
- this.interceptors = {};
1205
+ constructor() {
1206
+ super(...arguments);
1258
1207
  this.collectionName = '';
1259
- this.firestore = options.firestore;
1260
- this.collectionName = options.collectionName;
1261
- this.model = options.model;
1262
- this.fields = options.fields;
1263
- this.interceptors = options.interceptors;
1264
1208
  }
1265
1209
  collection(path) {
1266
1210
  return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
@@ -1307,14 +1251,11 @@ const withHelpers = (MixinBase) => {
1307
1251
  const withGetFirestore = (MixinBase) => {
1308
1252
  return class GetFirestore extends MixinBase {
1309
1253
  async get(identifiers) {
1310
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
1311
- const intercepted = await this.interceptors?.request?.({ instance });
1312
- const builded = intercepted?.instance || instance;
1313
- const docRef = await getDoc(doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
1254
+ const docRef = await getDoc(doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
1314
1255
  const data = docRef.data();
1315
1256
  if (isNil(data))
1316
1257
  throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1317
- return this.interceptors?.response?.(data, intercepted) || data;
1258
+ return data;
1318
1259
  }
1319
1260
  buildCollectionPathForGet(identifiers) {
1320
1261
  return this.isSubCollection(this)
@@ -1395,11 +1336,8 @@ const withFindFirestore = (MixinBase) => {
1395
1336
  return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
1396
1337
  };
1397
1338
  }
1398
- async find(find = {}) {
1399
- const collection = this.collection(this.buildCollectionPathForFind(find.filters));
1400
- const enableCount = find?.options?.enableCount ?? true;
1401
- const intercepted = await this.interceptors?.request?.({ find });
1402
- const { filters, limits, orderBy } = intercepted.find || find;
1339
+ async find({ filters, limits, orderBy, } = {}) {
1340
+ const collection = this.collection(this.buildCollectionPathForFind(filters));
1403
1341
  const queries = this.makeFirestoreWhere(filters || {});
1404
1342
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
1405
1343
  const offsets = await this.defineLimits(filters, limits);
@@ -1407,8 +1345,8 @@ const withFindFirestore = (MixinBase) => {
1407
1345
  const docs = await getDocs(query(collection, ...queryArgumments));
1408
1346
  const data = docs.docs.map((doc) => doc.data());
1409
1347
  return {
1410
- data: (await this.interceptors?.response?.(data, intercepted)) || data,
1411
- count: enableCount ? this.calculateCount(data, limits) : Infinity,
1348
+ data,
1349
+ count: this.calculateCount(data, limits),
1412
1350
  };
1413
1351
  }
1414
1352
  buildCollectionPathForFind(filters) {
@@ -1422,7 +1360,7 @@ const withFindFirestore = (MixinBase) => {
1422
1360
  const queries = [];
1423
1361
  if (limits?.offset) {
1424
1362
  if (this.model.isModel(limits.offset))
1425
- queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier[limits.offset.identifiersFields?.shift()]))));
1363
+ queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
1426
1364
  else if (isNumber(limits.offset) || isString(limits.offset))
1427
1365
  queries.push(startAt(limits.offset));
1428
1366
  }
@@ -1443,13 +1381,9 @@ const withFindFirestore = (MixinBase) => {
1443
1381
  const withCreateFirestore = (MixinBase) => {
1444
1382
  return class CreateFirestore extends MixinBase {
1445
1383
  async create(data) {
1446
- const instance = this.model.toInstance(data);
1447
- const intercepted = await this.interceptors?.request?.({ instance });
1448
- const builded = intercepted?.instance || instance;
1449
- const docRef = await this.save(builded);
1384
+ const docRef = await this.save(this.model.toInstance(data));
1450
1385
  const doc = await getDoc(docRef);
1451
- const docBuilded = (await this.interceptors?.response?.(doc.data(), intercepted)) || doc.data();
1452
- return docBuilded;
1386
+ return doc.data();
1453
1387
  }
1454
1388
  async save(data) {
1455
1389
  const id = data.identifier[data.identifiersFields?.shift()]?.toString();
@@ -1493,12 +1427,9 @@ const withUpdateFirestore = (MixinBase) => {
1493
1427
  const model = new this.model();
1494
1428
  const keyField = model.identifiersFields.shift();
1495
1429
  const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
1496
- const plainFromData = this.model.toInstance(this.paramsToPlain(data));
1497
- const intercepted = await this.interceptors?.request?.({ instance: plainFromData });
1498
- const builded = intercepted?.instance || plainFromData;
1499
- await setDoc(docRef, builded.toPlain(), { merge: true });
1500
- const docData = await getDoc(docRef).then((doc) => doc.data());
1501
- return this.interceptors?.response?.(docData, intercepted) || docData;
1430
+ await setDoc(docRef, this.paramsToPlain(data), { merge: true });
1431
+ const docData = await getDoc(docRef);
1432
+ return docData.data();
1502
1433
  }
1503
1434
  buildCollectionPathForUpdate(identifiers) {
1504
1435
  return this.isSubCollection(this)
@@ -1520,11 +1451,7 @@ const withUpdateFirestore = (MixinBase) => {
1520
1451
  const withDeleteFirestore = (MixinBase) => {
1521
1452
  return class DeleteFirestore extends MixinBase {
1522
1453
  async delete(identifiers) {
1523
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
1524
- const intercepted = await this.interceptors?.request?.({ instance });
1525
- const builded = intercepted?.instance || instance;
1526
- await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
1527
- await this.interceptors?.response?.(instance, intercepted);
1454
+ await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
1528
1455
  }
1529
1456
  buildCollectionPathForRemove(identifiers) {
1530
1457
  return this.isSubCollection(this)
@@ -1536,10 +1463,8 @@ const withDeleteFirestore = (MixinBase) => {
1536
1463
 
1537
1464
  const withSubCollection = (MixinBase, ParentModel) => {
1538
1465
  return class SubCollectionMix extends MixinBase {
1539
- constructor(...params) {
1540
- const options = params[0];
1541
- super(...params);
1542
- this.parentIdField = options.parentIdField;
1466
+ constructor(...args) {
1467
+ super(args);
1543
1468
  }
1544
1469
  collection(path) {
1545
1470
  return super.collection(path);
@@ -1553,87 +1478,73 @@ const withCrudFirestore = (MixinBase) => {
1553
1478
  };
1554
1479
 
1555
1480
  class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1556
- constructor({ firestore, interceptors }) {
1557
- super({
1558
- firestore,
1559
- collectionName: 'leads',
1560
- model: Lead,
1561
- interceptors,
1562
- });
1481
+ constructor(firestore) {
1482
+ super();
1483
+ this.firestore = firestore;
1484
+ this.collectionName = 'leads';
1485
+ this.model = Lead;
1563
1486
  }
1564
1487
  }
1565
1488
 
1566
1489
  class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1567
- constructor({ firestore, interceptors }, parentRepository) {
1568
- super({
1569
- firestore,
1570
- collectionName: 'editions',
1571
- parentIdField: 'subscriptionId',
1572
- model: Edition,
1573
- interceptors,
1574
- });
1490
+ constructor(firestore, parentRepository) {
1491
+ super();
1492
+ this.firestore = firestore;
1575
1493
  this.parentRepository = parentRepository;
1494
+ this.collectionName = 'editions';
1495
+ this.parentIdField = 'subscriptionId';
1496
+ this.model = Edition;
1576
1497
  }
1577
1498
  }
1578
1499
 
1579
1500
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1580
- constructor({ firestore, interceptors, }) {
1581
- super({
1582
- firestore,
1583
- collectionName: 'subscription',
1584
- model: Subscription,
1585
- interceptors,
1586
- });
1501
+ constructor(firestore) {
1502
+ super();
1503
+ this.firestore = firestore;
1504
+ this.collectionName = 'subscription';
1505
+ this.model = Subscription;
1587
1506
  }
1588
1507
  }
1589
1508
 
1590
1509
  class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1591
- constructor({ firestore, interceptors }, parentRepository) {
1592
- super({
1593
- firestore,
1594
- collectionName: 'payments',
1595
- parentIdField: 'subscriptionId',
1596
- model: SubscriptionPayment,
1597
- interceptors,
1598
- });
1510
+ constructor(firestore, parentRepository) {
1511
+ super();
1512
+ this.firestore = firestore;
1599
1513
  this.parentRepository = parentRepository;
1514
+ this.collectionName = 'payments';
1515
+ this.parentIdField = 'subscriptionId';
1516
+ this.model = SubscriptionPayment;
1600
1517
  }
1601
1518
  }
1602
1519
 
1603
1520
  class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1604
- constructor({ firestore, interceptors }, parentRepository) {
1605
- super({
1606
- firestore,
1607
- collectionName: 'address',
1608
- parentIdField: 'userId',
1609
- model: UserAddress,
1610
- interceptors,
1611
- });
1521
+ constructor(firestore, parentRepository) {
1522
+ super();
1523
+ this.firestore = firestore;
1612
1524
  this.parentRepository = parentRepository;
1525
+ this.collectionName = 'address';
1526
+ this.parentIdField = 'userId';
1527
+ this.model = UserAddress;
1613
1528
  }
1614
1529
  }
1615
1530
 
1616
1531
  class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1617
- constructor({ firestore, interceptors }, parentRepository) {
1618
- super({
1619
- firestore,
1620
- collectionName: 'CX',
1621
- parentIdField: 'userId',
1622
- model: BeautyProfile,
1623
- interceptors,
1624
- });
1532
+ constructor(firestore, parentRepository) {
1533
+ super();
1534
+ this.firestore = firestore;
1625
1535
  this.parentRepository = parentRepository;
1536
+ this.collectionName = 'CX';
1537
+ this.parentIdField = 'userId';
1538
+ this.model = BeautyProfile;
1626
1539
  }
1627
1540
  }
1628
1541
 
1629
1542
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1630
- constructor({ firestore, interceptors }) {
1631
- super({
1632
- firestore,
1633
- collectionName: 'users',
1634
- model: User,
1635
- interceptors,
1636
- });
1543
+ constructor(firestore) {
1544
+ super();
1545
+ this.firestore = firestore;
1546
+ this.collectionName = 'users';
1547
+ this.model = User;
1637
1548
  }
1638
1549
  async get(identifiers) {
1639
1550
  const user = await super.get({ id: identifiers.id });
@@ -1673,26 +1584,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1673
1584
  }
1674
1585
 
1675
1586
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1676
- constructor({ firestore, interceptors }, parentRepository) {
1677
- super({
1678
- firestore,
1679
- collectionName: 'payment_method',
1680
- parentIdField: 'userId',
1681
- model: UserPaymentMethod,
1682
- interceptors,
1683
- });
1587
+ constructor(firestore, parentRepository) {
1588
+ super();
1589
+ this.firestore = firestore;
1684
1590
  this.parentRepository = parentRepository;
1591
+ this.collectionName = 'payment_method';
1592
+ this.parentIdField = 'userId';
1593
+ this.model = UserPaymentMethod;
1685
1594
  }
1686
1595
  }
1687
1596
 
1688
1597
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1689
- constructor({ firestore, interceptors }) {
1690
- super({
1691
- firestore,
1692
- collectionName: 'categories',
1693
- model: Category,
1694
- interceptors,
1695
- });
1598
+ constructor(firestore) {
1599
+ super();
1600
+ this.firestore = firestore;
1601
+ this.collectionName = 'categories';
1602
+ this.model = Category;
1696
1603
  }
1697
1604
  async getCategoryBySlug(slug, shop) {
1698
1605
  const categoryDocs = await getDocs(query(this.collection(this.collectionName), where('slug', '==', slug), where('shop', '==', shop), where('published', '==', true)));
@@ -1702,14 +1609,14 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1702
1609
  throw new NotFoundError(`Document with slug ${slug} not found`);
1703
1610
  return categoryDocs.docs[0].data();
1704
1611
  }
1705
- async getCategoriesForHome(categoryIds, limit = 4, gender) {
1612
+ async getCategoriesForHome(categoryIds, limit = 4) {
1706
1613
  const categorySnap = await getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
1707
1614
  if (categorySnap.empty)
1708
1615
  throw new NotFoundError('Categories not found');
1709
1616
  const categories = categorySnap.docs.map((doc) => doc.data());
1710
1617
  const homeSections = await Promise.all(categories.map(async (category) => ({
1711
1618
  category,
1712
- products: await this.mountCategory(category, { limit, hasStock: true, gender }),
1619
+ products: await this.mountCategory(category, { limit, hasStock: true }),
1713
1620
  })));
1714
1621
  return homeSections;
1715
1622
  }
@@ -1725,8 +1632,6 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1725
1632
  wheres.push(where('published', '==', true), where('id', 'in', productIds));
1726
1633
  if (options?.hasStock)
1727
1634
  wheres.push(where('stock.quantity', '>', 0));
1728
- if (options?.gender)
1729
- wheres.push(where('tags', 'array-contains', options?.gender));
1730
1635
  if (options?.limit)
1731
1636
  wheres.push(limit(options?.limit));
1732
1637
  const productSnap = await getDocs(query(this.collection('productsErpVitrine'), ...wheres));
@@ -1739,14 +1644,12 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1739
1644
  }
1740
1645
 
1741
1646
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1742
- constructor({ firestore, interceptors }) {
1743
- super({
1744
- firestore,
1745
- collectionName: 'productsErpVitrine',
1746
- model: Product,
1747
- interceptors,
1748
- });
1647
+ constructor(firestore) {
1648
+ super();
1649
+ this.firestore = firestore;
1749
1650
  this.reviews = {};
1651
+ this.collectionName = 'productsErpVitrine';
1652
+ this.model = Product;
1750
1653
  }
1751
1654
  async getBySlug(slug) {
1752
1655
  const result = await this.find({
@@ -1781,98 +1684,43 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
1781
1684
  });
1782
1685
  return this.reviews[status];
1783
1686
  }
1784
- cleanShoppingCountFromIds() {
1785
- return;
1786
- }
1787
1687
  }
1788
1688
 
1789
1689
  class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
1790
- constructor({ firestore, interceptors }, parentRepository) {
1791
- super({
1792
- firestore,
1793
- collectionName: 'variants',
1794
- parentIdField: 'productId',
1795
- model: Variant,
1796
- interceptors,
1797
- });
1690
+ constructor(firestore, parentRepository) {
1691
+ super();
1692
+ this.firestore = firestore;
1798
1693
  this.parentRepository = parentRepository;
1694
+ this.collectionName = 'variants';
1695
+ this.parentIdField = 'productId';
1696
+ this.model = Variant;
1799
1697
  }
1800
1698
  }
1801
1699
 
1802
1700
  class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1803
- constructor({ firestore, interceptors }) {
1804
- super({
1805
- firestore,
1806
- collectionName: 'subscriptionProducts',
1807
- model: Product,
1808
- interceptors,
1809
- });
1810
- }
1811
- }
1812
-
1813
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1814
- constructor({ firestore, interceptors }) {
1815
- super({
1816
- firestore,
1817
- collectionName: 'buy2win',
1818
- model: Buy2Win,
1819
- interceptors,
1820
- });
1821
- }
1822
- }
1823
-
1824
- class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1825
- constructor({ firestore, interceptors, }) {
1826
- super({
1827
- firestore,
1828
- collectionName: 'dashboardCampaignsAuto',
1829
- model: CampaignDashboard,
1830
- interceptors,
1831
- });
1832
- }
1833
- }
1834
-
1835
- class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1836
- constructor({ firestore, interceptors, }) {
1837
- super({
1838
- firestore,
1839
- collectionName: 'hashtagCampaignsAuto',
1840
- model: CampaignHashtag,
1841
- interceptors,
1842
- });
1701
+ constructor(firestore) {
1702
+ super();
1703
+ this.firestore = firestore;
1704
+ this.collectionName = 'subscriptionProducts';
1705
+ this.model = Product;
1843
1706
  }
1844
1707
  }
1845
1708
 
1846
1709
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1847
- constructor({ firestore, interceptors }) {
1848
- super({
1849
- firestore,
1850
- collectionName: 'checkouts',
1851
- model: Checkout,
1852
- interceptors,
1853
- });
1854
- }
1855
- }
1856
-
1857
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1858
- constructor({ firestore, interceptors, }) {
1859
- super({
1860
- firestore,
1861
- collectionName: 'checkoutsSubscription',
1862
- model: CheckoutSubscription,
1863
- interceptors,
1864
- });
1710
+ constructor(firestore) {
1711
+ super();
1712
+ this.firestore = firestore;
1713
+ this.collectionName = 'checkouts';
1714
+ this.model = Checkout;
1865
1715
  }
1866
1716
  }
1867
1717
 
1868
1718
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1869
- constructor({ firestore, interceptors }) {
1870
- super({
1871
- firestore,
1872
- collectionName: 'coupons',
1873
- model: Coupon,
1874
- interceptors,
1875
- });
1719
+ constructor(firestore) {
1720
+ super();
1721
+ this.firestore = firestore;
1722
+ this.collectionName = 'coupons';
1723
+ this.model = Coupon;
1876
1724
  }
1877
1725
  buildModelInstance() {
1878
1726
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1894,16 +1742,9 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
1894
1742
  }
1895
1743
 
1896
1744
  class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1897
- constructor({ firestore, interceptors }) {
1898
- super({
1899
- firestore,
1900
- collectionName: 'orders',
1901
- model: Order,
1902
- interceptors,
1903
- fields: {
1904
- status: FirestoreFieldType.String,
1905
- },
1906
- });
1745
+ constructor(firestore) {
1746
+ super();
1747
+ this.firestore = firestore;
1907
1748
  this.orderFromFirestore = (order) => {
1908
1749
  if (!!order?.lineItems?.length) {
1909
1750
  order.lineItems = order.lineItems.map((lineItem) => {
@@ -1916,6 +1757,11 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1916
1757
  }
1917
1758
  return order;
1918
1759
  };
1760
+ this.collectionName = 'orders';
1761
+ this.model = Order;
1762
+ this.fields = {
1763
+ status: FirestoreFieldType.String,
1764
+ };
1919
1765
  }
1920
1766
  buildModelInstance() {
1921
1767
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1929,46 +1775,54 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1929
1775
  }
1930
1776
  }
1931
1777
 
1932
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1933
- constructor({ firestore, interceptors }) {
1934
- super({
1935
- firestore,
1936
- interceptors,
1937
- });
1938
- this.collectionName = 'legacyOrders';
1778
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1779
+ constructor(firestore) {
1780
+ super();
1781
+ this.firestore = firestore;
1782
+ this.collectionName = 'payments';
1783
+ this.model = Payment;
1939
1784
  }
1940
1785
  }
1941
1786
 
1942
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1943
- constructor({ firestore, interceptors }) {
1944
- super({
1945
- firestore,
1946
- collectionName: 'payments',
1947
- model: Payment,
1948
- interceptors,
1949
- });
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;
1950
1793
  }
1951
1794
  }
1952
1795
 
1953
1796
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1954
- constructor({ firestore, interceptors, }) {
1955
- super({
1956
- firestore,
1957
- collectionName: 'subscriptionPlans',
1958
- model: SubscriptionPlan,
1959
- interceptors,
1960
- });
1797
+ constructor(firestore) {
1798
+ super();
1799
+ this.firestore = firestore;
1800
+ this.collectionName = 'subscriptionPlans';
1801
+ this.model = SubscriptionPlan;
1802
+ }
1803
+ }
1804
+
1805
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1806
+ constructor(firestore) {
1807
+ super();
1808
+ this.firestore = firestore;
1809
+ this.collectionName = 'buy2win';
1810
+ this.model = Buy2Win;
1811
+ }
1812
+ }
1813
+
1814
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1815
+ constructor(firestore) {
1816
+ super(firestore);
1817
+ this.firestore = firestore;
1818
+ this.collectionName = 'legacyOrders';
1961
1819
  }
1962
1820
  }
1963
1821
 
1964
1822
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1965
- constructor({ firestore, interceptors }) {
1966
- super({
1967
- firestore,
1968
- collectionName: 'dms',
1969
- model: Home,
1970
- interceptors,
1971
- });
1823
+ constructor(firestore) {
1824
+ super();
1825
+ this.firestore = firestore;
1972
1826
  this.homeToFirestore = (home) => {
1973
1827
  if (home.data?.data) {
1974
1828
  home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
@@ -1997,6 +1851,8 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1997
1851
  category: Category.toInstance(homeCategoryGroup.category),
1998
1852
  products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
1999
1853
  });
1854
+ this.collectionName = 'dms';
1855
+ this.model = Home;
2000
1856
  }
2001
1857
  buildModelInstance() {
2002
1858
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2014,24 +1870,11 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2014
1870
  }
2015
1871
 
2016
1872
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2017
- constructor({ firestore, interceptors }) {
2018
- super({
2019
- firestore,
2020
- collectionName: 'shopMenus',
2021
- model: ShopMenu,
2022
- interceptors,
2023
- });
2024
- }
2025
- }
2026
-
2027
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2028
- constructor({ firestore, interceptors, }) {
2029
- super({
2030
- firestore,
2031
- collectionName: 'shopSettings',
2032
- model: ShopSettings,
2033
- interceptors,
2034
- });
1873
+ constructor(firestore) {
1874
+ super();
1875
+ this.firestore = firestore;
1876
+ this.collectionName = 'shopMenus';
1877
+ this.model = ShopMenu;
2035
1878
  }
2036
1879
  }
2037
1880
 
@@ -2108,7 +1951,7 @@ class AttributeOptionHelper {
2108
1951
  }
2109
1952
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2110
1953
  if (fields.includes(attributeName))
2111
- return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
1954
+ return { columnName: attributeName.toString(), attributeName };
2112
1955
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2113
1956
  const fieldOption = is(field)?.[attributeName];
2114
1957
  if (isNil(fieldOption))
@@ -2310,10 +2153,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
2310
2153
  }
2311
2154
  if (!!from)
2312
2155
  return { ...result, [attributeName]: from(data[columnName], data) };
2313
- return {
2314
- ...result,
2315
- [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName],
2316
- };
2156
+ return { ...result, [attributeName]: parseDateTime(data[columnName].toString()) };
2317
2157
  }, {});
2318
2158
  GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2319
2159
  const data = instance.toPlain?.() || instance;
@@ -2443,14 +2283,11 @@ const withHasuraGraphQL = (MixinBase) => {
2443
2283
  get headers() {
2444
2284
  return {
2445
2285
  'Content-Type': 'application/json',
2446
- ...(isNil(this.authOptions?.authToken) ? {} : { Authorization: this.authOptions?.authToken }),
2447
- ...(isNil(this.authOptions?.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions?.adminSecret }),
2448
- ...(isNil(this.authOptions?.authRole)
2286
+ ...(isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken }),
2287
+ ...(isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret }),
2288
+ ...(isNil(this.authOptions.authRole)
2449
2289
  ? {}
2450
- : {
2451
- 'X-Hasura-Role': this.authOptions.authRole.role,
2452
- 'X-Hasura-User-Id': this.authOptions?.authRole?.userId,
2453
- }),
2290
+ : { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }),
2454
2291
  };
2455
2292
  }
2456
2293
  async mutation(operation, fields, variables) {
@@ -2462,20 +2299,27 @@ const withHasuraGraphQL = (MixinBase) => {
2462
2299
  return this.fetch(resultQuery);
2463
2300
  }
2464
2301
  async query(operation, fields, variables) {
2465
- const builded = this.buildHasuraQueryFields({ operation, fields, variables });
2466
- const interpected = (await this.interceptors?.request?.(builded)) || builded;
2467
- const resultQuery = query$1(interpected);
2468
- const result = await this.fetch(resultQuery);
2469
- return (await this.interceptors?.response?.(result, interpected)) || result;
2302
+ const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2303
+ ? query$1(operation.map((option) => ({
2304
+ operation: option.operation,
2305
+ variables: option.variables,
2306
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2307
+ })))
2308
+ : query$1({
2309
+ operation,
2310
+ variables,
2311
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2312
+ });
2313
+ return this.fetch(resultQuery);
2470
2314
  }
2471
2315
  async fetch(params) {
2472
2316
  const headers = this.headers;
2473
- const { data: result } = await axios({
2474
- url: `${this.endpoint}`,
2317
+ const response = await fetch(`${this.endpoint}`, {
2475
2318
  method: 'POST',
2476
- data: params,
2319
+ body: JSON.stringify(params),
2477
2320
  headers,
2478
2321
  });
2322
+ const result = await response.json();
2479
2323
  if (!isNil(result.errors))
2480
2324
  throw new Error(JSON.stringify(result.errors));
2481
2325
  return result.data;
@@ -2510,19 +2354,6 @@ const withHasuraGraphQL = (MixinBase) => {
2510
2354
  convertDataToHasura(instance, update = false) {
2511
2355
  return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
2512
2356
  }
2513
- buildHasuraQueryFields({ operation, fields, variables, }) {
2514
- return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2515
- ? operation.map((option) => ({
2516
- operation: option.operation,
2517
- variables: option.variables,
2518
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2519
- }))
2520
- : {
2521
- operation,
2522
- variables,
2523
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2524
- };
2525
- }
2526
2357
  };
2527
2358
  };
2528
2359
 
@@ -2617,9 +2448,8 @@ const withGetHasuraGraphQL = (MixinBase) => {
2617
2448
 
2618
2449
  const withFindHasuraGraphQL = (MixinBase) => {
2619
2450
  return class FindHasuraGraphQLMixin extends MixinBase {
2620
- async find(params) {
2621
- const { filters, limits, orderBy, options } = params || {};
2622
- const enableCount = options?.enableCount ?? true;
2451
+ async find(options) {
2452
+ const { filters, limits, orderBy } = options || {};
2623
2453
  const variablesCount = {
2624
2454
  ...(isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } }),
2625
2455
  ...(isNil(filters)
@@ -2639,26 +2469,23 @@ const withFindHasuraGraphQL = (MixinBase) => {
2639
2469
  const result = await this.query([
2640
2470
  {
2641
2471
  operation: this.tableName,
2642
- fields: params.fields
2643
- ? params.fields
2472
+ fields: options.fields
2473
+ ? options.fields
2644
2474
  .map((fieldName) => this.fields.find((fieldOption) => fieldOption === fieldName) ??
2645
2475
  this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName))
2646
2476
  .filter(Boolean)
2647
2477
  : this.fields,
2648
2478
  variables,
2649
2479
  },
2650
- ...(enableCount
2651
- ? [
2652
- {
2653
- operation: `${this.tableName}_aggregate`,
2654
- fields: [{ aggregate: ['count'] }],
2655
- variables: variablesCount,
2656
- },
2657
- ]
2658
- : []),
2480
+ {
2481
+ operation: `${this.tableName}_aggregate`,
2482
+ fields: [{ aggregate: ['count'] }],
2483
+ variables: variablesCount,
2484
+ },
2659
2485
  ]);
2660
2486
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
2661
- return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
2487
+ const count = result[`${this.tableName}_aggregate`].aggregate.count;
2488
+ return { count, data };
2662
2489
  }
2663
2490
  };
2664
2491
  };
@@ -2697,66 +2524,13 @@ class VariantHasuraGraphQL extends Variant {
2697
2524
  }
2698
2525
  }
2699
2526
 
2700
- class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2701
- constructor({ endpoint, authOptions, interceptors, }) {
2702
- super({
2703
- tableName: 'category_filter',
2704
- model: CategoryFilter,
2705
- endpoint,
2706
- authOptions,
2707
- fields: [
2708
- 'id',
2709
- { filterId: { columnName: 'filter_id' } },
2710
- { categoryId: { columnName: 'category_id' } },
2711
- {
2712
- filter: {
2713
- columnName: 'filter',
2714
- foreignKeyColumn: { id: 'filterId' },
2715
- fields: [
2716
- 'id',
2717
- 'description',
2718
- 'slug',
2719
- 'enabled',
2720
- { createdAt: { columnName: 'created_at' } },
2721
- { updatedAt: { columnName: 'updated_at' } },
2722
- {
2723
- options: {
2724
- columnName: 'options',
2725
- foreignKeyColumn: { filterId: 'id' },
2726
- fields: [
2727
- 'id',
2728
- { filterId: { columnName: 'filter_id' } },
2729
- 'description',
2730
- { createdAt: { columnName: 'created_at' } },
2731
- { updatedAt: { columnName: 'updated_at' } },
2732
- ],
2733
- },
2734
- },
2735
- ],
2736
- },
2737
- },
2738
- ],
2739
- });
2740
- }
2741
- deleteByCategoryAndFilter(categoryId, filterId) {
2742
- return this.mutation('delete_category_filter', ['affected_rows'], {
2743
- where: {
2744
- type: 'category_filter_bool_exp',
2745
- required: true,
2746
- value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
2747
- },
2748
- });
2749
- }
2750
- }
2751
-
2752
2527
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2753
- constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
2528
+ constructor(endpoint, authOptions, productRepository) {
2754
2529
  super({
2755
2530
  tableName: 'category',
2756
2531
  model: Category,
2757
2532
  endpoint,
2758
2533
  authOptions,
2759
- interceptors,
2760
2534
  fields: [
2761
2535
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
2762
2536
  { firestoreId: { columnName: 'firestore_id' } },
@@ -2793,17 +2567,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2793
2567
  },
2794
2568
  },
2795
2569
  },
2796
- {
2797
- filters: {
2798
- columnName: 'filters',
2799
- foreignKeyColumn: { filter_id: 'id' },
2800
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
2801
- bindPersistData: (value) => ({
2802
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
2803
- }),
2804
- from: (filters) => filters?.map((filter) => filter?.filter) || [],
2805
- },
2806
- },
2570
+ 'filters',
2807
2571
  { createdAt: { columnName: 'created_at' } },
2808
2572
  { updatedAt: { columnName: 'updated_at' } },
2809
2573
  {
@@ -2828,7 +2592,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2828
2592
  ],
2829
2593
  });
2830
2594
  this.productRepository = productRepository;
2831
- this.categoryFilterRepository = categoryFilterRepository;
2832
2595
  }
2833
2596
  async create(params) {
2834
2597
  const { metadata, ...data } = params;
@@ -2836,30 +2599,29 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2836
2599
  }
2837
2600
  async get(identifiers) {
2838
2601
  return Number.isNaN(+identifiers.id)
2839
- ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
2602
+ ? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
2840
2603
  : super.get(identifiers);
2841
2604
  }
2842
2605
  async update(params) {
2843
- const { products, id: checkId, metadata, filters, ...data } = params;
2606
+ const { products, id: checkId, metadata, ...data } = params;
2844
2607
  const plainData = this.paramsToPlain({ id: checkId });
2845
2608
  const id = await this.getId(plainData.id);
2846
2609
  const category = await super.update({ id, ...data });
2847
2610
  category.products = products && (await this.updateProducts(+id, { products }));
2848
2611
  category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
2849
- category.filters = filters && (await this.updateFilters(+id, { filters }));
2850
2612
  return category;
2851
2613
  }
2852
2614
  async getCategoryBySlug(slug, shop) {
2853
2615
  if (!slug)
2854
2616
  return null;
2855
- const { data } = await this.find({ filters: { slug, shop, published: true }, options: { enableCount: false } });
2856
- if (!data.length)
2857
- throw new NotFoundError(`Category with slug ${slug} not found`);
2858
- if (data.length > 1)
2617
+ const { data, count } = await this.find({ filters: { slug, shop, published: true } });
2618
+ if (count > 1)
2859
2619
  throw new DuplicatedResultsError('Query returned duplicated values');
2620
+ if (!count)
2621
+ throw new NotFoundError(`Category with slug ${slug} not found`);
2860
2622
  return data.shift();
2861
2623
  }
2862
- async getCategoriesForHome(categoryIds, limit = 4, gender) {
2624
+ async getCategoriesForHome(categoryIds, limit = 4) {
2863
2625
  if (!categoryIds?.length)
2864
2626
  return [];
2865
2627
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -2877,7 +2639,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2877
2639
  return [];
2878
2640
  const homeSections = await Promise.all(categories.map(async (category) => ({
2879
2641
  category,
2880
- products: await this.mountCategory(category, { limit, hasStock: true, gender }),
2642
+ products: await this.mountCategory(category, { limit, hasStock: true }),
2881
2643
  })));
2882
2644
  return homeSections;
2883
2645
  }
@@ -2890,7 +2652,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2890
2652
  id: { operator: Where.IN, value: category.products },
2891
2653
  published: true,
2892
2654
  ...(options?.hasStock ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {}),
2893
- ...(options?.gender ? { tags: { operator: Where.IN, value: [options?.gender] } } : {}),
2894
2655
  },
2895
2656
  fields: [
2896
2657
  'id',
@@ -2916,10 +2677,8 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2916
2677
  'tags',
2917
2678
  'type',
2918
2679
  'shoppingCount',
2919
- 'gender',
2920
2680
  ],
2921
2681
  ...(options?.limit ? { limits: { limit: options?.limit } } : {}),
2922
- options: { enableCount: false },
2923
2682
  });
2924
2683
  products.push(...productsData);
2925
2684
  return products;
@@ -2927,7 +2686,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2927
2686
  async getId(id) {
2928
2687
  if (!Number.isNaN(+id))
2929
2688
  return id;
2930
- const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
2689
+ const { data } = await this.find({ filters: { firestoreId: id } });
2931
2690
  if (data?.[0]?.id)
2932
2691
  return data?.[0]?.id;
2933
2692
  throw new NotFoundError(`Category with id ${id} not found`);
@@ -2980,202 +2739,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2980
2739
  });
2981
2740
  return plainData.metadata;
2982
2741
  }
2983
- async updateFilters(categoryId, { filters }) {
2984
- if ('action' in filters && filters.action === 'remove' && filters.value.length) {
2985
- for (let i = 0; i < filters.value.length; i++) {
2986
- await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
2987
- }
2988
- return [];
2989
- }
2990
- if ('action' in filters && filters.action === 'merge' && filters.value.length) {
2991
- let filtersList = [];
2992
- for (let i = 0; i < filters.value.length; i++) {
2993
- try {
2994
- const hasFilter = await this.categoryFilterRepository
2995
- .find({
2996
- filters: {
2997
- categoryId,
2998
- filterId: filters.value[i].id,
2999
- },
3000
- })
3001
- .then((data) => data.data.shift()?.filter);
3002
- if (hasFilter) {
3003
- filtersList.push(hasFilter);
3004
- }
3005
- else {
3006
- await this.categoryFilterRepository.create({
3007
- filterId: filters.value[i].id,
3008
- categoryId,
3009
- });
3010
- filtersList.push(filters.value[i]);
3011
- }
3012
- }
3013
- catch (error) {
3014
- console.log('catch error: ', error);
3015
- }
3016
- }
3017
- return filtersList;
3018
- }
3019
- if (Array.isArray(filters) && filters.length) {
3020
- let filtersList = [];
3021
- for (let i = 0; i < filters.length; i++) {
3022
- try {
3023
- const hasFilter = await this.categoryFilterRepository
3024
- .find({
3025
- filters: {
3026
- categoryId,
3027
- filterId: filters[i].id,
3028
- },
3029
- })
3030
- .then((data) => data.data.shift()?.filter);
3031
- if (hasFilter) {
3032
- filtersList.push(hasFilter);
3033
- }
3034
- else {
3035
- await this.categoryFilterRepository.create({
3036
- filterId: filters[i].id,
3037
- categoryId,
3038
- });
3039
- filtersList.push(filters[i]);
3040
- }
3041
- }
3042
- catch (error) {
3043
- console.log('catch error: ', error);
3044
- }
3045
- }
3046
- return filtersList;
3047
- }
3048
- return [];
3049
- }
3050
- }
3051
-
3052
- class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3053
- constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
3054
- super({
3055
- tableName: 'filter',
3056
- model: Filter,
3057
- endpoint,
3058
- authOptions,
3059
- fields: [
3060
- 'id',
3061
- 'description',
3062
- 'slug',
3063
- 'enabled',
3064
- { createdAt: { columnName: 'created_at' } },
3065
- { updatedAt: { columnName: 'updated_at' } },
3066
- {
3067
- options: {
3068
- columnName: 'options',
3069
- foreignKeyColumn: { filterId: 'id' },
3070
- fields: [
3071
- 'id',
3072
- { filterId: { columnName: 'filter_id' } },
3073
- 'description',
3074
- { createdAt: { columnName: 'created_at' } },
3075
- { updatedAt: { columnName: 'updated_at' } },
3076
- ],
3077
- },
3078
- },
3079
- ],
3080
- });
3081
- this.filterOptionRepository = filterOptionRepository;
3082
- this.categoryFilterRepository = categoryFilterRepository;
3083
- }
3084
- async update(params) {
3085
- const { options, ...data } = params;
3086
- const filter = await super.update(data);
3087
- filter.options = await this.updateOptions(+data.id, { options });
3088
- return filter;
3089
- }
3090
- async updateOptions(filterId, { options }) {
3091
- if (!options)
3092
- return [];
3093
- if ('action' in options && options.action === 'remove' && options.value.length) {
3094
- for (let i = 0; i < options.value.length; i++) {
3095
- await this.filterOptionRepository.delete({ id: options.value[i].id });
3096
- }
3097
- return [];
3098
- }
3099
- if ('action' in options && options.action === 'merge' && options.value.length) {
3100
- let filterOptions = [];
3101
- for (let i = 0; i < options.value.length; i++) {
3102
- try {
3103
- const hasFilter = await this.filterOptionRepository.get({ id: options.value[i].id });
3104
- if (hasFilter)
3105
- filterOptions.push(hasFilter);
3106
- }
3107
- catch (error) {
3108
- const newOption = await this.filterOptionRepository.create({ ...options.value[i], filterId });
3109
- filterOptions.push(newOption);
3110
- }
3111
- }
3112
- return filterOptions;
3113
- }
3114
- if (Array.isArray(options) && options.length) {
3115
- let filterOptions = [];
3116
- for (let i = 0; i < options.length; i++) {
3117
- try {
3118
- const hasFilter = await this.filterOptionRepository.get({ id: options[i].id });
3119
- if (hasFilter)
3120
- filterOptions.push(hasFilter);
3121
- }
3122
- catch (error) {
3123
- const newOption = await this.filterOptionRepository.create({ ...options[i], filterId });
3124
- filterOptions.push(newOption);
3125
- }
3126
- }
3127
- }
3128
- return [];
3129
- }
3130
- async delete(params) {
3131
- const { data: categoryFilters } = await this.categoryFilterRepository.find({
3132
- filters: {
3133
- filterId: params.id,
3134
- },
3135
- });
3136
- if (categoryFilters.length)
3137
- throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
3138
- await this.deleteOptions(+params.id);
3139
- await super.delete({ id: +params.id });
3140
- return;
3141
- }
3142
- async deleteOptions(filterId) {
3143
- await this.mutation('delete_filter_option', ['affected_rows'], {
3144
- where: {
3145
- type: 'filter_option_bool_exp',
3146
- required: true,
3147
- value: { filter_id: { _eq: filterId } },
3148
- },
3149
- });
3150
- }
3151
- }
3152
-
3153
- class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3154
- constructor({ endpoint, authOptions, interceptors, }) {
3155
- super({
3156
- tableName: 'filter_option',
3157
- model: FilterOption,
3158
- endpoint,
3159
- authOptions,
3160
- fields: [
3161
- 'id',
3162
- 'description',
3163
- { filterId: { columnName: 'filter_id' } },
3164
- { createdAt: { columnName: 'created_at' } },
3165
- { updatedAt: { columnName: 'updated_at' } },
3166
- ],
3167
- });
3168
- }
3169
2742
  }
3170
2743
 
3171
2744
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3172
- constructor({ endpoint, authOptions, interceptors, }) {
2745
+ constructor(endpoint, authOptions) {
3173
2746
  super({
3174
2747
  tableName: 'product',
3175
2748
  model: ProductHasuraGraphQL,
3176
2749
  endpoint,
3177
2750
  authOptions,
3178
- interceptors,
3179
2751
  fields: [],
3180
2752
  });
3181
2753
  this.bindReviewToModel = (plain) => ({
@@ -3304,7 +2876,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3304
2876
  'weight',
3305
2877
  'gender',
3306
2878
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
3307
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
3308
2879
  { isKit: { columnName: 'is_kit' } },
3309
2880
  { createdAt: { columnName: 'created_at' } },
3310
2881
  { updatedAt: { columnName: 'updated_at' } },
@@ -3396,7 +2967,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3396
2967
  }
3397
2968
  async get(identifiers) {
3398
2969
  const product = Number.isNaN(+identifiers.id)
3399
- ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
2970
+ ? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
3400
2971
  : await super.get(identifiers);
3401
2972
  if (product.productId)
3402
2973
  throw new NotFoundError('Product not found, it is a variant');
@@ -3420,12 +2991,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3420
2991
  filters: {
3421
2992
  slug,
3422
2993
  },
3423
- fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
3424
- options: {
3425
- enableCount: false,
3426
- },
3427
2994
  });
3428
2995
  const product = result?.data?.shift();
2996
+ product.reviews = await this.findReviewsByProduct(+product.id);
3429
2997
  return product;
3430
2998
  }
3431
2999
  async update(params) {
@@ -3575,7 +3143,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3575
3143
  async getId(id) {
3576
3144
  if (!Number.isNaN(+id))
3577
3145
  return id;
3578
- const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3146
+ const { data } = await this.find({ filters: { firestoreId: id } });
3579
3147
  if (data?.[0]?.id)
3580
3148
  return data?.[0]?.id;
3581
3149
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3631,29 +3199,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3631
3199
  });
3632
3200
  return data && data[0] && this.bindReviewToModel(data[0]);
3633
3201
  }
3634
- async cleanShoppingCountFromIds(ids) {
3635
- return await this.mutation('update_product', ['affected_rows'], {
3636
- where: {
3637
- value: { id: { _nin: ids } },
3638
- type: 'product_bool_exp',
3639
- required: true,
3640
- },
3641
- _set: {
3642
- value: { shopping_count: 0 },
3643
- type: 'product_set_input',
3644
- },
3645
- });
3646
- }
3647
3202
  }
3648
3203
 
3649
3204
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3650
- constructor({ endpoint, authOptions, interceptors, }) {
3205
+ constructor(endpoint, authOptions) {
3651
3206
  super({
3652
3207
  tableName: 'product',
3653
3208
  model: VariantHasuraGraphQL,
3654
3209
  endpoint,
3655
3210
  authOptions,
3656
- interceptors,
3657
3211
  fields: [
3658
3212
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
3659
3213
  { firestoreId: { columnName: 'firestore_id' } },
@@ -3689,12 +3243,12 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3689
3243
  };
3690
3244
  },
3691
3245
  bindPersistData: (priceData) => ({
3692
- ...((priceData?.price || 0) >= 0 && { price: priceData.price }),
3693
- ...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
3694
- ...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
3246
+ ...(priceData?.price >= 0 && { price: priceData.price }),
3247
+ ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
3248
+ ...(priceData.subscriberDiscountPercentage >= 0 && {
3695
3249
  subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
3696
3250
  }),
3697
- ...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
3251
+ ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
3698
3252
  }),
3699
3253
  },
3700
3254
  },
@@ -3746,7 +3300,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3746
3300
  async getId(id) {
3747
3301
  if (!Number.isNaN(+id))
3748
3302
  return id;
3749
- const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3303
+ const { data } = await this.find({ filters: { firestoreId: id } });
3750
3304
  if (data?.[0]?.id)
3751
3305
  return data?.[0]?.id;
3752
3306
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3757,5 +3311,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3757
3311
  * Generated bundle index. Do not edit.
3758
3312
  */
3759
3313
 
3760
- 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 };
3314
+ 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 };
3761
3315
  //# sourceMappingURL=infrab4a-connect.mjs.map