@infrab4a/connect 4.0.0-beta.50 → 4.0.0-beta.6

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 (303) hide show
  1. package/domain/catalog/index.d.ts +0 -1
  2. package/domain/catalog/models/category.d.ts +22 -5
  3. package/domain/catalog/models/index.d.ts +0 -5
  4. package/domain/catalog/models/kit-product.d.ts +4 -4
  5. package/domain/catalog/models/product.d.ts +35 -5
  6. package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
  7. package/domain/catalog/models/types/index.d.ts +1 -2
  8. package/domain/catalog/models/types/shop-description.type.d.ts +0 -1
  9. package/domain/catalog/models/variant.d.ts +2 -1
  10. package/domain/catalog/repositories/category.repository.d.ts +3 -6
  11. package/domain/catalog/repositories/index.d.ts +0 -5
  12. package/domain/catalog/repositories/product.repository.d.ts +1 -4
  13. package/domain/generic/model/base.model.d.ts +5 -9
  14. package/domain/generic/model/types/base-model-builder.type.d.ts +2 -4
  15. package/domain/generic/model/types/identifier-model.type.d.ts +5 -6
  16. package/domain/generic/model/types/model-base-structure.type.d.ts +3 -9
  17. package/domain/generic/model/types/non-function-property-name.type.d.ts +3 -12
  18. package/domain/generic/repository/find.repository.d.ts +1 -7
  19. package/domain/generic/repository/get.repository.d.ts +2 -2
  20. package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
  21. package/domain/generic/repository/types/repository-find-result.type.d.ts +1 -11
  22. package/domain/generic/repository/types/repository-order-by-list.type.d.ts +2 -2
  23. package/domain/generic/repository/types/repository-update-params.type.d.ts +2 -2
  24. package/domain/location/models/address.d.ts +3 -5
  25. package/domain/shop-settings/models/index.d.ts +0 -1
  26. package/domain/shop-settings/models/types/index.d.ts +1 -6
  27. package/domain/shop-settings/repositories/index.d.ts +0 -1
  28. package/domain/shopping/models/buy-2-win.d.ts +1 -3
  29. package/domain/shopping/models/checkout.d.ts +6 -5
  30. package/domain/shopping/models/coupons/coupon.d.ts +6 -34
  31. package/domain/shopping/models/index.d.ts +4 -5
  32. package/domain/shopping/models/order.d.ts +0 -1
  33. package/domain/shopping/models/shipping-method.d.ts +0 -1
  34. package/domain/shopping/models/subscription/checkout.d.ts +4 -3
  35. package/domain/shopping/repositories/index.d.ts +2 -4
  36. package/domain/users/models/lead.d.ts +0 -1
  37. package/domain/users/models/subscription/subscription.d.ts +3 -3
  38. package/domain/users/models/user-address.d.ts +2 -1
  39. package/domain/users/models/user.d.ts +3 -2
  40. package/esm2020/domain/catalog/index.mjs +1 -2
  41. package/esm2020/domain/catalog/models/category.mjs +6 -10
  42. package/esm2020/domain/catalog/models/index.mjs +1 -6
  43. package/esm2020/domain/catalog/models/kit-product.mjs +7 -7
  44. package/esm2020/domain/catalog/models/product.mjs +6 -8
  45. package/esm2020/domain/catalog/models/types/category-filter.type.mjs +2 -0
  46. package/esm2020/domain/catalog/models/types/index.mjs +2 -3
  47. package/esm2020/domain/catalog/models/types/shop-description.type.mjs +1 -1
  48. package/esm2020/domain/catalog/models/variant.mjs +4 -1
  49. package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
  50. package/esm2020/domain/catalog/repositories/index.mjs +1 -6
  51. package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
  52. package/esm2020/domain/generic/model/base.model.mjs +2 -3
  53. package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +1 -1
  54. package/esm2020/domain/generic/model/types/identifier-model.type.mjs +1 -1
  55. package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +1 -1
  56. package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +1 -1
  57. package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
  58. package/esm2020/domain/generic/repository/get.repository.mjs +1 -1
  59. package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +1 -1
  60. package/esm2020/domain/generic/repository/types/repository-find-result.type.mjs +1 -1
  61. package/esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs +1 -1
  62. package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +1 -1
  63. package/esm2020/domain/location/models/address.mjs +2 -2
  64. package/esm2020/domain/shop-settings/models/index.mjs +1 -2
  65. package/esm2020/domain/shop-settings/models/types/index.mjs +2 -7
  66. package/esm2020/domain/shop-settings/repositories/index.mjs +1 -2
  67. package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
  68. package/esm2020/domain/shopping/models/checkout.mjs +7 -6
  69. package/esm2020/domain/shopping/models/coupons/coupon.mjs +16 -16
  70. package/esm2020/domain/shopping/models/index.mjs +5 -6
  71. package/esm2020/domain/shopping/models/order.mjs +1 -1
  72. package/esm2020/domain/shopping/models/shipping-method.mjs +1 -1
  73. package/esm2020/domain/shopping/models/subscription/checkout.mjs +6 -6
  74. package/esm2020/domain/shopping/repositories/index.mjs +3 -5
  75. package/esm2020/domain/users/models/lead.mjs +1 -1
  76. package/esm2020/domain/users/models/subscription/subscription.mjs +6 -6
  77. package/esm2020/domain/users/models/user-address.mjs +1 -1
  78. package/esm2020/domain/users/models/user.mjs +2 -2
  79. package/esm2020/domain/users/use-cases/authentication.mjs +2 -2
  80. package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +11 -28
  81. package/esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs +1 -1
  82. package/esm2020/infra/elasticsearch/indexes/products-index.mjs +51 -63
  83. package/esm2020/infra/elasticsearch/types/elastic-search-result.mjs +1 -1
  84. package/esm2020/infra/firebase/auth/authentication-firebase-auth.service.mjs +1 -1
  85. package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +4 -8
  86. package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
  87. package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +2 -6
  88. package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +8 -11
  89. package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +4 -27
  90. package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +3 -6
  91. package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +1 -1
  92. package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +3 -5
  93. package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +4 -7
  94. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +8 -21
  95. package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +7 -15
  96. package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +8 -10
  97. package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +6 -8
  98. package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +30 -36
  99. package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +1 -2
  100. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +6 -8
  101. package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +6 -8
  102. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +6 -8
  103. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +6 -8
  104. package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +6 -8
  105. package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +4 -6
  106. package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +4 -6
  107. package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +9 -11
  108. package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +6 -8
  109. package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +6 -8
  110. package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +6 -8
  111. package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +8 -10
  112. package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +6 -8
  113. package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +8 -10
  114. package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +8 -10
  115. package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +8 -10
  116. package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +6 -8
  117. package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +8 -10
  118. package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +1 -1
  119. package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +1 -1
  120. package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
  121. package/esm2020/infra/firebase/firestore/types/index.mjs +3 -4
  122. package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +3 -3
  123. package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +5 -6
  124. package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +1 -1
  125. package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +25 -36
  126. package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +4 -6
  127. package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
  128. package/esm2020/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.mjs +3 -5
  129. package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +20 -126
  130. package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +3 -5
  131. package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +24 -40
  132. package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +5 -7
  133. package/esm2020/infra/hasura-graphql/models/product-hasura-graphql.mjs +1 -1
  134. package/esm2020/infra/hasura-graphql/models/variant-hasura-graphql.mjs +1 -1
  135. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +14 -131
  136. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +1 -6
  137. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +20 -70
  138. package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +7 -9
  139. package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +1 -1
  140. package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
  141. package/esm2020/utils/index.mjs +4 -6
  142. package/fesm2015/infrab4a-connect.mjs +421 -2000
  143. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  144. package/fesm2020/infrab4a-connect.mjs +425 -1967
  145. package/fesm2020/infrab4a-connect.mjs.map +1 -1
  146. package/infra/elasticsearch/adapters/axios.adapter.d.ts +5 -7
  147. package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +2 -3
  148. package/infra/elasticsearch/indexes/products-index.d.ts +10 -8
  149. package/infra/elasticsearch/types/elastic-search-result.d.ts +0 -2
  150. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
  151. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +1 -2
  152. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +2 -2
  153. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
  154. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +4 -13
  155. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +2 -2
  156. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +2 -2
  157. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +4 -8
  158. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
  159. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +5 -8
  160. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +5 -6
  161. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +4 -3
  162. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +4 -3
  163. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
  164. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +0 -1
  165. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +4 -3
  166. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +4 -3
  167. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +4 -3
  168. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +4 -3
  169. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
  170. package/infra/firebase/firestore/repositories/shopping/index.d.ts +3 -5
  171. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +4 -3
  172. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
  173. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +4 -3
  174. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +4 -3
  175. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +4 -3
  176. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +4 -3
  177. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +4 -3
  178. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +4 -3
  179. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +4 -3
  180. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +4 -3
  181. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
  182. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +4 -3
  183. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
  184. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +5 -5
  185. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +1 -3
  186. package/infra/firebase/firestore/types/index.d.ts +2 -3
  187. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +3 -9
  188. package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +5 -5
  189. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +2 -4
  190. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +5 -9
  191. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +1 -2
  192. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +3 -3
  193. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +1 -1
  194. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +15 -24
  195. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +6 -7
  196. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +3 -15
  197. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
  198. package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +0 -4
  199. package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +0 -1
  200. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +5 -12
  201. package/infra/hasura-graphql/repositories/catalog/index.d.ts +0 -5
  202. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +4 -6
  203. package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
  204. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +6 -9
  205. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +3 -7
  206. package/package.json +1 -2
  207. package/utils/index.d.ts +22 -5
  208. package/domain/catalog/helpers/index.d.ts +0 -1
  209. package/domain/catalog/helpers/round-product-price.helper.d.ts +0 -4
  210. package/domain/catalog/models/category-base.d.ts +0 -30
  211. package/domain/catalog/models/category-collection-children.d.ts +0 -13
  212. package/domain/catalog/models/category-filter.d.ts +0 -13
  213. package/domain/catalog/models/category-for-product.d.ts +0 -5
  214. package/domain/catalog/models/filter-option.d.ts +0 -9
  215. package/domain/catalog/models/filter.d.ts +0 -12
  216. package/domain/catalog/models/product-base.d.ts +0 -40
  217. package/domain/catalog/models/product-for-category.d.ts +0 -7
  218. package/domain/catalog/models/product-for-kit.d.ts +0 -7
  219. package/domain/catalog/models/types/category-product.d.ts +0 -4
  220. package/domain/catalog/models/types/product-evaluation.type.d.ts +0 -6
  221. package/domain/catalog/models/wishlist.d.ts +0 -6
  222. package/domain/catalog/repositories/category-collection-children.repository.d.ts +0 -4
  223. package/domain/catalog/repositories/category-filter.repository.d.ts +0 -6
  224. package/domain/catalog/repositories/filter-option.repository.d.ts +0 -4
  225. package/domain/catalog/repositories/filter.repository.d.ts +0 -4
  226. package/domain/catalog/repositories/wishlist.repository.d.ts +0 -6
  227. package/domain/shop-settings/models/shop-settings.d.ts +0 -9
  228. package/domain/shop-settings/models/types/shop-banner.type.d.ts +0 -12
  229. package/domain/shop-settings/models/types/shop-brands.type.d.ts +0 -10
  230. package/domain/shop-settings/models/types/shop-carousel.type.d.ts +0 -5
  231. package/domain/shop-settings/models/types/shop-collection.type.d.ts +0 -9
  232. package/domain/shop-settings/models/types/shop-section.type.d.ts +0 -9
  233. package/domain/shop-settings/repositories/shop-settings.repository.d.ts +0 -4
  234. package/domain/shopping/models/campaign-dashboard.d.ts +0 -15
  235. package/domain/shopping/models/campaign-hashtag.d.ts +0 -18
  236. package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +0 -4
  237. package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +0 -4
  238. package/esm2020/domain/catalog/helpers/index.mjs +0 -2
  239. package/esm2020/domain/catalog/helpers/round-product-price.helper.mjs +0 -15
  240. package/esm2020/domain/catalog/models/category-base.mjs +0 -18
  241. package/esm2020/domain/catalog/models/category-collection-children.mjs +0 -13
  242. package/esm2020/domain/catalog/models/category-filter.mjs +0 -19
  243. package/esm2020/domain/catalog/models/category-for-product.mjs +0 -7
  244. package/esm2020/domain/catalog/models/filter-option.mjs +0 -7
  245. package/esm2020/domain/catalog/models/filter.mjs +0 -7
  246. package/esm2020/domain/catalog/models/product-base.mjs +0 -25
  247. package/esm2020/domain/catalog/models/product-for-category.mjs +0 -14
  248. package/esm2020/domain/catalog/models/product-for-kit.mjs +0 -14
  249. package/esm2020/domain/catalog/models/types/category-product.mjs +0 -2
  250. package/esm2020/domain/catalog/models/types/product-evaluation.type.mjs +0 -2
  251. package/esm2020/domain/catalog/models/wishlist.mjs +0 -7
  252. package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +0 -2
  253. package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +0 -2
  254. package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +0 -2
  255. package/esm2020/domain/catalog/repositories/filter.repository.mjs +0 -2
  256. package/esm2020/domain/catalog/repositories/wishlist.repository.mjs +0 -2
  257. package/esm2020/domain/shop-settings/models/shop-settings.mjs +0 -7
  258. package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +0 -2
  259. package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +0 -2
  260. package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +0 -2
  261. package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +0 -2
  262. package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +0 -2
  263. package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +0 -2
  264. package/esm2020/domain/shopping/models/campaign-dashboard.mjs +0 -7
  265. package/esm2020/domain/shopping/models/campaign-hashtag.mjs +0 -7
  266. package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +0 -2
  267. package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +0 -2
  268. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +0 -14
  269. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +0 -14
  270. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +0 -14
  271. package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +0 -2
  272. package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +0 -39
  273. package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +0 -107
  274. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +0 -105
  275. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +0 -22
  276. package/esm2020/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.mjs +0 -236
  277. package/esm2020/utils/decorators/debug.class.decorator.mjs +0 -7
  278. package/esm2020/utils/decorators/index.mjs +0 -3
  279. package/esm2020/utils/decorators/trace.method.decorator.mjs +0 -81
  280. package/esm2020/utils/helpers/class-name.helper.mjs +0 -15
  281. package/esm2020/utils/helpers/debug-decorator.helper.mjs +0 -18
  282. package/esm2020/utils/helpers/debug.helper.mjs +0 -150
  283. package/esm2020/utils/helpers/index.mjs +0 -5
  284. package/esm2020/utils/helpers/reflect.helper.mjs +0 -165
  285. package/esm2020/utils/log.utils.mjs +0 -9
  286. package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +0 -7
  287. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -8
  288. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -8
  289. package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +0 -14
  290. package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +0 -10
  291. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -12
  292. package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +0 -18
  293. package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +0 -10
  294. package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +0 -27
  295. package/utils/decorators/debug.class.decorator.d.ts +0 -2
  296. package/utils/decorators/index.d.ts +0 -2
  297. package/utils/decorators/trace.method.decorator.d.ts +0 -14
  298. package/utils/helpers/class-name.helper.d.ts +0 -3
  299. package/utils/helpers/debug-decorator.helper.d.ts +0 -9
  300. package/utils/helpers/debug.helper.d.ts +0 -60
  301. package/utils/helpers/index.d.ts +0 -4
  302. package/utils/helpers/reflect.helper.d.ts +0 -50
  303. package/utils/log.utils.d.ts +0 -7
@@ -3,21 +3,18 @@ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transforme
3
3
  import { __decorate, __metadata, __awaiter, __rest } from 'tslib';
4
4
  import { parseISO } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
- import { isNil, isArray, first, last, flatten, compact, get as get$1, isString, each, unset, isObject, isNumber, isDate, set, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
7
- export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, unset } from 'lodash';
8
- import { Subject } from 'rxjs';
9
- import { debug } from 'debug';
6
+ import lodash, { get as get$1, isString as isString$1 } from 'lodash';
10
7
  import { CustomError } from 'ts-custom-error';
11
8
  import axios from 'axios';
12
9
  import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
13
10
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
14
11
  import { mutation, query as query$1 } from 'gql-query-builder';
12
+ import fetch from 'node-fetch';
15
13
 
16
14
  class BaseModel {
17
15
  get identifier() {
18
16
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
19
- const data = this;
20
- return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: data[field] })), {});
17
+ return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
21
18
  }
22
19
  get identifiersFields() {
23
20
  return this.constructor.identifiersFields;
@@ -463,437 +460,11 @@ __decorate([
463
460
  __metadata("design:type", Payment)
464
461
  ], SubscriptionPayment.prototype, "payment", void 0);
465
462
 
466
- var DebugNamespaces;
467
- (function (DebugNamespaces) {
468
- DebugNamespaces["ROOT"] = "connect";
469
- DebugNamespaces["TRACE"] = "trace";
470
- DebugNamespaces["ERROR"] = "error";
471
- })(DebugNamespaces || (DebugNamespaces = {}));
472
- const Logger = debug(DebugNamespaces.ROOT);
473
-
474
- class ReflectHelper {
475
- static get items() {
476
- return this._items;
477
- }
478
- static get keys() {
479
- return Object.keys(ReflectHelper.items);
480
- }
481
- static has(key, target, property) {
482
- return (!isNil(key) &&
483
- !isNil(ReflectHelper.items[key]) &&
484
- (isNil(target) ||
485
- (!isNil(ReflectHelper.items[key][target]) &&
486
- (isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
487
- }
488
- static get({ key, target, property, own = true }) {
489
- try {
490
- if (own) {
491
- return Reflect.getOwnMetadata(key, target, property) || null;
492
- }
493
- else {
494
- return Reflect.getMetadata(key, target, property) || null;
495
- }
496
- }
497
- catch (_err) {
498
- return null;
499
- }
500
- }
501
- static first({ key, target, property, own = true }) {
502
- const values = ReflectHelper.get({ key, target, property, own });
503
- return isArray(values) ? first(values) : values;
504
- }
505
- static last({ key, target, property, own = true }) {
506
- const values = ReflectHelper.get({ key, target, property, own });
507
- return isArray(values) ? last(values) : values;
508
- }
509
- static set({ key, target, property, value, propertyDescriptor }) {
510
- Reflect.defineMetadata(key, value, target, property);
511
- ReflectHelper.put({ key, target, property, value, propertyDescriptor });
512
- }
513
- static add({ key, target, property, value, propertyDescriptor }) {
514
- let values = ReflectHelper.get({ key, target, property }) || new Array();
515
- if (!Array.isArray(values))
516
- values = [values];
517
- values.push(value);
518
- ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
519
- }
520
- static all({ key }) {
521
- const items = ReflectHelper.items[key] || {};
522
- return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
523
- }
524
- static allFrom(key, target) {
525
- return Object.keys(target)
526
- .filter((property) => property !== 'object')
527
- .map((property) => this.allValuesFrom(key, target, property));
528
- }
529
- static allValuesFrom(key, target, property) {
530
- const values = target[property];
531
- let value = values.value;
532
- const propertyDescriptor = values.propertyDescriptor;
533
- if (!isArray(value))
534
- value = [value];
535
- return flatten(value.map((val) => {
536
- return {
537
- key,
538
- target: target.object,
539
- property,
540
- value: val,
541
- propertyDescriptor,
542
- };
543
- }));
544
- }
545
- static delete({ key, target, property }) {
546
- Reflect.deleteMetadata(key, target, property);
547
- return ReflectHelper.remove(key, target, property);
548
- }
549
- static clear(key) {
550
- if (!key) {
551
- ReflectHelper.keys.forEach((storedKey) => {
552
- ReflectHelper.clear(storedKey);
553
- });
554
- }
555
- else {
556
- if (ReflectHelper.keys.includes(key)) {
557
- Object.values(ReflectHelper.items[key]).forEach((target) => {
558
- if (ReflectHelper.has(key, target)) {
559
- Object.values(ReflectHelper.items[key][target.toString()]).forEach((property) => {
560
- ReflectHelper.delete({
561
- key,
562
- target: target.object,
563
- property: String(property),
564
- });
565
- ReflectHelper.remove(key, target, String(property));
566
- });
567
- }
568
- ReflectHelper.delete({ key, target: target.object });
569
- ReflectHelper.remove(key, target);
570
- });
571
- }
572
- }
573
- }
574
- static getType({ target, propertyKey }) {
575
- return Reflect.getMetadata('design:type', target, propertyKey);
576
- }
577
- static getReturntype({ target, propertyKey }) {
578
- return Reflect.getMetadata('design:returntype', target, propertyKey);
579
- }
580
- static getAllMethods(target) {
581
- const props = [];
582
- let obj = target;
583
- do {
584
- props.push(...Object.getOwnPropertyNames(obj));
585
- } while ((obj = Object.getPrototypeOf(obj)));
586
- return props.sort().filter((e, i, arr) => {
587
- if ([
588
- '__defineGetter__',
589
- '__defineSetter__',
590
- '__lookupGetter__',
591
- '__lookupSetter__',
592
- 'constructor',
593
- 'hasOwnProperty',
594
- 'isPrototypeOf',
595
- 'propertyIsEnumerable',
596
- 'toLocaleString',
597
- 'toString',
598
- 'valueOf',
599
- ].includes(e))
600
- return false;
601
- if (e != arr[i + 1] && typeof target[e] === 'function')
602
- return true;
603
- });
604
- }
605
- static put({ key, target, property, value, propertyDescriptor }) {
606
- const index = target.constructor.name;
607
- ReflectHelper.items[key] = ReflectHelper.items[key] || {};
608
- ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
609
- ReflectHelper.items[key][index].object = target;
610
- if (isNil(property)) {
611
- ReflectHelper.items[key][index].value = {
612
- value,
613
- propertyDescriptor,
614
- };
615
- }
616
- else {
617
- ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
618
- ReflectHelper.items[key][index][String(property)] = {
619
- value,
620
- propertyDescriptor,
621
- };
622
- }
623
- }
624
- static remove(key, target, property) {
625
- if (ReflectHelper.has(key, target, property))
626
- return delete ReflectHelper.items[key][target][String(property)];
627
- else if (ReflectHelper.has(key, target))
628
- return delete ReflectHelper.items[key][target];
629
- else if (ReflectHelper.has(key))
630
- return delete ReflectHelper.items[key];
631
- else
632
- return false;
633
- }
634
- }
635
- ReflectHelper._items = {};
636
-
637
- class DebugDecoratorHelper {
638
- static set(target, options) {
639
- ReflectHelper.add({
640
- key: DebugDecoratorHelper.DebugNamingMetadataKey,
641
- target,
642
- value: options,
643
- });
644
- }
645
- static get(target) {
646
- return ReflectHelper.first({
647
- key: DebugDecoratorHelper.DebugNamingMetadataKey,
648
- target,
649
- });
650
- }
651
- }
652
- DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
653
-
654
- class ClassNameHelper {
655
- static get(clazz) {
656
- if (!clazz)
657
- return null;
658
- const prototype = Object.getPrototypeOf(clazz);
659
- const names = compact([
660
- get$1(clazz, 'constructor.name'),
661
- get$1(prototype, 'constructor.name'),
662
- get$1(prototype, '__proto__.constructor.name'),
663
- ]);
664
- return names.find((name) => name !== 'class_1');
665
- }
666
- }
667
-
668
- const isDebuggable = (object) => {
669
- return 'debug' in object;
670
- };
671
- class DebugHelper {
672
- constructor(...namespace) {
673
- this.namespaces = new Set();
674
- this.push(...namespace);
675
- }
676
- static namespacesFor(target) {
677
- if (isNil(target))
678
- return [];
679
- const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
680
- const namespaces = get$1(decorator, 'namespaces', []);
681
- const name = get$1(decorator, 'name', ClassNameHelper.get(target));
682
- return [...namespaces, name];
683
- }
684
- static as(...namespaces) {
685
- return new DebugHelper(...namespaces);
686
- }
687
- static for(target, ...namespaces) {
688
- const targetNamespaces = this.namespacesFor(target);
689
- return new DebugHelper(...targetNamespaces, ...namespaces);
690
- }
691
- static from(target, ...namespaces) {
692
- if (this.isDebuggable(target)) {
693
- const debug = target.debug;
694
- if (namespaces)
695
- debug.push(...namespaces);
696
- return debug;
697
- }
698
- return DebugHelper.for(target, ...namespaces);
699
- }
700
- static clonedFrom(target, ...namespaces) {
701
- if (this.isDebuggable(target)) {
702
- namespaces.push(...target.debug.entries);
703
- }
704
- else if (!isNil(target)) {
705
- namespaces.push(...this.namespacesFor(target));
706
- }
707
- return DebugHelper.for(target, ...namespaces);
708
- }
709
- static clone(target, ...namespaces) {
710
- let original;
711
- if (this.isDebuggable(target)) {
712
- original = target.debug;
713
- namespaces.push(...original.entries);
714
- }
715
- return {
716
- original,
717
- debug: DebugHelper.for(target, ...namespaces),
718
- };
719
- }
720
- static replace(target, attrs) {
721
- if (this.isDebuggable(target))
722
- target.debug = attrs.with;
723
- }
724
- static mock(target, ...namespaces) {
725
- const { original, debug } = DebugHelper.clone(target, ...namespaces);
726
- DebugHelper.replace(target, { with: debug });
727
- return { original, debug };
728
- }
729
- get entries() {
730
- return Array.from(get$1(this, 'namespaces', []));
731
- }
732
- get namespace() {
733
- return compact(flatten(this.entries)).join(':');
734
- }
735
- log(message, ...args) {
736
- this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
737
- DebugHelper.logs$.next({ namespace: this.namespace, message, args });
738
- return this;
739
- }
740
- trace(message, ...args) {
741
- this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
742
- DebugHelper.traces$.next({ namespace: this.namespace, message, args });
743
- return this;
744
- }
745
- error(error, ...args) {
746
- this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
747
- DebugHelper.errors$.next({ namespace: this.namespace, error, args });
748
- return this;
749
- }
750
- build() {
751
- this.logger = Logger;
752
- this.tracer = Logger;
753
- this.err = Logger;
754
- this.entries.forEach((namespace) => {
755
- this.logger = this.logger.extend(namespace);
756
- this.tracer = this.tracer.extend(namespace);
757
- this.err = this.err.extend(namespace);
758
- });
759
- return this;
760
- }
761
- with(...namespace) {
762
- return new DebugHelper(...this.entries, ...namespace);
763
- }
764
- push(...namespace) {
765
- if (namespace) {
766
- namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
767
- }
768
- return this.build();
769
- }
770
- unshift(...namespace) {
771
- if (namespace) {
772
- return this.reset(...namespace, ...this.entries);
773
- }
774
- return this;
775
- }
776
- reset(...namespace) {
777
- this.namespaces = new Set(flatten(compact(namespace)));
778
- return this.build();
779
- }
780
- startWith(...namespace) {
781
- const current = this.namespaces;
782
- this.namespaces = new Set(flatten([compact(namespace), ...current]));
783
- return this.build();
784
- }
785
- shift() {
786
- const list = this.entries;
787
- list.shift();
788
- return this.reset(...list);
789
- }
790
- pop() {
791
- const list = this.entries;
792
- list.pop();
793
- return this.reset(...list);
794
- }
795
- clear() {
796
- return this.reset();
797
- }
798
- remove(...namespace) {
799
- if (namespace) {
800
- namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
801
- }
802
- return this.build();
803
- }
804
- puts(...args) {
805
- return [`[${this.namespace}]`, ...args].join(' ');
463
+ class Address extends BaseModel {
464
+ static get identifiersFields() {
465
+ return ['id'];
806
466
  }
807
467
  }
808
- DebugHelper.logs$ = new Subject();
809
- DebugHelper.traces$ = new Subject();
810
- DebugHelper.errors$ = new Subject();
811
- DebugHelper.isDebuggable = isDebuggable;
812
-
813
- function Debug(opts) {
814
- return function (target) {
815
- DebugDecoratorHelper.set(target.prototype, opts);
816
- };
817
- }
818
-
819
- const ASYNC_IDENTIFIER = 'async';
820
- function Log(options = {}) {
821
- return Trace(Object.assign({ level: 'log' }, options));
822
- }
823
- function Trace(options = {}) {
824
- return function (target, propertyKey, propertyDescriptor) {
825
- const method = propertyDescriptor.value;
826
- const isPromise = method.toString().includes(ASYNC_IDENTIFIER);
827
- const args = {
828
- options,
829
- method,
830
- target,
831
- propertyKey,
832
- propertyDescriptor,
833
- };
834
- propertyDescriptor.value = isPromise ? promiseTracer(args) : functionTracer(args);
835
- return propertyDescriptor;
836
- };
837
- }
838
- const traceCall = function ({ target, propertyKey, propertyDescriptor, args }) {
839
- if (!target.debug)
840
- target.debug = DebugHelper.for(target, propertyKey);
841
- return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
842
- };
843
- const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
844
- return function (...args) {
845
- return new Promise((resolve, reject) => {
846
- const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
847
- if (get$1(options, 'level', '') === 'log') {
848
- debug.with('params').log(args);
849
- }
850
- return method
851
- .apply(this, args)
852
- .then((result) => {
853
- if (options.callbackFn) {
854
- options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
855
- }
856
- if (get$1(options, 'level', '') === 'log') {
857
- debug.with('returns').log(result === undefined ? 'void' : result);
858
- }
859
- return resolve(result);
860
- })
861
- .catch((error) => {
862
- debug.error(error, ...args);
863
- debug.with('stack').error(error.stack).pop();
864
- return reject(error);
865
- })
866
- .finally(() => {
867
- return debug.trace('finally', { args }).pop();
868
- });
869
- });
870
- };
871
- };
872
- const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
873
- return function (...args) {
874
- const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
875
- if (get$1(options, 'level', '') === 'log') {
876
- debug.with('params').log(args);
877
- }
878
- let result;
879
- try {
880
- result = method.apply(this, args);
881
- if (options.callbackFn)
882
- options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
883
- if (get$1(options, 'level', '') === 'log') {
884
- debug.with('returns').log(result === undefined ? 'void' : result);
885
- }
886
- return result;
887
- }
888
- catch (error) {
889
- debug.error(error, ...args).pop();
890
- throw error;
891
- }
892
- finally {
893
- debug.trace('finally', { args }).pop();
894
- }
895
- };
896
- };
897
468
 
898
469
  const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
899
470
 
@@ -901,7 +472,7 @@ function is(value) {
901
472
  return value;
902
473
  }
903
474
 
904
- 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);
475
+ 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);
905
476
 
906
477
  class Base {
907
478
  constructor(...args) {
@@ -910,7 +481,7 @@ class Base {
910
481
  }
911
482
 
912
483
  const parseDateTime = (value) => {
913
- if (!isString(value))
484
+ if (!isString$1(value))
914
485
  return value;
915
486
  if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
916
487
  !/^\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))
@@ -921,6 +492,8 @@ const parseDateTime = (value) => {
921
492
  return date;
922
493
  };
923
494
 
495
+ const { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
496
+
924
497
  var CheckoutTypes;
925
498
  (function (CheckoutTypes) {
926
499
  CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
@@ -965,28 +538,26 @@ class Coupon extends BaseModel {
965
538
  static createCoupon(userId) {
966
539
  return this.toInstance({
967
540
  nickname: `${Date.now()}`,
541
+ type: CouponTypes.ABSOLUTE,
968
542
  checkoutType: CheckoutTypes.ECOMMERCE,
969
- discount: {
970
- subscriber: {
971
- type: CouponTypes.ABSOLUTE,
972
- value: 10,
973
- },
974
- non_subscriber: {
975
- type: CouponTypes.ABSOLUTE,
976
- value: 10,
977
- },
978
- subscription: {
979
- type: CouponTypes.ABSOLUTE,
980
- value: 10,
981
- },
982
- },
543
+ discount: 30,
983
544
  user: userId,
545
+ useLimit: 1,
546
+ useLimitPerUser: true,
984
547
  createdAt: new Date(Date.now()),
985
548
  beginAt: new Date(Date.now()),
986
549
  expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
987
550
  });
988
551
  }
989
552
  }
553
+ __decorate([
554
+ Expose({ name: 'checkout_type' }),
555
+ __metadata("design:type", Number)
556
+ ], Coupon.prototype, "checkoutType", void 0);
557
+ __decorate([
558
+ Expose({ name: 'exclusivity_type' }),
559
+ __metadata("design:type", Number)
560
+ ], Coupon.prototype, "exclusivityType", void 0);
990
561
 
991
562
  class SubscriptionPlan extends BaseModel {
992
563
  static get identifiersFields() {
@@ -1026,18 +597,6 @@ __decorate([
1026
597
  __metadata("design:type", BeautyProfile)
1027
598
  ], User.prototype, "beautyProfile", void 0);
1028
599
 
1029
- class Address extends BaseModel {
1030
- static get identifiersFields() {
1031
- return ['id'];
1032
- }
1033
- }
1034
-
1035
- class UserAddress extends Address {
1036
- static get identifiersFields() {
1037
- return ['id', 'userId'];
1038
- }
1039
- }
1040
-
1041
600
  class Subscription extends BaseModel {
1042
601
  static get identifiersFields() {
1043
602
  return ['id'];
@@ -1052,12 +611,12 @@ __decorate([
1052
611
  __metadata("design:type", SubscriptionPlan)
1053
612
  ], Subscription.prototype, "subscriptionPlan", void 0);
1054
613
  __decorate([
1055
- Type(() => UserAddress),
1056
- __metadata("design:type", UserAddress)
614
+ Type(() => Address),
615
+ __metadata("design:type", Address)
1057
616
  ], Subscription.prototype, "shippingAddress", void 0);
1058
617
  __decorate([
1059
- Type(() => UserAddress),
1060
- __metadata("design:type", UserAddress)
618
+ Type(() => Address),
619
+ __metadata("design:type", Address)
1061
620
  ], Subscription.prototype, "billingAddress", void 0);
1062
621
  __decorate([
1063
622
  Type(() => Coupon),
@@ -1072,6 +631,12 @@ __decorate([
1072
631
  __metadata("design:type", Array)
1073
632
  ], Subscription.prototype, "payment", void 0);
1074
633
 
634
+ class UserAddress extends Address {
635
+ static get identifiersFields() {
636
+ return ['id', 'userId'];
637
+ }
638
+ }
639
+
1075
640
  class UserPaymentMethod extends BaseModel {
1076
641
  static get identifiersFields() {
1077
642
  return ['id', 'userId'];
@@ -1104,7 +669,7 @@ class Authentication {
1104
669
  return __awaiter(this, void 0, void 0, function* () {
1105
670
  const method = this.getServiceByMethod(signInMethod);
1106
671
  const userAuth = yield this.authService[method]({ email, password });
1107
- const user = this.userRepository.get({ id: userAuth.id });
672
+ const user = this.userRepository.get(userAuth);
1108
673
  if (!isNil(user))
1109
674
  return user;
1110
675
  if (/^.+@b4a.com.br$/.test(userAuth.email))
@@ -1191,123 +756,14 @@ class RecoveryPassword {
1191
756
  }
1192
757
  }
1193
758
 
1194
- class Filter extends BaseModel {
1195
- static get identifiersFields() {
1196
- return ['id'];
1197
- }
1198
- }
1199
-
1200
- class CategoryBase extends BaseModel {
1201
- static get identifiersFields() {
1202
- return ['id'];
1203
- }
1204
- }
1205
- __decorate([
1206
- Type(() => CategoryBase),
1207
- __metadata("design:type", CategoryBase)
1208
- ], CategoryBase.prototype, "parent", void 0);
1209
- __decorate([
1210
- Type(() => Filter),
1211
- __metadata("design:type", Array)
1212
- ], CategoryBase.prototype, "filters", void 0);
1213
-
1214
- class CategoryForProduct extends CategoryBase {
1215
- static get identifiersFields() {
1216
- return ['id'];
1217
- }
1218
- }
1219
-
1220
- class ProductBase extends BaseModel {
1221
- get evaluation() {
1222
- return {
1223
- reviews: this.reviews,
1224
- count: this.reviewsTotal,
1225
- rating: this.rate,
1226
- };
1227
- }
1228
- set evaluation(evaluation) {
1229
- if (!evaluation) {
1230
- this.reviews = null;
1231
- this.reviewsTotal = null;
1232
- this.rate = null;
1233
- return;
1234
- }
1235
- this.reviews = evaluation.reviews || this.reviews;
1236
- this.reviewsTotal = evaluation.count || this.reviewsTotal;
1237
- this.rate = evaluation.rating || this.rate;
1238
- }
1239
- static get identifiersFields() {
1240
- return ['id'];
1241
- }
1242
- }
1243
-
1244
- class ProductForKit extends ProductBase {
1245
- static get identifiersFields() {
1246
- return ['id'];
1247
- }
1248
- }
1249
- __decorate([
1250
- Type(() => CategoryForProduct),
1251
- __metadata("design:type", CategoryForProduct)
1252
- ], ProductForKit.prototype, "category", void 0);
1253
-
1254
- class KitProduct extends BaseModel {
1255
- static get identifiersFields() {
1256
- return ['productId', 'kitProductId'];
1257
- }
1258
- }
1259
- __decorate([
1260
- Type(() => ProductForKit),
1261
- __metadata("design:type", ProductForKit)
1262
- ], KitProduct.prototype, "kit", void 0);
1263
- __decorate([
1264
- Type(() => ProductForKit),
1265
- __metadata("design:type", ProductForKit)
1266
- ], KitProduct.prototype, "product", void 0);
1267
-
1268
- class ProductForCategory extends ProductBase {
1269
- static get identifiersFields() {
1270
- return ['id'];
1271
- }
1272
- }
1273
- __decorate([
1274
- Type(() => KitProduct),
1275
- __metadata("design:type", Array)
1276
- ], ProductForCategory.prototype, "kitProducts", void 0);
1277
-
1278
- class Category extends CategoryBase {
1279
- static get identifiersFields() {
759
+ class Category extends BaseModel {
760
+ identifierFields() {
1280
761
  return ['id'];
1281
762
  }
1282
- }
1283
- __decorate([
1284
- Type(() => ProductForCategory),
1285
- __metadata("design:type", Array)
1286
- ], Category.prototype, "childrenProducts", void 0);
1287
-
1288
- class CategoryCollectionChildren extends BaseModel {
1289
- static get identifiersFields() {
1290
- return ['collectionId', 'categoryId'];
1291
- }
1292
- }
1293
- __decorate([
1294
- Type(() => CategoryCollectionChildren),
1295
- __metadata("design:type", CategoryCollectionChildren)
1296
- ], CategoryCollectionChildren.prototype, "parent", void 0);
1297
-
1298
- class CategoryFilter extends BaseModel {
1299
763
  static get identifiersFields() {
1300
764
  return ['id'];
1301
765
  }
1302
766
  }
1303
- __decorate([
1304
- Type(() => Filter),
1305
- __metadata("design:type", Filter)
1306
- ], CategoryFilter.prototype, "filter", void 0);
1307
- __decorate([
1308
- Type(() => Category),
1309
- __metadata("design:type", Category)
1310
- ], CategoryFilter.prototype, "category", void 0);
1311
767
 
1312
768
  var GenderDestination;
1313
769
  (function (GenderDestination) {
@@ -1324,60 +780,54 @@ var Shops;
1324
780
  Shops["ALL"] = "ALL";
1325
781
  })(Shops || (Shops = {}));
1326
782
 
1327
- class FilterOption extends BaseModel {
1328
- static get identifiersFields() {
783
+ class Product extends BaseModel {
784
+ identifierFields() {
1329
785
  return ['id'];
1330
786
  }
1331
- }
1332
-
1333
- class Product extends ProductBase {
1334
787
  static get identifiersFields() {
1335
788
  return ['id'];
1336
789
  }
1337
790
  }
1338
- __decorate([
1339
- Type(() => CategoryForProduct),
1340
- __metadata("design:type", CategoryForProduct)
1341
- ], Product.prototype, "category", void 0);
1342
791
  __decorate([
1343
792
  Type(() => KitProduct),
1344
793
  __metadata("design:type", Array)
1345
794
  ], Product.prototype, "kitProducts", void 0);
1346
795
 
1347
- class Variant extends BaseModel {
1348
- static get identifiersFields() {
1349
- return ['id', 'productId'];
1350
- }
1351
- }
1352
-
1353
- class Wishlist extends Category {
1354
- static get identifiersFields() {
1355
- return ['id'];
1356
- }
1357
- }
1358
-
1359
- class Buy2Win extends BaseModel {
796
+ class KitProduct extends BaseModel {
1360
797
  static get identifiersFields() {
1361
- return ['id'];
798
+ return ['productId', 'kitProducId'];
1362
799
  }
1363
800
  }
1364
801
  __decorate([
1365
- Type(() => Category),
1366
- __metadata("design:type", Array)
1367
- ], Buy2Win.prototype, "categories", void 0);
802
+ Type(() => Product),
803
+ __metadata("design:type", Product)
804
+ ], KitProduct.prototype, "kit", void 0);
805
+ __decorate([
806
+ Type(() => Product),
807
+ __metadata("design:type", Product)
808
+ ], KitProduct.prototype, "product", void 0);
1368
809
 
1369
- class CampaignDashboard extends BaseModel {
1370
- static get identifiersFields() {
810
+ class Variant extends BaseModel {
811
+ identifierFields() {
1371
812
  return ['id'];
1372
813
  }
1373
- }
1374
-
1375
- class CampaignHashtag extends BaseModel {
1376
814
  static get identifiersFields() {
1377
- return ['id'];
815
+ return ['id', 'productId'];
1378
816
  }
1379
817
  }
1380
818
 
819
+ var OrderStatus;
820
+ (function (OrderStatus) {
821
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
822
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
823
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
824
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
825
+ OrderStatus["ENVIADO"] = "Enviado";
826
+ OrderStatus["ENTREGUE"] = "Entregue";
827
+ OrderStatus["CANCELADO"] = "Cancelado";
828
+ OrderStatus["CREDIT_CARD"] = "credit_card";
829
+ })(OrderStatus || (OrderStatus = {}));
830
+
1381
831
  class LineItem extends Product {
1382
832
  }
1383
833
 
@@ -1401,12 +851,12 @@ __decorate([
1401
851
  __metadata("design:type", User)
1402
852
  ], Checkout.prototype, "user", void 0);
1403
853
  __decorate([
1404
- Type(() => UserAddress),
1405
- __metadata("design:type", UserAddress)
854
+ Type(() => Address),
855
+ __metadata("design:type", Address)
1406
856
  ], Checkout.prototype, "shippingAddress", void 0);
1407
857
  __decorate([
1408
- Type(() => UserAddress),
1409
- __metadata("design:type", UserAddress)
858
+ Type(() => Address),
859
+ __metadata("design:type", Address)
1410
860
  ], Checkout.prototype, "billingAddress", void 0);
1411
861
  __decorate([
1412
862
  Type(() => ShippingMethod),
@@ -1417,18 +867,6 @@ __decorate([
1417
867
  __metadata("design:type", Coupon)
1418
868
  ], Checkout.prototype, "coupon", void 0);
1419
869
 
1420
- var OrderStatus;
1421
- (function (OrderStatus) {
1422
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
1423
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
1424
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
1425
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
1426
- OrderStatus["ENVIADO"] = "Enviado";
1427
- OrderStatus["ENTREGUE"] = "Entregue";
1428
- OrderStatus["CANCELADO"] = "Cancelado";
1429
- OrderStatus["CREDIT_CARD"] = "credit_card";
1430
- })(OrderStatus || (OrderStatus = {}));
1431
-
1432
870
  class Order extends Checkout {
1433
871
  }
1434
872
  __decorate([
@@ -1442,12 +880,12 @@ class CheckoutSubscription extends BaseModel {
1442
880
  }
1443
881
  }
1444
882
  __decorate([
1445
- Type(() => UserAddress),
1446
- __metadata("design:type", UserAddress)
883
+ Type(() => Address),
884
+ __metadata("design:type", Address)
1447
885
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
1448
886
  __decorate([
1449
- Type(() => UserAddress),
1450
- __metadata("design:type", UserAddress)
887
+ Type(() => Address),
888
+ __metadata("design:type", Address)
1451
889
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
1452
890
  __decorate([
1453
891
  Type(() => SubscriptionPlan),
@@ -1458,19 +896,15 @@ __decorate([
1458
896
  __metadata("design:type", Coupon)
1459
897
  ], CheckoutSubscription.prototype, "coupon", void 0);
1460
898
 
1461
- class RoundProductPricesHelper {
1462
- static roundProductPrices(product) {
1463
- product.price.price = Number(product.price.price.toFixed(2));
1464
- product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
1465
- if (product.price.subscriberPrice) {
1466
- product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
1467
- }
1468
- if (product instanceof LineItem && product.pricePaid) {
1469
- product.pricePaid = Number(product.pricePaid.toFixed(2));
1470
- }
1471
- return product;
899
+ class Buy2Win extends BaseModel {
900
+ static get identifiersFields() {
901
+ return ['id'];
1472
902
  }
1473
903
  }
904
+ __decorate([
905
+ Type(() => Category),
906
+ __metadata("design:type", Array)
907
+ ], Buy2Win.prototype, "categories", void 0);
1474
908
 
1475
909
  var FilterType;
1476
910
  (function (FilterType) {
@@ -1571,12 +1005,6 @@ class ShopMenu extends BaseModel {
1571
1005
  }
1572
1006
  }
1573
1007
 
1574
- class ShopSettings extends BaseModel {
1575
- static get identifiersFields() {
1576
- return ['id'];
1577
- }
1578
- }
1579
-
1580
1008
  class InvalidArgumentError extends CustomError {
1581
1009
  constructor(message) {
1582
1010
  super(message);
@@ -1607,17 +1035,13 @@ class AxiosAdapter {
1607
1035
  constructor(config) {
1608
1036
  this.config = config;
1609
1037
  }
1610
- get(index, id) {
1038
+ get(index) {
1611
1039
  return __awaiter(this, void 0, void 0, function* () {
1612
1040
  try {
1613
1041
  const { data } = yield axios({
1614
- url: `${this.config.url}/${index}/_doc/${id}`,
1042
+ url: `${this.config.url}/${index}`,
1615
1043
  method: 'GET',
1616
- responseType: 'json',
1617
- headers: {
1618
- 'Content-Type': 'application/json',
1619
- Authorization: `ApiKey ${this.config.credential}`,
1620
- },
1044
+ headers: { Authorization: `Basic ${this.config.credential}` },
1621
1045
  });
1622
1046
  return data._source;
1623
1047
  }
@@ -1631,14 +1055,9 @@ class AxiosAdapter {
1631
1055
  query(index, query) {
1632
1056
  return __awaiter(this, void 0, void 0, function* () {
1633
1057
  const { data } = yield axios({
1634
- url: `${this.config.url}/${index}/_search`,
1058
+ url: `${this.config.url}/${index}`,
1635
1059
  method: 'POST',
1636
- responseType: 'json',
1637
- headers: {
1638
- Accept: 'application/vnd.elasticsearch+json;compatible-with=7',
1639
- 'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
1640
- Authorization: `ApiKey ${this.config.credential}`,
1641
- },
1060
+ headers: { Authorization: `Basic ${this.config.credential}` },
1642
1061
  data: query,
1643
1062
  });
1644
1063
  return {
@@ -1650,29 +1069,19 @@ class AxiosAdapter {
1650
1069
  save(index, data) {
1651
1070
  return __awaiter(this, void 0, void 0, function* () {
1652
1071
  yield axios({
1653
- url: `${this.config.url}/${index}/_doc`,
1654
- method: 'POST',
1655
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1656
- data,
1657
- });
1658
- });
1659
- }
1660
- update(index, id, data) {
1661
- return __awaiter(this, void 0, void 0, function* () {
1662
- yield axios({
1663
- url: `${this.config.url}/${index}/_update/${id}`,
1072
+ url: `${this.config.url}/${index}`,
1664
1073
  method: 'PUT',
1665
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1074
+ headers: { Authorization: `Basic ${this.config.credential}` },
1666
1075
  data,
1667
1076
  });
1668
1077
  });
1669
1078
  }
1670
- delete(index, id) {
1079
+ delete(index) {
1671
1080
  return __awaiter(this, void 0, void 0, function* () {
1672
1081
  yield axios({
1673
- url: `${this.config.url}/${index}/_doc/${id}`,
1082
+ url: `${this.config.url}/${index}`,
1674
1083
  method: 'DELETE',
1675
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1084
+ headers: { Authorization: `Basic ${this.config.credential}` },
1676
1085
  });
1677
1086
  });
1678
1087
  }
@@ -1681,19 +1090,16 @@ class AxiosAdapter {
1681
1090
  class ProductsIndex {
1682
1091
  constructor(adapter) {
1683
1092
  this.adapter = adapter;
1684
- this.index = `products`;
1685
1093
  }
1686
- getById(id) {
1094
+ get(id) {
1687
1095
  return __awaiter(this, void 0, void 0, function* () {
1688
- const data = yield this.adapter.get(this.index, id);
1096
+ const data = yield this.adapter.get(`products/_doc/${id}`);
1689
1097
  return Product.toInstance(data);
1690
1098
  });
1691
1099
  }
1692
- search(searchTerm, total, shop) {
1100
+ findById(ids, options) {
1693
1101
  return __awaiter(this, void 0, void 0, function* () {
1694
- const size = total || 9;
1695
1102
  const fields = [
1696
- 'EAN',
1697
1103
  'brand',
1698
1104
  'id',
1699
1105
  'images',
@@ -1704,88 +1110,73 @@ class ProductsIndex {
1704
1110
  'stock',
1705
1111
  'slug',
1706
1112
  'reviews',
1113
+ 'pricePaid',
1114
+ 'isGift',
1115
+ 'stock',
1116
+ 'weight',
1117
+ 'tags',
1707
1118
  'hasVariants',
1708
- 'rate',
1119
+ 'type',
1709
1120
  ];
1710
- const filter = [{ term: { published: true } }];
1711
- if (size > 9) {
1712
- fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
1713
- }
1714
- else {
1715
- filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
1716
- }
1717
- const search = yield this.adapter.query(this.index, {
1718
- size,
1719
- _source: fields,
1720
- query: {
1121
+ const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
1721
1122
  bool: {
1722
- must: {
1723
- multi_match: {
1724
- query: `${searchTerm}`,
1725
- type: 'bool_prefix',
1726
- fields: [
1727
- 'name',
1728
- 'name.folded',
1729
- 'name.search',
1730
- 'description',
1731
- 'description.search',
1732
- 'description.folded',
1733
- 'brand',
1734
- 'brand.search',
1735
- 'brand.folded',
1736
- ],
1737
- fuzziness: 2,
1123
+ filter: [
1124
+ {
1125
+ terms: {
1126
+ _id: ids,
1127
+ },
1738
1128
  },
1739
- },
1740
- should: {
1741
- match_phrase_prefix: {
1742
- 'name.search': {
1743
- query: `${searchTerm}`,
1744
- slop: 10,
1129
+ {
1130
+ term: {
1131
+ published: true,
1745
1132
  },
1746
1133
  },
1747
- },
1748
- filter,
1134
+ ...((options === null || options === void 0 ? void 0 : options.hasStock)
1135
+ ? [
1136
+ {
1137
+ range: {
1138
+ 'stock.quantity': {
1139
+ gt: 0,
1140
+ },
1141
+ },
1142
+ },
1143
+ ]
1144
+ : []),
1145
+ ],
1749
1146
  },
1750
- },
1751
- });
1752
- search.hits = search.hits
1753
- .filter((e) => e._source.name !== '')
1754
- .map((hit) => {
1755
- RoundProductPricesHelper.roundProductPrices(hit._source);
1756
- return hit;
1757
- });
1758
- return search;
1147
+ } }, ((options === null || options === void 0 ? void 0 : options.size) ? { size: options === null || options === void 0 ? void 0 : options.size } : {})));
1148
+ return hits.map((hit) => Product.toInstance(hit._source));
1759
1149
  });
1760
1150
  }
1761
1151
  save(product) {
1762
1152
  return __awaiter(this, void 0, void 0, function* () {
1153
+ delete product.createdAt;
1154
+ delete product.updatedAt;
1155
+ delete product.kitProducts;
1763
1156
  try {
1764
- const { createdAt, updatedAt, kitProducts } = product, data = __rest(product, ["createdAt", "updatedAt", "kitProducts"]);
1765
- this.adapter.save(this.index, data);
1766
- }
1767
- catch (error) {
1768
- console.error(error);
1769
- }
1770
- });
1771
- }
1772
- update(product) {
1773
- return __awaiter(this, void 0, void 0, function* () {
1774
- try {
1775
- yield this.adapter.update(this.index, product.id, product);
1157
+ if (!product.firestoreId)
1158
+ throw new Error('Is not a product from firestore');
1159
+ yield this.get(product.firestoreId);
1160
+ yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
1776
1161
  }
1777
1162
  catch (error) {
1778
- console.error(error);
1163
+ if (!(error instanceof Error))
1164
+ throw error;
1165
+ console.error(error.message);
1166
+ yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
1779
1167
  }
1780
1168
  });
1781
1169
  }
1782
- delete(id) {
1170
+ delete(product) {
1783
1171
  return __awaiter(this, void 0, void 0, function* () {
1172
+ if (!product.firestoreId)
1173
+ return;
1784
1174
  try {
1785
- yield this.adapter.delete(this.index, id);
1175
+ yield this.get(product.firestoreId);
1176
+ yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
1786
1177
  }
1787
1178
  catch (error) {
1788
- console.error(error);
1179
+ yield this.adapter.delete(`products/_doc/${product.id}`);
1789
1180
  }
1790
1181
  });
1791
1182
  }
@@ -1813,39 +1204,17 @@ const withFirestore = (MixinBase) => {
1813
1204
  ? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
1814
1205
  : bindDate(data[key], key) })), {});
1815
1206
  };
1816
- const omitByRecursivelyInPlace = (value, iteratee) => {
1817
- each(value, (v, k) => {
1818
- if (iteratee(v, k)) {
1819
- unset(value, k);
1820
- }
1821
- else if (isObject(v)) {
1822
- omitByRecursivelyInPlace(v, iteratee);
1823
- }
1824
- });
1825
- return value;
1826
- };
1827
1207
  return class extends MixinBase {
1828
- constructor(...params) {
1829
- super(...params);
1830
- this.fields = {};
1831
- this.interceptors = {};
1208
+ constructor() {
1209
+ super(...arguments);
1832
1210
  this.collectionName = '';
1833
- const options = params[0];
1834
- this.firestore = options.firestore;
1835
- this.collectionName = options.collectionName;
1836
- this.model = options.model;
1837
- this.fields = options.fields;
1838
- this.interceptors = options.interceptors;
1839
1211
  }
1840
1212
  collection(path) {
1841
1213
  return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
1842
1214
  }
1843
1215
  buildModelInstance() {
1844
1216
  return {
1845
- toFirestore: (data) => {
1846
- const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
1847
- return omitByRecursivelyInPlace(plain, (value) => value === undefined);
1848
- },
1217
+ toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
1849
1218
  fromFirestore: (snap) => {
1850
1219
  const data = snap.data();
1851
1220
  let bindedData = null;
@@ -1885,16 +1254,12 @@ const withHelpers = (MixinBase) => {
1885
1254
  const withGetFirestore = (MixinBase) => {
1886
1255
  return class GetFirestore extends MixinBase {
1887
1256
  get(identifiers) {
1888
- var _a, _b, _c, _d;
1889
1257
  return __awaiter(this, void 0, void 0, function* () {
1890
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
1891
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
1892
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
1893
- const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
1258
+ const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
1894
1259
  const data = docRef.data();
1895
1260
  if (isNil(data))
1896
1261
  throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1897
- return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, data, intercepted)) || data;
1262
+ return data;
1898
1263
  });
1899
1264
  }
1900
1265
  buildCollectionPathForGet(identifiers) {
@@ -1932,7 +1297,7 @@ const withFindFirestore = (MixinBase) => {
1932
1297
  ], []);
1933
1298
  this.buildWhereSentence = (fieldName, options) => {
1934
1299
  if (this.isSubCollection(this) && fieldName === this.parentIdField)
1935
- return [];
1300
+ [];
1936
1301
  const value = (options === null || options === void 0 ? void 0 : options.value) || options;
1937
1302
  const object = {};
1938
1303
  set(object, fieldName, value);
@@ -1973,13 +1338,9 @@ const withFindFirestore = (MixinBase) => {
1973
1338
  return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
1974
1339
  };
1975
1340
  }
1976
- find(find = {}) {
1977
- var _a, _b, _c, _d, _e, _f;
1341
+ find({ filters, limits, orderBy, } = {}) {
1978
1342
  return __awaiter(this, void 0, void 0, function* () {
1979
- const collection = this.collection(this.buildCollectionPathForFind(find.filters));
1980
- const enableCount = (_b = (_a = find === null || find === void 0 ? void 0 : find.options) === null || _a === void 0 ? void 0 : _a.enableCount) !== null && _b !== void 0 ? _b : true;
1981
- const intercepted = yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.request) === null || _d === void 0 ? void 0 : _d.call(_c, { find }));
1982
- const { filters, limits, orderBy } = intercepted.find || find;
1343
+ const collection = this.collection(this.buildCollectionPathForFind(filters));
1983
1344
  const queries = this.makeFirestoreWhere(filters || {});
1984
1345
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
1985
1346
  const offsets = yield this.defineLimits(filters, limits);
@@ -1987,8 +1348,8 @@ const withFindFirestore = (MixinBase) => {
1987
1348
  const docs = yield getDocs(query(collection, ...queryArgumments));
1988
1349
  const data = docs.docs.map((doc) => doc.data());
1989
1350
  return {
1990
- data: (yield ((_f = (_e = this.interceptors) === null || _e === void 0 ? void 0 : _e.response) === null || _f === void 0 ? void 0 : _f.call(_e, data, intercepted))) || data,
1991
- count: enableCount ? this.calculateCount(data, limits) : Infinity,
1351
+ data,
1352
+ count: this.calculateCount(data, limits),
1992
1353
  };
1993
1354
  });
1994
1355
  }
@@ -2000,12 +1361,11 @@ const withFindFirestore = (MixinBase) => {
2000
1361
  return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
2001
1362
  }
2002
1363
  defineLimits(filters, limits) {
2003
- var _a;
2004
1364
  return __awaiter(this, void 0, void 0, function* () {
2005
1365
  const queries = [];
2006
1366
  if (limits === null || limits === void 0 ? void 0 : limits.offset) {
2007
1367
  if (this.model.isModel(limits.offset))
2008
- queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), (_a = Object.values(limits.offset.identifier).shift()) === null || _a === void 0 ? void 0 : _a.toString()))));
1368
+ queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
2009
1369
  else if (isNumber(limits.offset) || isString(limits.offset))
2010
1370
  queries.push(startAt(limits.offset));
2011
1371
  }
@@ -2027,21 +1387,16 @@ const withFindFirestore = (MixinBase) => {
2027
1387
  const withCreateFirestore = (MixinBase) => {
2028
1388
  return class CreateFirestore extends MixinBase {
2029
1389
  create(data) {
2030
- var _a, _b, _c, _d;
2031
1390
  return __awaiter(this, void 0, void 0, function* () {
2032
- const instance = this.model.toInstance(data);
2033
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
2034
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2035
- const docRef = yield this.save(builded);
1391
+ const docRef = yield this.save(this.model.toInstance(data));
2036
1392
  const doc = yield getDoc(docRef);
2037
- const docBuilded = (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, doc.data(), intercepted))) || doc.data();
2038
- return docBuilded;
1393
+ return doc.data();
2039
1394
  });
2040
1395
  }
2041
1396
  save(data) {
2042
1397
  var _a, _b;
2043
1398
  return __awaiter(this, void 0, void 0, function* () {
2044
- const id = (_b = (_a = Object.values(data.identifier)) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.toString();
1399
+ const id = (_b = data.identifier[(_a = data.identifiersFields) === null || _a === void 0 ? void 0 : _a.shift()]) === null || _b === void 0 ? void 0 : _b.toString();
2045
1400
  const collectionPath = this.buildCollectionPathForAdd(data);
2046
1401
  const collection = this.collection(collectionPath);
2047
1402
  if (isEmpty(id))
@@ -2083,17 +1438,13 @@ const withUpdateFirestore = (MixinBase) => {
2083
1438
  };
2084
1439
  return class UpdateFirestore extends MixinBase {
2085
1440
  update(data) {
2086
- var _a, _b, _c, _d;
2087
1441
  return __awaiter(this, void 0, void 0, function* () {
2088
1442
  const model = new this.model();
2089
1443
  const keyField = model.identifiersFields.shift();
2090
1444
  const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
2091
- const plainFromData = this.model.toInstance(this.paramsToPlain(data));
2092
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance: plainFromData }));
2093
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || plainFromData;
2094
- yield setDoc(docRef, builded.toPlain(), { merge: true });
2095
- const docData = yield getDoc(docRef).then((doc) => doc.data());
2096
- return ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, docData, intercepted)) || docData;
1445
+ yield setDoc(docRef, this.paramsToPlain(data), { merge: true });
1446
+ const docData = yield getDoc(docRef);
1447
+ return docData.data();
2097
1448
  });
2098
1449
  }
2099
1450
  buildCollectionPathForUpdate(identifiers) {
@@ -2113,13 +1464,8 @@ const withUpdateFirestore = (MixinBase) => {
2113
1464
  const withDeleteFirestore = (MixinBase) => {
2114
1465
  return class DeleteFirestore extends MixinBase {
2115
1466
  delete(identifiers) {
2116
- var _a, _b, _c, _d;
2117
1467
  return __awaiter(this, void 0, void 0, function* () {
2118
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => (Object.assign(Object.assign({}, acc), { [field]: identifiers[field] })), {}));
2119
- const intercepted = yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, { instance }));
2120
- const builded = (intercepted === null || intercepted === void 0 ? void 0 : intercepted.instance) || instance;
2121
- yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
2122
- yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, instance, intercepted));
1468
+ yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
2123
1469
  });
2124
1470
  }
2125
1471
  buildCollectionPathForRemove(identifiers) {
@@ -2132,10 +1478,8 @@ const withDeleteFirestore = (MixinBase) => {
2132
1478
 
2133
1479
  const withSubCollection = (MixinBase, ParentModel) => {
2134
1480
  return class SubCollectionMix extends MixinBase {
2135
- constructor(...params) {
2136
- const options = params[0];
2137
- super(...params);
2138
- this.parentIdField = options.parentIdField;
1481
+ constructor(...args) {
1482
+ super(args);
2139
1483
  }
2140
1484
  collection(path) {
2141
1485
  return super.collection(path);
@@ -2149,87 +1493,73 @@ const withCrudFirestore = (MixinBase) => {
2149
1493
  };
2150
1494
 
2151
1495
  class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2152
- constructor({ firestore, interceptors }) {
2153
- super({
2154
- firestore,
2155
- collectionName: 'leads',
2156
- model: Lead,
2157
- interceptors,
2158
- });
1496
+ constructor(firestore) {
1497
+ super();
1498
+ this.firestore = firestore;
1499
+ this.collectionName = 'leads';
1500
+ this.model = Lead;
2159
1501
  }
2160
1502
  }
2161
1503
 
2162
1504
  class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
2163
- constructor({ firestore, interceptors }, parentRepository) {
2164
- super({
2165
- firestore,
2166
- collectionName: 'editions',
2167
- parentIdField: 'subscriptionId',
2168
- model: Edition,
2169
- interceptors,
2170
- });
1505
+ constructor(firestore, parentRepository) {
1506
+ super();
1507
+ this.firestore = firestore;
2171
1508
  this.parentRepository = parentRepository;
1509
+ this.collectionName = 'editions';
1510
+ this.parentIdField = 'subscriptionId';
1511
+ this.model = Edition;
2172
1512
  }
2173
1513
  }
2174
1514
 
2175
1515
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2176
- constructor({ firestore, interceptors, }) {
2177
- super({
2178
- firestore,
2179
- collectionName: 'subscription',
2180
- model: Subscription,
2181
- interceptors,
2182
- });
1516
+ constructor(firestore) {
1517
+ super();
1518
+ this.firestore = firestore;
1519
+ this.collectionName = 'subscription';
1520
+ this.model = Subscription;
2183
1521
  }
2184
1522
  }
2185
1523
 
2186
1524
  class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
2187
- constructor({ firestore, interceptors }, parentRepository) {
2188
- super({
2189
- firestore,
2190
- collectionName: 'payments',
2191
- parentIdField: 'subscriptionId',
2192
- model: SubscriptionPayment,
2193
- interceptors,
2194
- });
1525
+ constructor(firestore, parentRepository) {
1526
+ super();
1527
+ this.firestore = firestore;
2195
1528
  this.parentRepository = parentRepository;
1529
+ this.collectionName = 'payments';
1530
+ this.parentIdField = 'subscriptionId';
1531
+ this.model = SubscriptionPayment;
2196
1532
  }
2197
1533
  }
2198
1534
 
2199
1535
  class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
2200
- constructor({ firestore, interceptors }, parentRepository) {
2201
- super({
2202
- firestore,
2203
- collectionName: 'address',
2204
- parentIdField: 'userId',
2205
- model: UserAddress,
2206
- interceptors,
2207
- });
1536
+ constructor(firestore, parentRepository) {
1537
+ super();
1538
+ this.firestore = firestore;
2208
1539
  this.parentRepository = parentRepository;
1540
+ this.collectionName = 'address';
1541
+ this.parentIdField = 'userId';
1542
+ this.model = UserAddress;
2209
1543
  }
2210
1544
  }
2211
1545
 
2212
1546
  class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
2213
- constructor({ firestore, interceptors }, parentRepository) {
2214
- super({
2215
- firestore,
2216
- collectionName: 'CX',
2217
- parentIdField: 'userId',
2218
- model: BeautyProfile,
2219
- interceptors,
2220
- });
1547
+ constructor(firestore, parentRepository) {
1548
+ super();
1549
+ this.firestore = firestore;
2221
1550
  this.parentRepository = parentRepository;
1551
+ this.collectionName = 'CX';
1552
+ this.parentIdField = 'userId';
1553
+ this.model = BeautyProfile;
2222
1554
  }
2223
1555
  }
2224
1556
 
2225
1557
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2226
- constructor({ firestore, interceptors }) {
2227
- super({
2228
- firestore,
2229
- collectionName: 'users',
2230
- model: User,
2231
- interceptors,
2232
- });
1558
+ constructor(firestore) {
1559
+ super();
1560
+ this.firestore = firestore;
1561
+ this.collectionName = 'users';
1562
+ this.model = User;
2233
1563
  }
2234
1564
  get(identifiers) {
2235
1565
  const _super = Object.create(null, {
@@ -2280,26 +1610,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2280
1610
  }
2281
1611
 
2282
1612
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
2283
- constructor({ firestore, interceptors }, parentRepository) {
2284
- super({
2285
- firestore,
2286
- collectionName: 'payment_method',
2287
- parentIdField: 'userId',
2288
- model: UserPaymentMethod,
2289
- interceptors,
2290
- });
1613
+ constructor(firestore, parentRepository) {
1614
+ super();
1615
+ this.firestore = firestore;
2291
1616
  this.parentRepository = parentRepository;
1617
+ this.collectionName = 'payment_method';
1618
+ this.parentIdField = 'userId';
1619
+ this.model = UserPaymentMethod;
2292
1620
  }
2293
1621
  }
2294
1622
 
2295
1623
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2296
- constructor({ firestore, interceptors }) {
2297
- super({
2298
- firestore,
2299
- collectionName: 'categories',
2300
- model: Category,
2301
- interceptors,
2302
- });
1624
+ constructor(firestore) {
1625
+ super();
1626
+ this.firestore = firestore;
1627
+ this.collectionName = 'categories';
1628
+ this.model = Category;
2303
1629
  }
2304
1630
  getCategoryBySlug(slug, shop) {
2305
1631
  return __awaiter(this, void 0, void 0, function* () {
@@ -2311,7 +1637,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2311
1637
  return categoryDocs.docs[0].data();
2312
1638
  });
2313
1639
  }
2314
- getCategoriesForHome(categoryIds, limit = 4, gender) {
1640
+ getCategoriesForHome(categoryIds, limit = 4) {
2315
1641
  return __awaiter(this, void 0, void 0, function* () {
2316
1642
  const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
2317
1643
  if (categorySnap.empty)
@@ -2320,7 +1646,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2320
1646
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
2321
1647
  return ({
2322
1648
  category,
2323
- products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
1649
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
2324
1650
  });
2325
1651
  })));
2326
1652
  return homeSections;
@@ -2339,8 +1665,6 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2339
1665
  wheres.push(where('published', '==', true), where('id', 'in', productIds));
2340
1666
  if (options === null || options === void 0 ? void 0 : options.hasStock)
2341
1667
  wheres.push(where('stock.quantity', '>', 0));
2342
- if (options === null || options === void 0 ? void 0 : options.gender)
2343
- wheres.push(where('tags', 'array-contains', options === null || options === void 0 ? void 0 : options.gender));
2344
1668
  if (options === null || options === void 0 ? void 0 : options.limit)
2345
1669
  wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
2346
1670
  const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
@@ -2351,26 +1675,15 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2351
1675
  return is(products);
2352
1676
  });
2353
1677
  }
2354
- getCategoryByShop(shop) {
2355
- return;
2356
- }
2357
- getChildren(parentId) {
2358
- return;
2359
- }
2360
- isChild(id, parentId) {
2361
- return;
2362
- }
2363
1678
  }
2364
1679
 
2365
1680
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2366
- constructor({ firestore, interceptors }) {
2367
- super({
2368
- firestore,
2369
- collectionName: 'productsErpVitrine',
2370
- model: Product,
2371
- interceptors,
2372
- });
1681
+ constructor(firestore) {
1682
+ super();
1683
+ this.firestore = firestore;
2373
1684
  this.reviews = {};
1685
+ this.collectionName = 'productsErpVitrine';
1686
+ this.model = Product;
2374
1687
  }
2375
1688
  getBySlug(slug) {
2376
1689
  var _a;
@@ -2411,101 +1724,43 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
2411
1724
  return this.reviews[status];
2412
1725
  });
2413
1726
  }
2414
- cleanShoppingCountFromIds() {
2415
- return;
2416
- }
2417
- findCatalog(params) {
2418
- return this.find(params);
2419
- }
2420
1727
  }
2421
1728
 
2422
1729
  class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
2423
- constructor({ firestore, interceptors }, parentRepository) {
2424
- super({
2425
- firestore,
2426
- collectionName: 'variants',
2427
- parentIdField: 'productId',
2428
- model: Variant,
2429
- interceptors,
2430
- });
1730
+ constructor(firestore, parentRepository) {
1731
+ super();
1732
+ this.firestore = firestore;
2431
1733
  this.parentRepository = parentRepository;
1734
+ this.collectionName = 'variants';
1735
+ this.parentIdField = 'productId';
1736
+ this.model = Variant;
2432
1737
  }
2433
1738
  }
2434
1739
 
2435
1740
  class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2436
- constructor({ firestore, interceptors }) {
2437
- super({
2438
- firestore,
2439
- collectionName: 'subscriptionProducts',
2440
- model: Product,
2441
- interceptors,
2442
- });
2443
- }
2444
- }
2445
-
2446
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2447
- constructor({ firestore, interceptors }) {
2448
- super({
2449
- firestore,
2450
- collectionName: 'buy2win',
2451
- model: Buy2Win,
2452
- interceptors,
2453
- });
2454
- }
2455
- }
2456
-
2457
- class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2458
- constructor({ firestore, interceptors, }) {
2459
- super({
2460
- firestore,
2461
- collectionName: 'dashboardCampaignsAuto',
2462
- model: CampaignDashboard,
2463
- interceptors,
2464
- });
2465
- }
2466
- }
2467
-
2468
- class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2469
- constructor({ firestore, interceptors, }) {
2470
- super({
2471
- firestore,
2472
- collectionName: 'hashtagCampaignsAuto',
2473
- model: CampaignHashtag,
2474
- interceptors,
2475
- });
1741
+ constructor(firestore) {
1742
+ super();
1743
+ this.firestore = firestore;
1744
+ this.collectionName = 'subscriptionProducts';
1745
+ this.model = Product;
2476
1746
  }
2477
1747
  }
2478
1748
 
2479
1749
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2480
- constructor({ firestore, interceptors }) {
2481
- super({
2482
- firestore,
2483
- collectionName: 'checkouts',
2484
- model: Checkout,
2485
- interceptors,
2486
- });
2487
- }
2488
- }
2489
-
2490
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2491
- constructor({ firestore, interceptors, }) {
2492
- super({
2493
- firestore,
2494
- collectionName: 'checkoutsSubscription',
2495
- model: CheckoutSubscription,
2496
- interceptors,
2497
- });
1750
+ constructor(firestore) {
1751
+ super();
1752
+ this.firestore = firestore;
1753
+ this.collectionName = 'checkouts';
1754
+ this.model = Checkout;
2498
1755
  }
2499
1756
  }
2500
1757
 
2501
1758
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2502
- constructor({ firestore, interceptors }) {
2503
- super({
2504
- firestore,
2505
- collectionName: 'coupons',
2506
- model: Coupon,
2507
- interceptors,
2508
- });
1759
+ constructor(firestore) {
1760
+ super();
1761
+ this.firestore = firestore;
1762
+ this.collectionName = 'coupons';
1763
+ this.model = Coupon;
2509
1764
  }
2510
1765
  buildModelInstance() {
2511
1766
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2527,16 +1782,9 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
2527
1782
  }
2528
1783
 
2529
1784
  class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2530
- constructor({ firestore, interceptors }) {
2531
- super({
2532
- firestore,
2533
- collectionName: 'orders',
2534
- model: Order,
2535
- interceptors,
2536
- fields: {
2537
- status: FirestoreFieldType.String,
2538
- },
2539
- });
1785
+ constructor(firestore) {
1786
+ super();
1787
+ this.firestore = firestore;
2540
1788
  this.orderFromFirestore = (order) => {
2541
1789
  var _a;
2542
1790
  if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
@@ -2550,6 +1798,11 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
2550
1798
  }
2551
1799
  return order;
2552
1800
  };
1801
+ this.collectionName = 'orders';
1802
+ this.model = Order;
1803
+ this.fields = {
1804
+ status: FirestoreFieldType.String,
1805
+ };
2553
1806
  }
2554
1807
  buildModelInstance() {
2555
1808
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2563,62 +1816,86 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
2563
1816
  }
2564
1817
  }
2565
1818
 
2566
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
2567
- constructor({ firestore, interceptors }) {
2568
- super({
2569
- firestore,
2570
- interceptors,
2571
- });
2572
- this.collectionName = 'legacyOrders';
1819
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1820
+ constructor(firestore) {
1821
+ super();
1822
+ this.firestore = firestore;
1823
+ this.collectionName = 'payments';
1824
+ this.model = Payment;
2573
1825
  }
2574
1826
  }
2575
1827
 
2576
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2577
- constructor({ firestore, interceptors }) {
2578
- super({
2579
- firestore,
2580
- collectionName: 'payments',
2581
- model: Payment,
2582
- interceptors,
2583
- });
1828
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1829
+ constructor(firestore) {
1830
+ super();
1831
+ this.firestore = firestore;
1832
+ this.collectionName = 'checkoutsSubscription';
1833
+ this.model = CheckoutSubscription;
2584
1834
  }
2585
1835
  }
2586
1836
 
2587
1837
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2588
- constructor({ firestore, interceptors, }) {
2589
- super({
2590
- firestore,
2591
- collectionName: 'subscriptionPlans',
2592
- model: SubscriptionPlan,
2593
- interceptors,
2594
- });
1838
+ constructor(firestore) {
1839
+ super();
1840
+ this.firestore = firestore;
1841
+ this.collectionName = 'subscriptionPlans';
1842
+ this.model = SubscriptionPlan;
1843
+ }
1844
+ }
1845
+
1846
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1847
+ constructor(firestore) {
1848
+ super();
1849
+ this.firestore = firestore;
1850
+ this.collectionName = 'buy2win';
1851
+ this.model = Buy2Win;
1852
+ }
1853
+ }
1854
+
1855
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1856
+ constructor(firestore) {
1857
+ super(firestore);
1858
+ this.firestore = firestore;
1859
+ this.collectionName = 'legacyOrders';
2595
1860
  }
2596
1861
  }
2597
1862
 
2598
1863
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2599
- constructor({ firestore, interceptors }) {
2600
- super({
2601
- firestore,
2602
- collectionName: 'dms',
2603
- model: Home,
2604
- interceptors,
2605
- });
2606
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => {
2607
- var _a, _b, _c;
2608
- return ({
2609
- category: ((_a = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _a === void 0 ? void 0 : _a.toPlain)
2610
- ? (_b = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category) === null || _b === void 0 ? void 0 : _b.toPlain()
2611
- : homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category,
2612
- products: ((_c = homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.products) === null || _c === void 0 ? void 0 : _c.map((product) => ((product === null || product === void 0 ? void 0 : product.toPlain) ? product === null || product === void 0 ? void 0 : product.toPlain() : product)).filter(Boolean)) || [],
2613
- });
1864
+ constructor(firestore) {
1865
+ super();
1866
+ this.firestore = firestore;
1867
+ this.homeToFirestore = (home) => {
1868
+ var _a;
1869
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
1870
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
1871
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.homeCategoryGroupToPlain);
1872
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.homeCategoryGroupToPlain);
1873
+ }
1874
+ return home;
2614
1875
  };
2615
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
1876
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
1877
+ category: homeCategoryGroup.category.toPlain(),
1878
+ products: homeCategoryGroup.products.map((product) => product.toPlain()),
1879
+ });
1880
+ this.homeFromFirestore = (home) => {
2616
1881
  var _a;
2617
- return ({
2618
- category: Category.toInstance(homeCategoryGroup === null || homeCategoryGroup === void 0 ? void 0 : homeCategoryGroup.category),
2619
- products: (_a = homeCategoryGroup.products) === null || _a === void 0 ? void 0 : _a.map((product) => Product.toInstance(product)),
2620
- });
1882
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
1883
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
1884
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
1885
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
1886
+ home.data.createdAt =
1887
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
1888
+ home.data.expiresAt =
1889
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
1890
+ }
1891
+ return home;
2621
1892
  };
1893
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
1894
+ category: Category.toInstance(homeCategoryGroup.category),
1895
+ products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
1896
+ });
1897
+ this.collectionName = 'dms';
1898
+ this.model = Home;
2622
1899
  }
2623
1900
  buildModelInstance() {
2624
1901
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2633,49 +1910,14 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2633
1910
  },
2634
1911
  };
2635
1912
  }
2636
- homeToFirestore(home) {
2637
- var _a, _b, _c, _d;
2638
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
2639
- home.data.data.discoverProducts = ((_b = home.data.data.discoverProducts) === null || _b === void 0 ? void 0 : _b.map(this.homeCategoryGroupToPlain)) || [];
2640
- home.data.data.featuredProducts = ((_c = home.data.data.featuredProducts) === null || _c === void 0 ? void 0 : _c.map(this.homeCategoryGroupToPlain)) || [];
2641
- home.data.data.verticalProducts = ((_d = home.data.data.verticalProducts) === null || _d === void 0 ? void 0 : _d.map(this.homeCategoryGroupToPlain)) || [];
2642
- }
2643
- return home;
2644
- }
2645
- homeFromFirestore(home) {
2646
- var _a;
2647
- if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
2648
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
2649
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
2650
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
2651
- home.data.createdAt =
2652
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
2653
- home.data.expiresAt =
2654
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
2655
- }
2656
- return home;
2657
- }
2658
1913
  }
2659
1914
 
2660
1915
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2661
- constructor({ firestore, interceptors }) {
2662
- super({
2663
- firestore,
2664
- collectionName: 'shopMenus',
2665
- model: ShopMenu,
2666
- interceptors,
2667
- });
2668
- }
2669
- }
2670
-
2671
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2672
- constructor({ firestore, interceptors, }) {
2673
- super({
2674
- firestore,
2675
- collectionName: 'shopSettings',
2676
- model: ShopSettings,
2677
- interceptors,
2678
- });
1916
+ constructor(firestore) {
1917
+ super();
1918
+ this.firestore = firestore;
1919
+ this.collectionName = 'shopMenus';
1920
+ this.model = ShopMenu;
2679
1921
  }
2680
1922
  }
2681
1923
 
@@ -2765,7 +2007,7 @@ class AttributeOptionHelper {
2765
2007
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2766
2008
  var _a;
2767
2009
  if (fields.includes(attributeName))
2768
- return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
2010
+ return { columnName: attributeName.toString(), attributeName };
2769
2011
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2770
2012
  const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
2771
2013
  if (isNil(fieldOption))
@@ -2774,7 +2016,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2774
2016
  return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
2775
2017
  return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
2776
2018
  };
2777
- AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.columnName);
2019
+ AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
2778
2020
  AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
2779
2021
  if (fields.includes(columnName))
2780
2022
  return { columnName, attributeName: columnName };
@@ -2854,23 +2096,22 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
2854
2096
  }, {});
2855
2097
  BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2856
2098
  const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2857
- const isNestedField = !Array.isArray(options) &&
2099
+ if (!Array.isArray(options) &&
2858
2100
  isObject(options) &&
2859
2101
  isNil(options === null || options === void 0 ? void 0 : options.operator) &&
2860
2102
  isNil(options === null || options === void 0 ? void 0 : options.value) &&
2861
- isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
2862
- if (isNestedField)
2103
+ isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
2863
2104
  return Object.keys(options).reduce((variables, key) => {
2864
2105
  const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
2865
2106
  const columnName = fieldOptions.columnName;
2866
2107
  const columnFields = fieldOptions.fields;
2867
- return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || columnFields || fields) });
2108
+ return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), columnFields || []) });
2868
2109
  }, {});
2869
2110
  if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
2870
2111
  return {
2871
2112
  [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
2872
2113
  };
2873
- if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2114
+ if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2874
2115
  options = Object.values(options)[0];
2875
2116
  return Array.isArray(options)
2876
2117
  ? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
@@ -2902,14 +2143,28 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
2902
2143
  if (field === 'affected_rows')
2903
2144
  return field;
2904
2145
  const fieldName = Object.keys(field).shift();
2905
- const fieldValue = is(field[fieldName]);
2146
+ const fieldValue = field[fieldName];
2906
2147
  if (Array.isArray(fieldValue))
2907
2148
  return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
2908
2149
  if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
2909
- return;
2910
- const isNestedField = !!fieldValue.fields;
2911
- if (isNestedField)
2912
- return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
2150
+ return null;
2151
+ if (fieldValue.fields)
2152
+ return !fieldValue.filters
2153
+ ? {
2154
+ [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2155
+ }
2156
+ : {
2157
+ operation: fieldValue.columnName || fieldName,
2158
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2159
+ variables: {
2160
+ [`${fieldValue.columnName}_where`]: {
2161
+ name: 'where',
2162
+ type: fieldValue.filters.filterType,
2163
+ value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2164
+ required: true,
2165
+ },
2166
+ },
2167
+ };
2913
2168
  return fieldValue.columnName;
2914
2169
  }).filter((field) => !!field);
2915
2170
  };
@@ -2927,7 +2182,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
2927
2182
  }
2928
2183
  if (!!from)
2929
2184
  return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
2930
- return Object.assign(Object.assign({}, result), { [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName] });
2185
+ return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
2931
2186
  }, {});
2932
2187
  GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2933
2188
  var _a;
@@ -2943,8 +2198,7 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2943
2198
  !Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
2944
2199
  return Object.keys(foreignKeyColumn).reduce((object, current) => {
2945
2200
  var _a;
2946
- const { columnName: foreignColumnName } = AttributeOptionHelper.FindByAttribute(foreignKeyColumn[current], fields);
2947
- return Object.assign(Object.assign({}, object), { [foreignColumnName]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] });
2201
+ return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] }));
2948
2202
  }, Object.assign({}, result));
2949
2203
  if (update &&
2950
2204
  isObject(data[attributeName]) &&
@@ -2972,25 +2226,6 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2972
2226
  return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
2973
2227
  }, {});
2974
2228
  };
2975
- GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
2976
- const hasCustomFilters = !!fieldValue.filters;
2977
- if (hasCustomFilters)
2978
- return {
2979
- operation: fieldValue.columnName || fieldName,
2980
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2981
- variables: {
2982
- [`${fieldValue.columnName}_where`]: {
2983
- name: 'where',
2984
- type: fieldValue.filters.filterType,
2985
- value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2986
- required: true,
2987
- },
2988
- },
2989
- };
2990
- return {
2991
- [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2992
- };
2993
- };
2994
2229
 
2995
2230
  const withCreateHasuraGraphQL = (MixinBase) => {
2996
2231
  return class CreateHasuraGraphQLMixin extends MixinBase {
@@ -3002,7 +2237,6 @@ const withCreateHasuraGraphQL = (MixinBase) => {
3002
2237
  }
3003
2238
  create(data) {
3004
2239
  return __awaiter(this, void 0, void 0, function* () {
3005
- this.logger = DebugHelper.from(this, 'create');
3006
2240
  const newData = yield this.save(this.model.toInstance(data));
3007
2241
  return this.model.toInstance(newData);
3008
2242
  });
@@ -3015,11 +2249,12 @@ const withCreateHasuraGraphQL = (MixinBase) => {
3015
2249
  const columnOptions = Object.values(field).shift();
3016
2250
  return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
3017
2251
  columnOptions.foreignKeyColumn && [
3018
- ...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => { var _a; return (_a = AttributeOptionHelper.FindByAttribute(foreignKeyName, this.fields)) === null || _a === void 0 ? void 0 : _a.columnName; }),
2252
+ ...Object.values(columnOptions.foreignKeyColumn),
3019
2253
  {
3020
2254
  [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
3021
2255
  var _a;
3022
- return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || foreignKeyField;
2256
+ return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
2257
+ foreignKeyField;
3023
2258
  }),
3024
2259
  },
3025
2260
  ]);
@@ -3044,11 +2279,9 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
3044
2279
  }
3045
2280
  delete(identifiers) {
3046
2281
  return __awaiter(this, void 0, void 0, function* () {
3047
- this.logger = DebugHelper.from(this, 'delete');
3048
2282
  const instance = this.model.toInstance(identifiers);
3049
2283
  yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
3050
- const identifierBinded = identifier;
3051
- if (isNil(instance.identifier[identifierBinded]))
2284
+ if (isNil(instance[identifier]))
3052
2285
  return ids;
3053
2286
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
3054
2287
  const value = columnOption.to(identifiers[identifier], instance);
@@ -3073,16 +2306,11 @@ const withHasuraGraphQL = (MixinBase) => {
3073
2306
  this.authOptions = options.authOptions;
3074
2307
  this.model = options.model;
3075
2308
  this.fields = options.fields || this.model.identifiersFields;
3076
- this.logger = DebugHelper.from(this);
3077
2309
  }
3078
2310
  get headers() {
3079
- var _a, _b, _c, _d, _e, _f, _g;
3080
- return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil((_a = this.authOptions) === null || _a === void 0 ? void 0 : _a.authToken) ? {} : { Authorization: (_b = this.authOptions) === null || _b === void 0 ? void 0 : _b.authToken })), (isNil((_c = this.authOptions) === null || _c === void 0 ? void 0 : _c.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': (_d = this.authOptions) === null || _d === void 0 ? void 0 : _d.adminSecret })), (isNil((_e = this.authOptions) === null || _e === void 0 ? void 0 : _e.authRole)
2311
+ return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
3081
2312
  ? {}
3082
- : {
3083
- 'X-Hasura-Role': this.authOptions.authRole.role,
3084
- 'X-Hasura-User-Id': (_g = (_f = this.authOptions) === null || _f === void 0 ? void 0 : _f.authRole) === null || _g === void 0 ? void 0 : _g.userId,
3085
- }));
2313
+ : { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }));
3086
2314
  }
3087
2315
  mutation(operation, fields, variables) {
3088
2316
  return __awaiter(this, void 0, void 0, function* () {
@@ -3095,32 +2323,32 @@ const withHasuraGraphQL = (MixinBase) => {
3095
2323
  });
3096
2324
  }
3097
2325
  query(operation, fields, variables) {
3098
- var _a, _b, _c, _d;
3099
2326
  return __awaiter(this, void 0, void 0, function* () {
3100
- const builded = this.buildHasuraQueryFields({
3101
- operation,
3102
- fields: fields,
3103
- variables,
3104
- });
3105
- const interpected = (yield ((_b = (_a = this.interceptors) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? void 0 : _b.call(_a, builded))) || builded;
3106
- const resultQuery = query$1(interpected);
3107
- const result = yield this.fetch(resultQuery);
3108
- return (yield ((_d = (_c = this.interceptors) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.call(_c, result, interpected))) || result;
2327
+ const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2328
+ ? query$1(operation.map((option) => ({
2329
+ operation: option.operation,
2330
+ variables: option.variables,
2331
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2332
+ })))
2333
+ : query$1({
2334
+ operation,
2335
+ variables,
2336
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2337
+ });
2338
+ return this.fetch(resultQuery);
3109
2339
  });
3110
2340
  }
3111
2341
  fetch(params) {
3112
2342
  return __awaiter(this, void 0, void 0, function* () {
3113
- this.logger.with('params').log(params);
3114
2343
  const headers = this.headers;
3115
- const { data: result } = yield axios({
3116
- url: `${this.endpoint}`,
2344
+ const response = yield fetch(`${this.endpoint}`, {
3117
2345
  method: 'POST',
3118
- data: params,
2346
+ body: JSON.stringify(params),
3119
2347
  headers,
3120
2348
  });
2349
+ const result = yield response.json();
3121
2350
  if (!isNil(result.errors))
3122
2351
  throw new Error(JSON.stringify(result.errors));
3123
- this.logger.with('returns').log(result);
3124
2352
  return result.data;
3125
2353
  });
3126
2354
  }
@@ -3147,26 +2375,13 @@ const withHasuraGraphQL = (MixinBase) => {
3147
2375
  return value;
3148
2376
  return date;
3149
2377
  }
3150
- convertDataFromHasura(data, fields) {
3151
- const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
2378
+ convertDataFromHasura(data) {
2379
+ const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
3152
2380
  return this.model.toInstance(plain);
3153
2381
  }
3154
2382
  convertDataToHasura(instance, update = false) {
3155
2383
  return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
3156
2384
  }
3157
- buildHasuraQueryFields({ operation, fields, variables, }) {
3158
- return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
3159
- ? operation.map((option) => ({
3160
- operation: option.operation,
3161
- variables: option.variables,
3162
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
3163
- }))
3164
- : {
3165
- operation,
3166
- variables,
3167
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
3168
- };
3169
- }
3170
2385
  };
3171
2386
  };
3172
2387
 
@@ -3190,7 +2405,6 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
3190
2405
  }
3191
2406
  update(data) {
3192
2407
  return __awaiter(this, void 0, void 0, function* () {
3193
- this.logger = DebugHelper.from(this, 'update');
3194
2408
  const plainData = this.paramsToPlain(data);
3195
2409
  yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
3196
2410
  _set: {
@@ -3215,11 +2429,10 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
3215
2429
  const instance = this.model.toInstance(data);
3216
2430
  return this.model.identifiersFields.reduce((ids, identifier) => {
3217
2431
  var _a;
3218
- const identifierBinded = identifier;
3219
- if (isNil(instance.identifier[identifierBinded]))
2432
+ if (isNil(instance[identifier]))
3220
2433
  return ids;
3221
- const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
3222
- const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifierBinded], instance)) || data[columnOption.attributeName];
2434
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2435
+ const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier], instance)) || data[columnOption.attributeName];
3223
2436
  return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
3224
2437
  }, {});
3225
2438
  }
@@ -3235,12 +2448,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
3235
2448
  }
3236
2449
  get(identifiers) {
3237
2450
  return __awaiter(this, void 0, void 0, function* () {
3238
- this.logger = DebugHelper.from(this, 'get');
3239
2451
  const instance = this.model.toInstance(identifiers);
3240
2452
  const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
3241
2453
  var _a;
3242
- const identifierBinded = identifier;
3243
- if (isNil(instance[identifierBinded]))
2454
+ if (isNil(instance[identifier]))
3244
2455
  return ids;
3245
2456
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
3246
2457
  const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier], instance)) ||
@@ -3262,46 +2473,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
3262
2473
 
3263
2474
  const withFindHasuraGraphQL = (MixinBase) => {
3264
2475
  return class FindHasuraGraphQLMixin extends MixinBase {
3265
- constructor() {
3266
- super(...arguments);
3267
- this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
3268
- ...acc,
3269
- {
3270
- [AttributeOptionHelper.FindByAttribute(current, fields)
3271
- .columnName]: orderBy[current] === 'asc'
3272
- ? 'asc_nulls_last'
3273
- : 'desc_nulls_last',
3274
- },
3275
- ], []);
3276
- this.bindAggretageAttributes = (aggregates, fields) => {
3277
- var _a, _b;
3278
- return [
3279
- ...(((_a = aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal) === null || _a === void 0 ? void 0 : _a.length)
3280
- ? [
3281
- {
3282
- min: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.minimal, fields),
3283
- },
3284
- ]
3285
- : []),
3286
- ...(((_b = aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum) === null || _b === void 0 ? void 0 : _b.length)
3287
- ? [
3288
- {
3289
- max: this.bindAttributesToColumns(aggregates === null || aggregates === void 0 ? void 0 : aggregates.maximum, fields),
3290
- },
3291
- ]
3292
- : []),
3293
- ];
3294
- };
3295
- this.bindDistinctAttributes = (distinct, fields) => this.bindAttributesToColumns(distinct, fields);
3296
- this.bindAttributesToColumns = (attributes, fields) => attributes.map((attr) => { var _a; return ((_a = AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)) === null || _a === void 0 ? void 0 : _a.columnName) || attr; });
3297
- }
3298
- find(params) {
3299
- var _a, _b, _c, _d, _e, _f, _g, _h;
2476
+ find(options) {
3300
2477
  return __awaiter(this, void 0, void 0, function* () {
3301
- this.logger = DebugHelper.from(this, 'find');
3302
- const { filters, limits, orderBy, options } = params || {};
3303
- const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
3304
- const variablesFilters = isNil(filters)
2478
+ const { filters, limits, orderBy } = options || {};
2479
+ const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
3305
2480
  ? {}
3306
2481
  : {
3307
2482
  where: {
@@ -3309,26 +2484,13 @@ const withFindHasuraGraphQL = (MixinBase) => {
3309
2484
  type: `${this.tableName}_bool_exp`,
3310
2485
  required: true,
3311
2486
  },
3312
- };
3313
- const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
3314
- ? {}
3315
- : {
3316
- order_by: {
3317
- type: `${this.tableName}_order_by!`,
3318
- list: true,
3319
- value: this.bindOrderByAttributes(orderBy, this.fields),
3320
- },
3321
- })), variablesFilters);
2487
+ }));
3322
2488
  const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
3323
- const aggregateFields = [
3324
- ...(enableCount ? ['count'] : []),
3325
- ...this.bindAggretageAttributes(params.options, this.fields),
3326
- ];
3327
2489
  const result = yield this.query([
3328
2490
  {
3329
2491
  operation: this.tableName,
3330
- fields: params.fields
3331
- ? params.fields
2492
+ fields: options.fields
2493
+ ? options.fields
3332
2494
  .map((fieldName) => {
3333
2495
  var _a;
3334
2496
  return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
@@ -3337,64 +2499,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
3337
2499
  : this.fields,
3338
2500
  variables,
3339
2501
  },
3340
- ...(aggregateFields.length > 0
3341
- ? [
3342
- {
3343
- operation: `${this.tableName}_aggregate`,
3344
- fields: [
3345
- {
3346
- aggregate: aggregateFields,
3347
- },
3348
- ],
3349
- variables: variablesCount,
3350
- },
3351
- ]
3352
- : []),
3353
- ...((!((_b = params.limits) === null || _b === void 0 ? void 0 : _b.offset) &&
3354
- ((_d = (_c = params.options) === null || _c === void 0 ? void 0 : _c.distinct) === null || _d === void 0 ? void 0 : _d.map((distinct) => {
3355
- var _a, _b;
3356
- const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === distinct)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
3357
- const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || distinct;
3358
- return {
3359
- operation: {
3360
- name: `${this.tableName}`,
3361
- alias: `${this.tableName}_${distinct.toString()}_distinct`,
3362
- },
3363
- fields: [distinctOption],
3364
- variables: Object.assign(Object.assign({}, variablesFilters), { [`${this.tableName}_${fieldName}_distinct`]: {
3365
- type: `${this.tableName}_select_column!`,
3366
- list: true,
3367
- value: fieldName,
3368
- name: 'distinct_on',
3369
- } }),
3370
- };
3371
- }))) ||
3372
- []),
2502
+ {
2503
+ operation: `${this.tableName}_aggregate`,
2504
+ fields: [{ aggregate: ['count'] }],
2505
+ variables: variablesCount,
2506
+ },
3373
2507
  ]);
3374
2508
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
3375
- return Object.assign(Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_e = options === null || options === void 0 ? void 0 : options.minimal) === null || _e === void 0 ? void 0 : _e.length)
3376
- ? {
3377
- minimal: options.minimal.reduce((minimals, current) => {
3378
- var _a;
3379
- return (Object.assign(Object.assign({}, minimals), set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
3380
- }, {}),
3381
- }
3382
- : {})), (((_f = options === null || options === void 0 ? void 0 : options.maximum) === null || _f === void 0 ? void 0 : _f.length)
3383
- ? {
3384
- maximum: options.maximum.reduce((maximums, current) => {
3385
- var _a;
3386
- return (Object.assign(Object.assign({}, maximums), set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[((_a = AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)) === null || _a === void 0 ? void 0 : _a.columnName) || current])));
3387
- }, {}),
3388
- }
3389
- : {})), (!((_g = params.limits) === null || _g === void 0 ? void 0 : _g.offset) &&
3390
- ((_h = options === null || options === void 0 ? void 0 : options.distinct) === null || _h === void 0 ? void 0 : _h.length) && {
3391
- distinct: options === null || options === void 0 ? void 0 : options.distinct.reduce((distinct, current) => {
3392
- var _a, _b;
3393
- const distinctOption = (_a = this.fields.find((fieldOption) => fieldOption === current)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
3394
- const fieldName = ((_b = Object.values(distinctOption).shift()) === null || _b === void 0 ? void 0 : _b.columnName) || current;
3395
- return Object.assign(Object.assign({}, distinct), { [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]) });
3396
- }, {}),
3397
- }));
2509
+ const count = result[`${this.tableName}_aggregate`].aggregate.count;
2510
+ return { count, data };
3398
2511
  });
3399
2512
  }
3400
2513
  };
@@ -3434,154 +2547,13 @@ class VariantHasuraGraphQL extends Variant {
3434
2547
  }
3435
2548
  }
3436
2549
 
3437
- class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3438
- constructor({ endpoint, authOptions, interceptors, }) {
3439
- super({
3440
- tableName: 'category_collection_children',
3441
- model: CategoryCollectionChildren,
3442
- endpoint,
3443
- authOptions,
3444
- interceptors,
3445
- fields: [
3446
- { collectionId: { columnName: 'collection_id' } },
3447
- { categoryId: { columnName: 'category_id' } },
3448
- 'name',
3449
- 'slug',
3450
- 'reference',
3451
- { parentCollectionId: { columnName: 'parent_collection_id' } },
3452
- { parentCategoryId: { columnName: 'parent_category_id' } },
3453
- {
3454
- parent: {
3455
- columnName: 'parent',
3456
- foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
3457
- fields: [
3458
- { collectionId: { columnName: 'collection_id' } },
3459
- { categoryId: { columnName: 'category_id' } },
3460
- 'name',
3461
- 'slug',
3462
- 'reference',
3463
- { parentCollectionId: { columnName: 'parent_collection_id' } },
3464
- { parentCategoryId: { columnName: 'parent_category_id' } },
3465
- ],
3466
- },
3467
- },
3468
- ],
3469
- });
3470
- }
3471
- }
3472
-
3473
- class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3474
- constructor({ endpoint, authOptions, interceptors, }) {
3475
- super({
3476
- tableName: 'category_filter',
3477
- model: CategoryFilter,
3478
- endpoint,
3479
- authOptions,
3480
- interceptors,
3481
- fields: [
3482
- 'id',
3483
- { filterId: { columnName: 'filter_id' } },
3484
- { categoryId: { columnName: 'category_id' } },
3485
- {
3486
- filter: {
3487
- columnName: 'filter',
3488
- foreignKeyColumn: { id: 'filterId' },
3489
- fields: [
3490
- 'id',
3491
- 'description',
3492
- 'slug',
3493
- 'enabled',
3494
- { createdAt: { columnName: 'created_at' } },
3495
- { updatedAt: { columnName: 'updated_at' } },
3496
- {
3497
- options: {
3498
- columnName: 'options',
3499
- foreignKeyColumn: { filterId: 'id' },
3500
- fields: [
3501
- 'id',
3502
- { filterId: { columnName: 'filter_id' } },
3503
- 'description',
3504
- { createdAt: { columnName: 'created_at' } },
3505
- { updatedAt: { columnName: 'updated_at' } },
3506
- ],
3507
- },
3508
- },
3509
- ],
3510
- },
3511
- },
3512
- {
3513
- category: {
3514
- columnName: 'category',
3515
- foreignKeyColumn: { id: 'categoryId' },
3516
- fields: [
3517
- 'id',
3518
- 'description',
3519
- {
3520
- products: {
3521
- columnName: 'products',
3522
- fields: ['product_id'],
3523
- from: (value) => value.map((product) => product.product_id.toString()),
3524
- to: (productIds) => productIds.map((productId) => ({
3525
- product_id: +productId,
3526
- })),
3527
- },
3528
- },
3529
- {
3530
- childrenProducts: {
3531
- columnName: 'children_products',
3532
- foreignKeyColumn: { category_id: 'id' },
3533
- fields: [
3534
- 'id',
3535
- 'name',
3536
- 'slug',
3537
- {
3538
- categories: {
3539
- columnName: 'categories',
3540
- fields: ['category_id'],
3541
- bindPersistData: (value) => ({
3542
- categories: { data: value.map((category) => ({ category_id: +category })) },
3543
- }),
3544
- to: (categories) => categories.map((categoryId) => +categoryId),
3545
- from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || [],
3546
- },
3547
- },
3548
- ],
3549
- },
3550
- },
3551
- ],
3552
- },
3553
- },
3554
- ],
3555
- });
3556
- }
3557
- deleteByCategory(categoryId) {
3558
- return this.mutation('delete_category_filter', ['affected_rows'], {
3559
- where: {
3560
- type: 'category_filter_bool_exp',
3561
- required: true,
3562
- value: { category_id: { _eq: categoryId } },
3563
- },
3564
- });
3565
- }
3566
- deleteByCategoryAndFilter(categoryId, filterId) {
3567
- return this.mutation('delete_category_filter', ['affected_rows'], {
3568
- where: {
3569
- type: 'category_filter_bool_exp',
3570
- required: true,
3571
- value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
3572
- },
3573
- });
3574
- }
3575
- }
3576
-
3577
2550
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3578
- constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
2551
+ constructor(endpoint, authOptions, productRepository) {
3579
2552
  super({
3580
2553
  tableName: 'category',
3581
2554
  model: Category,
3582
2555
  endpoint,
3583
2556
  authOptions,
3584
- interceptors,
3585
2557
  fields: [
3586
2558
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
3587
2559
  { firestoreId: { columnName: 'firestore_id' } },
@@ -3590,7 +2562,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3590
2562
  'image',
3591
2563
  'published',
3592
2564
  'shop',
3593
- { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
3594
2565
  'slug',
3595
2566
  { brandCategory: { columnName: 'brand_category' } },
3596
2567
  { brandCategoryBanner: { columnName: 'brand_banner' } },
@@ -3616,17 +2587,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3616
2587
  },
3617
2588
  },
3618
2589
  },
3619
- {
3620
- filters: {
3621
- columnName: 'filters',
3622
- foreignKeyColumn: { filter_id: 'id' },
3623
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
3624
- bindPersistData: (value) => ({
3625
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
3626
- }),
3627
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
3628
- },
3629
- },
2590
+ 'filters',
3630
2591
  { createdAt: { columnName: 'created_at' } },
3631
2592
  { updatedAt: { columnName: 'updated_at' } },
3632
2593
  {
@@ -3648,21 +2609,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3648
2609
  }),
3649
2610
  },
3650
2611
  },
3651
- { isCollection: { columnName: 'is_collection' } },
3652
- { isWishlist: { columnName: 'is_wishlist' } },
3653
- 'reference',
3654
- { parentId: { columnName: 'parent_id' } },
3655
- {
3656
- parent: {
3657
- columnName: 'parent',
3658
- foreignKeyColumn: { id: 'parentId' },
3659
- fields: ['id', 'name', 'reference', 'slug'],
3660
- },
3661
- },
3662
2612
  ],
3663
2613
  });
3664
2614
  this.productRepository = productRepository;
3665
- this.categoryFilterRepository = categoryFilterRepository;
3666
2615
  }
3667
2616
  create(params) {
3668
2617
  const _super = Object.create(null, {
@@ -3670,7 +2619,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3670
2619
  });
3671
2620
  return __awaiter(this, void 0, void 0, function* () {
3672
2621
  const { metadata } = params, data = __rest(params, ["metadata"]);
3673
- return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
2622
+ return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
3674
2623
  });
3675
2624
  }
3676
2625
  get(identifiers) {
@@ -3680,7 +2629,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3680
2629
  var _a;
3681
2630
  return __awaiter(this, void 0, void 0, function* () {
3682
2631
  return Number.isNaN(+identifiers.id)
3683
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2632
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
3684
2633
  : _super.get.call(this, identifiers);
3685
2634
  });
3686
2635
  }
@@ -3689,13 +2638,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3689
2638
  update: { get: () => super.update }
3690
2639
  });
3691
2640
  return __awaiter(this, void 0, void 0, function* () {
3692
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
2641
+ const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
3693
2642
  const plainData = this.paramsToPlain({ id: checkId });
3694
2643
  const id = yield this.getId(plainData.id);
3695
- const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: false }));
2644
+ const category = yield _super.update.call(this, Object.assign({ id }, data));
3696
2645
  category.products = products && (yield this.updateProducts(+id, { products }));
3697
2646
  category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
3698
- category.filters = filters && (yield this.updateFilters(+id, { filters }));
3699
2647
  return category;
3700
2648
  });
3701
2649
  }
@@ -3703,42 +2651,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3703
2651
  return __awaiter(this, void 0, void 0, function* () {
3704
2652
  if (!slug)
3705
2653
  return null;
3706
- const { data } = yield this.find({
3707
- filters: {
3708
- slug,
3709
- shops: { operator: Where.IN, value: [shop] },
3710
- published: { operator: Where.EQUALS, value: true },
3711
- isWishlist: { operator: Where.EQUALS, value: false },
3712
- },
3713
- options: {
3714
- enableCount: false,
3715
- },
3716
- });
3717
- if (!data.length)
3718
- throw new NotFoundError(`Category with slug ${slug} not found`);
3719
- if (data.length > 1)
2654
+ const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
2655
+ if (count > 1)
3720
2656
  throw new DuplicatedResultsError('Query returned duplicated values');
2657
+ if (!count)
2658
+ throw new NotFoundError(`Category with slug ${slug} not found`);
3721
2659
  return data.shift();
3722
2660
  });
3723
2661
  }
3724
- getCategoryByShop(shop) {
3725
- return __awaiter(this, void 0, void 0, function* () {
3726
- if (!shop)
3727
- return;
3728
- const { data } = yield this.find({
3729
- filters: {
3730
- shops: { operator: Where.IN, value: [shop] },
3731
- published: { operator: Where.EQUALS, value: true },
3732
- isWishlist: { operator: Where.EQUALS, value: false },
3733
- },
3734
- options: {
3735
- enableCount: false,
3736
- },
3737
- });
3738
- return data;
3739
- });
3740
- }
3741
- getCategoriesForHome(categoryIds, limit = 4, gender) {
2662
+ getCategoriesForHome(categoryIds, limit = 4) {
3742
2663
  return __awaiter(this, void 0, void 0, function* () {
3743
2664
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
3744
2665
  return [];
@@ -3758,7 +2679,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3758
2679
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
3759
2680
  return ({
3760
2681
  category,
3761
- products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
2682
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
3762
2683
  });
3763
2684
  })));
3764
2685
  return homeSections;
@@ -3770,7 +2691,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3770
2691
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
3771
2692
  return [];
3772
2693
  const products = [];
3773
- const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
2694
+ const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
3774
2695
  'id',
3775
2696
  'name',
3776
2697
  'slug',
@@ -3794,9 +2715,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3794
2715
  'tags',
3795
2716
  'type',
3796
2717
  'shoppingCount',
3797
- 'gender',
3798
- 'createdAt',
3799
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
2718
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
3800
2719
  products.push(...productsData);
3801
2720
  return products;
3802
2721
  });
@@ -3806,7 +2725,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3806
2725
  return __awaiter(this, void 0, void 0, function* () {
3807
2726
  if (!Number.isNaN(+id))
3808
2727
  return id;
3809
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
2728
+ const { data } = yield this.find({ filters: { firestoreId: id } });
3810
2729
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3811
2730
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3812
2731
  throw new NotFoundError(`Category with id ${id} not found`);
@@ -3864,220 +2783,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3864
2783
  return plainData.metadata;
3865
2784
  });
3866
2785
  }
3867
- updateFilters(categoryId, { filters }) {
3868
- return __awaiter(this, void 0, void 0, function* () {
3869
- if ('action' in filters && filters.action === 'remove' && filters.value.length) {
3870
- for (let i = 0; i < filters.value.length; i++) {
3871
- yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
3872
- }
3873
- return [];
3874
- }
3875
- if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3876
- let filtersList = [];
3877
- const currentFilters = yield this.categoryFilterRepository
3878
- .find({
3879
- filters: {
3880
- categoryId,
3881
- },
3882
- })
3883
- .then((res) => res.data);
3884
- const currentFiltersId = currentFilters.map((f) => f.id);
3885
- const filtersUpdatedId = filters.value.map((f) => f.id);
3886
- const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
3887
- const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
3888
- for (const filter of filterToBeDeleted) {
3889
- const index = currentFilters.findIndex((f) => f.id == filter);
3890
- if (index != -1) {
3891
- currentFilters.splice(index, 1);
3892
- }
3893
- yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
3894
- }
3895
- for (const filter of filterToBeInserted) {
3896
- const newCategoryFilter = yield this.categoryFilterRepository.create({
3897
- filterId: filter,
3898
- categoryId,
3899
- });
3900
- filtersList.push(filter);
3901
- }
3902
- return filters.value;
3903
- }
3904
- if (Array.isArray(filters) && filters.length) {
3905
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
3906
- let filtersList = [];
3907
- for (let i = 0; i < filters.length; i++) {
3908
- const newCategoryFilter = yield this.categoryFilterRepository.create({
3909
- filterId: filters[i].id,
3910
- categoryId,
3911
- });
3912
- filtersList.push(newCategoryFilter);
3913
- }
3914
- return filters;
3915
- }
3916
- });
3917
- }
3918
- getChildren(parentId) {
3919
- return __awaiter(this, void 0, void 0, function* () {
3920
- const { category_tree } = yield this.query('category_tree', ['id', 'name', 'parent_id'], {
3921
- args: {
3922
- type: 'category_tree_args',
3923
- value: { parentid: parentId },
3924
- required: true,
3925
- },
3926
- });
3927
- return category_tree.map((category) => Category.toInstance(category));
3928
- });
3929
- }
3930
- isChild(id, parentId) {
3931
- return __awaiter(this, void 0, void 0, function* () {
3932
- const categoryTree = yield this.getChildren(parentId);
3933
- return categoryTree.some((c) => c.id == id.toString());
3934
- });
3935
- }
3936
- }
3937
-
3938
- class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3939
- constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
3940
- super({
3941
- tableName: 'filter',
3942
- model: Filter,
3943
- endpoint,
3944
- authOptions,
3945
- interceptors,
3946
- fields: [
3947
- 'id',
3948
- 'description',
3949
- 'slug',
3950
- 'enabled',
3951
- { createdAt: { columnName: 'created_at' } },
3952
- { updatedAt: { columnName: 'updated_at' } },
3953
- {
3954
- options: {
3955
- columnName: 'options',
3956
- foreignKeyColumn: { filterId: 'id' },
3957
- fields: [
3958
- 'id',
3959
- { filterId: { columnName: 'filter_id' } },
3960
- 'description',
3961
- { createdAt: { columnName: 'created_at' } },
3962
- { updatedAt: { columnName: 'updated_at' } },
3963
- ],
3964
- },
3965
- },
3966
- ],
3967
- });
3968
- this.filterOptionRepository = filterOptionRepository;
3969
- this.categoryFilterRepository = categoryFilterRepository;
3970
- }
3971
- update(params) {
3972
- const _super = Object.create(null, {
3973
- update: { get: () => super.update }
3974
- });
3975
- return __awaiter(this, void 0, void 0, function* () {
3976
- const { options } = params, data = __rest(params, ["options"]);
3977
- const filter = yield _super.update.call(this, data);
3978
- filter.options = yield this.updateOptions(+data.id, { options });
3979
- return filter;
3980
- });
3981
- }
3982
- updateOptions(filterId, { options }) {
3983
- return __awaiter(this, void 0, void 0, function* () {
3984
- if (!options)
3985
- return [];
3986
- if ('action' in options && options.action === 'remove' && options.value.length) {
3987
- for (let i = 0; i < options.value.length; i++) {
3988
- yield this.filterOptionRepository.delete({ id: options.value[i].id });
3989
- }
3990
- return [];
3991
- }
3992
- if ('action' in options && options.action === 'merge' && options.value.length) {
3993
- let filterOptions = [];
3994
- for (let i = 0; i < options.value.length; i++) {
3995
- try {
3996
- const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
3997
- if (hasFilter)
3998
- filterOptions.push(hasFilter);
3999
- }
4000
- catch (error) {
4001
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
4002
- filterOptions.push(newOption);
4003
- }
4004
- }
4005
- return filterOptions;
4006
- }
4007
- if (Array.isArray(options) && options.length) {
4008
- let filterOptions = [];
4009
- for (let i = 0; i < options.length; i++) {
4010
- try {
4011
- const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
4012
- if (hasFilter)
4013
- filterOptions.push(hasFilter);
4014
- }
4015
- catch (error) {
4016
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
4017
- filterOptions.push(newOption);
4018
- }
4019
- }
4020
- }
4021
- return [];
4022
- });
4023
- }
4024
- delete(params) {
4025
- const _super = Object.create(null, {
4026
- delete: { get: () => super.delete }
4027
- });
4028
- return __awaiter(this, void 0, void 0, function* () {
4029
- const { data: categoryFilters } = yield this.categoryFilterRepository.find({
4030
- filters: {
4031
- filterId: params.id,
4032
- },
4033
- });
4034
- if (categoryFilters.length)
4035
- throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
4036
- yield this.deleteOptions(+params.id);
4037
- yield _super.delete.call(this, { id: +params.id });
4038
- return;
4039
- });
4040
- }
4041
- deleteOptions(filterId) {
4042
- return __awaiter(this, void 0, void 0, function* () {
4043
- yield this.mutation('delete_filter_option', ['affected_rows'], {
4044
- where: {
4045
- type: 'filter_option_bool_exp',
4046
- required: true,
4047
- value: { filter_id: { _eq: filterId } },
4048
- },
4049
- });
4050
- });
4051
- }
4052
- }
4053
-
4054
- class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4055
- constructor({ endpoint, authOptions, interceptors, }) {
4056
- super({
4057
- tableName: 'filter_option',
4058
- model: FilterOption,
4059
- endpoint,
4060
- authOptions,
4061
- interceptors,
4062
- fields: [
4063
- 'id',
4064
- 'description',
4065
- { filterId: { columnName: 'filter_id' } },
4066
- { createdAt: { columnName: 'created_at' } },
4067
- { updatedAt: { columnName: 'updated_at' } },
4068
- ],
4069
- });
4070
- }
4071
2786
  }
4072
2787
 
4073
2788
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4074
- constructor({ endpoint, authOptions, interceptors, }) {
2789
+ constructor(endpoint, authOptions) {
4075
2790
  super({
4076
2791
  tableName: 'product',
4077
2792
  model: ProductHasuraGraphQL,
4078
2793
  endpoint,
4079
2794
  authOptions,
4080
- interceptors,
4081
2795
  fields: [],
4082
2796
  });
4083
2797
  this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id']))), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
@@ -4100,29 +2814,26 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4100
2814
  whoMustUse: data.who_must_use,
4101
2815
  howToUse: data.how_to_use,
4102
2816
  brand: data.brand_description,
4103
- ingredients: data.ingredients,
4104
2817
  }),
4105
- bindFindFilter: (filters) => {
4106
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
2818
+ bindFindFilter: (sentence) => {
2819
+ const filters = Object.values(sentence).shift();
2820
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((filters === null || filters === void 0 ? void 0 : filters.description) && { description: filters.description })), (filters.differentials && { differentials: filters.differentials })), (filters.whoMustUse && {
4107
2821
  who_must_use: filters.whoMustUse,
4108
2822
  })), (filters.howToUse && {
4109
2823
  how_to_use: filters.howToUse,
4110
2824
  })), (filters.brand && {
4111
2825
  brand_description: filters.brand,
4112
- })), (filters.ingredients && {
4113
- ingredients: filters.ingredients,
4114
2826
  }));
4115
2827
  },
4116
- bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
2828
+ bindPersistData: (descriptionData) => (Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((descriptionData === null || descriptionData === void 0 ? void 0 : descriptionData.description) && { description: descriptionData.description })), (descriptionData.differentials && { differentials: descriptionData.differentials })), (descriptionData.whoMustUse && {
4117
2829
  who_must_use: descriptionData.whoMustUse,
4118
- })), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand })), (descriptionData.ingredients && { ingredients: descriptionData.ingredients }))),
2830
+ })), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))),
4119
2831
  },
4120
2832
  },
4121
2833
  { differentials: { columnName: 'differentials' } },
4122
2834
  { whoMustUse: { columnName: 'who_must_use' } },
4123
2835
  { howToUse: { columnName: 'how_to_use' } },
4124
2836
  { brandDescription: { columnName: 'brand_description' } },
4125
- { ingredients: { columnName: 'ingredients' } },
4126
2837
  { hasVariants: { columnName: 'has_variants' } },
4127
2838
  {
4128
2839
  images: {
@@ -4146,7 +2857,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4146
2857
  subscriberDiscountPercentage: data.subscriber_discount_percentage,
4147
2858
  subscriberPrice: data.subscriber_price,
4148
2859
  }),
4149
- bindFindFilter: (filters) => {
2860
+ bindFindFilter: (sentence) => {
2861
+ const filters = Object.values(sentence).shift();
4150
2862
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
4151
2863
  subscriber_discount_percentage: filters.subscriberDiscountPercentage,
4152
2864
  })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
@@ -4170,29 +2882,27 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4170
2882
  to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
4171
2883
  },
4172
2884
  },
4173
- { hasStock: { columnName: 'has_stock' } },
4174
2885
  'slug',
4175
2886
  'type',
4176
2887
  'video',
4177
2888
  'weight',
4178
2889
  'gender',
4179
- { intGender: { columnName: 'int_gender' } },
4180
2890
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
4181
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
4182
2891
  { isKit: { columnName: 'is_kit' } },
4183
2892
  { createdAt: { columnName: 'created_at' } },
4184
2893
  { updatedAt: { columnName: 'updated_at' } },
4185
- { rate: { columnName: 'rating' } },
4186
- { reviewsTotal: { columnName: 'reviews_total' } },
4187
- { shoppingCount: { columnName: 'shopping_count' } },
4188
- { categoryId: { columnName: 'category_id' } },
4189
2894
  {
4190
- category: {
4191
- columnName: 'category',
4192
- foreignKeyColumn: { id: 'categoryId' },
4193
- fields: ['id', 'name', 'reference', 'slug'],
2895
+ rate: {
2896
+ columnName: 'reviews_aggregate',
2897
+ filters: {
2898
+ filters: { status: true },
2899
+ filterType: 'product_review_bool_exp',
2900
+ },
2901
+ fields: [{ aggregate: [{ avg: ['rate'] }] }],
2902
+ from: (value) => value.aggregate.avg.rate,
4194
2903
  },
4195
2904
  },
2905
+ { shoppingCount: { columnName: 'shopping_count' } },
4196
2906
  ];
4197
2907
  this.fields = [
4198
2908
  ...commonFields,
@@ -4279,7 +2989,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4279
2989
  var _a;
4280
2990
  return __awaiter(this, void 0, void 0, function* () {
4281
2991
  const product = Number.isNaN(+identifiers.id)
4282
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2992
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
4283
2993
  : yield _super.get.call(this, identifiers);
4284
2994
  if (product.productId)
4285
2995
  throw new NotFoundError('Product not found, it is a variant');
@@ -4291,29 +3001,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4291
3001
  const _super = Object.create(null, {
4292
3002
  find: { get: () => super.find }
4293
3003
  });
4294
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4295
3004
  return __awaiter(this, void 0, void 0, function* () {
4296
- const _o = params || {}, { filters, fields } = _o, options = __rest(_o, ["filters", "fields"]);
3005
+ const _a = params || {}, { filters, fields } = _a, options = __rest(_a, ["filters", "fields"]);
4297
3006
  const bindFields = fields ||
4298
3007
  this.fields
4299
3008
  .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
4300
3009
  .filter((field) => field !== 'reviews');
4301
- if ((_b = (_a = options.options) === null || _a === void 0 ? void 0 : _a.minimal) === null || _b === void 0 ? void 0 : _b.includes('price'))
4302
- (_c = options.options) === null || _c === void 0 ? void 0 : _c.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4303
- if ((_e = (_d = options.options) === null || _d === void 0 ? void 0 : _d.maximum) === null || _e === void 0 ? void 0 : _e.includes('price'))
4304
- (_f = options.options) === null || _f === void 0 ? void 0 : _f.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4305
- (_h = (_g = options.options) === null || _g === void 0 ? void 0 : _g.minimal) === null || _h === void 0 ? void 0 : _h.splice((_j = options.options) === null || _j === void 0 ? void 0 : _j.minimal.indexOf('price'), 1);
4306
- (_l = (_k = options.options) === null || _k === void 0 ? void 0 : _k.maximum) === null || _l === void 0 ? void 0 : _l.splice((_m = options.options) === null || _m === void 0 ? void 0 : _m.maximum.indexOf('price'), 1);
4307
- return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: [
4308
- ...bindFields,
4309
- ...(bindFields.includes('price')
4310
- ? [
4311
- 'subscriberPrice',
4312
- 'subscriberDiscountPercentage',
4313
- 'fullPrice',
4314
- ]
4315
- : []),
4316
- ] }));
3010
+ return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: bindFields }));
4317
3011
  });
4318
3012
  }
4319
3013
  getBySlug(slug) {
@@ -4323,13 +3017,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4323
3017
  filters: {
4324
3018
  slug,
4325
3019
  },
4326
- fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
4327
- options: {
4328
- enableCount: false,
4329
- },
4330
3020
  });
4331
3021
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
4332
- RoundProductPricesHelper.roundProductPrices(product);
3022
+ product.reviews = yield this.findReviewsByProduct(+product.id);
4333
3023
  return product;
4334
3024
  });
4335
3025
  }
@@ -4369,11 +3059,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4369
3059
  ], []);
4370
3060
  });
4371
3061
  }
4372
- findCatalog(params, mainGender) {
4373
- return __awaiter(this, void 0, void 0, function* () {
4374
- return this.find(Object.assign(Object.assign({}, params), { filters: Object.assign(Object.assign({}, params.filters), { published: true }), orderBy: Object.assign(Object.assign({ hasStock: 'desc' }, (!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' })), omit(params.orderBy, ['hasStock', 'intGender'])) }));
4375
- });
4376
- }
4377
3062
  updateCategories(productId, { categories }) {
4378
3063
  return __awaiter(this, void 0, void 0, function* () {
4379
3064
  if ('action' in categories && categories.action === 'remove') {
@@ -4497,7 +3182,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4497
3182
  return __awaiter(this, void 0, void 0, function* () {
4498
3183
  if (!Number.isNaN(+id))
4499
3184
  return id;
4500
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3185
+ const { data } = yield this.find({ filters: { firestoreId: id } });
4501
3186
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
4502
3187
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
4503
3188
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -4553,31 +3238,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4553
3238
  return data && data[0] && this.bindReviewToModel(data[0]);
4554
3239
  });
4555
3240
  }
4556
- cleanShoppingCountFromIds(ids) {
4557
- return __awaiter(this, void 0, void 0, function* () {
4558
- return yield this.mutation('update_product', ['affected_rows'], {
4559
- where: {
4560
- value: { id: { _nin: ids } },
4561
- type: 'product_bool_exp',
4562
- required: true,
4563
- },
4564
- _set: {
4565
- value: { shopping_count: 0 },
4566
- type: 'product_set_input',
4567
- },
4568
- });
4569
- });
4570
- }
4571
3241
  }
4572
3242
 
4573
3243
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4574
- constructor({ endpoint, authOptions, interceptors, }) {
3244
+ constructor(endpoint, authOptions) {
4575
3245
  super({
4576
3246
  tableName: 'product',
4577
3247
  model: VariantHasuraGraphQL,
4578
3248
  endpoint,
4579
3249
  authOptions,
4580
- interceptors,
4581
3250
  fields: [
4582
3251
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4583
3252
  { firestoreId: { columnName: 'firestore_id' } },
@@ -4607,9 +3276,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4607
3276
  subscriber_price: filters.subscriberPrice,
4608
3277
  }));
4609
3278
  },
4610
- bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (((priceData === null || priceData === void 0 ? void 0 : priceData.price) || 0) >= 0 && { price: priceData.price })), (((priceData === null || priceData === void 0 ? void 0 : priceData.fullPrice) || 0) >= 0 && { full_price: priceData.fullPrice })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberDiscountPercentage) || 0) >= 0 && {
3279
+ bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
4611
3280
  subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4612
- })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberPrice) || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }))),
3281
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
4613
3282
  },
4614
3283
  },
4615
3284
  { fullPrice: { columnName: 'full_price' } },
@@ -4623,7 +3292,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4623
3292
  to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
4624
3293
  },
4625
3294
  },
4626
- { hasStock: { columnName: 'has_stock' } },
4627
3295
  'weight',
4628
3296
  { name: { to: () => '', from: () => undefined } },
4629
3297
  { hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
@@ -4679,7 +3347,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4679
3347
  return __awaiter(this, void 0, void 0, function* () {
4680
3348
  if (!Number.isNaN(+id))
4681
3349
  return id;
4682
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3350
+ const { data } = yield this.find({ filters: { firestoreId: id } });
4683
3351
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
4684
3352
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
4685
3353
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -4687,256 +3355,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4687
3355
  }
4688
3356
  }
4689
3357
 
4690
- class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4691
- constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
4692
- super({
4693
- tableName: 'category',
4694
- model: Wishlist,
4695
- endpoint,
4696
- authOptions,
4697
- interceptors,
4698
- fields: [
4699
- { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4700
- { firestoreId: { columnName: 'firestore_id' } },
4701
- 'name',
4702
- 'description',
4703
- 'image',
4704
- 'published',
4705
- 'shop',
4706
- { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
4707
- 'slug',
4708
- { brandCategory: { columnName: 'brand_category' } },
4709
- { brandCategoryBanner: { columnName: 'brand_banner' } },
4710
- { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
4711
- { brandLogo: { columnName: 'brand_logo' } },
4712
- { brandCondition: { columnName: 'brand_condition' } },
4713
- {
4714
- conditions: {
4715
- columnName: 'tag_condition',
4716
- type: HasuraGraphQLColumnType.Jsonb,
4717
- from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
4718
- bindPersistData: (value) => {
4719
- return {
4720
- brand_condition: value.brand,
4721
- tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
4722
- };
4723
- },
4724
- bindFindFilter: (sentence) => {
4725
- return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
4726
- },
4727
- },
4728
- },
4729
- {
4730
- filters: {
4731
- columnName: 'filters',
4732
- foreignKeyColumn: { filter_id: 'id' },
4733
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4734
- bindPersistData: (value) => ({
4735
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4736
- }),
4737
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4738
- },
4739
- },
4740
- { createdAt: { columnName: 'created_at' } },
4741
- { updatedAt: { columnName: 'updated_at' } },
4742
- {
4743
- products: {
4744
- columnName: 'products',
4745
- fields: ['product_id'],
4746
- from: (value) => value.map((product) => product.product_id.toString()),
4747
- to: (productIds) => productIds.map((productId) => ({
4748
- product_id: +productId,
4749
- })),
4750
- },
4751
- },
4752
- {
4753
- metadata: {
4754
- columnName: 'metadata',
4755
- fields: ['title', 'description'],
4756
- bindPersistData: (value) => ({
4757
- metadata: { data: value },
4758
- }),
4759
- },
4760
- },
4761
- { isCollection: { columnName: 'is_collection' } },
4762
- { isWishlist: { columnName: 'is_wishlist' } },
4763
- 'reference',
4764
- { parentId: { columnName: 'parent_id' } },
4765
- {
4766
- parent: {
4767
- columnName: 'parent',
4768
- foreignKeyColumn: { id: 'parentId' },
4769
- fields: ['id', 'name', 'reference', 'slug'],
4770
- },
4771
- },
4772
- { personId: { columnName: 'person_id' } },
4773
- ],
4774
- });
4775
- this.categoryFilterRepository = categoryFilterRepository;
4776
- }
4777
- create(params) {
4778
- const _super = Object.create(null, {
4779
- create: { get: () => super.create }
4780
- });
4781
- return __awaiter(this, void 0, void 0, function* () {
4782
- const { metadata } = params, data = __rest(params, ["metadata"]);
4783
- return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
4784
- });
4785
- }
4786
- get(identifiers) {
4787
- const _super = Object.create(null, {
4788
- get: { get: () => super.get }
4789
- });
4790
- return __awaiter(this, void 0, void 0, function* () {
4791
- const data = yield _super.get.call(this, identifiers);
4792
- if (!data.isWishlist)
4793
- throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
4794
- return data;
4795
- });
4796
- }
4797
- update(params) {
4798
- const _super = Object.create(null, {
4799
- update: { get: () => super.update }
4800
- });
4801
- return __awaiter(this, void 0, void 0, function* () {
4802
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
4803
- const plainData = this.paramsToPlain({ id: checkId });
4804
- const id = plainData.id;
4805
- const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
4806
- category.products = products && (yield this.updateProducts(+id, { products }));
4807
- category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
4808
- return category;
4809
- });
4810
- }
4811
- getWishlistBySlug(slug) {
4812
- return __awaiter(this, void 0, void 0, function* () {
4813
- if (!slug)
4814
- return;
4815
- const { data } = yield this.find({
4816
- filters: {
4817
- slug,
4818
- isWishlist: { operator: Where.EQUALS, value: true },
4819
- },
4820
- options: {
4821
- enableCount: false,
4822
- },
4823
- });
4824
- if (!data.length)
4825
- throw new NotFoundError(`Wishlist with slug ${slug} not found`);
4826
- if (data.length > 1)
4827
- throw new DuplicatedResultsError('Query returned duplicated values');
4828
- return data.shift();
4829
- });
4830
- }
4831
- getWishlistByPerson(personId) {
4832
- return __awaiter(this, void 0, void 0, function* () {
4833
- if (!personId)
4834
- return;
4835
- const { data } = yield this.find({
4836
- filters: {
4837
- personId: { operator: Where.EQUALS, value: personId },
4838
- isWishlist: { operator: Where.EQUALS, value: true },
4839
- },
4840
- options: {
4841
- enableCount: false,
4842
- },
4843
- });
4844
- if (!data.length)
4845
- throw new NotFoundError(`Wishlists from person ${personId} not found`);
4846
- return data;
4847
- });
4848
- }
4849
- updateProducts(categoryId, { products }) {
4850
- return __awaiter(this, void 0, void 0, function* () {
4851
- if ('action' in products && products.action === 'remove') {
4852
- yield this.mutation('delete_category_product', ['affected_rows'], {
4853
- where: {
4854
- type: 'category_product_bool_exp',
4855
- required: true,
4856
- value: { category_id: { _eq: categoryId } },
4857
- },
4858
- });
4859
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
4860
- return [];
4861
- }
4862
- const plainData = this.paramsToPlain({ products });
4863
- if (!plainData.products || plainData.products.length <= 0)
4864
- return [];
4865
- yield this.mutation('delete_category_product', ['affected_rows'], {
4866
- where: {
4867
- type: 'category_product_bool_exp',
4868
- required: true,
4869
- value: { category_id: { _eq: categoryId } },
4870
- },
4871
- });
4872
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
4873
- yield this.mutation('insert_category_product', ['affected_rows'], {
4874
- objects: {
4875
- type: '[category_product_insert_input!]',
4876
- required: true,
4877
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4878
- },
4879
- });
4880
- return plainData.products;
4881
- });
4882
- }
4883
- updateMetadata(categoryId, { metadata }) {
4884
- return __awaiter(this, void 0, void 0, function* () {
4885
- const plainData = this.paramsToPlain({ metadata });
4886
- if (!plainData.metadata)
4887
- return;
4888
- yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
4889
- pk_columns: {
4890
- value: { category_id: categoryId },
4891
- type: 'category_metadata_pk_columns_input',
4892
- required: true,
4893
- },
4894
- _set: {
4895
- value: omit(metadata, ['category_id']),
4896
- type: 'category_metadata_set_input',
4897
- required: true,
4898
- },
4899
- });
4900
- return plainData.metadata;
4901
- });
4902
- }
4903
- getCategoryBySlug(slug, _shop) {
4904
- return this.getWishlistBySlug(slug);
4905
- }
4906
- getCategoryByShop(shop) {
4907
- return __awaiter(this, void 0, void 0, function* () {
4908
- if (!shop)
4909
- return;
4910
- const { data } = yield this.find({
4911
- filters: {
4912
- shops: { operator: Where.IN, value: [shop] },
4913
- published: { operator: Where.EQUALS, value: true },
4914
- isWishlist: { operator: Where.EQUALS, value: true },
4915
- },
4916
- options: {
4917
- enableCount: false,
4918
- },
4919
- });
4920
- return data;
4921
- });
4922
- }
4923
- getCategoriesForHome(categoryIds, limit, gender) {
4924
- return;
4925
- }
4926
- mountCategory(category, options) {
4927
- return;
4928
- }
4929
- getChildren(parentId) {
4930
- return;
4931
- }
4932
- isChild(id, parentId) {
4933
- return;
4934
- }
4935
- }
4936
-
4937
3358
  /**
4938
3359
  * Generated bundle index. Do not edit.
4939
3360
  */
4940
3361
 
4941
- 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, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, 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, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3362
+ 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 };
4942
3363
  //# sourceMappingURL=infrab4a-connect.mjs.map