@infrab4a/connect 4.0.0-beta.18 → 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 -9
  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 +17 -23
  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 +225 -692
  81. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  82. package/fesm2020/infrab4a-connect.mjs +225 -671
  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,17 +1251,11 @@ const withHelpers = (MixinBase) => {
1307
1251
  const withGetFirestore = (MixinBase) => {
1308
1252
  return class GetFirestore extends MixinBase {
1309
1253
  async get(identifiers) {
1310
- console.log(this.buildCollectionPathForGet(identifiers));
1311
- console.log(this.firestore);
1312
- console.log(this.collection(this.buildCollectionPathForGet(identifiers)));
1313
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
1314
- const intercepted = await this.interceptors?.request?.({ instance });
1315
- const builded = intercepted?.instance || instance;
1316
- 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()));
1317
1255
  const data = docRef.data();
1318
1256
  if (isNil(data))
1319
1257
  throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1320
- return this.interceptors?.response?.(data, intercepted) || data;
1258
+ return data;
1321
1259
  }
1322
1260
  buildCollectionPathForGet(identifiers) {
1323
1261
  return this.isSubCollection(this)
@@ -1398,11 +1336,8 @@ const withFindFirestore = (MixinBase) => {
1398
1336
  return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
1399
1337
  };
1400
1338
  }
1401
- async find(find = {}) {
1402
- const collection = this.collection(this.buildCollectionPathForFind(find.filters));
1403
- const enableCount = find?.options?.enableCount ?? true;
1404
- const intercepted = await this.interceptors?.request?.({ find });
1405
- const { filters, limits, orderBy } = intercepted.find || find;
1339
+ async find({ filters, limits, orderBy, } = {}) {
1340
+ const collection = this.collection(this.buildCollectionPathForFind(filters));
1406
1341
  const queries = this.makeFirestoreWhere(filters || {});
1407
1342
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
1408
1343
  const offsets = await this.defineLimits(filters, limits);
@@ -1410,8 +1345,8 @@ const withFindFirestore = (MixinBase) => {
1410
1345
  const docs = await getDocs(query(collection, ...queryArgumments));
1411
1346
  const data = docs.docs.map((doc) => doc.data());
1412
1347
  return {
1413
- data: (await this.interceptors?.response?.(data, intercepted)) || data,
1414
- count: enableCount ? this.calculateCount(data, limits) : Infinity,
1348
+ data,
1349
+ count: this.calculateCount(data, limits),
1415
1350
  };
1416
1351
  }
1417
1352
  buildCollectionPathForFind(filters) {
@@ -1425,7 +1360,7 @@ const withFindFirestore = (MixinBase) => {
1425
1360
  const queries = [];
1426
1361
  if (limits?.offset) {
1427
1362
  if (this.model.isModel(limits.offset))
1428
- 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()))));
1429
1364
  else if (isNumber(limits.offset) || isString(limits.offset))
1430
1365
  queries.push(startAt(limits.offset));
1431
1366
  }
@@ -1446,13 +1381,9 @@ const withFindFirestore = (MixinBase) => {
1446
1381
  const withCreateFirestore = (MixinBase) => {
1447
1382
  return class CreateFirestore extends MixinBase {
1448
1383
  async create(data) {
1449
- const instance = this.model.toInstance(data);
1450
- const intercepted = await this.interceptors?.request?.({ instance });
1451
- const builded = intercepted?.instance || instance;
1452
- const docRef = await this.save(builded);
1384
+ const docRef = await this.save(this.model.toInstance(data));
1453
1385
  const doc = await getDoc(docRef);
1454
- const docBuilded = (await this.interceptors?.response?.(doc.data(), intercepted)) || doc.data();
1455
- return docBuilded;
1386
+ return doc.data();
1456
1387
  }
1457
1388
  async save(data) {
1458
1389
  const id = data.identifier[data.identifiersFields?.shift()]?.toString();
@@ -1496,12 +1427,9 @@ const withUpdateFirestore = (MixinBase) => {
1496
1427
  const model = new this.model();
1497
1428
  const keyField = model.identifiersFields.shift();
1498
1429
  const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
1499
- const plainFromData = this.model.toInstance(this.paramsToPlain(data));
1500
- const intercepted = await this.interceptors?.request?.({ instance: plainFromData });
1501
- const builded = intercepted?.instance || plainFromData;
1502
- await setDoc(docRef, builded.toPlain(), { merge: true });
1503
- const docData = await getDoc(docRef).then((doc) => doc.data());
1504
- 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();
1505
1433
  }
1506
1434
  buildCollectionPathForUpdate(identifiers) {
1507
1435
  return this.isSubCollection(this)
@@ -1523,11 +1451,7 @@ const withUpdateFirestore = (MixinBase) => {
1523
1451
  const withDeleteFirestore = (MixinBase) => {
1524
1452
  return class DeleteFirestore extends MixinBase {
1525
1453
  async delete(identifiers) {
1526
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
1527
- const intercepted = await this.interceptors?.request?.({ instance });
1528
- const builded = intercepted?.instance || instance;
1529
- await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
1530
- await this.interceptors?.response?.(instance, intercepted);
1454
+ await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
1531
1455
  }
1532
1456
  buildCollectionPathForRemove(identifiers) {
1533
1457
  return this.isSubCollection(this)
@@ -1539,10 +1463,8 @@ const withDeleteFirestore = (MixinBase) => {
1539
1463
 
1540
1464
  const withSubCollection = (MixinBase, ParentModel) => {
1541
1465
  return class SubCollectionMix extends MixinBase {
1542
- constructor(...params) {
1543
- const options = params[0];
1544
- super(...params);
1545
- this.parentIdField = options.parentIdField;
1466
+ constructor(...args) {
1467
+ super(args);
1546
1468
  }
1547
1469
  collection(path) {
1548
1470
  return super.collection(path);
@@ -1556,87 +1478,73 @@ const withCrudFirestore = (MixinBase) => {
1556
1478
  };
1557
1479
 
1558
1480
  class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1559
- constructor({ firestore, interceptors }) {
1560
- super({
1561
- firestore,
1562
- collectionName: 'leads',
1563
- model: Lead,
1564
- interceptors,
1565
- });
1481
+ constructor(firestore) {
1482
+ super();
1483
+ this.firestore = firestore;
1484
+ this.collectionName = 'leads';
1485
+ this.model = Lead;
1566
1486
  }
1567
1487
  }
1568
1488
 
1569
1489
  class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1570
- constructor({ firestore, interceptors }, parentRepository) {
1571
- super({
1572
- firestore,
1573
- collectionName: 'editions',
1574
- parentIdField: 'subscriptionId',
1575
- model: Edition,
1576
- interceptors,
1577
- });
1490
+ constructor(firestore, parentRepository) {
1491
+ super();
1492
+ this.firestore = firestore;
1578
1493
  this.parentRepository = parentRepository;
1494
+ this.collectionName = 'editions';
1495
+ this.parentIdField = 'subscriptionId';
1496
+ this.model = Edition;
1579
1497
  }
1580
1498
  }
1581
1499
 
1582
1500
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1583
- constructor({ firestore, interceptors, }) {
1584
- super({
1585
- firestore,
1586
- collectionName: 'subscription',
1587
- model: Subscription,
1588
- interceptors,
1589
- });
1501
+ constructor(firestore) {
1502
+ super();
1503
+ this.firestore = firestore;
1504
+ this.collectionName = 'subscription';
1505
+ this.model = Subscription;
1590
1506
  }
1591
1507
  }
1592
1508
 
1593
1509
  class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1594
- constructor({ firestore, interceptors }, parentRepository) {
1595
- super({
1596
- firestore,
1597
- collectionName: 'payments',
1598
- parentIdField: 'subscriptionId',
1599
- model: SubscriptionPayment,
1600
- interceptors,
1601
- });
1510
+ constructor(firestore, parentRepository) {
1511
+ super();
1512
+ this.firestore = firestore;
1602
1513
  this.parentRepository = parentRepository;
1514
+ this.collectionName = 'payments';
1515
+ this.parentIdField = 'subscriptionId';
1516
+ this.model = SubscriptionPayment;
1603
1517
  }
1604
1518
  }
1605
1519
 
1606
1520
  class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1607
- constructor({ firestore, interceptors }, parentRepository) {
1608
- super({
1609
- firestore,
1610
- collectionName: 'address',
1611
- parentIdField: 'userId',
1612
- model: UserAddress,
1613
- interceptors,
1614
- });
1521
+ constructor(firestore, parentRepository) {
1522
+ super();
1523
+ this.firestore = firestore;
1615
1524
  this.parentRepository = parentRepository;
1525
+ this.collectionName = 'address';
1526
+ this.parentIdField = 'userId';
1527
+ this.model = UserAddress;
1616
1528
  }
1617
1529
  }
1618
1530
 
1619
1531
  class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1620
- constructor({ firestore, interceptors }, parentRepository) {
1621
- super({
1622
- firestore,
1623
- collectionName: 'CX',
1624
- parentIdField: 'userId',
1625
- model: BeautyProfile,
1626
- interceptors,
1627
- });
1532
+ constructor(firestore, parentRepository) {
1533
+ super();
1534
+ this.firestore = firestore;
1628
1535
  this.parentRepository = parentRepository;
1536
+ this.collectionName = 'CX';
1537
+ this.parentIdField = 'userId';
1538
+ this.model = BeautyProfile;
1629
1539
  }
1630
1540
  }
1631
1541
 
1632
1542
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1633
- constructor({ firestore, interceptors }) {
1634
- super({
1635
- firestore,
1636
- collectionName: 'users',
1637
- model: User,
1638
- interceptors,
1639
- });
1543
+ constructor(firestore) {
1544
+ super();
1545
+ this.firestore = firestore;
1546
+ this.collectionName = 'users';
1547
+ this.model = User;
1640
1548
  }
1641
1549
  async get(identifiers) {
1642
1550
  const user = await super.get({ id: identifiers.id });
@@ -1676,26 +1584,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1676
1584
  }
1677
1585
 
1678
1586
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1679
- constructor({ firestore, interceptors }, parentRepository) {
1680
- super({
1681
- firestore,
1682
- collectionName: 'payment_method',
1683
- parentIdField: 'userId',
1684
- model: UserPaymentMethod,
1685
- interceptors,
1686
- });
1587
+ constructor(firestore, parentRepository) {
1588
+ super();
1589
+ this.firestore = firestore;
1687
1590
  this.parentRepository = parentRepository;
1591
+ this.collectionName = 'payment_method';
1592
+ this.parentIdField = 'userId';
1593
+ this.model = UserPaymentMethod;
1688
1594
  }
1689
1595
  }
1690
1596
 
1691
1597
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1692
- constructor({ firestore, interceptors }) {
1693
- super({
1694
- firestore,
1695
- collectionName: 'categories',
1696
- model: Category,
1697
- interceptors,
1698
- });
1598
+ constructor(firestore) {
1599
+ super();
1600
+ this.firestore = firestore;
1601
+ this.collectionName = 'categories';
1602
+ this.model = Category;
1699
1603
  }
1700
1604
  async getCategoryBySlug(slug, shop) {
1701
1605
  const categoryDocs = await getDocs(query(this.collection(this.collectionName), where('slug', '==', slug), where('shop', '==', shop), where('published', '==', true)));
@@ -1705,14 +1609,14 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1705
1609
  throw new NotFoundError(`Document with slug ${slug} not found`);
1706
1610
  return categoryDocs.docs[0].data();
1707
1611
  }
1708
- async getCategoriesForHome(categoryIds, limit = 4, gender) {
1612
+ async getCategoriesForHome(categoryIds, limit = 4) {
1709
1613
  const categorySnap = await getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
1710
1614
  if (categorySnap.empty)
1711
1615
  throw new NotFoundError('Categories not found');
1712
1616
  const categories = categorySnap.docs.map((doc) => doc.data());
1713
1617
  const homeSections = await Promise.all(categories.map(async (category) => ({
1714
1618
  category,
1715
- products: await this.mountCategory(category, { limit, hasStock: true, gender }),
1619
+ products: await this.mountCategory(category, { limit, hasStock: true }),
1716
1620
  })));
1717
1621
  return homeSections;
1718
1622
  }
@@ -1728,8 +1632,6 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1728
1632
  wheres.push(where('published', '==', true), where('id', 'in', productIds));
1729
1633
  if (options?.hasStock)
1730
1634
  wheres.push(where('stock.quantity', '>', 0));
1731
- if (options?.gender)
1732
- wheres.push(where('tags', 'array-contains', options?.gender));
1733
1635
  if (options?.limit)
1734
1636
  wheres.push(limit(options?.limit));
1735
1637
  const productSnap = await getDocs(query(this.collection('productsErpVitrine'), ...wheres));
@@ -1742,14 +1644,12 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1742
1644
  }
1743
1645
 
1744
1646
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1745
- constructor({ firestore, interceptors }) {
1746
- super({
1747
- firestore,
1748
- collectionName: 'productsErpVitrine',
1749
- model: Product,
1750
- interceptors,
1751
- });
1647
+ constructor(firestore) {
1648
+ super();
1649
+ this.firestore = firestore;
1752
1650
  this.reviews = {};
1651
+ this.collectionName = 'productsErpVitrine';
1652
+ this.model = Product;
1753
1653
  }
1754
1654
  async getBySlug(slug) {
1755
1655
  const result = await this.find({
@@ -1784,98 +1684,43 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
1784
1684
  });
1785
1685
  return this.reviews[status];
1786
1686
  }
1787
- cleanShoppingCountFromIds() {
1788
- return;
1789
- }
1790
1687
  }
1791
1688
 
1792
1689
  class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
1793
- constructor({ firestore, interceptors }, parentRepository) {
1794
- super({
1795
- firestore,
1796
- collectionName: 'variants',
1797
- parentIdField: 'productId',
1798
- model: Variant,
1799
- interceptors,
1800
- });
1690
+ constructor(firestore, parentRepository) {
1691
+ super();
1692
+ this.firestore = firestore;
1801
1693
  this.parentRepository = parentRepository;
1694
+ this.collectionName = 'variants';
1695
+ this.parentIdField = 'productId';
1696
+ this.model = Variant;
1802
1697
  }
1803
1698
  }
1804
1699
 
1805
1700
  class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1806
- constructor({ firestore, interceptors }) {
1807
- super({
1808
- firestore,
1809
- collectionName: 'subscriptionProducts',
1810
- model: Product,
1811
- interceptors,
1812
- });
1813
- }
1814
- }
1815
-
1816
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1817
- constructor({ firestore, interceptors }) {
1818
- super({
1819
- firestore,
1820
- collectionName: 'buy2win',
1821
- model: Buy2Win,
1822
- interceptors,
1823
- });
1824
- }
1825
- }
1826
-
1827
- class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1828
- constructor({ firestore, interceptors, }) {
1829
- super({
1830
- firestore,
1831
- collectionName: 'dashboardCampaignsAuto',
1832
- model: CampaignDashboard,
1833
- interceptors,
1834
- });
1835
- }
1836
- }
1837
-
1838
- class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1839
- constructor({ firestore, interceptors, }) {
1840
- super({
1841
- firestore,
1842
- collectionName: 'hashtagCampaignsAuto',
1843
- model: CampaignHashtag,
1844
- interceptors,
1845
- });
1701
+ constructor(firestore) {
1702
+ super();
1703
+ this.firestore = firestore;
1704
+ this.collectionName = 'subscriptionProducts';
1705
+ this.model = Product;
1846
1706
  }
1847
1707
  }
1848
1708
 
1849
1709
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1850
- constructor({ firestore, interceptors }) {
1851
- super({
1852
- firestore,
1853
- collectionName: 'checkouts',
1854
- model: Checkout,
1855
- interceptors,
1856
- });
1857
- }
1858
- }
1859
-
1860
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1861
- constructor({ firestore, interceptors, }) {
1862
- super({
1863
- firestore,
1864
- collectionName: 'checkoutsSubscription',
1865
- model: CheckoutSubscription,
1866
- interceptors,
1867
- });
1710
+ constructor(firestore) {
1711
+ super();
1712
+ this.firestore = firestore;
1713
+ this.collectionName = 'checkouts';
1714
+ this.model = Checkout;
1868
1715
  }
1869
1716
  }
1870
1717
 
1871
1718
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1872
- constructor({ firestore, interceptors }) {
1873
- super({
1874
- firestore,
1875
- collectionName: 'coupons',
1876
- model: Coupon,
1877
- interceptors,
1878
- });
1719
+ constructor(firestore) {
1720
+ super();
1721
+ this.firestore = firestore;
1722
+ this.collectionName = 'coupons';
1723
+ this.model = Coupon;
1879
1724
  }
1880
1725
  buildModelInstance() {
1881
1726
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1897,16 +1742,9 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
1897
1742
  }
1898
1743
 
1899
1744
  class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1900
- constructor({ firestore, interceptors }) {
1901
- super({
1902
- firestore,
1903
- collectionName: 'orders',
1904
- model: Order,
1905
- interceptors,
1906
- fields: {
1907
- status: FirestoreFieldType.String,
1908
- },
1909
- });
1745
+ constructor(firestore) {
1746
+ super();
1747
+ this.firestore = firestore;
1910
1748
  this.orderFromFirestore = (order) => {
1911
1749
  if (!!order?.lineItems?.length) {
1912
1750
  order.lineItems = order.lineItems.map((lineItem) => {
@@ -1919,6 +1757,11 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1919
1757
  }
1920
1758
  return order;
1921
1759
  };
1760
+ this.collectionName = 'orders';
1761
+ this.model = Order;
1762
+ this.fields = {
1763
+ status: FirestoreFieldType.String,
1764
+ };
1922
1765
  }
1923
1766
  buildModelInstance() {
1924
1767
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1932,46 +1775,54 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1932
1775
  }
1933
1776
  }
1934
1777
 
1935
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1936
- constructor({ firestore, interceptors }) {
1937
- super({
1938
- firestore,
1939
- interceptors,
1940
- });
1941
- 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;
1942
1784
  }
1943
1785
  }
1944
1786
 
1945
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1946
- constructor({ firestore, interceptors }) {
1947
- super({
1948
- firestore,
1949
- collectionName: 'payments',
1950
- model: Payment,
1951
- interceptors,
1952
- });
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;
1953
1793
  }
1954
1794
  }
1955
1795
 
1956
1796
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1957
- constructor({ firestore, interceptors, }) {
1958
- super({
1959
- firestore,
1960
- collectionName: 'subscriptionPlans',
1961
- model: SubscriptionPlan,
1962
- interceptors,
1963
- });
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';
1964
1819
  }
1965
1820
  }
1966
1821
 
1967
1822
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1968
- constructor({ firestore, interceptors }) {
1969
- super({
1970
- firestore,
1971
- collectionName: 'dms',
1972
- model: Home,
1973
- interceptors,
1974
- });
1823
+ constructor(firestore) {
1824
+ super();
1825
+ this.firestore = firestore;
1975
1826
  this.homeToFirestore = (home) => {
1976
1827
  if (home.data?.data) {
1977
1828
  home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
@@ -2000,6 +1851,8 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2000
1851
  category: Category.toInstance(homeCategoryGroup.category),
2001
1852
  products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
2002
1853
  });
1854
+ this.collectionName = 'dms';
1855
+ this.model = Home;
2003
1856
  }
2004
1857
  buildModelInstance() {
2005
1858
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2017,24 +1870,11 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2017
1870
  }
2018
1871
 
2019
1872
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2020
- constructor({ firestore, interceptors }) {
2021
- super({
2022
- firestore,
2023
- collectionName: 'shopMenus',
2024
- model: ShopMenu,
2025
- interceptors,
2026
- });
2027
- }
2028
- }
2029
-
2030
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2031
- constructor({ firestore, interceptors, }) {
2032
- super({
2033
- firestore,
2034
- collectionName: 'shopSettings',
2035
- model: ShopSettings,
2036
- interceptors,
2037
- });
1873
+ constructor(firestore) {
1874
+ super();
1875
+ this.firestore = firestore;
1876
+ this.collectionName = 'shopMenus';
1877
+ this.model = ShopMenu;
2038
1878
  }
2039
1879
  }
2040
1880
 
@@ -2111,7 +1951,7 @@ class AttributeOptionHelper {
2111
1951
  }
2112
1952
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2113
1953
  if (fields.includes(attributeName))
2114
- return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
1954
+ return { columnName: attributeName.toString(), attributeName };
2115
1955
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2116
1956
  const fieldOption = is(field)?.[attributeName];
2117
1957
  if (isNil(fieldOption))
@@ -2313,10 +2153,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
2313
2153
  }
2314
2154
  if (!!from)
2315
2155
  return { ...result, [attributeName]: from(data[columnName], data) };
2316
- return {
2317
- ...result,
2318
- [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName],
2319
- };
2156
+ return { ...result, [attributeName]: parseDateTime(data[columnName].toString()) };
2320
2157
  }, {});
2321
2158
  GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2322
2159
  const data = instance.toPlain?.() || instance;
@@ -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) {
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, 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) {
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