@infrab4a/connect 4.0.0-beta.49 → 4.0.0-beta.5

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 -6
  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 -8
  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 +15 -84
  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 -1969
  143. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  144. package/fesm2020/infrab4a-connect.mjs +422 -1926
  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 -8
  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 -23
  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 -14
  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 +5 -7
  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,19 @@ 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 * as lodash from 'lodash';
7
+ import { get as get$1, isString as isString$1 } from 'lodash';
10
8
  import { CustomError } from 'ts-custom-error';
11
9
  import axios from 'axios';
12
10
  import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
13
11
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
14
12
  import { mutation, query as query$1 } from 'gql-query-builder';
13
+ import fetch from 'node-fetch';
15
14
 
16
15
  class BaseModel {
17
16
  get identifier() {
18
17
  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] })), {});
18
+ return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
21
19
  }
22
20
  get identifiersFields() {
23
21
  return this.constructor.identifiersFields;
@@ -463,437 +461,11 @@ __decorate([
463
461
  __metadata("design:type", Payment)
464
462
  ], SubscriptionPayment.prototype, "payment", void 0);
465
463
 
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(' ');
464
+ class Address extends BaseModel {
465
+ static get identifiersFields() {
466
+ return ['id'];
806
467
  }
807
468
  }
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
469
 
898
470
  const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
899
471
 
@@ -901,7 +473,7 @@ function is(value) {
901
473
  return value;
902
474
  }
903
475
 
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);
476
+ const isUUID = (value) => isString$1(value) && /[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}/.test(value);
905
477
 
906
478
  class Base {
907
479
  constructor(...args) {
@@ -910,7 +482,7 @@ class Base {
910
482
  }
911
483
 
912
484
  const parseDateTime = (value) => {
913
- if (!isString(value))
485
+ if (!isString$1(value))
914
486
  return value;
915
487
  if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
916
488
  !/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T\d{2}:\d{2}:\d{2}/.test(value))
@@ -921,6 +493,8 @@ const parseDateTime = (value) => {
921
493
  return date;
922
494
  };
923
495
 
496
+ const { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
497
+
924
498
  var CheckoutTypes;
925
499
  (function (CheckoutTypes) {
926
500
  CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
@@ -965,28 +539,26 @@ class Coupon extends BaseModel {
965
539
  static createCoupon(userId) {
966
540
  return this.toInstance({
967
541
  nickname: `${Date.now()}`,
542
+ type: CouponTypes.ABSOLUTE,
968
543
  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
- },
544
+ discount: 30,
983
545
  user: userId,
546
+ useLimit: 1,
547
+ useLimitPerUser: true,
984
548
  createdAt: new Date(Date.now()),
985
549
  beginAt: new Date(Date.now()),
986
550
  expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
987
551
  });
988
552
  }
989
553
  }
554
+ __decorate([
555
+ Expose({ name: 'checkout_type' }),
556
+ __metadata("design:type", Number)
557
+ ], Coupon.prototype, "checkoutType", void 0);
558
+ __decorate([
559
+ Expose({ name: 'exclusivity_type' }),
560
+ __metadata("design:type", Number)
561
+ ], Coupon.prototype, "exclusivityType", void 0);
990
562
 
991
563
  class SubscriptionPlan extends BaseModel {
992
564
  static get identifiersFields() {
@@ -1026,18 +598,6 @@ __decorate([
1026
598
  __metadata("design:type", BeautyProfile)
1027
599
  ], User.prototype, "beautyProfile", void 0);
1028
600
 
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
601
  class Subscription extends BaseModel {
1042
602
  static get identifiersFields() {
1043
603
  return ['id'];
@@ -1052,12 +612,12 @@ __decorate([
1052
612
  __metadata("design:type", SubscriptionPlan)
1053
613
  ], Subscription.prototype, "subscriptionPlan", void 0);
1054
614
  __decorate([
1055
- Type(() => UserAddress),
1056
- __metadata("design:type", UserAddress)
615
+ Type(() => Address),
616
+ __metadata("design:type", Address)
1057
617
  ], Subscription.prototype, "shippingAddress", void 0);
1058
618
  __decorate([
1059
- Type(() => UserAddress),
1060
- __metadata("design:type", UserAddress)
619
+ Type(() => Address),
620
+ __metadata("design:type", Address)
1061
621
  ], Subscription.prototype, "billingAddress", void 0);
1062
622
  __decorate([
1063
623
  Type(() => Coupon),
@@ -1072,6 +632,12 @@ __decorate([
1072
632
  __metadata("design:type", Array)
1073
633
  ], Subscription.prototype, "payment", void 0);
1074
634
 
635
+ class UserAddress extends Address {
636
+ static get identifiersFields() {
637
+ return ['id', 'userId'];
638
+ }
639
+ }
640
+
1075
641
  class UserPaymentMethod extends BaseModel {
1076
642
  static get identifiersFields() {
1077
643
  return ['id', 'userId'];
@@ -1104,7 +670,7 @@ class Authentication {
1104
670
  return __awaiter(this, void 0, void 0, function* () {
1105
671
  const method = this.getServiceByMethod(signInMethod);
1106
672
  const userAuth = yield this.authService[method]({ email, password });
1107
- const user = this.userRepository.get({ id: userAuth.id });
673
+ const user = this.userRepository.get(userAuth);
1108
674
  if (!isNil(user))
1109
675
  return user;
1110
676
  if (/^.+@b4a.com.br$/.test(userAuth.email))
@@ -1191,123 +757,14 @@ class RecoveryPassword {
1191
757
  }
1192
758
  }
1193
759
 
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() {
760
+ class Category extends BaseModel {
761
+ identifierFields() {
1280
762
  return ['id'];
1281
763
  }
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
764
  static get identifiersFields() {
1300
765
  return ['id'];
1301
766
  }
1302
767
  }
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
768
 
1312
769
  var GenderDestination;
1313
770
  (function (GenderDestination) {
@@ -1324,60 +781,54 @@ var Shops;
1324
781
  Shops["ALL"] = "ALL";
1325
782
  })(Shops || (Shops = {}));
1326
783
 
1327
- class FilterOption extends BaseModel {
1328
- static get identifiersFields() {
784
+ class Product extends BaseModel {
785
+ identifierFields() {
1329
786
  return ['id'];
1330
787
  }
1331
- }
1332
-
1333
- class Product extends ProductBase {
1334
788
  static get identifiersFields() {
1335
789
  return ['id'];
1336
790
  }
1337
791
  }
1338
- __decorate([
1339
- Type(() => CategoryForProduct),
1340
- __metadata("design:type", CategoryForProduct)
1341
- ], Product.prototype, "category", void 0);
1342
792
  __decorate([
1343
793
  Type(() => KitProduct),
1344
794
  __metadata("design:type", Array)
1345
795
  ], Product.prototype, "kitProducts", void 0);
1346
796
 
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 {
797
+ class KitProduct extends BaseModel {
1360
798
  static get identifiersFields() {
1361
- return ['id'];
799
+ return ['productId', 'kitProducId'];
1362
800
  }
1363
801
  }
1364
802
  __decorate([
1365
- Type(() => Category),
1366
- __metadata("design:type", Array)
1367
- ], Buy2Win.prototype, "categories", void 0);
803
+ Type(() => Product),
804
+ __metadata("design:type", Product)
805
+ ], KitProduct.prototype, "kit", void 0);
806
+ __decorate([
807
+ Type(() => Product),
808
+ __metadata("design:type", Product)
809
+ ], KitProduct.prototype, "product", void 0);
1368
810
 
1369
- class CampaignDashboard extends BaseModel {
1370
- static get identifiersFields() {
811
+ class Variant extends BaseModel {
812
+ identifierFields() {
1371
813
  return ['id'];
1372
814
  }
1373
- }
1374
-
1375
- class CampaignHashtag extends BaseModel {
1376
815
  static get identifiersFields() {
1377
- return ['id'];
816
+ return ['id', 'productId'];
1378
817
  }
1379
818
  }
1380
819
 
820
+ var OrderStatus;
821
+ (function (OrderStatus) {
822
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
823
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
824
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
825
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
826
+ OrderStatus["ENVIADO"] = "Enviado";
827
+ OrderStatus["ENTREGUE"] = "Entregue";
828
+ OrderStatus["CANCELADO"] = "Cancelado";
829
+ OrderStatus["CREDIT_CARD"] = "credit_card";
830
+ })(OrderStatus || (OrderStatus = {}));
831
+
1381
832
  class LineItem extends Product {
1382
833
  }
1383
834
 
@@ -1401,12 +852,12 @@ __decorate([
1401
852
  __metadata("design:type", User)
1402
853
  ], Checkout.prototype, "user", void 0);
1403
854
  __decorate([
1404
- Type(() => UserAddress),
1405
- __metadata("design:type", UserAddress)
855
+ Type(() => Address),
856
+ __metadata("design:type", Address)
1406
857
  ], Checkout.prototype, "shippingAddress", void 0);
1407
858
  __decorate([
1408
- Type(() => UserAddress),
1409
- __metadata("design:type", UserAddress)
859
+ Type(() => Address),
860
+ __metadata("design:type", Address)
1410
861
  ], Checkout.prototype, "billingAddress", void 0);
1411
862
  __decorate([
1412
863
  Type(() => ShippingMethod),
@@ -1417,18 +868,6 @@ __decorate([
1417
868
  __metadata("design:type", Coupon)
1418
869
  ], Checkout.prototype, "coupon", void 0);
1419
870
 
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
871
  class Order extends Checkout {
1433
872
  }
1434
873
  __decorate([
@@ -1442,12 +881,12 @@ class CheckoutSubscription extends BaseModel {
1442
881
  }
1443
882
  }
1444
883
  __decorate([
1445
- Type(() => UserAddress),
1446
- __metadata("design:type", UserAddress)
884
+ Type(() => Address),
885
+ __metadata("design:type", Address)
1447
886
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
1448
887
  __decorate([
1449
- Type(() => UserAddress),
1450
- __metadata("design:type", UserAddress)
888
+ Type(() => Address),
889
+ __metadata("design:type", Address)
1451
890
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
1452
891
  __decorate([
1453
892
  Type(() => SubscriptionPlan),
@@ -1458,19 +897,15 @@ __decorate([
1458
897
  __metadata("design:type", Coupon)
1459
898
  ], CheckoutSubscription.prototype, "coupon", void 0);
1460
899
 
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;
900
+ class Buy2Win extends BaseModel {
901
+ static get identifiersFields() {
902
+ return ['id'];
1472
903
  }
1473
904
  }
905
+ __decorate([
906
+ Type(() => Category),
907
+ __metadata("design:type", Array)
908
+ ], Buy2Win.prototype, "categories", void 0);
1474
909
 
1475
910
  var FilterType;
1476
911
  (function (FilterType) {
@@ -1571,12 +1006,6 @@ class ShopMenu extends BaseModel {
1571
1006
  }
1572
1007
  }
1573
1008
 
1574
- class ShopSettings extends BaseModel {
1575
- static get identifiersFields() {
1576
- return ['id'];
1577
- }
1578
- }
1579
-
1580
1009
  class InvalidArgumentError extends CustomError {
1581
1010
  constructor(message) {
1582
1011
  super(message);
@@ -1607,17 +1036,13 @@ class AxiosAdapter {
1607
1036
  constructor(config) {
1608
1037
  this.config = config;
1609
1038
  }
1610
- get(index, id) {
1039
+ get(index) {
1611
1040
  return __awaiter(this, void 0, void 0, function* () {
1612
1041
  try {
1613
1042
  const { data } = yield axios({
1614
- url: `${this.config.url}/${index}/_doc/${id}`,
1043
+ url: `${this.config.url}/${index}`,
1615
1044
  method: 'GET',
1616
- responseType: 'json',
1617
- headers: {
1618
- 'Content-Type': 'application/json',
1619
- Authorization: `ApiKey ${this.config.credential}`,
1620
- },
1045
+ headers: { Authorization: `Basic ${this.config.credential}` },
1621
1046
  });
1622
1047
  return data._source;
1623
1048
  }
@@ -1631,14 +1056,9 @@ class AxiosAdapter {
1631
1056
  query(index, query) {
1632
1057
  return __awaiter(this, void 0, void 0, function* () {
1633
1058
  const { data } = yield axios({
1634
- url: `${this.config.url}/${index}/_search`,
1059
+ url: `${this.config.url}/${index}`,
1635
1060
  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
- },
1061
+ headers: { Authorization: `Basic ${this.config.credential}` },
1642
1062
  data: query,
1643
1063
  });
1644
1064
  return {
@@ -1650,29 +1070,19 @@ class AxiosAdapter {
1650
1070
  save(index, data) {
1651
1071
  return __awaiter(this, void 0, void 0, function* () {
1652
1072
  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}`,
1073
+ url: `${this.config.url}/${index}`,
1664
1074
  method: 'PUT',
1665
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1075
+ headers: { Authorization: `Basic ${this.config.credential}` },
1666
1076
  data,
1667
1077
  });
1668
1078
  });
1669
1079
  }
1670
- delete(index, id) {
1080
+ delete(index) {
1671
1081
  return __awaiter(this, void 0, void 0, function* () {
1672
1082
  yield axios({
1673
- url: `${this.config.url}/${index}/_doc/${id}`,
1083
+ url: `${this.config.url}/${index}`,
1674
1084
  method: 'DELETE',
1675
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1085
+ headers: { Authorization: `Basic ${this.config.credential}` },
1676
1086
  });
1677
1087
  });
1678
1088
  }
@@ -1681,19 +1091,16 @@ class AxiosAdapter {
1681
1091
  class ProductsIndex {
1682
1092
  constructor(adapter) {
1683
1093
  this.adapter = adapter;
1684
- this.index = `products`;
1685
1094
  }
1686
- getById(id) {
1095
+ get(id) {
1687
1096
  return __awaiter(this, void 0, void 0, function* () {
1688
- const data = yield this.adapter.get(this.index, id);
1097
+ const data = yield this.adapter.get(`products/_doc/${id}`);
1689
1098
  return Product.toInstance(data);
1690
1099
  });
1691
1100
  }
1692
- search(searchTerm, total, shop) {
1101
+ findById(ids, options) {
1693
1102
  return __awaiter(this, void 0, void 0, function* () {
1694
- const size = total || 9;
1695
1103
  const fields = [
1696
- 'EAN',
1697
1104
  'brand',
1698
1105
  'id',
1699
1106
  'images',
@@ -1704,88 +1111,73 @@ class ProductsIndex {
1704
1111
  'stock',
1705
1112
  'slug',
1706
1113
  'reviews',
1114
+ 'pricePaid',
1115
+ 'isGift',
1116
+ 'stock',
1117
+ 'weight',
1118
+ 'tags',
1707
1119
  'hasVariants',
1708
- 'rate',
1120
+ 'type',
1709
1121
  ];
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: {
1122
+ const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
1721
1123
  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,
1124
+ filter: [
1125
+ {
1126
+ terms: {
1127
+ _id: ids,
1128
+ },
1738
1129
  },
1739
- },
1740
- should: {
1741
- match_phrase_prefix: {
1742
- 'name.search': {
1743
- query: `${searchTerm}`,
1744
- slop: 10,
1130
+ {
1131
+ term: {
1132
+ published: true,
1745
1133
  },
1746
1134
  },
1747
- },
1748
- filter,
1135
+ ...((options === null || options === void 0 ? void 0 : options.hasStock)
1136
+ ? [
1137
+ {
1138
+ range: {
1139
+ 'stock.quantity': {
1140
+ gt: 0,
1141
+ },
1142
+ },
1143
+ },
1144
+ ]
1145
+ : []),
1146
+ ],
1749
1147
  },
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;
1148
+ } }, ((options === null || options === void 0 ? void 0 : options.size) ? { size: options === null || options === void 0 ? void 0 : options.size } : {})));
1149
+ return hits.map((hit) => Product.toInstance(hit._source));
1759
1150
  });
1760
1151
  }
1761
1152
  save(product) {
1762
1153
  return __awaiter(this, void 0, void 0, function* () {
1154
+ delete product.createdAt;
1155
+ delete product.updatedAt;
1156
+ delete product.kitProducts;
1763
1157
  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);
1158
+ if (!product.firestoreId)
1159
+ throw new Error('Is not a product from firestore');
1160
+ yield this.get(product.firestoreId);
1161
+ yield this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
1776
1162
  }
1777
1163
  catch (error) {
1778
- console.error(error);
1164
+ if (!(error instanceof Error))
1165
+ throw error;
1166
+ console.error(error.message);
1167
+ yield this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
1779
1168
  }
1780
1169
  });
1781
1170
  }
1782
- delete(id) {
1171
+ delete(product) {
1783
1172
  return __awaiter(this, void 0, void 0, function* () {
1173
+ if (!product.firestoreId)
1174
+ return;
1784
1175
  try {
1785
- yield this.adapter.delete(this.index, id);
1176
+ yield this.get(product.firestoreId);
1177
+ yield this.adapter.delete(`products/_doc/${product.firestoreId}`);
1786
1178
  }
1787
1179
  catch (error) {
1788
- console.error(error);
1180
+ yield this.adapter.delete(`products/_doc/${product.id}`);
1789
1181
  }
1790
1182
  });
1791
1183
  }
@@ -1813,39 +1205,17 @@ const withFirestore = (MixinBase) => {
1813
1205
  ? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
1814
1206
  : bindDate(data[key], key) })), {});
1815
1207
  };
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
1208
  return class extends MixinBase {
1828
- constructor(...params) {
1829
- super(...params);
1830
- this.fields = {};
1831
- this.interceptors = {};
1209
+ constructor() {
1210
+ super(...arguments);
1832
1211
  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
1212
  }
1840
1213
  collection(path) {
1841
1214
  return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
1842
1215
  }
1843
1216
  buildModelInstance() {
1844
1217
  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
- },
1218
+ toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
1849
1219
  fromFirestore: (snap) => {
1850
1220
  const data = snap.data();
1851
1221
  let bindedData = null;
@@ -1885,16 +1255,12 @@ const withHelpers = (MixinBase) => {
1885
1255
  const withGetFirestore = (MixinBase) => {
1886
1256
  return class GetFirestore extends MixinBase {
1887
1257
  get(identifiers) {
1888
- var _a, _b, _c, _d;
1889
1258
  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()));
1259
+ const docRef = yield getDoc(doc(yield this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
1894
1260
  const data = docRef.data();
1895
1261
  if (isNil(data))
1896
1262
  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;
1263
+ return data;
1898
1264
  });
1899
1265
  }
1900
1266
  buildCollectionPathForGet(identifiers) {
@@ -1932,7 +1298,7 @@ const withFindFirestore = (MixinBase) => {
1932
1298
  ], []);
1933
1299
  this.buildWhereSentence = (fieldName, options) => {
1934
1300
  if (this.isSubCollection(this) && fieldName === this.parentIdField)
1935
- return [];
1301
+ [];
1936
1302
  const value = (options === null || options === void 0 ? void 0 : options.value) || options;
1937
1303
  const object = {};
1938
1304
  set(object, fieldName, value);
@@ -1973,13 +1339,9 @@ const withFindFirestore = (MixinBase) => {
1973
1339
  return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
1974
1340
  };
1975
1341
  }
1976
- find(find = {}) {
1977
- var _a, _b, _c, _d, _e, _f;
1342
+ find({ filters, limits, orderBy, } = {}) {
1978
1343
  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;
1344
+ const collection = this.collection(this.buildCollectionPathForFind(filters));
1983
1345
  const queries = this.makeFirestoreWhere(filters || {});
1984
1346
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
1985
1347
  const offsets = yield this.defineLimits(filters, limits);
@@ -1987,8 +1349,8 @@ const withFindFirestore = (MixinBase) => {
1987
1349
  const docs = yield getDocs(query(collection, ...queryArgumments));
1988
1350
  const data = docs.docs.map((doc) => doc.data());
1989
1351
  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,
1352
+ data,
1353
+ count: this.calculateCount(data, limits),
1992
1354
  };
1993
1355
  });
1994
1356
  }
@@ -2000,12 +1362,11 @@ const withFindFirestore = (MixinBase) => {
2000
1362
  return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
2001
1363
  }
2002
1364
  defineLimits(filters, limits) {
2003
- var _a;
2004
1365
  return __awaiter(this, void 0, void 0, function* () {
2005
1366
  const queries = [];
2006
1367
  if (limits === null || limits === void 0 ? void 0 : limits.offset) {
2007
1368
  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()))));
1369
+ queries.push(startAfter(yield getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
2009
1370
  else if (isNumber(limits.offset) || isString(limits.offset))
2010
1371
  queries.push(startAt(limits.offset));
2011
1372
  }
@@ -2027,21 +1388,16 @@ const withFindFirestore = (MixinBase) => {
2027
1388
  const withCreateFirestore = (MixinBase) => {
2028
1389
  return class CreateFirestore extends MixinBase {
2029
1390
  create(data) {
2030
- var _a, _b, _c, _d;
2031
1391
  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);
1392
+ const docRef = yield this.save(this.model.toInstance(data));
2036
1393
  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;
1394
+ return doc.data();
2039
1395
  });
2040
1396
  }
2041
1397
  save(data) {
2042
1398
  var _a, _b;
2043
1399
  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();
1400
+ 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
1401
  const collectionPath = this.buildCollectionPathForAdd(data);
2046
1402
  const collection = this.collection(collectionPath);
2047
1403
  if (isEmpty(id))
@@ -2083,17 +1439,13 @@ const withUpdateFirestore = (MixinBase) => {
2083
1439
  };
2084
1440
  return class UpdateFirestore extends MixinBase {
2085
1441
  update(data) {
2086
- var _a, _b, _c, _d;
2087
1442
  return __awaiter(this, void 0, void 0, function* () {
2088
1443
  const model = new this.model();
2089
1444
  const keyField = model.identifiersFields.shift();
2090
1445
  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;
1446
+ yield setDoc(docRef, this.paramsToPlain(data), { merge: true });
1447
+ const docData = yield getDoc(docRef);
1448
+ return docData.data();
2097
1449
  });
2098
1450
  }
2099
1451
  buildCollectionPathForUpdate(identifiers) {
@@ -2113,13 +1465,8 @@ const withUpdateFirestore = (MixinBase) => {
2113
1465
  const withDeleteFirestore = (MixinBase) => {
2114
1466
  return class DeleteFirestore extends MixinBase {
2115
1467
  delete(identifiers) {
2116
- var _a, _b, _c, _d;
2117
1468
  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));
1469
+ yield deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
2123
1470
  });
2124
1471
  }
2125
1472
  buildCollectionPathForRemove(identifiers) {
@@ -2132,10 +1479,8 @@ const withDeleteFirestore = (MixinBase) => {
2132
1479
 
2133
1480
  const withSubCollection = (MixinBase, ParentModel) => {
2134
1481
  return class SubCollectionMix extends MixinBase {
2135
- constructor(...params) {
2136
- const options = params[0];
2137
- super(...params);
2138
- this.parentIdField = options.parentIdField;
1482
+ constructor(...args) {
1483
+ super(args);
2139
1484
  }
2140
1485
  collection(path) {
2141
1486
  return super.collection(path);
@@ -2149,87 +1494,73 @@ const withCrudFirestore = (MixinBase) => {
2149
1494
  };
2150
1495
 
2151
1496
  class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2152
- constructor({ firestore, interceptors }) {
2153
- super({
2154
- firestore,
2155
- collectionName: 'leads',
2156
- model: Lead,
2157
- interceptors,
2158
- });
1497
+ constructor(firestore) {
1498
+ super();
1499
+ this.firestore = firestore;
1500
+ this.collectionName = 'leads';
1501
+ this.model = Lead;
2159
1502
  }
2160
1503
  }
2161
1504
 
2162
1505
  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
- });
1506
+ constructor(firestore, parentRepository) {
1507
+ super();
1508
+ this.firestore = firestore;
2171
1509
  this.parentRepository = parentRepository;
1510
+ this.collectionName = 'editions';
1511
+ this.parentIdField = 'subscriptionId';
1512
+ this.model = Edition;
2172
1513
  }
2173
1514
  }
2174
1515
 
2175
1516
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2176
- constructor({ firestore, interceptors, }) {
2177
- super({
2178
- firestore,
2179
- collectionName: 'subscription',
2180
- model: Subscription,
2181
- interceptors,
2182
- });
1517
+ constructor(firestore) {
1518
+ super();
1519
+ this.firestore = firestore;
1520
+ this.collectionName = 'subscription';
1521
+ this.model = Subscription;
2183
1522
  }
2184
1523
  }
2185
1524
 
2186
1525
  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
- });
1526
+ constructor(firestore, parentRepository) {
1527
+ super();
1528
+ this.firestore = firestore;
2195
1529
  this.parentRepository = parentRepository;
1530
+ this.collectionName = 'payments';
1531
+ this.parentIdField = 'subscriptionId';
1532
+ this.model = SubscriptionPayment;
2196
1533
  }
2197
1534
  }
2198
1535
 
2199
1536
  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
- });
1537
+ constructor(firestore, parentRepository) {
1538
+ super();
1539
+ this.firestore = firestore;
2208
1540
  this.parentRepository = parentRepository;
1541
+ this.collectionName = 'address';
1542
+ this.parentIdField = 'userId';
1543
+ this.model = UserAddress;
2209
1544
  }
2210
1545
  }
2211
1546
 
2212
1547
  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
- });
1548
+ constructor(firestore, parentRepository) {
1549
+ super();
1550
+ this.firestore = firestore;
2221
1551
  this.parentRepository = parentRepository;
1552
+ this.collectionName = 'CX';
1553
+ this.parentIdField = 'userId';
1554
+ this.model = BeautyProfile;
2222
1555
  }
2223
1556
  }
2224
1557
 
2225
1558
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2226
- constructor({ firestore, interceptors }) {
2227
- super({
2228
- firestore,
2229
- collectionName: 'users',
2230
- model: User,
2231
- interceptors,
2232
- });
1559
+ constructor(firestore) {
1560
+ super();
1561
+ this.firestore = firestore;
1562
+ this.collectionName = 'users';
1563
+ this.model = User;
2233
1564
  }
2234
1565
  get(identifiers) {
2235
1566
  const _super = Object.create(null, {
@@ -2280,26 +1611,22 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2280
1611
  }
2281
1612
 
2282
1613
  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
- });
1614
+ constructor(firestore, parentRepository) {
1615
+ super();
1616
+ this.firestore = firestore;
2291
1617
  this.parentRepository = parentRepository;
1618
+ this.collectionName = 'payment_method';
1619
+ this.parentIdField = 'userId';
1620
+ this.model = UserPaymentMethod;
2292
1621
  }
2293
1622
  }
2294
1623
 
2295
1624
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2296
- constructor({ firestore, interceptors }) {
2297
- super({
2298
- firestore,
2299
- collectionName: 'categories',
2300
- model: Category,
2301
- interceptors,
2302
- });
1625
+ constructor(firestore) {
1626
+ super();
1627
+ this.firestore = firestore;
1628
+ this.collectionName = 'categories';
1629
+ this.model = Category;
2303
1630
  }
2304
1631
  getCategoryBySlug(slug, shop) {
2305
1632
  return __awaiter(this, void 0, void 0, function* () {
@@ -2311,7 +1638,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2311
1638
  return categoryDocs.docs[0].data();
2312
1639
  });
2313
1640
  }
2314
- getCategoriesForHome(categoryIds, limit = 4, gender) {
1641
+ getCategoriesForHome(categoryIds, limit = 4) {
2315
1642
  return __awaiter(this, void 0, void 0, function* () {
2316
1643
  const categorySnap = yield getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
2317
1644
  if (categorySnap.empty)
@@ -2320,7 +1647,7 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2320
1647
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
2321
1648
  return ({
2322
1649
  category,
2323
- products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
1650
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
2324
1651
  });
2325
1652
  })));
2326
1653
  return homeSections;
@@ -2339,8 +1666,6 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2339
1666
  wheres.push(where('published', '==', true), where('id', 'in', productIds));
2340
1667
  if (options === null || options === void 0 ? void 0 : options.hasStock)
2341
1668
  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
1669
  if (options === null || options === void 0 ? void 0 : options.limit)
2345
1670
  wheres.push(limit(options === null || options === void 0 ? void 0 : options.limit));
2346
1671
  const productSnap = yield getDocs(query(this.collection('productsErpVitrine'), ...wheres));
@@ -2351,26 +1676,15 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
2351
1676
  return is(products);
2352
1677
  });
2353
1678
  }
2354
- getCategoryByShop(shop) {
2355
- return;
2356
- }
2357
- getChildren(parentId) {
2358
- return;
2359
- }
2360
- isChild(id, parentId) {
2361
- return;
2362
- }
2363
1679
  }
2364
1680
 
2365
1681
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2366
- constructor({ firestore, interceptors }) {
2367
- super({
2368
- firestore,
2369
- collectionName: 'productsErpVitrine',
2370
- model: Product,
2371
- interceptors,
2372
- });
1682
+ constructor(firestore) {
1683
+ super();
1684
+ this.firestore = firestore;
2373
1685
  this.reviews = {};
1686
+ this.collectionName = 'productsErpVitrine';
1687
+ this.model = Product;
2374
1688
  }
2375
1689
  getBySlug(slug) {
2376
1690
  var _a;
@@ -2411,101 +1725,43 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
2411
1725
  return this.reviews[status];
2412
1726
  });
2413
1727
  }
2414
- cleanShoppingCountFromIds() {
2415
- return;
2416
- }
2417
- findCatalog(params) {
2418
- return this.find(params);
2419
- }
2420
1728
  }
2421
1729
 
2422
1730
  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
- });
1731
+ constructor(firestore, parentRepository) {
1732
+ super();
1733
+ this.firestore = firestore;
2431
1734
  this.parentRepository = parentRepository;
1735
+ this.collectionName = 'variants';
1736
+ this.parentIdField = 'productId';
1737
+ this.model = Variant;
2432
1738
  }
2433
1739
  }
2434
1740
 
2435
1741
  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
- });
1742
+ constructor(firestore) {
1743
+ super();
1744
+ this.firestore = firestore;
1745
+ this.collectionName = 'subscriptionProducts';
1746
+ this.model = Product;
2476
1747
  }
2477
1748
  }
2478
1749
 
2479
1750
  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
- });
1751
+ constructor(firestore) {
1752
+ super();
1753
+ this.firestore = firestore;
1754
+ this.collectionName = 'checkouts';
1755
+ this.model = Checkout;
2498
1756
  }
2499
1757
  }
2500
1758
 
2501
1759
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2502
- constructor({ firestore, interceptors }) {
2503
- super({
2504
- firestore,
2505
- collectionName: 'coupons',
2506
- model: Coupon,
2507
- interceptors,
2508
- });
1760
+ constructor(firestore) {
1761
+ super();
1762
+ this.firestore = firestore;
1763
+ this.collectionName = 'coupons';
1764
+ this.model = Coupon;
2509
1765
  }
2510
1766
  buildModelInstance() {
2511
1767
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2527,16 +1783,9 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
2527
1783
  }
2528
1784
 
2529
1785
  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
- });
1786
+ constructor(firestore) {
1787
+ super();
1788
+ this.firestore = firestore;
2540
1789
  this.orderFromFirestore = (order) => {
2541
1790
  var _a;
2542
1791
  if (!!((_a = order === null || order === void 0 ? void 0 : order.lineItems) === null || _a === void 0 ? void 0 : _a.length)) {
@@ -2550,6 +1799,11 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
2550
1799
  }
2551
1800
  return order;
2552
1801
  };
1802
+ this.collectionName = 'orders';
1803
+ this.model = Order;
1804
+ this.fields = {
1805
+ status: FirestoreFieldType.String,
1806
+ };
2553
1807
  }
2554
1808
  buildModelInstance() {
2555
1809
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2563,62 +1817,86 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
2563
1817
  }
2564
1818
  }
2565
1819
 
2566
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
2567
- constructor({ firestore, interceptors }) {
2568
- super({
2569
- firestore,
2570
- interceptors,
2571
- });
2572
- this.collectionName = 'legacyOrders';
1820
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1821
+ constructor(firestore) {
1822
+ super();
1823
+ this.firestore = firestore;
1824
+ this.collectionName = 'payments';
1825
+ this.model = Payment;
2573
1826
  }
2574
1827
  }
2575
1828
 
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
- });
1829
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1830
+ constructor(firestore) {
1831
+ super();
1832
+ this.firestore = firestore;
1833
+ this.collectionName = 'checkoutsSubscription';
1834
+ this.model = CheckoutSubscription;
2584
1835
  }
2585
1836
  }
2586
1837
 
2587
1838
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2588
- constructor({ firestore, interceptors, }) {
2589
- super({
2590
- firestore,
2591
- collectionName: 'subscriptionPlans',
2592
- model: SubscriptionPlan,
2593
- interceptors,
2594
- });
1839
+ constructor(firestore) {
1840
+ super();
1841
+ this.firestore = firestore;
1842
+ this.collectionName = 'subscriptionPlans';
1843
+ this.model = SubscriptionPlan;
1844
+ }
1845
+ }
1846
+
1847
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1848
+ constructor(firestore) {
1849
+ super();
1850
+ this.firestore = firestore;
1851
+ this.collectionName = 'buy2win';
1852
+ this.model = Buy2Win;
1853
+ }
1854
+ }
1855
+
1856
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1857
+ constructor(firestore) {
1858
+ super(firestore);
1859
+ this.firestore = firestore;
1860
+ this.collectionName = 'legacyOrders';
2595
1861
  }
2596
1862
  }
2597
1863
 
2598
1864
  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
- });
1865
+ constructor(firestore) {
1866
+ super();
1867
+ this.firestore = firestore;
1868
+ this.homeToFirestore = (home) => {
1869
+ var _a;
1870
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
1871
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
1872
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.homeCategoryGroupToPlain);
1873
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.homeCategoryGroupToPlain);
1874
+ }
1875
+ return home;
2614
1876
  };
2615
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => {
1877
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
1878
+ category: homeCategoryGroup.category.toPlain(),
1879
+ products: homeCategoryGroup.products.map((product) => product.toPlain()),
1880
+ });
1881
+ this.homeFromFirestore = (home) => {
2616
1882
  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
- });
1883
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
1884
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
1885
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
1886
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
1887
+ home.data.createdAt =
1888
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
1889
+ home.data.expiresAt =
1890
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
1891
+ }
1892
+ return home;
2621
1893
  };
1894
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
1895
+ category: Category.toInstance(homeCategoryGroup.category),
1896
+ products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
1897
+ });
1898
+ this.collectionName = 'dms';
1899
+ this.model = Home;
2622
1900
  }
2623
1901
  buildModelInstance() {
2624
1902
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -2633,49 +1911,14 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
2633
1911
  },
2634
1912
  };
2635
1913
  }
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
1914
  }
2659
1915
 
2660
1916
  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
- });
1917
+ constructor(firestore) {
1918
+ super();
1919
+ this.firestore = firestore;
1920
+ this.collectionName = 'shopMenus';
1921
+ this.model = ShopMenu;
2679
1922
  }
2680
1923
  }
2681
1924
 
@@ -2765,7 +2008,7 @@ class AttributeOptionHelper {
2765
2008
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2766
2009
  var _a;
2767
2010
  if (fields.includes(attributeName))
2768
- return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
2011
+ return { columnName: attributeName.toString(), attributeName };
2769
2012
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2770
2013
  const fieldOption = (_a = is(field)) === null || _a === void 0 ? void 0 : _a[attributeName];
2771
2014
  if (isNil(fieldOption))
@@ -2774,7 +2017,7 @@ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2774
2017
  return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
2775
2018
  return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
2776
2019
  };
2777
- AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.columnName);
2020
+ AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
2778
2021
  AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
2779
2022
  if (fields.includes(columnName))
2780
2023
  return { columnName, attributeName: columnName };
@@ -2854,23 +2097,22 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
2854
2097
  }, {});
2855
2098
  BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2856
2099
  const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2857
- const isNestedField = !Array.isArray(options) &&
2100
+ if (!Array.isArray(options) &&
2858
2101
  isObject(options) &&
2859
2102
  isNil(options === null || options === void 0 ? void 0 : options.operator) &&
2860
2103
  isNil(options === null || options === void 0 ? void 0 : options.value) &&
2861
- isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to);
2862
- if (isNestedField)
2104
+ isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
2863
2105
  return Object.keys(options).reduce((variables, key) => {
2864
2106
  const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
2865
2107
  const columnName = fieldOptions.columnName;
2866
2108
  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) });
2109
+ return Object.assign(Object.assign({}, variables), { [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), columnFields || []) });
2868
2110
  }, {});
2869
2111
  if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
2870
2112
  return {
2871
2113
  [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
2872
2114
  };
2873
- if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2115
+ if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2874
2116
  options = Object.values(options)[0];
2875
2117
  return Array.isArray(options)
2876
2118
  ? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions))), {})
@@ -2902,14 +2144,28 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
2902
2144
  if (field === 'affected_rows')
2903
2145
  return field;
2904
2146
  const fieldName = Object.keys(field).shift();
2905
- const fieldValue = is(field[fieldName]);
2147
+ const fieldValue = field[fieldName];
2906
2148
  if (Array.isArray(fieldValue))
2907
2149
  return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
2908
2150
  if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
2909
- return;
2910
- const isNestedField = !!fieldValue.fields;
2911
- if (isNestedField)
2912
- return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
2151
+ return null;
2152
+ if (fieldValue.fields)
2153
+ return !fieldValue.filters
2154
+ ? {
2155
+ [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2156
+ }
2157
+ : {
2158
+ operation: fieldValue.columnName || fieldName,
2159
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2160
+ variables: {
2161
+ [`${fieldValue.columnName}_where`]: {
2162
+ name: 'where',
2163
+ type: fieldValue.filters.filterType,
2164
+ value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2165
+ required: true,
2166
+ },
2167
+ },
2168
+ };
2913
2169
  return fieldValue.columnName;
2914
2170
  }).filter((field) => !!field);
2915
2171
  };
@@ -2927,7 +2183,7 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
2927
2183
  }
2928
2184
  if (!!from)
2929
2185
  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] });
2186
+ return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName].toString()) });
2931
2187
  }, {});
2932
2188
  GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2933
2189
  var _a;
@@ -2943,8 +2199,7 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2943
2199
  !Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = is(data[attributeName])) === null || _a === void 0 ? void 0 : _a[key]); }).length)
2944
2200
  return Object.keys(foreignKeyColumn).reduce((object, current) => {
2945
2201
  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] });
2202
+ return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] }));
2948
2203
  }, Object.assign({}, result));
2949
2204
  if (update &&
2950
2205
  isObject(data[attributeName]) &&
@@ -2972,25 +2227,6 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2972
2227
  return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
2973
2228
  }, {});
2974
2229
  };
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
2230
 
2995
2231
  const withCreateHasuraGraphQL = (MixinBase) => {
2996
2232
  return class CreateHasuraGraphQLMixin extends MixinBase {
@@ -3002,7 +2238,6 @@ const withCreateHasuraGraphQL = (MixinBase) => {
3002
2238
  }
3003
2239
  create(data) {
3004
2240
  return __awaiter(this, void 0, void 0, function* () {
3005
- this.logger = DebugHelper.from(this, 'create');
3006
2241
  const newData = yield this.save(this.model.toInstance(data));
3007
2242
  return this.model.toInstance(newData);
3008
2243
  });
@@ -3015,11 +2250,12 @@ const withCreateHasuraGraphQL = (MixinBase) => {
3015
2250
  const columnOptions = Object.values(field).shift();
3016
2251
  return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
3017
2252
  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; }),
2253
+ ...Object.values(columnOptions.foreignKeyColumn),
3019
2254
  {
3020
2255
  [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
3021
2256
  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;
2257
+ return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
2258
+ foreignKeyField;
3023
2259
  }),
3024
2260
  },
3025
2261
  ]);
@@ -3044,11 +2280,9 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
3044
2280
  }
3045
2281
  delete(identifiers) {
3046
2282
  return __awaiter(this, void 0, void 0, function* () {
3047
- this.logger = DebugHelper.from(this, 'delete');
3048
2283
  const instance = this.model.toInstance(identifiers);
3049
2284
  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]))
2285
+ if (isNil(instance[identifier]))
3052
2286
  return ids;
3053
2287
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
3054
2288
  const value = columnOption.to(identifiers[identifier], instance);
@@ -3073,16 +2307,11 @@ const withHasuraGraphQL = (MixinBase) => {
3073
2307
  this.authOptions = options.authOptions;
3074
2308
  this.model = options.model;
3075
2309
  this.fields = options.fields || this.model.identifiersFields;
3076
- this.logger = DebugHelper.from(this);
3077
2310
  }
3078
2311
  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)
2312
+ return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
3081
2313
  ? {}
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
- }));
2314
+ : { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }));
3086
2315
  }
3087
2316
  mutation(operation, fields, variables) {
3088
2317
  return __awaiter(this, void 0, void 0, function* () {
@@ -3095,32 +2324,32 @@ const withHasuraGraphQL = (MixinBase) => {
3095
2324
  });
3096
2325
  }
3097
2326
  query(operation, fields, variables) {
3098
- var _a, _b, _c, _d;
3099
2327
  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;
2328
+ const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2329
+ ? query$1(operation.map((option) => ({
2330
+ operation: option.operation,
2331
+ variables: option.variables,
2332
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2333
+ })))
2334
+ : query$1({
2335
+ operation,
2336
+ variables,
2337
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2338
+ });
2339
+ return this.fetch(resultQuery);
3109
2340
  });
3110
2341
  }
3111
2342
  fetch(params) {
3112
2343
  return __awaiter(this, void 0, void 0, function* () {
3113
- this.logger.with('params').log(params);
3114
2344
  const headers = this.headers;
3115
- const { data: result } = yield axios({
3116
- url: `${this.endpoint}`,
2345
+ const response = yield fetch(`${this.endpoint}`, {
3117
2346
  method: 'POST',
3118
- data: params,
2347
+ body: JSON.stringify(params),
3119
2348
  headers,
3120
2349
  });
2350
+ const result = yield response.json();
3121
2351
  if (!isNil(result.errors))
3122
2352
  throw new Error(JSON.stringify(result.errors));
3123
- this.logger.with('returns').log(result);
3124
2353
  return result.data;
3125
2354
  });
3126
2355
  }
@@ -3147,26 +2376,13 @@ const withHasuraGraphQL = (MixinBase) => {
3147
2376
  return value;
3148
2377
  return date;
3149
2378
  }
3150
- convertDataFromHasura(data, fields) {
3151
- const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
2379
+ convertDataFromHasura(data) {
2380
+ const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
3152
2381
  return this.model.toInstance(plain);
3153
2382
  }
3154
2383
  convertDataToHasura(instance, update = false) {
3155
2384
  return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
3156
2385
  }
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
2386
  };
3171
2387
  };
3172
2388
 
@@ -3190,7 +2406,6 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
3190
2406
  }
3191
2407
  update(data) {
3192
2408
  return __awaiter(this, void 0, void 0, function* () {
3193
- this.logger = DebugHelper.from(this, 'update');
3194
2409
  const plainData = this.paramsToPlain(data);
3195
2410
  yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
3196
2411
  _set: {
@@ -3215,11 +2430,10 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
3215
2430
  const instance = this.model.toInstance(data);
3216
2431
  return this.model.identifiersFields.reduce((ids, identifier) => {
3217
2432
  var _a;
3218
- const identifierBinded = identifier;
3219
- if (isNil(instance.identifier[identifierBinded]))
2433
+ if (isNil(instance[identifier]))
3220
2434
  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];
2435
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2436
+ 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
2437
  return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
3224
2438
  }, {});
3225
2439
  }
@@ -3235,12 +2449,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
3235
2449
  }
3236
2450
  get(identifiers) {
3237
2451
  return __awaiter(this, void 0, void 0, function* () {
3238
- this.logger = DebugHelper.from(this, 'get');
3239
2452
  const instance = this.model.toInstance(identifiers);
3240
2453
  const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
3241
2454
  var _a;
3242
- const identifierBinded = identifier;
3243
- if (isNil(instance[identifierBinded]))
2455
+ if (isNil(instance[identifier]))
3244
2456
  return ids;
3245
2457
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
3246
2458
  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,53 +2474,10 @@ const withGetHasuraGraphQL = (MixinBase) => {
3262
2474
 
3263
2475
  const withFindHasuraGraphQL = (MixinBase) => {
3264
2476
  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.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; });
3296
- }
3297
- find(params) {
3298
- var _a, _b, _c;
2477
+ find(options) {
3299
2478
  return __awaiter(this, void 0, void 0, function* () {
3300
- this.logger = DebugHelper.from(this, 'find');
3301
- const { filters, limits, orderBy, options } = params || {};
3302
- const enableCount = (_a = options === null || options === void 0 ? void 0 : options.enableCount) !== null && _a !== void 0 ? _a : true;
3303
- const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy)
3304
- ? {}
3305
- : {
3306
- order_by: {
3307
- type: `${this.tableName}_order_by!`,
3308
- list: true,
3309
- value: this.bindOrderByAttributes(orderBy, this.fields),
3310
- },
3311
- })), (isNil(filters)
2479
+ const { filters, limits, orderBy } = options || {};
2480
+ const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
3312
2481
  ? {}
3313
2482
  : {
3314
2483
  where: {
@@ -3318,15 +2487,11 @@ const withFindHasuraGraphQL = (MixinBase) => {
3318
2487
  },
3319
2488
  }));
3320
2489
  const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
3321
- const aggregateFields = [
3322
- ...(enableCount ? ['count'] : []),
3323
- ...this.bindAggretageAttributes(params.options, this.fields),
3324
- ];
3325
2490
  const result = yield this.query([
3326
2491
  {
3327
2492
  operation: this.tableName,
3328
- fields: params.fields
3329
- ? params.fields
2493
+ fields: options.fields
2494
+ ? options.fields
3330
2495
  .map((fieldName) => {
3331
2496
  var _a;
3332
2497
  return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
@@ -3335,36 +2500,15 @@ const withFindHasuraGraphQL = (MixinBase) => {
3335
2500
  : this.fields,
3336
2501
  variables,
3337
2502
  },
3338
- ...(aggregateFields.length > 0
3339
- ? [
3340
- {
3341
- operation: `${this.tableName}_aggregate`,
3342
- fields: [
3343
- {
3344
- aggregate: aggregateFields,
3345
- },
3346
- ],
3347
- variables: variablesCount,
3348
- },
3349
- ]
3350
- : []),
2503
+ {
2504
+ operation: `${this.tableName}_aggregate`,
2505
+ fields: [{ aggregate: ['count'] }],
2506
+ variables: variablesCount,
2507
+ },
3351
2508
  ]);
3352
2509
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
3353
- return Object.assign(Object.assign({ data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity }, (((_b = options === null || options === void 0 ? void 0 : options.minimal) === null || _b === void 0 ? void 0 : _b.length)
3354
- ? {
3355
- minimal: options.minimal.reduce((minimals, current) => {
3356
- var _a;
3357
- 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])));
3358
- }, {}),
3359
- }
3360
- : {})), (((_c = options === null || options === void 0 ? void 0 : options.maximum) === null || _c === void 0 ? void 0 : _c.length)
3361
- ? {
3362
- maximum: options.maximum.reduce((maximums, current) => {
3363
- var _a;
3364
- 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])));
3365
- }, {}),
3366
- }
3367
- : {}));
2510
+ const count = result[`${this.tableName}_aggregate`].aggregate.count;
2511
+ return { count, data };
3368
2512
  });
3369
2513
  }
3370
2514
  };
@@ -3404,154 +2548,13 @@ class VariantHasuraGraphQL extends Variant {
3404
2548
  }
3405
2549
  }
3406
2550
 
3407
- class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3408
- constructor({ endpoint, authOptions, interceptors, }) {
3409
- super({
3410
- tableName: 'category_collection_children',
3411
- model: CategoryCollectionChildren,
3412
- endpoint,
3413
- authOptions,
3414
- interceptors,
3415
- fields: [
3416
- { collectionId: { columnName: 'collection_id' } },
3417
- { categoryId: { columnName: 'category_id' } },
3418
- 'name',
3419
- 'slug',
3420
- 'reference',
3421
- { parentCollectionId: { columnName: 'parent_collection_id' } },
3422
- { parentCategoryId: { columnName: 'parent_category_id' } },
3423
- {
3424
- parent: {
3425
- columnName: 'parent',
3426
- foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
3427
- fields: [
3428
- { collectionId: { columnName: 'collection_id' } },
3429
- { categoryId: { columnName: 'category_id' } },
3430
- 'name',
3431
- 'slug',
3432
- 'reference',
3433
- { parentCollectionId: { columnName: 'parent_collection_id' } },
3434
- { parentCategoryId: { columnName: 'parent_category_id' } },
3435
- ],
3436
- },
3437
- },
3438
- ],
3439
- });
3440
- }
3441
- }
3442
-
3443
- class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3444
- constructor({ endpoint, authOptions, interceptors, }) {
3445
- super({
3446
- tableName: 'category_filter',
3447
- model: CategoryFilter,
3448
- endpoint,
3449
- authOptions,
3450
- interceptors,
3451
- fields: [
3452
- 'id',
3453
- { filterId: { columnName: 'filter_id' } },
3454
- { categoryId: { columnName: 'category_id' } },
3455
- {
3456
- filter: {
3457
- columnName: 'filter',
3458
- foreignKeyColumn: { id: 'filterId' },
3459
- fields: [
3460
- 'id',
3461
- 'description',
3462
- 'slug',
3463
- 'enabled',
3464
- { createdAt: { columnName: 'created_at' } },
3465
- { updatedAt: { columnName: 'updated_at' } },
3466
- {
3467
- options: {
3468
- columnName: 'options',
3469
- foreignKeyColumn: { filterId: 'id' },
3470
- fields: [
3471
- 'id',
3472
- { filterId: { columnName: 'filter_id' } },
3473
- 'description',
3474
- { createdAt: { columnName: 'created_at' } },
3475
- { updatedAt: { columnName: 'updated_at' } },
3476
- ],
3477
- },
3478
- },
3479
- ],
3480
- },
3481
- },
3482
- {
3483
- category: {
3484
- columnName: 'category',
3485
- foreignKeyColumn: { id: 'categoryId' },
3486
- fields: [
3487
- 'id',
3488
- 'description',
3489
- {
3490
- products: {
3491
- columnName: 'products',
3492
- fields: ['product_id'],
3493
- from: (value) => value.map((product) => product.product_id.toString()),
3494
- to: (productIds) => productIds.map((productId) => ({
3495
- product_id: +productId,
3496
- })),
3497
- },
3498
- },
3499
- {
3500
- childrenProducts: {
3501
- columnName: 'children_products',
3502
- foreignKeyColumn: { category_id: 'id' },
3503
- fields: [
3504
- 'id',
3505
- 'name',
3506
- 'slug',
3507
- {
3508
- categories: {
3509
- columnName: 'categories',
3510
- fields: ['category_id'],
3511
- bindPersistData: (value) => ({
3512
- categories: { data: value.map((category) => ({ category_id: +category })) },
3513
- }),
3514
- to: (categories) => categories.map((categoryId) => +categoryId),
3515
- 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(); })) || [],
3516
- },
3517
- },
3518
- ],
3519
- },
3520
- },
3521
- ],
3522
- },
3523
- },
3524
- ],
3525
- });
3526
- }
3527
- deleteByCategory(categoryId) {
3528
- return this.mutation('delete_category_filter', ['affected_rows'], {
3529
- where: {
3530
- type: 'category_filter_bool_exp',
3531
- required: true,
3532
- value: { category_id: { _eq: categoryId } },
3533
- },
3534
- });
3535
- }
3536
- deleteByCategoryAndFilter(categoryId, filterId) {
3537
- return this.mutation('delete_category_filter', ['affected_rows'], {
3538
- where: {
3539
- type: 'category_filter_bool_exp',
3540
- required: true,
3541
- value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
3542
- },
3543
- });
3544
- }
3545
- }
3546
-
3547
2551
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3548
- constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
2552
+ constructor(endpoint, authOptions, productRepository) {
3549
2553
  super({
3550
2554
  tableName: 'category',
3551
2555
  model: Category,
3552
2556
  endpoint,
3553
2557
  authOptions,
3554
- interceptors,
3555
2558
  fields: [
3556
2559
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
3557
2560
  { firestoreId: { columnName: 'firestore_id' } },
@@ -3560,7 +2563,6 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3560
2563
  'image',
3561
2564
  'published',
3562
2565
  'shop',
3563
- { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
3564
2566
  'slug',
3565
2567
  { brandCategory: { columnName: 'brand_category' } },
3566
2568
  { brandCategoryBanner: { columnName: 'brand_banner' } },
@@ -3586,17 +2588,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3586
2588
  },
3587
2589
  },
3588
2590
  },
3589
- {
3590
- filters: {
3591
- columnName: 'filters',
3592
- foreignKeyColumn: { filter_id: 'id' },
3593
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
3594
- bindPersistData: (value) => ({
3595
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
3596
- }),
3597
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
3598
- },
3599
- },
2591
+ 'filters',
3600
2592
  { createdAt: { columnName: 'created_at' } },
3601
2593
  { updatedAt: { columnName: 'updated_at' } },
3602
2594
  {
@@ -3618,21 +2610,9 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3618
2610
  }),
3619
2611
  },
3620
2612
  },
3621
- { isCollection: { columnName: 'is_collection' } },
3622
- { isWishlist: { columnName: 'is_wishlist' } },
3623
- 'reference',
3624
- { parentId: { columnName: 'parent_id' } },
3625
- {
3626
- parent: {
3627
- columnName: 'parent',
3628
- foreignKeyColumn: { id: 'parentId' },
3629
- fields: ['id', 'name', 'reference', 'slug'],
3630
- },
3631
- },
3632
2613
  ],
3633
2614
  });
3634
2615
  this.productRepository = productRepository;
3635
- this.categoryFilterRepository = categoryFilterRepository;
3636
2616
  }
3637
2617
  create(params) {
3638
2618
  const _super = Object.create(null, {
@@ -3640,7 +2620,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3640
2620
  });
3641
2621
  return __awaiter(this, void 0, void 0, function* () {
3642
2622
  const { metadata } = params, data = __rest(params, ["metadata"]);
3643
- return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: false, metadata: metadata || { description: null, title: null } }));
2623
+ return _super.create.call(this, Object.assign(Object.assign({}, data), { metadata: metadata || { description: null, title: null } }));
3644
2624
  });
3645
2625
  }
3646
2626
  get(identifiers) {
@@ -3650,7 +2630,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3650
2630
  var _a;
3651
2631
  return __awaiter(this, void 0, void 0, function* () {
3652
2632
  return Number.isNaN(+identifiers.id)
3653
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2633
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
3654
2634
  : _super.get.call(this, identifiers);
3655
2635
  });
3656
2636
  }
@@ -3659,13 +2639,12 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3659
2639
  update: { get: () => super.update }
3660
2640
  });
3661
2641
  return __awaiter(this, void 0, void 0, function* () {
3662
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
2642
+ const { products, id: checkId, metadata } = params, data = __rest(params, ["products", "id", "metadata"]);
3663
2643
  const plainData = this.paramsToPlain({ id: checkId });
3664
2644
  const id = yield this.getId(plainData.id);
3665
- const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: false }));
2645
+ const category = yield _super.update.call(this, Object.assign({ id }, data));
3666
2646
  category.products = products && (yield this.updateProducts(+id, { products }));
3667
2647
  category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
3668
- category.filters = filters && (yield this.updateFilters(+id, { filters }));
3669
2648
  return category;
3670
2649
  });
3671
2650
  }
@@ -3673,42 +2652,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3673
2652
  return __awaiter(this, void 0, void 0, function* () {
3674
2653
  if (!slug)
3675
2654
  return null;
3676
- const { data } = yield this.find({
3677
- filters: {
3678
- slug,
3679
- shops: { operator: Where.IN, value: [shop] },
3680
- published: { operator: Where.EQUALS, value: true },
3681
- isWishlist: { operator: Where.EQUALS, value: false },
3682
- },
3683
- options: {
3684
- enableCount: false,
3685
- },
3686
- });
3687
- if (!data.length)
3688
- throw new NotFoundError(`Category with slug ${slug} not found`);
3689
- if (data.length > 1)
2655
+ const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
2656
+ if (count > 1)
3690
2657
  throw new DuplicatedResultsError('Query returned duplicated values');
2658
+ if (!count)
2659
+ throw new NotFoundError(`Category with slug ${slug} not found`);
3691
2660
  return data.shift();
3692
2661
  });
3693
2662
  }
3694
- getCategoryByShop(shop) {
3695
- return __awaiter(this, void 0, void 0, function* () {
3696
- if (!shop)
3697
- return;
3698
- const { data } = yield this.find({
3699
- filters: {
3700
- shops: { operator: Where.IN, value: [shop] },
3701
- published: { operator: Where.EQUALS, value: true },
3702
- isWishlist: { operator: Where.EQUALS, value: false },
3703
- },
3704
- options: {
3705
- enableCount: false,
3706
- },
3707
- });
3708
- return data;
3709
- });
3710
- }
3711
- getCategoriesForHome(categoryIds, limit = 4, gender) {
2663
+ getCategoriesForHome(categoryIds, limit = 4) {
3712
2664
  return __awaiter(this, void 0, void 0, function* () {
3713
2665
  if (!(categoryIds === null || categoryIds === void 0 ? void 0 : categoryIds.length))
3714
2666
  return [];
@@ -3728,7 +2680,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3728
2680
  const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
3729
2681
  return ({
3730
2682
  category,
3731
- products: yield this.mountCategory(category, { limit, hasStock: true, gender }),
2683
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
3732
2684
  });
3733
2685
  })));
3734
2686
  return homeSections;
@@ -3740,7 +2692,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3740
2692
  if (!((_a = category === null || category === void 0 ? void 0 : category.products) === null || _a === void 0 ? void 0 : _a.length))
3741
2693
  return [];
3742
2694
  const products = [];
3743
- const { data: productsData } = yield this.productRepository.find(Object.assign(Object.assign({ filters: Object.assign(Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), ((options === null || options === void 0 ? void 0 : options.gender) ? { tags: { operator: Where.IN, value: [options === null || options === void 0 ? void 0 : options.gender] } } : {})), fields: [
2695
+ const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, published: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
3744
2696
  'id',
3745
2697
  'name',
3746
2698
  'slug',
@@ -3764,9 +2716,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3764
2716
  'tags',
3765
2717
  'type',
3766
2718
  'shoppingCount',
3767
- 'gender',
3768
- 'createdAt',
3769
- ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})), { options: { enableCount: false } }));
2719
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
3770
2720
  products.push(...productsData);
3771
2721
  return products;
3772
2722
  });
@@ -3776,7 +2726,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3776
2726
  return __awaiter(this, void 0, void 0, function* () {
3777
2727
  if (!Number.isNaN(+id))
3778
2728
  return id;
3779
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
2729
+ const { data } = yield this.find({ filters: { firestoreId: id } });
3780
2730
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
3781
2731
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
3782
2732
  throw new NotFoundError(`Category with id ${id} not found`);
@@ -3834,220 +2784,15 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
3834
2784
  return plainData.metadata;
3835
2785
  });
3836
2786
  }
3837
- updateFilters(categoryId, { filters }) {
3838
- return __awaiter(this, void 0, void 0, function* () {
3839
- if ('action' in filters && filters.action === 'remove' && filters.value.length) {
3840
- for (let i = 0; i < filters.value.length; i++) {
3841
- yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
3842
- }
3843
- return [];
3844
- }
3845
- if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3846
- let filtersList = [];
3847
- const currentFilters = yield this.categoryFilterRepository
3848
- .find({
3849
- filters: {
3850
- categoryId,
3851
- },
3852
- })
3853
- .then((res) => res.data);
3854
- const currentFiltersId = currentFilters.map((f) => f.id);
3855
- const filtersUpdatedId = filters.value.map((f) => f.id);
3856
- const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
3857
- const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
3858
- for (const filter of filterToBeDeleted) {
3859
- const index = currentFilters.findIndex((f) => f.id == filter);
3860
- if (index != -1) {
3861
- currentFilters.splice(index, 1);
3862
- }
3863
- yield this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
3864
- }
3865
- for (const filter of filterToBeInserted) {
3866
- const newCategoryFilter = yield this.categoryFilterRepository.create({
3867
- filterId: filter,
3868
- categoryId,
3869
- });
3870
- filtersList.push(filter);
3871
- }
3872
- return filters.value;
3873
- }
3874
- if (Array.isArray(filters) && filters.length) {
3875
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
3876
- let filtersList = [];
3877
- for (let i = 0; i < filters.length; i++) {
3878
- const newCategoryFilter = yield this.categoryFilterRepository.create({
3879
- filterId: filters[i].id,
3880
- categoryId,
3881
- });
3882
- filtersList.push(newCategoryFilter);
3883
- }
3884
- return filters;
3885
- }
3886
- });
3887
- }
3888
- getChildren(parentId) {
3889
- return __awaiter(this, void 0, void 0, function* () {
3890
- const { category_tree } = yield this.query('category_tree', ['id', 'name', 'parent_id'], {
3891
- args: {
3892
- type: 'category_tree_args',
3893
- value: { parentid: parentId },
3894
- required: true,
3895
- },
3896
- });
3897
- return category_tree.map((category) => Category.toInstance(category));
3898
- });
3899
- }
3900
- isChild(id, parentId) {
3901
- return __awaiter(this, void 0, void 0, function* () {
3902
- const categoryTree = yield this.getChildren(parentId);
3903
- return categoryTree.some((c) => c.id == id.toString());
3904
- });
3905
- }
3906
- }
3907
-
3908
- class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3909
- constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
3910
- super({
3911
- tableName: 'filter',
3912
- model: Filter,
3913
- endpoint,
3914
- authOptions,
3915
- interceptors,
3916
- fields: [
3917
- 'id',
3918
- 'description',
3919
- 'slug',
3920
- 'enabled',
3921
- { createdAt: { columnName: 'created_at' } },
3922
- { updatedAt: { columnName: 'updated_at' } },
3923
- {
3924
- options: {
3925
- columnName: 'options',
3926
- foreignKeyColumn: { filterId: 'id' },
3927
- fields: [
3928
- 'id',
3929
- { filterId: { columnName: 'filter_id' } },
3930
- 'description',
3931
- { createdAt: { columnName: 'created_at' } },
3932
- { updatedAt: { columnName: 'updated_at' } },
3933
- ],
3934
- },
3935
- },
3936
- ],
3937
- });
3938
- this.filterOptionRepository = filterOptionRepository;
3939
- this.categoryFilterRepository = categoryFilterRepository;
3940
- }
3941
- update(params) {
3942
- const _super = Object.create(null, {
3943
- update: { get: () => super.update }
3944
- });
3945
- return __awaiter(this, void 0, void 0, function* () {
3946
- const { options } = params, data = __rest(params, ["options"]);
3947
- const filter = yield _super.update.call(this, data);
3948
- filter.options = yield this.updateOptions(+data.id, { options });
3949
- return filter;
3950
- });
3951
- }
3952
- updateOptions(filterId, { options }) {
3953
- return __awaiter(this, void 0, void 0, function* () {
3954
- if (!options)
3955
- return [];
3956
- if ('action' in options && options.action === 'remove' && options.value.length) {
3957
- for (let i = 0; i < options.value.length; i++) {
3958
- yield this.filterOptionRepository.delete({ id: options.value[i].id });
3959
- }
3960
- return [];
3961
- }
3962
- if ('action' in options && options.action === 'merge' && options.value.length) {
3963
- let filterOptions = [];
3964
- for (let i = 0; i < options.value.length; i++) {
3965
- try {
3966
- const hasFilter = yield this.filterOptionRepository.get({ id: options.value[i].id });
3967
- if (hasFilter)
3968
- filterOptions.push(hasFilter);
3969
- }
3970
- catch (error) {
3971
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options.value[i]), { filterId }));
3972
- filterOptions.push(newOption);
3973
- }
3974
- }
3975
- return filterOptions;
3976
- }
3977
- if (Array.isArray(options) && options.length) {
3978
- let filterOptions = [];
3979
- for (let i = 0; i < options.length; i++) {
3980
- try {
3981
- const hasFilter = yield this.filterOptionRepository.get({ id: options[i].id });
3982
- if (hasFilter)
3983
- filterOptions.push(hasFilter);
3984
- }
3985
- catch (error) {
3986
- const newOption = yield this.filterOptionRepository.create(Object.assign(Object.assign({}, options[i]), { filterId }));
3987
- filterOptions.push(newOption);
3988
- }
3989
- }
3990
- }
3991
- return [];
3992
- });
3993
- }
3994
- delete(params) {
3995
- const _super = Object.create(null, {
3996
- delete: { get: () => super.delete }
3997
- });
3998
- return __awaiter(this, void 0, void 0, function* () {
3999
- const { data: categoryFilters } = yield this.categoryFilterRepository.find({
4000
- filters: {
4001
- filterId: params.id,
4002
- },
4003
- });
4004
- if (categoryFilters.length)
4005
- throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
4006
- yield this.deleteOptions(+params.id);
4007
- yield _super.delete.call(this, { id: +params.id });
4008
- return;
4009
- });
4010
- }
4011
- deleteOptions(filterId) {
4012
- return __awaiter(this, void 0, void 0, function* () {
4013
- yield this.mutation('delete_filter_option', ['affected_rows'], {
4014
- where: {
4015
- type: 'filter_option_bool_exp',
4016
- required: true,
4017
- value: { filter_id: { _eq: filterId } },
4018
- },
4019
- });
4020
- });
4021
- }
4022
- }
4023
-
4024
- class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4025
- constructor({ endpoint, authOptions, interceptors, }) {
4026
- super({
4027
- tableName: 'filter_option',
4028
- model: FilterOption,
4029
- endpoint,
4030
- authOptions,
4031
- interceptors,
4032
- fields: [
4033
- 'id',
4034
- 'description',
4035
- { filterId: { columnName: 'filter_id' } },
4036
- { createdAt: { columnName: 'created_at' } },
4037
- { updatedAt: { columnName: 'updated_at' } },
4038
- ],
4039
- });
4040
- }
4041
2787
  }
4042
2788
 
4043
2789
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4044
- constructor({ endpoint, authOptions, interceptors, }) {
2790
+ constructor(endpoint, authOptions) {
4045
2791
  super({
4046
2792
  tableName: 'product',
4047
2793
  model: ProductHasuraGraphQL,
4048
2794
  endpoint,
4049
2795
  authOptions,
4050
- interceptors,
4051
2796
  fields: [],
4052
2797
  });
4053
2798
  this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id']))), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
@@ -4070,29 +2815,26 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4070
2815
  whoMustUse: data.who_must_use,
4071
2816
  howToUse: data.how_to_use,
4072
2817
  brand: data.brand_description,
4073
- ingredients: data.ingredients,
4074
2818
  }),
4075
- bindFindFilter: (filters) => {
4076
- 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 && {
2819
+ bindFindFilter: (sentence) => {
2820
+ const filters = Object.values(sentence).shift();
2821
+ 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 && {
4077
2822
  who_must_use: filters.whoMustUse,
4078
2823
  })), (filters.howToUse && {
4079
2824
  how_to_use: filters.howToUse,
4080
2825
  })), (filters.brand && {
4081
2826
  brand_description: filters.brand,
4082
- })), (filters.ingredients && {
4083
- ingredients: filters.ingredients,
4084
2827
  }));
4085
2828
  },
4086
- 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 && {
2829
+ 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 && {
4087
2830
  who_must_use: descriptionData.whoMustUse,
4088
- })), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand })), (descriptionData.ingredients && { ingredients: descriptionData.ingredients }))),
2831
+ })), (descriptionData.howToUse && { how_to_use: descriptionData.howToUse })), (descriptionData.brand && { brand_description: descriptionData.brand }))),
4089
2832
  },
4090
2833
  },
4091
2834
  { differentials: { columnName: 'differentials' } },
4092
2835
  { whoMustUse: { columnName: 'who_must_use' } },
4093
2836
  { howToUse: { columnName: 'how_to_use' } },
4094
2837
  { brandDescription: { columnName: 'brand_description' } },
4095
- { ingredients: { columnName: 'ingredients' } },
4096
2838
  { hasVariants: { columnName: 'has_variants' } },
4097
2839
  {
4098
2840
  images: {
@@ -4116,7 +2858,8 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4116
2858
  subscriberDiscountPercentage: data.subscriber_discount_percentage,
4117
2859
  subscriberPrice: data.subscriber_price,
4118
2860
  }),
4119
- bindFindFilter: (filters) => {
2861
+ bindFindFilter: (sentence) => {
2862
+ const filters = Object.values(sentence).shift();
4120
2863
  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) && {
4121
2864
  subscriber_discount_percentage: filters.subscriberDiscountPercentage,
4122
2865
  })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
@@ -4140,29 +2883,27 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4140
2883
  to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
4141
2884
  },
4142
2885
  },
4143
- { hasStock: { columnName: 'has_stock' } },
4144
2886
  'slug',
4145
2887
  'type',
4146
2888
  'video',
4147
2889
  'weight',
4148
2890
  'gender',
4149
- { intGender: { columnName: 'int_gender' } },
4150
2891
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
4151
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
4152
2892
  { isKit: { columnName: 'is_kit' } },
4153
2893
  { createdAt: { columnName: 'created_at' } },
4154
2894
  { updatedAt: { columnName: 'updated_at' } },
4155
- { rate: { columnName: 'rating' } },
4156
- { reviewsTotal: { columnName: 'reviews_total' } },
4157
- { shoppingCount: { columnName: 'shopping_count' } },
4158
- { categoryId: { columnName: 'category_id' } },
4159
2895
  {
4160
- category: {
4161
- columnName: 'category',
4162
- foreignKeyColumn: { id: 'categoryId' },
4163
- fields: ['id', 'name', 'reference', 'slug'],
2896
+ rate: {
2897
+ columnName: 'reviews_aggregate',
2898
+ filters: {
2899
+ filters: { status: true },
2900
+ filterType: 'product_review_bool_exp',
2901
+ },
2902
+ fields: [{ aggregate: [{ avg: ['rate'] }] }],
2903
+ from: (value) => value.aggregate.avg.rate,
4164
2904
  },
4165
2905
  },
2906
+ { shoppingCount: { columnName: 'shopping_count' } },
4166
2907
  ];
4167
2908
  this.fields = [
4168
2909
  ...commonFields,
@@ -4249,7 +2990,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4249
2990
  var _a;
4250
2991
  return __awaiter(this, void 0, void 0, function* () {
4251
2992
  const product = Number.isNaN(+identifiers.id)
4252
- ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data) === null || _a === void 0 ? void 0 : _a[0]
2993
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
4253
2994
  : yield _super.get.call(this, identifiers);
4254
2995
  if (product.productId)
4255
2996
  throw new NotFoundError('Product not found, it is a variant');
@@ -4261,29 +3002,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4261
3002
  const _super = Object.create(null, {
4262
3003
  find: { get: () => super.find }
4263
3004
  });
4264
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4265
3005
  return __awaiter(this, void 0, void 0, function* () {
4266
- const _o = params || {}, { filters, fields } = _o, options = __rest(_o, ["filters", "fields"]);
3006
+ const _a = params || {}, { filters, fields } = _a, options = __rest(_a, ["filters", "fields"]);
4267
3007
  const bindFields = fields ||
4268
3008
  this.fields
4269
3009
  .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
4270
3010
  .filter((field) => field !== 'reviews');
4271
- if ((_b = (_a = options.options) === null || _a === void 0 ? void 0 : _a.minimal) === null || _b === void 0 ? void 0 : _b.includes('price'))
4272
- (_c = options.options) === null || _c === void 0 ? void 0 : _c.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4273
- if ((_e = (_d = options.options) === null || _d === void 0 ? void 0 : _d.maximum) === null || _e === void 0 ? void 0 : _e.includes('price'))
4274
- (_f = options.options) === null || _f === void 0 ? void 0 : _f.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4275
- (_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);
4276
- (_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);
4277
- return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: [
4278
- ...bindFields,
4279
- ...(bindFields.includes('price')
4280
- ? [
4281
- 'subscriberPrice',
4282
- 'subscriberDiscountPercentage',
4283
- 'fullPrice',
4284
- ]
4285
- : []),
4286
- ] }));
3011
+ return _super.find.call(this, Object.assign(Object.assign({}, options), { filters: Object.assign(Object.assign({}, filters), { productId: { operator: Where.ISNULL } }), fields: bindFields }));
4287
3012
  });
4288
3013
  }
4289
3014
  getBySlug(slug) {
@@ -4293,13 +3018,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4293
3018
  filters: {
4294
3019
  slug,
4295
3020
  },
4296
- fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
4297
- options: {
4298
- enableCount: false,
4299
- },
4300
3021
  });
4301
3022
  const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
4302
- RoundProductPricesHelper.roundProductPrices(product);
3023
+ product.reviews = yield this.findReviewsByProduct(+product.id);
4303
3024
  return product;
4304
3025
  });
4305
3026
  }
@@ -4339,11 +3060,6 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4339
3060
  ], []);
4340
3061
  });
4341
3062
  }
4342
- findCatalog(params, mainGender) {
4343
- return __awaiter(this, void 0, void 0, function* () {
4344
- 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'])) }));
4345
- });
4346
- }
4347
3063
  updateCategories(productId, { categories }) {
4348
3064
  return __awaiter(this, void 0, void 0, function* () {
4349
3065
  if ('action' in categories && categories.action === 'remove') {
@@ -4467,7 +3183,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4467
3183
  return __awaiter(this, void 0, void 0, function* () {
4468
3184
  if (!Number.isNaN(+id))
4469
3185
  return id;
4470
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3186
+ const { data } = yield this.find({ filters: { firestoreId: id } });
4471
3187
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
4472
3188
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
4473
3189
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -4523,31 +3239,15 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4523
3239
  return data && data[0] && this.bindReviewToModel(data[0]);
4524
3240
  });
4525
3241
  }
4526
- cleanShoppingCountFromIds(ids) {
4527
- return __awaiter(this, void 0, void 0, function* () {
4528
- return yield this.mutation('update_product', ['affected_rows'], {
4529
- where: {
4530
- value: { id: { _nin: ids } },
4531
- type: 'product_bool_exp',
4532
- required: true,
4533
- },
4534
- _set: {
4535
- value: { shopping_count: 0 },
4536
- type: 'product_set_input',
4537
- },
4538
- });
4539
- });
4540
- }
4541
3242
  }
4542
3243
 
4543
3244
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4544
- constructor({ endpoint, authOptions, interceptors, }) {
3245
+ constructor(endpoint, authOptions) {
4545
3246
  super({
4546
3247
  tableName: 'product',
4547
3248
  model: VariantHasuraGraphQL,
4548
3249
  endpoint,
4549
3250
  authOptions,
4550
- interceptors,
4551
3251
  fields: [
4552
3252
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4553
3253
  { firestoreId: { columnName: 'firestore_id' } },
@@ -4577,9 +3277,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4577
3277
  subscriber_price: filters.subscriberPrice,
4578
3278
  }));
4579
3279
  },
4580
- bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, (((priceData === null || priceData === void 0 ? void 0 : priceData.price) || 0) >= 0 && { price: priceData.price })), (((priceData === null || priceData === void 0 ? void 0 : priceData.fullPrice) || 0) >= 0 && { full_price: priceData.fullPrice })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberDiscountPercentage) || 0) >= 0 && {
3280
+ bindPersistData: (priceData) => (Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
4581
3281
  subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4582
- })), (((priceData === null || priceData === void 0 ? void 0 : priceData.subscriberPrice) || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }))),
3282
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }))),
4583
3283
  },
4584
3284
  },
4585
3285
  { fullPrice: { columnName: 'full_price' } },
@@ -4593,7 +3293,6 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4593
3293
  to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
4594
3294
  },
4595
3295
  },
4596
- { hasStock: { columnName: 'has_stock' } },
4597
3296
  'weight',
4598
3297
  { name: { to: () => '', from: () => undefined } },
4599
3298
  { hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
@@ -4649,7 +3348,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4649
3348
  return __awaiter(this, void 0, void 0, function* () {
4650
3349
  if (!Number.isNaN(+id))
4651
3350
  return id;
4652
- const { data } = yield this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3351
+ const { data } = yield this.find({ filters: { firestoreId: id } });
4653
3352
  if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
4654
3353
  return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
4655
3354
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -4657,256 +3356,9 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
4657
3356
  }
4658
3357
  }
4659
3358
 
4660
- class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4661
- constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
4662
- super({
4663
- tableName: 'category',
4664
- model: Wishlist,
4665
- endpoint,
4666
- authOptions,
4667
- interceptors,
4668
- fields: [
4669
- { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4670
- { firestoreId: { columnName: 'firestore_id' } },
4671
- 'name',
4672
- 'description',
4673
- 'image',
4674
- 'published',
4675
- 'shop',
4676
- { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
4677
- 'slug',
4678
- { brandCategory: { columnName: 'brand_category' } },
4679
- { brandCategoryBanner: { columnName: 'brand_banner' } },
4680
- { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
4681
- { brandLogo: { columnName: 'brand_logo' } },
4682
- { brandCondition: { columnName: 'brand_condition' } },
4683
- {
4684
- conditions: {
4685
- columnName: 'tag_condition',
4686
- type: HasuraGraphQLColumnType.Jsonb,
4687
- from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
4688
- bindPersistData: (value) => {
4689
- return {
4690
- brand_condition: value.brand,
4691
- tag_condition: (value === null || value === void 0 ? void 0 : value.tags) || [],
4692
- };
4693
- },
4694
- bindFindFilter: (sentence) => {
4695
- return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
4696
- },
4697
- },
4698
- },
4699
- {
4700
- filters: {
4701
- columnName: 'filters',
4702
- foreignKeyColumn: { filter_id: 'id' },
4703
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4704
- bindPersistData: (value) => ({
4705
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4706
- }),
4707
- from: (filters) => (filters === null || filters === void 0 ? void 0 : filters.map((filter) => filter === null || filter === void 0 ? void 0 : filter.filter)) || [],
4708
- },
4709
- },
4710
- { createdAt: { columnName: 'created_at' } },
4711
- { updatedAt: { columnName: 'updated_at' } },
4712
- {
4713
- products: {
4714
- columnName: 'products',
4715
- fields: ['product_id'],
4716
- from: (value) => value.map((product) => product.product_id.toString()),
4717
- to: (productIds) => productIds.map((productId) => ({
4718
- product_id: +productId,
4719
- })),
4720
- },
4721
- },
4722
- {
4723
- metadata: {
4724
- columnName: 'metadata',
4725
- fields: ['title', 'description'],
4726
- bindPersistData: (value) => ({
4727
- metadata: { data: value },
4728
- }),
4729
- },
4730
- },
4731
- { isCollection: { columnName: 'is_collection' } },
4732
- { isWishlist: { columnName: 'is_wishlist' } },
4733
- 'reference',
4734
- { parentId: { columnName: 'parent_id' } },
4735
- {
4736
- parent: {
4737
- columnName: 'parent',
4738
- foreignKeyColumn: { id: 'parentId' },
4739
- fields: ['id', 'name', 'reference', 'slug'],
4740
- },
4741
- },
4742
- { personId: { columnName: 'person_id' } },
4743
- ],
4744
- });
4745
- this.categoryFilterRepository = categoryFilterRepository;
4746
- }
4747
- create(params) {
4748
- const _super = Object.create(null, {
4749
- create: { get: () => super.create }
4750
- });
4751
- return __awaiter(this, void 0, void 0, function* () {
4752
- const { metadata } = params, data = __rest(params, ["metadata"]);
4753
- return _super.create.call(this, Object.assign(Object.assign({}, data), { isWishlist: true, isCollection: true, brandCategory: false, metadata: metadata || { description: data.description, title: data.name } }));
4754
- });
4755
- }
4756
- get(identifiers) {
4757
- const _super = Object.create(null, {
4758
- get: { get: () => super.get }
4759
- });
4760
- return __awaiter(this, void 0, void 0, function* () {
4761
- const data = yield _super.get.call(this, identifiers);
4762
- if (!data.isWishlist)
4763
- throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
4764
- return data;
4765
- });
4766
- }
4767
- update(params) {
4768
- const _super = Object.create(null, {
4769
- update: { get: () => super.update }
4770
- });
4771
- return __awaiter(this, void 0, void 0, function* () {
4772
- const { products, id: checkId, metadata, filters } = params, data = __rest(params, ["products", "id", "metadata", "filters"]);
4773
- const plainData = this.paramsToPlain({ id: checkId });
4774
- const id = plainData.id;
4775
- const category = yield _super.update.call(this, Object.assign(Object.assign({ id }, data), { isWishlist: true, isCollection: true, brandCategory: false }));
4776
- category.products = products && (yield this.updateProducts(+id, { products }));
4777
- category.metadata = metadata && (yield this.updateMetadata(+id, { metadata }));
4778
- return category;
4779
- });
4780
- }
4781
- getWishlistBySlug(slug) {
4782
- return __awaiter(this, void 0, void 0, function* () {
4783
- if (!slug)
4784
- return;
4785
- const { data } = yield this.find({
4786
- filters: {
4787
- slug,
4788
- isWishlist: { operator: Where.EQUALS, value: true },
4789
- },
4790
- options: {
4791
- enableCount: false,
4792
- },
4793
- });
4794
- if (!data.length)
4795
- throw new NotFoundError(`Wishlist with slug ${slug} not found`);
4796
- if (data.length > 1)
4797
- throw new DuplicatedResultsError('Query returned duplicated values');
4798
- return data.shift();
4799
- });
4800
- }
4801
- getWishlistByPerson(personId) {
4802
- return __awaiter(this, void 0, void 0, function* () {
4803
- if (!personId)
4804
- return;
4805
- const { data } = yield this.find({
4806
- filters: {
4807
- personId: { operator: Where.EQUALS, value: personId },
4808
- isWishlist: { operator: Where.EQUALS, value: true },
4809
- },
4810
- options: {
4811
- enableCount: false,
4812
- },
4813
- });
4814
- if (!data.length)
4815
- throw new NotFoundError(`Wishlists from person ${personId} not found`);
4816
- return data;
4817
- });
4818
- }
4819
- updateProducts(categoryId, { products }) {
4820
- return __awaiter(this, void 0, void 0, function* () {
4821
- if ('action' in products && products.action === 'remove') {
4822
- yield this.mutation('delete_category_product', ['affected_rows'], {
4823
- where: {
4824
- type: 'category_product_bool_exp',
4825
- required: true,
4826
- value: { category_id: { _eq: categoryId } },
4827
- },
4828
- });
4829
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
4830
- return [];
4831
- }
4832
- const plainData = this.paramsToPlain({ products });
4833
- if (!plainData.products || plainData.products.length <= 0)
4834
- return [];
4835
- yield this.mutation('delete_category_product', ['affected_rows'], {
4836
- where: {
4837
- type: 'category_product_bool_exp',
4838
- required: true,
4839
- value: { category_id: { _eq: categoryId } },
4840
- },
4841
- });
4842
- yield this.categoryFilterRepository.deleteByCategory(categoryId);
4843
- yield this.mutation('insert_category_product', ['affected_rows'], {
4844
- objects: {
4845
- type: '[category_product_insert_input!]',
4846
- required: true,
4847
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4848
- },
4849
- });
4850
- return plainData.products;
4851
- });
4852
- }
4853
- updateMetadata(categoryId, { metadata }) {
4854
- return __awaiter(this, void 0, void 0, function* () {
4855
- const plainData = this.paramsToPlain({ metadata });
4856
- if (!plainData.metadata)
4857
- return;
4858
- yield this.mutation('update_category_metadata_by_pk', ['category_id'], {
4859
- pk_columns: {
4860
- value: { category_id: categoryId },
4861
- type: 'category_metadata_pk_columns_input',
4862
- required: true,
4863
- },
4864
- _set: {
4865
- value: omit(metadata, ['category_id']),
4866
- type: 'category_metadata_set_input',
4867
- required: true,
4868
- },
4869
- });
4870
- return plainData.metadata;
4871
- });
4872
- }
4873
- getCategoryBySlug(slug, _shop) {
4874
- return this.getWishlistBySlug(slug);
4875
- }
4876
- getCategoryByShop(shop) {
4877
- return __awaiter(this, void 0, void 0, function* () {
4878
- if (!shop)
4879
- return;
4880
- const { data } = yield this.find({
4881
- filters: {
4882
- shops: { operator: Where.IN, value: [shop] },
4883
- published: { operator: Where.EQUALS, value: true },
4884
- isWishlist: { operator: Where.EQUALS, value: true },
4885
- },
4886
- options: {
4887
- enableCount: false,
4888
- },
4889
- });
4890
- return data;
4891
- });
4892
- }
4893
- getCategoriesForHome(categoryIds, limit, gender) {
4894
- return;
4895
- }
4896
- mountCategory(category, options) {
4897
- return;
4898
- }
4899
- getChildren(parentId) {
4900
- return;
4901
- }
4902
- isChild(id, parentId) {
4903
- return;
4904
- }
4905
- }
4906
-
4907
3359
  /**
4908
3360
  * Generated bundle index. Do not edit.
4909
3361
  */
4910
3362
 
4911
- 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 };
3363
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, chunk, get, is, isBoolean, isDate, isEmpty, isInteger, isNaN$1 as isNaN, isNil, isNumber, isObject, isString, isUUID, now, omit, parseDateTime, pick, set, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
4912
3364
  //# sourceMappingURL=infrab4a-connect.mjs.map