@infrab4a/connect 4.0.0-beta.3 → 4.0.0-beta.31

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 (280) hide show
  1. package/domain/catalog/helpers/index.d.ts +1 -0
  2. package/domain/catalog/helpers/round-product-price.helper.d.ts +4 -0
  3. package/domain/catalog/index.d.ts +1 -0
  4. package/domain/catalog/models/category-collection-children.d.ts +13 -0
  5. package/domain/catalog/models/category-filter.d.ts +11 -0
  6. package/domain/catalog/models/category.d.ts +10 -5
  7. package/domain/catalog/models/filter-option.d.ts +9 -0
  8. package/domain/catalog/models/filter.d.ts +12 -0
  9. package/domain/catalog/models/index.d.ts +4 -0
  10. package/domain/catalog/models/kit-product.d.ts +1 -1
  11. package/domain/catalog/models/product.d.ts +8 -3
  12. package/domain/catalog/models/types/category-product.d.ts +4 -0
  13. package/domain/catalog/models/types/index.d.ts +2 -1
  14. package/domain/catalog/models/types/product-evaluation.type.d.ts +6 -0
  15. package/domain/catalog/models/types/shop-description.type.d.ts +1 -0
  16. package/domain/catalog/models/variant.d.ts +1 -2
  17. package/domain/catalog/repositories/category-collection-children.repository.d.ts +4 -0
  18. package/domain/catalog/repositories/category-filter.repository.d.ts +5 -0
  19. package/domain/catalog/repositories/category.repository.d.ts +6 -3
  20. package/domain/catalog/repositories/filter-option.repository.d.ts +4 -0
  21. package/domain/catalog/repositories/filter.repository.d.ts +4 -0
  22. package/domain/catalog/repositories/index.d.ts +4 -0
  23. package/domain/catalog/repositories/product.repository.d.ts +1 -0
  24. package/domain/generic/model/base.model.d.ts +9 -5
  25. package/domain/generic/model/types/base-model-builder.type.d.ts +4 -2
  26. package/domain/generic/model/types/identifier-model.type.d.ts +6 -5
  27. package/domain/generic/model/types/model-base-structure.type.d.ts +9 -3
  28. package/domain/generic/model/types/non-function-property-name.type.d.ts +12 -3
  29. package/domain/generic/repository/find.repository.d.ts +3 -0
  30. package/domain/generic/repository/get.repository.d.ts +2 -2
  31. package/domain/generic/repository/types/repository-find-filters.type.d.ts +3 -3
  32. package/domain/generic/repository/types/repository-order-by-list.type.d.ts +2 -2
  33. package/domain/generic/repository/types/repository-update-params.type.d.ts +2 -2
  34. package/domain/location/models/address.d.ts +5 -3
  35. package/domain/shop-settings/models/index.d.ts +1 -0
  36. package/domain/shop-settings/models/shop-settings.d.ts +9 -0
  37. package/domain/shop-settings/models/types/index.d.ts +6 -1
  38. package/domain/shop-settings/models/types/shop-banner.type.d.ts +12 -0
  39. package/domain/shop-settings/models/types/shop-brands.type.d.ts +10 -0
  40. package/domain/shop-settings/models/types/shop-carousel.type.d.ts +5 -0
  41. package/domain/shop-settings/models/types/shop-collection.type.d.ts +9 -0
  42. package/domain/shop-settings/models/types/shop-section.type.d.ts +9 -0
  43. package/domain/shop-settings/repositories/index.d.ts +1 -0
  44. package/domain/shop-settings/repositories/shop-settings.repository.d.ts +4 -0
  45. package/domain/shopping/models/buy-2-win.d.ts +3 -1
  46. package/domain/shopping/models/campaign-dashboard.d.ts +15 -0
  47. package/domain/shopping/models/campaign-hashtag.d.ts +18 -0
  48. package/domain/shopping/models/checkout.d.ts +5 -6
  49. package/domain/shopping/models/index.d.ts +5 -4
  50. package/domain/shopping/models/subscription/checkout.d.ts +3 -4
  51. package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +4 -0
  52. package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +4 -0
  53. package/domain/shopping/repositories/index.d.ts +4 -2
  54. package/domain/users/models/lead.d.ts +1 -0
  55. package/domain/users/models/subscription/subscription.d.ts +3 -3
  56. package/domain/users/models/user-address.d.ts +1 -2
  57. package/domain/users/models/user.d.ts +2 -3
  58. package/esm2020/domain/catalog/helpers/index.mjs +2 -0
  59. package/esm2020/domain/catalog/helpers/round-product-price.helper.mjs +15 -0
  60. package/esm2020/domain/catalog/index.mjs +2 -1
  61. package/esm2020/domain/catalog/models/category-collection-children.mjs +13 -0
  62. package/esm2020/domain/catalog/models/category-filter.mjs +14 -0
  63. package/esm2020/domain/catalog/models/category.mjs +12 -4
  64. package/esm2020/domain/catalog/models/filter-option.mjs +7 -0
  65. package/esm2020/domain/catalog/models/filter.mjs +7 -0
  66. package/esm2020/domain/catalog/models/index.mjs +5 -1
  67. package/esm2020/domain/catalog/models/kit-product.mjs +2 -2
  68. package/esm2020/domain/catalog/models/product.mjs +23 -3
  69. package/esm2020/domain/catalog/models/types/category-product.mjs +2 -0
  70. package/esm2020/domain/catalog/models/types/index.mjs +3 -2
  71. package/esm2020/domain/catalog/models/types/product-evaluation.type.mjs +2 -0
  72. package/esm2020/domain/catalog/models/types/shop-description.type.mjs +1 -1
  73. package/esm2020/domain/catalog/models/variant.mjs +1 -4
  74. package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +2 -0
  75. package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +2 -0
  76. package/esm2020/domain/catalog/repositories/category.repository.mjs +1 -1
  77. package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +2 -0
  78. package/esm2020/domain/catalog/repositories/filter.repository.mjs +2 -0
  79. package/esm2020/domain/catalog/repositories/index.mjs +5 -1
  80. package/esm2020/domain/catalog/repositories/product.repository.mjs +1 -1
  81. package/esm2020/domain/generic/model/base.model.mjs +3 -2
  82. package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +1 -1
  83. package/esm2020/domain/generic/model/types/identifier-model.type.mjs +1 -1
  84. package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +1 -1
  85. package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +1 -1
  86. package/esm2020/domain/generic/repository/find.repository.mjs +1 -1
  87. package/esm2020/domain/generic/repository/get.repository.mjs +1 -1
  88. package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +1 -1
  89. package/esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs +1 -1
  90. package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +1 -1
  91. package/esm2020/domain/location/models/address.mjs +2 -2
  92. package/esm2020/domain/shop-settings/models/index.mjs +2 -1
  93. package/esm2020/domain/shop-settings/models/shop-settings.mjs +7 -0
  94. package/esm2020/domain/shop-settings/models/types/index.mjs +7 -2
  95. package/esm2020/domain/shop-settings/models/types/shop-banner.type.mjs +2 -0
  96. package/esm2020/domain/shop-settings/models/types/shop-brands.type.mjs +2 -0
  97. package/esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs +2 -0
  98. package/esm2020/domain/shop-settings/models/types/shop-collection.type.mjs +2 -0
  99. package/esm2020/domain/shop-settings/models/types/shop-section.type.mjs +2 -0
  100. package/esm2020/domain/shop-settings/repositories/index.mjs +2 -1
  101. package/esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs +2 -0
  102. package/esm2020/domain/shopping/models/buy-2-win.mjs +2 -2
  103. package/esm2020/domain/shopping/models/campaign-dashboard.mjs +7 -0
  104. package/esm2020/domain/shopping/models/campaign-hashtag.mjs +7 -0
  105. package/esm2020/domain/shopping/models/checkout.mjs +6 -7
  106. package/esm2020/domain/shopping/models/index.mjs +6 -5
  107. package/esm2020/domain/shopping/models/order.mjs +1 -1
  108. package/esm2020/domain/shopping/models/subscription/checkout.mjs +6 -6
  109. package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +2 -0
  110. package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +2 -0
  111. package/esm2020/domain/shopping/repositories/index.mjs +5 -3
  112. package/esm2020/domain/users/models/lead.mjs +1 -1
  113. package/esm2020/domain/users/models/subscription/edition.mjs +1 -1
  114. package/esm2020/domain/users/models/subscription/payment.mjs +1 -1
  115. package/esm2020/domain/users/models/subscription/subscription.mjs +6 -6
  116. package/esm2020/domain/users/models/user-address.mjs +1 -1
  117. package/esm2020/domain/users/models/user-payment-method.mjs +1 -1
  118. package/esm2020/domain/users/models/user.mjs +2 -2
  119. package/esm2020/domain/users/use-cases/authentication.mjs +2 -2
  120. package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +28 -11
  121. package/esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs +1 -1
  122. package/esm2020/infra/elasticsearch/indexes/products-index.mjs +63 -51
  123. package/esm2020/infra/elasticsearch/types/elastic-search-result.mjs +1 -1
  124. package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +8 -4
  125. package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +1 -1
  126. package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +6 -2
  127. package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +10 -7
  128. package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +27 -4
  129. package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +6 -3
  130. package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +1 -1
  131. package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +5 -3
  132. package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +7 -4
  133. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +21 -8
  134. package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +11 -6
  135. package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +10 -8
  136. package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +8 -6
  137. package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +36 -30
  138. package/esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs +2 -1
  139. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +8 -6
  140. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +14 -0
  141. package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +8 -6
  142. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +14 -0
  143. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +14 -0
  144. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +8 -6
  145. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +8 -6
  146. package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +8 -6
  147. package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +6 -4
  148. package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +6 -4
  149. package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +11 -9
  150. package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +8 -6
  151. package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +8 -6
  152. package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +8 -6
  153. package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +10 -8
  154. package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +8 -6
  155. package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +10 -8
  156. package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +10 -8
  157. package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +10 -8
  158. package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +8 -6
  159. package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +10 -8
  160. package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +2 -0
  161. package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +1 -1
  162. package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +1 -1
  163. package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +1 -1
  164. package/esm2020/infra/firebase/firestore/types/index.mjs +4 -3
  165. package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +2 -2
  166. package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +5 -4
  167. package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +1 -1
  168. package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +36 -25
  169. package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +6 -4
  170. package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +1 -1
  171. package/esm2020/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.mjs +5 -3
  172. package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +36 -15
  173. package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +5 -3
  174. package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +40 -24
  175. package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +7 -5
  176. package/esm2020/infra/hasura-graphql/models/product-hasura-graphql.mjs +1 -1
  177. package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +38 -0
  178. package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +56 -0
  179. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +144 -12
  180. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +105 -0
  181. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +22 -0
  182. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +5 -1
  183. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +49 -16
  184. package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +8 -7
  185. package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +1 -1
  186. package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +1 -1
  187. package/esm2020/utils/decorators/debug.class.decorator.mjs +7 -0
  188. package/esm2020/utils/decorators/index.mjs +3 -0
  189. package/esm2020/utils/decorators/trace.method.decorator.mjs +81 -0
  190. package/esm2020/utils/helpers/class-name.helper.mjs +15 -0
  191. package/esm2020/utils/helpers/debug-decorator.helper.mjs +18 -0
  192. package/esm2020/utils/helpers/debug.helper.mjs +150 -0
  193. package/esm2020/utils/helpers/index.mjs +5 -0
  194. package/esm2020/utils/helpers/reflect.helper.mjs +165 -0
  195. package/esm2020/utils/index.mjs +6 -4
  196. package/esm2020/utils/log.utils.mjs +9 -0
  197. package/fesm2015/infrab4a-connect.mjs +1537 -392
  198. package/fesm2015/infrab4a-connect.mjs.map +1 -1
  199. package/fesm2020/infrab4a-connect.mjs +1501 -388
  200. package/fesm2020/infrab4a-connect.mjs.map +1 -1
  201. package/infra/elasticsearch/adapters/axios.adapter.d.ts +7 -5
  202. package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +3 -2
  203. package/infra/elasticsearch/indexes/products-index.d.ts +8 -10
  204. package/infra/elasticsearch/types/elastic-search-result.d.ts +2 -0
  205. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +2 -2
  206. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +2 -1
  207. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +2 -2
  208. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +2 -2
  209. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +13 -4
  210. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +2 -2
  211. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +2 -2
  212. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +8 -4
  213. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +3 -3
  214. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +8 -5
  215. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +4 -4
  216. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +3 -4
  217. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +3 -4
  218. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +4 -4
  219. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +1 -0
  220. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +3 -4
  221. package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +7 -0
  222. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +3 -4
  223. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +8 -0
  224. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +8 -0
  225. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +3 -4
  226. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +3 -4
  227. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +4 -4
  228. package/infra/firebase/firestore/repositories/shopping/index.d.ts +5 -3
  229. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +3 -4
  230. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +4 -4
  231. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +3 -4
  232. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +3 -4
  233. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +3 -4
  234. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +3 -4
  235. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +3 -4
  236. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +3 -4
  237. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +3 -4
  238. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +3 -4
  239. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +4 -4
  240. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +3 -4
  241. package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +14 -0
  242. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
  243. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +5 -5
  244. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +3 -1
  245. package/infra/firebase/firestore/types/index.d.ts +3 -2
  246. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +9 -3
  247. package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +5 -5
  248. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +4 -2
  249. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +8 -5
  250. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +2 -1
  251. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +3 -3
  252. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +1 -1
  253. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +12 -15
  254. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +7 -6
  255. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +14 -3
  256. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +2 -2
  257. package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +2 -0
  258. package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +10 -0
  259. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +11 -0
  260. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +12 -5
  261. package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +18 -0
  262. package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +10 -0
  263. package/infra/hasura-graphql/repositories/catalog/index.d.ts +4 -0
  264. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +4 -3
  265. package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +4 -4
  266. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +7 -5
  267. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +7 -3
  268. package/package.json +2 -1
  269. package/utils/decorators/debug.class.decorator.d.ts +2 -0
  270. package/utils/decorators/index.d.ts +2 -0
  271. package/utils/decorators/trace.method.decorator.d.ts +14 -0
  272. package/utils/helpers/class-name.helper.d.ts +3 -0
  273. package/utils/helpers/debug-decorator.helper.d.ts +9 -0
  274. package/utils/helpers/debug.helper.d.ts +60 -0
  275. package/utils/helpers/index.d.ts +4 -0
  276. package/utils/helpers/reflect.helper.d.ts +50 -0
  277. package/utils/index.d.ts +5 -22
  278. package/utils/log.utils.d.ts +7 -0
  279. package/domain/catalog/models/types/category-filter.type.d.ts +0 -4
  280. package/esm2020/domain/catalog/models/types/category-filter.type.mjs +0 -2
@@ -3,19 +3,21 @@ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transforme
3
3
  import { __decorate, __metadata } from 'tslib';
4
4
  import { parseISO } from 'date-fns';
5
5
  export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
- import * as lodash from 'lodash';
7
- import { get as get$1, isString as isString$1 } from 'lodash';
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, 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';
8
10
  import { CustomError } from 'ts-custom-error';
9
11
  import axios from 'axios';
10
12
  import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
11
13
  import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
12
14
  import { mutation, query as query$1 } from 'gql-query-builder';
13
- import fetch from 'node-fetch';
14
15
 
15
16
  class BaseModel {
16
17
  get identifier() {
17
18
  const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
18
- return fields.reduce((object, field) => ({ ...object, [field]: this[field] }), {});
19
+ const data = this;
20
+ return fields.reduce((object, field) => ({ ...object, [field]: data[field] }), {});
19
21
  }
20
22
  get identifiersFields() {
21
23
  return this.constructor.identifiersFields;
@@ -461,11 +463,437 @@ __decorate([
461
463
  __metadata("design:type", Payment)
462
464
  ], SubscriptionPayment.prototype, "payment", void 0);
463
465
 
464
- class Address extends BaseModel {
465
- static get identifiersFields() {
466
- return ['id'];
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
+ }
467
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(' ');
806
+ }
807
+ }
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({ 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
+ };
468
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
+ };
469
897
 
470
898
  const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
471
899
 
@@ -473,7 +901,7 @@ function is(value) {
473
901
  return value;
474
902
  }
475
903
 
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);
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);
477
905
 
478
906
  class Base {
479
907
  constructor(...args) {
@@ -482,7 +910,7 @@ class Base {
482
910
  }
483
911
 
484
912
  const parseDateTime = (value) => {
485
- if (!isString$1(value))
913
+ if (!isString(value))
486
914
  return value;
487
915
  if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
488
916
  !/^\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))
@@ -493,8 +921,6 @@ const parseDateTime = (value) => {
493
921
  return date;
494
922
  };
495
923
 
496
- const { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN: isNaN$1, isNil, isNumber, isObject, isString, now, omit, pick, set, } = lodash;
497
-
498
924
  var CheckoutTypes;
499
925
  (function (CheckoutTypes) {
500
926
  CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
@@ -598,6 +1024,18 @@ __decorate([
598
1024
  __metadata("design:type", BeautyProfile)
599
1025
  ], User.prototype, "beautyProfile", void 0);
600
1026
 
1027
+ class Address extends BaseModel {
1028
+ static get identifiersFields() {
1029
+ return ['id'];
1030
+ }
1031
+ }
1032
+
1033
+ class UserAddress extends Address {
1034
+ static get identifiersFields() {
1035
+ return ['id', 'userId'];
1036
+ }
1037
+ }
1038
+
601
1039
  class Subscription extends BaseModel {
602
1040
  static get identifiersFields() {
603
1041
  return ['id'];
@@ -612,12 +1050,12 @@ __decorate([
612
1050
  __metadata("design:type", SubscriptionPlan)
613
1051
  ], Subscription.prototype, "subscriptionPlan", void 0);
614
1052
  __decorate([
615
- Type(() => Address),
616
- __metadata("design:type", Address)
1053
+ Type(() => UserAddress),
1054
+ __metadata("design:type", UserAddress)
617
1055
  ], Subscription.prototype, "shippingAddress", void 0);
618
1056
  __decorate([
619
- Type(() => Address),
620
- __metadata("design:type", Address)
1057
+ Type(() => UserAddress),
1058
+ __metadata("design:type", UserAddress)
621
1059
  ], Subscription.prototype, "billingAddress", void 0);
622
1060
  __decorate([
623
1061
  Type(() => Coupon),
@@ -632,12 +1070,6 @@ __decorate([
632
1070
  __metadata("design:type", Array)
633
1071
  ], Subscription.prototype, "payment", void 0);
634
1072
 
635
- class UserAddress extends Address {
636
- static get identifiersFields() {
637
- return ['id', 'userId'];
638
- }
639
- }
640
-
641
1073
  class UserPaymentMethod extends BaseModel {
642
1074
  static get identifiersFields() {
643
1075
  return ['id', 'userId'];
@@ -669,7 +1101,7 @@ class Authentication {
669
1101
  async signIn({ email, password }, signInMethod) {
670
1102
  const method = this.getServiceByMethod(signInMethod);
671
1103
  const userAuth = await this.authService[method]({ email, password });
672
- const user = this.userRepository.get(userAuth);
1104
+ const user = this.userRepository.get({ id: userAuth.id });
673
1105
  if (!isNil(user))
674
1106
  return user;
675
1107
  if (/^.+@b4a.com.br$/.test(userAuth.email))
@@ -762,14 +1194,45 @@ class RecoveryPassword {
762
1194
  }
763
1195
  }
764
1196
 
1197
+ class Filter extends BaseModel {
1198
+ static get identifiersFields() {
1199
+ return ['id'];
1200
+ }
1201
+ }
1202
+
765
1203
  class Category extends BaseModel {
766
- identifierFields() {
1204
+ static get identifiersFields() {
767
1205
  return ['id'];
768
1206
  }
1207
+ }
1208
+ __decorate([
1209
+ Type(() => Category),
1210
+ __metadata("design:type", Category)
1211
+ ], Category.prototype, "parent", void 0);
1212
+ __decorate([
1213
+ Type(() => Filter),
1214
+ __metadata("design:type", Array)
1215
+ ], Category.prototype, "filters", void 0);
1216
+
1217
+ class CategoryCollectionChildren extends BaseModel {
1218
+ static get identifiersFields() {
1219
+ return ['collectionId', 'categoryId'];
1220
+ }
1221
+ }
1222
+ __decorate([
1223
+ Type(() => CategoryCollectionChildren),
1224
+ __metadata("design:type", CategoryCollectionChildren)
1225
+ ], CategoryCollectionChildren.prototype, "parent", void 0);
1226
+
1227
+ class CategoryFilter extends BaseModel {
769
1228
  static get identifiersFields() {
770
1229
  return ['id'];
771
1230
  }
772
1231
  }
1232
+ __decorate([
1233
+ Type(() => Filter),
1234
+ __metadata("design:type", Filter)
1235
+ ], CategoryFilter.prototype, "filter", void 0);
773
1236
 
774
1237
  var GenderDestination;
775
1238
  (function (GenderDestination) {
@@ -786,14 +1249,39 @@ var Shops;
786
1249
  Shops["ALL"] = "ALL";
787
1250
  })(Shops || (Shops = {}));
788
1251
 
789
- class Product extends BaseModel {
790
- identifierFields() {
1252
+ class FilterOption extends BaseModel {
1253
+ static get identifiersFields() {
791
1254
  return ['id'];
792
1255
  }
1256
+ }
1257
+
1258
+ class Product extends BaseModel {
1259
+ get evaluation() {
1260
+ return {
1261
+ reviews: this.reviews,
1262
+ count: this.reviewsTotal,
1263
+ rating: this.rate,
1264
+ };
1265
+ }
1266
+ set evaluation(evaluation) {
1267
+ if (!evaluation) {
1268
+ this.reviews = null;
1269
+ this.reviewsTotal = null;
1270
+ this.rate = null;
1271
+ return;
1272
+ }
1273
+ this.reviews = evaluation.reviews || this.reviews;
1274
+ this.reviewsTotal = evaluation.count || this.reviewsTotal;
1275
+ this.rate = evaluation.rating || this.rate;
1276
+ }
793
1277
  static get identifiersFields() {
794
1278
  return ['id'];
795
1279
  }
796
1280
  }
1281
+ __decorate([
1282
+ Type(() => Category),
1283
+ __metadata("design:type", Category)
1284
+ ], Product.prototype, "category", void 0);
797
1285
  __decorate([
798
1286
  Type(() => KitProduct),
799
1287
  __metadata("design:type", Array)
@@ -801,7 +1289,7 @@ __decorate([
801
1289
 
802
1290
  class KitProduct extends BaseModel {
803
1291
  static get identifiersFields() {
804
- return ['productId', 'kitProducId'];
1292
+ return ['productId', 'kitProductId'];
805
1293
  }
806
1294
  }
807
1295
  __decorate([
@@ -814,25 +1302,32 @@ __decorate([
814
1302
  ], KitProduct.prototype, "product", void 0);
815
1303
 
816
1304
  class Variant extends BaseModel {
817
- identifierFields() {
1305
+ static get identifiersFields() {
1306
+ return ['id', 'productId'];
1307
+ }
1308
+ }
1309
+
1310
+ class Buy2Win extends BaseModel {
1311
+ static get identifiersFields() {
818
1312
  return ['id'];
819
1313
  }
1314
+ }
1315
+ __decorate([
1316
+ Type(() => Category),
1317
+ __metadata("design:type", Array)
1318
+ ], Buy2Win.prototype, "categories", void 0);
1319
+
1320
+ class CampaignDashboard extends BaseModel {
820
1321
  static get identifiersFields() {
821
- return ['id', 'productId'];
1322
+ return ['id'];
822
1323
  }
823
1324
  }
824
1325
 
825
- var OrderStatus;
826
- (function (OrderStatus) {
827
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
828
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
829
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
830
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
831
- OrderStatus["ENVIADO"] = "Enviado";
832
- OrderStatus["ENTREGUE"] = "Entregue";
833
- OrderStatus["CANCELADO"] = "Cancelado";
834
- OrderStatus["CREDIT_CARD"] = "credit_card";
835
- })(OrderStatus || (OrderStatus = {}));
1326
+ class CampaignHashtag extends BaseModel {
1327
+ static get identifiersFields() {
1328
+ return ['id'];
1329
+ }
1330
+ }
836
1331
 
837
1332
  class LineItem extends Product {
838
1333
  }
@@ -857,12 +1352,12 @@ __decorate([
857
1352
  __metadata("design:type", User)
858
1353
  ], Checkout.prototype, "user", void 0);
859
1354
  __decorate([
860
- Type(() => Address),
861
- __metadata("design:type", Address)
1355
+ Type(() => UserAddress),
1356
+ __metadata("design:type", UserAddress)
862
1357
  ], Checkout.prototype, "shippingAddress", void 0);
863
1358
  __decorate([
864
- Type(() => Address),
865
- __metadata("design:type", Address)
1359
+ Type(() => UserAddress),
1360
+ __metadata("design:type", UserAddress)
866
1361
  ], Checkout.prototype, "billingAddress", void 0);
867
1362
  __decorate([
868
1363
  Type(() => ShippingMethod),
@@ -873,6 +1368,18 @@ __decorate([
873
1368
  __metadata("design:type", Coupon)
874
1369
  ], Checkout.prototype, "coupon", void 0);
875
1370
 
1371
+ var OrderStatus;
1372
+ (function (OrderStatus) {
1373
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
1374
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
1375
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
1376
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
1377
+ OrderStatus["ENVIADO"] = "Enviado";
1378
+ OrderStatus["ENTREGUE"] = "Entregue";
1379
+ OrderStatus["CANCELADO"] = "Cancelado";
1380
+ OrderStatus["CREDIT_CARD"] = "credit_card";
1381
+ })(OrderStatus || (OrderStatus = {}));
1382
+
876
1383
  class Order extends Checkout {
877
1384
  }
878
1385
  __decorate([
@@ -886,12 +1393,12 @@ class CheckoutSubscription extends BaseModel {
886
1393
  }
887
1394
  }
888
1395
  __decorate([
889
- Type(() => Address),
890
- __metadata("design:type", Address)
1396
+ Type(() => UserAddress),
1397
+ __metadata("design:type", UserAddress)
891
1398
  ], CheckoutSubscription.prototype, "shippingAddress", void 0);
892
1399
  __decorate([
893
- Type(() => Address),
894
- __metadata("design:type", Address)
1400
+ Type(() => UserAddress),
1401
+ __metadata("design:type", UserAddress)
895
1402
  ], CheckoutSubscription.prototype, "billingAddress", void 0);
896
1403
  __decorate([
897
1404
  Type(() => SubscriptionPlan),
@@ -902,15 +1409,19 @@ __decorate([
902
1409
  __metadata("design:type", Coupon)
903
1410
  ], CheckoutSubscription.prototype, "coupon", void 0);
904
1411
 
905
- class Buy2Win extends BaseModel {
906
- static get identifiersFields() {
907
- return ['id'];
1412
+ class RoundProductPricesHelper {
1413
+ static roundProductPrices(product) {
1414
+ product.price.price = Number(product.price.price.toFixed(2));
1415
+ product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
1416
+ if (product.price.subscriberPrice) {
1417
+ product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
1418
+ }
1419
+ if (product instanceof LineItem && product.pricePaid) {
1420
+ product.pricePaid = Number(product.pricePaid.toFixed(2));
1421
+ }
1422
+ return product;
908
1423
  }
909
1424
  }
910
- __decorate([
911
- Type(() => Category),
912
- __metadata("design:type", Array)
913
- ], Buy2Win.prototype, "categories", void 0);
914
1425
 
915
1426
  var FilterType;
916
1427
  (function (FilterType) {
@@ -1011,6 +1522,12 @@ class ShopMenu extends BaseModel {
1011
1522
  }
1012
1523
  }
1013
1524
 
1525
+ class ShopSettings extends BaseModel {
1526
+ static get identifiersFields() {
1527
+ return ['id'];
1528
+ }
1529
+ }
1530
+
1014
1531
  class InvalidArgumentError extends CustomError {
1015
1532
  constructor(message) {
1016
1533
  super(message);
@@ -1041,12 +1558,16 @@ class AxiosAdapter {
1041
1558
  constructor(config) {
1042
1559
  this.config = config;
1043
1560
  }
1044
- async get(index) {
1561
+ async get(index, id) {
1045
1562
  try {
1046
1563
  const { data } = await axios({
1047
- url: `${this.config.url}/${index}`,
1564
+ url: `${this.config.url}/${index}/_doc/${id}`,
1048
1565
  method: 'GET',
1049
- headers: { Authorization: `Basic ${this.config.credential}` },
1566
+ responseType: 'json',
1567
+ headers: {
1568
+ 'Content-Type': 'application/json',
1569
+ Authorization: `ApiKey ${this.config.credential}`,
1570
+ },
1050
1571
  });
1051
1572
  return data._source;
1052
1573
  }
@@ -1058,9 +1579,14 @@ class AxiosAdapter {
1058
1579
  }
1059
1580
  async query(index, query) {
1060
1581
  const { data } = await axios({
1061
- url: `${this.config.url}/${index}`,
1582
+ url: `${this.config.url}/${index}/_search`,
1062
1583
  method: 'POST',
1063
- headers: { Authorization: `Basic ${this.config.credential}` },
1584
+ responseType: 'json',
1585
+ headers: {
1586
+ Accept: 'application/vnd.elasticsearch+json;compatible-with=7',
1587
+ 'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
1588
+ Authorization: `ApiKey ${this.config.credential}`,
1589
+ },
1064
1590
  data: query,
1065
1591
  });
1066
1592
  return {
@@ -1070,17 +1596,25 @@ class AxiosAdapter {
1070
1596
  }
1071
1597
  async save(index, data) {
1072
1598
  await axios({
1073
- url: `${this.config.url}/${index}`,
1599
+ url: `${this.config.url}/${index}/_doc`,
1600
+ method: 'POST',
1601
+ headers: { Authorization: `ApiKey ${this.config.credential}` },
1602
+ data,
1603
+ });
1604
+ }
1605
+ async update(index, id, data) {
1606
+ await axios({
1607
+ url: `${this.config.url}/${index}/_update/${id}`,
1074
1608
  method: 'PUT',
1075
- headers: { Authorization: `Basic ${this.config.credential}` },
1609
+ headers: { Authorization: `ApiKey ${this.config.credential}` },
1076
1610
  data,
1077
1611
  });
1078
1612
  }
1079
- async delete(index) {
1613
+ async delete(index, id) {
1080
1614
  await axios({
1081
- url: `${this.config.url}/${index}`,
1615
+ url: `${this.config.url}/${index}/_doc/${id}`,
1082
1616
  method: 'DELETE',
1083
- headers: { Authorization: `Basic ${this.config.credential}` },
1617
+ headers: { Authorization: `ApiKey ${this.config.credential}` },
1084
1618
  });
1085
1619
  }
1086
1620
  }
@@ -1088,13 +1622,16 @@ class AxiosAdapter {
1088
1622
  class ProductsIndex {
1089
1623
  constructor(adapter) {
1090
1624
  this.adapter = adapter;
1625
+ this.index = `products`;
1091
1626
  }
1092
- async get(id) {
1093
- const data = await this.adapter.get(`products/_doc/${id}`);
1627
+ async getById(id) {
1628
+ const data = await this.adapter.get(this.index, id);
1094
1629
  return Product.toInstance(data);
1095
1630
  }
1096
- async findById(ids, options) {
1631
+ async search(searchTerm, total, shop) {
1632
+ const size = total >= 10 ? 500 : 9;
1097
1633
  const fields = [
1634
+ 'EAN',
1098
1635
  'brand',
1099
1636
  'id',
1100
1637
  'images',
@@ -1105,73 +1642,82 @@ class ProductsIndex {
1105
1642
  'stock',
1106
1643
  'slug',
1107
1644
  'reviews',
1108
- 'pricePaid',
1109
- 'isGift',
1110
- 'stock',
1111
- 'weight',
1112
- 'tags',
1113
1645
  'hasVariants',
1114
- 'type',
1646
+ 'rate',
1115
1647
  ];
1116
- const { hits } = await this.adapter.query('products/_search', {
1648
+ const filter = [{ term: { published: true } }];
1649
+ if (size > 9) {
1650
+ fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
1651
+ }
1652
+ else {
1653
+ filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
1654
+ }
1655
+ const search = await this.adapter.query(this.index, {
1656
+ size,
1117
1657
  _source: fields,
1118
1658
  query: {
1119
1659
  bool: {
1120
- filter: [
1121
- {
1122
- terms: {
1123
- _id: ids,
1124
- },
1660
+ must: {
1661
+ multi_match: {
1662
+ query: `${searchTerm}`,
1663
+ type: 'bool_prefix',
1664
+ fields: [
1665
+ 'name',
1666
+ 'name.folded',
1667
+ 'name.search',
1668
+ 'description',
1669
+ 'description.search',
1670
+ 'description.folded',
1671
+ 'brand',
1672
+ 'brand.search',
1673
+ 'brand.folded',
1674
+ ],
1675
+ fuzziness: 2,
1125
1676
  },
1126
- {
1127
- term: {
1128
- published: true,
1677
+ },
1678
+ should: {
1679
+ match_phrase_prefix: {
1680
+ 'name.search': {
1681
+ query: `${searchTerm}`,
1682
+ slop: 10,
1129
1683
  },
1130
1684
  },
1131
- ...(options?.hasStock
1132
- ? [
1133
- {
1134
- range: {
1135
- 'stock.quantity': {
1136
- gt: 0,
1137
- },
1138
- },
1139
- },
1140
- ]
1141
- : []),
1142
- ],
1685
+ },
1686
+ filter,
1143
1687
  },
1144
1688
  },
1145
- ...(options?.size ? { size: options?.size } : {}),
1146
1689
  });
1147
- return hits.map((hit) => Product.toInstance(hit._source));
1690
+ search.hits = search.hits
1691
+ .filter((e) => e._source.name !== '')
1692
+ .map((hit) => {
1693
+ RoundProductPricesHelper.roundProductPrices(hit._source);
1694
+ return hit;
1695
+ });
1696
+ return search;
1148
1697
  }
1149
1698
  async save(product) {
1150
- delete product.createdAt;
1151
- delete product.updatedAt;
1152
- delete product.kitProducts;
1153
1699
  try {
1154
- if (!product.firestoreId)
1155
- throw new Error('Is not a product from firestore');
1156
- await this.get(product.firestoreId);
1157
- await this.adapter.save(`products/_doc/${product.firestoreId}`, product.toPlain());
1700
+ const { createdAt, updatedAt, kitProducts, ...data } = product;
1701
+ this.adapter.save(this.index, data);
1158
1702
  }
1159
1703
  catch (error) {
1160
- if (!(error instanceof Error))
1161
- throw error;
1162
- console.error(error.message);
1163
- await this.adapter.save(`products/_doc/${product.id}`, product.toPlain());
1704
+ console.error(error);
1164
1705
  }
1165
1706
  }
1166
- async delete(product) {
1167
- if (!product.firestoreId)
1168
- return;
1707
+ async update(product) {
1708
+ try {
1709
+ await this.adapter.update(this.index, product.id, product);
1710
+ }
1711
+ catch (error) {
1712
+ console.error(error);
1713
+ }
1714
+ }
1715
+ async delete(id) {
1169
1716
  try {
1170
- await this.get(product.firestoreId);
1171
- await this.adapter.delete(`products/_doc/${product.firestoreId}`);
1717
+ await this.adapter.delete(this.index, id);
1172
1718
  }
1173
1719
  catch (error) {
1174
- await this.adapter.delete(`products/_doc/${product.id}`);
1720
+ console.error(error);
1175
1721
  }
1176
1722
  }
1177
1723
  }
@@ -1201,17 +1747,39 @@ const withFirestore = (MixinBase) => {
1201
1747
  : bindDate(data[key], key),
1202
1748
  }), {});
1203
1749
  };
1750
+ const omitByRecursivelyInPlace = (value, iteratee) => {
1751
+ each(value, (v, k) => {
1752
+ if (iteratee(v, k)) {
1753
+ unset(value, k);
1754
+ }
1755
+ else if (isObject(v)) {
1756
+ omitByRecursivelyInPlace(v, iteratee);
1757
+ }
1758
+ });
1759
+ return value;
1760
+ };
1204
1761
  return class extends MixinBase {
1205
- constructor() {
1206
- super(...arguments);
1762
+ constructor(...params) {
1763
+ const options = params[0];
1764
+ super(...params);
1765
+ this.fields = {};
1766
+ this.interceptors = {};
1207
1767
  this.collectionName = '';
1768
+ this.firestore = options.firestore;
1769
+ this.collectionName = options.collectionName;
1770
+ this.model = options.model;
1771
+ this.fields = options.fields;
1772
+ this.interceptors = options.interceptors;
1208
1773
  }
1209
1774
  collection(path) {
1210
1775
  return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
1211
1776
  }
1212
1777
  buildModelInstance() {
1213
1778
  return {
1214
- toFirestore: (data) => (data?.toPlain ? data.toPlain() : data),
1779
+ toFirestore: (data) => {
1780
+ const plain = data?.toPlain ? data.toPlain() : data;
1781
+ return omitByRecursivelyInPlace(plain, (value) => value === undefined);
1782
+ },
1215
1783
  fromFirestore: (snap) => {
1216
1784
  const data = snap.data();
1217
1785
  let bindedData = null;
@@ -1251,11 +1819,14 @@ const withHelpers = (MixinBase) => {
1251
1819
  const withGetFirestore = (MixinBase) => {
1252
1820
  return class GetFirestore extends MixinBase {
1253
1821
  async get(identifiers) {
1254
- const docRef = await getDoc(doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(identifiers).shift().toString()));
1822
+ const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
1823
+ const intercepted = await this.interceptors?.request?.({ instance });
1824
+ const builded = intercepted?.instance || instance;
1825
+ const docRef = await getDoc(doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
1255
1826
  const data = docRef.data();
1256
1827
  if (isNil(data))
1257
1828
  throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1258
- return data;
1829
+ return this.interceptors?.response?.(data, intercepted) || data;
1259
1830
  }
1260
1831
  buildCollectionPathForGet(identifiers) {
1261
1832
  return this.isSubCollection(this)
@@ -1336,8 +1907,11 @@ const withFindFirestore = (MixinBase) => {
1336
1907
  return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
1337
1908
  };
1338
1909
  }
1339
- async find({ filters, limits, orderBy, } = {}) {
1340
- const collection = this.collection(this.buildCollectionPathForFind(filters));
1910
+ async find(find = {}) {
1911
+ const collection = this.collection(this.buildCollectionPathForFind(find.filters));
1912
+ const enableCount = find?.options?.enableCount ?? true;
1913
+ const intercepted = await this.interceptors?.request?.({ find });
1914
+ const { filters, limits, orderBy } = intercepted.find || find;
1341
1915
  const queries = this.makeFirestoreWhere(filters || {});
1342
1916
  const ordination = this.makeFirestoreOrderBy(filters, orderBy);
1343
1917
  const offsets = await this.defineLimits(filters, limits);
@@ -1345,8 +1919,8 @@ const withFindFirestore = (MixinBase) => {
1345
1919
  const docs = await getDocs(query(collection, ...queryArgumments));
1346
1920
  const data = docs.docs.map((doc) => doc.data());
1347
1921
  return {
1348
- data,
1349
- count: this.calculateCount(data, limits),
1922
+ data: (await this.interceptors?.response?.(data, intercepted)) || data,
1923
+ count: enableCount ? this.calculateCount(data, limits) : Infinity,
1350
1924
  };
1351
1925
  }
1352
1926
  buildCollectionPathForFind(filters) {
@@ -1360,7 +1934,7 @@ const withFindFirestore = (MixinBase) => {
1360
1934
  const queries = [];
1361
1935
  if (limits?.offset) {
1362
1936
  if (this.model.isModel(limits.offset))
1363
- queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), limits.offset.identifier.shift()))));
1937
+ queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), Object.values(limits.offset.identifier).shift()?.toString()))));
1364
1938
  else if (isNumber(limits.offset) || isString(limits.offset))
1365
1939
  queries.push(startAt(limits.offset));
1366
1940
  }
@@ -1381,12 +1955,16 @@ const withFindFirestore = (MixinBase) => {
1381
1955
  const withCreateFirestore = (MixinBase) => {
1382
1956
  return class CreateFirestore extends MixinBase {
1383
1957
  async create(data) {
1384
- const docRef = await this.save(this.model.toInstance(data));
1958
+ const instance = this.model.toInstance(data);
1959
+ const intercepted = await this.interceptors?.request?.({ instance });
1960
+ const builded = intercepted?.instance || instance;
1961
+ const docRef = await this.save(builded);
1385
1962
  const doc = await getDoc(docRef);
1386
- return doc.data();
1963
+ const docBuilded = (await this.interceptors?.response?.(doc.data(), intercepted)) || doc.data();
1964
+ return docBuilded;
1387
1965
  }
1388
1966
  async save(data) {
1389
- const id = data.identifier[data.identifiersFields?.shift()]?.toString();
1967
+ const id = Object.values(data.identifier)?.shift()?.toString();
1390
1968
  const collectionPath = this.buildCollectionPathForAdd(data);
1391
1969
  const collection = this.collection(collectionPath);
1392
1970
  if (isEmpty(id))
@@ -1427,9 +2005,12 @@ const withUpdateFirestore = (MixinBase) => {
1427
2005
  const model = new this.model();
1428
2006
  const keyField = model.identifiersFields.shift();
1429
2007
  const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
1430
- await setDoc(docRef, this.paramsToPlain(data), { merge: true });
1431
- const docData = await getDoc(docRef);
1432
- return docData.data();
2008
+ const plainFromData = this.model.toInstance(this.paramsToPlain(data));
2009
+ const intercepted = await this.interceptors?.request?.({ instance: plainFromData });
2010
+ const builded = intercepted?.instance || plainFromData;
2011
+ await setDoc(docRef, builded.toPlain(), { merge: true });
2012
+ const docData = await getDoc(docRef).then((doc) => doc.data());
2013
+ return this.interceptors?.response?.(docData, intercepted) || docData;
1433
2014
  }
1434
2015
  buildCollectionPathForUpdate(identifiers) {
1435
2016
  return this.isSubCollection(this)
@@ -1451,7 +2032,11 @@ const withUpdateFirestore = (MixinBase) => {
1451
2032
  const withDeleteFirestore = (MixinBase) => {
1452
2033
  return class DeleteFirestore extends MixinBase {
1453
2034
  async delete(identifiers) {
1454
- await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(identifiers).shift().toString()));
2035
+ const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
2036
+ const intercepted = await this.interceptors?.request?.({ instance });
2037
+ const builded = intercepted?.instance || instance;
2038
+ await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
2039
+ await this.interceptors?.response?.(instance, intercepted);
1455
2040
  }
1456
2041
  buildCollectionPathForRemove(identifiers) {
1457
2042
  return this.isSubCollection(this)
@@ -1463,8 +2048,10 @@ const withDeleteFirestore = (MixinBase) => {
1463
2048
 
1464
2049
  const withSubCollection = (MixinBase, ParentModel) => {
1465
2050
  return class SubCollectionMix extends MixinBase {
1466
- constructor(...args) {
1467
- super(args);
2051
+ constructor(...params) {
2052
+ const options = params[0];
2053
+ super(...params);
2054
+ this.parentIdField = options.parentIdField;
1468
2055
  }
1469
2056
  collection(path) {
1470
2057
  return super.collection(path);
@@ -1478,73 +2065,87 @@ const withCrudFirestore = (MixinBase) => {
1478
2065
  };
1479
2066
 
1480
2067
  class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1481
- constructor(firestore) {
1482
- super();
1483
- this.firestore = firestore;
1484
- this.collectionName = 'leads';
1485
- this.model = Lead;
2068
+ constructor({ firestore, interceptors }) {
2069
+ super({
2070
+ firestore,
2071
+ collectionName: 'leads',
2072
+ model: Lead,
2073
+ interceptors,
2074
+ });
1486
2075
  }
1487
2076
  }
1488
2077
 
1489
2078
  class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1490
- constructor(firestore, parentRepository) {
1491
- super();
1492
- this.firestore = firestore;
2079
+ constructor({ firestore, interceptors }, parentRepository) {
2080
+ super({
2081
+ firestore,
2082
+ collectionName: 'editions',
2083
+ parentIdField: 'subscriptionId',
2084
+ model: Edition,
2085
+ interceptors,
2086
+ });
1493
2087
  this.parentRepository = parentRepository;
1494
- this.collectionName = 'editions';
1495
- this.parentIdField = 'subscriptionId';
1496
- this.model = Edition;
1497
2088
  }
1498
2089
  }
1499
2090
 
1500
2091
  class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1501
- constructor(firestore) {
1502
- super();
1503
- this.firestore = firestore;
1504
- this.collectionName = 'subscription';
1505
- this.model = Subscription;
2092
+ constructor({ firestore, interceptors, }) {
2093
+ super({
2094
+ firestore,
2095
+ collectionName: 'subscription',
2096
+ model: Subscription,
2097
+ interceptors,
2098
+ });
1506
2099
  }
1507
2100
  }
1508
2101
 
1509
2102
  class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1510
- constructor(firestore, parentRepository) {
1511
- super();
1512
- this.firestore = firestore;
2103
+ constructor({ firestore, interceptors }, parentRepository) {
2104
+ super({
2105
+ firestore,
2106
+ collectionName: 'payments',
2107
+ parentIdField: 'subscriptionId',
2108
+ model: SubscriptionPayment,
2109
+ interceptors,
2110
+ });
1513
2111
  this.parentRepository = parentRepository;
1514
- this.collectionName = 'payments';
1515
- this.parentIdField = 'subscriptionId';
1516
- this.model = SubscriptionPayment;
1517
2112
  }
1518
2113
  }
1519
2114
 
1520
2115
  class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1521
- constructor(firestore, parentRepository) {
1522
- super();
1523
- this.firestore = firestore;
2116
+ constructor({ firestore, interceptors }, parentRepository) {
2117
+ super({
2118
+ firestore,
2119
+ collectionName: 'address',
2120
+ parentIdField: 'userId',
2121
+ model: UserAddress,
2122
+ interceptors,
2123
+ });
1524
2124
  this.parentRepository = parentRepository;
1525
- this.collectionName = 'address';
1526
- this.parentIdField = 'userId';
1527
- this.model = UserAddress;
1528
2125
  }
1529
2126
  }
1530
2127
 
1531
2128
  class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1532
- constructor(firestore, parentRepository) {
1533
- super();
1534
- this.firestore = firestore;
2129
+ constructor({ firestore, interceptors }, parentRepository) {
2130
+ super({
2131
+ firestore,
2132
+ collectionName: 'CX',
2133
+ parentIdField: 'userId',
2134
+ model: BeautyProfile,
2135
+ interceptors,
2136
+ });
1535
2137
  this.parentRepository = parentRepository;
1536
- this.collectionName = 'CX';
1537
- this.parentIdField = 'userId';
1538
- this.model = BeautyProfile;
1539
2138
  }
1540
2139
  }
1541
2140
 
1542
2141
  class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1543
- constructor(firestore) {
1544
- super();
1545
- this.firestore = firestore;
1546
- this.collectionName = 'users';
1547
- this.model = User;
2142
+ constructor({ firestore, interceptors }) {
2143
+ super({
2144
+ firestore,
2145
+ collectionName: 'users',
2146
+ model: User,
2147
+ interceptors,
2148
+ });
1548
2149
  }
1549
2150
  async get(identifiers) {
1550
2151
  const user = await super.get({ id: identifiers.id });
@@ -1584,22 +2185,26 @@ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1584
2185
  }
1585
2186
 
1586
2187
  class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1587
- constructor(firestore, parentRepository) {
1588
- super();
1589
- this.firestore = firestore;
2188
+ constructor({ firestore, interceptors }, parentRepository) {
2189
+ super({
2190
+ firestore,
2191
+ collectionName: 'payment_method',
2192
+ parentIdField: 'userId',
2193
+ model: UserPaymentMethod,
2194
+ interceptors,
2195
+ });
1590
2196
  this.parentRepository = parentRepository;
1591
- this.collectionName = 'payment_method';
1592
- this.parentIdField = 'userId';
1593
- this.model = UserPaymentMethod;
1594
2197
  }
1595
2198
  }
1596
2199
 
1597
2200
  class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1598
- constructor(firestore) {
1599
- super();
1600
- this.firestore = firestore;
1601
- this.collectionName = 'categories';
1602
- this.model = Category;
2201
+ constructor({ firestore, interceptors }) {
2202
+ super({
2203
+ firestore,
2204
+ collectionName: 'categories',
2205
+ model: Category,
2206
+ interceptors,
2207
+ });
1603
2208
  }
1604
2209
  async getCategoryBySlug(slug, shop) {
1605
2210
  const categoryDocs = await getDocs(query(this.collection(this.collectionName), where('slug', '==', slug), where('shop', '==', shop), where('published', '==', true)));
@@ -1609,14 +2214,14 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1609
2214
  throw new NotFoundError(`Document with slug ${slug} not found`);
1610
2215
  return categoryDocs.docs[0].data();
1611
2216
  }
1612
- async getCategoriesForHome(categoryIds, limit = 4) {
2217
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
1613
2218
  const categorySnap = await getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
1614
2219
  if (categorySnap.empty)
1615
2220
  throw new NotFoundError('Categories not found');
1616
2221
  const categories = categorySnap.docs.map((doc) => doc.data());
1617
2222
  const homeSections = await Promise.all(categories.map(async (category) => ({
1618
2223
  category,
1619
- products: await this.mountCategory(category, { limit, hasStock: true }),
2224
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
1620
2225
  })));
1621
2226
  return homeSections;
1622
2227
  }
@@ -1632,6 +2237,8 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1632
2237
  wheres.push(where('published', '==', true), where('id', 'in', productIds));
1633
2238
  if (options?.hasStock)
1634
2239
  wheres.push(where('stock.quantity', '>', 0));
2240
+ if (options?.gender)
2241
+ wheres.push(where('tags', 'array-contains', options?.gender));
1635
2242
  if (options?.limit)
1636
2243
  wheres.push(limit(options?.limit));
1637
2244
  const productSnap = await getDocs(query(this.collection('productsErpVitrine'), ...wheres));
@@ -1641,15 +2248,26 @@ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFire
1641
2248
  }
1642
2249
  return is(products);
1643
2250
  }
2251
+ getCategoryByShop(shop) {
2252
+ return;
2253
+ }
2254
+ getChildren(parentId) {
2255
+ return;
2256
+ }
2257
+ isChild(id, parentId) {
2258
+ return;
2259
+ }
1644
2260
  }
1645
2261
 
1646
2262
  class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1647
- constructor(firestore) {
1648
- super();
1649
- this.firestore = firestore;
2263
+ constructor({ firestore, interceptors }) {
2264
+ super({
2265
+ firestore,
2266
+ collectionName: 'productsErpVitrine',
2267
+ model: Product,
2268
+ interceptors,
2269
+ });
1650
2270
  this.reviews = {};
1651
- this.collectionName = 'productsErpVitrine';
1652
- this.model = Product;
1653
2271
  }
1654
2272
  async getBySlug(slug) {
1655
2273
  const result = await this.find({
@@ -1684,43 +2302,98 @@ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFires
1684
2302
  });
1685
2303
  return this.reviews[status];
1686
2304
  }
2305
+ cleanShoppingCountFromIds() {
2306
+ return;
2307
+ }
1687
2308
  }
1688
2309
 
1689
2310
  class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
1690
- constructor(firestore, parentRepository) {
1691
- super();
1692
- this.firestore = firestore;
2311
+ constructor({ firestore, interceptors }, parentRepository) {
2312
+ super({
2313
+ firestore,
2314
+ collectionName: 'variants',
2315
+ parentIdField: 'productId',
2316
+ model: Variant,
2317
+ interceptors,
2318
+ });
1693
2319
  this.parentRepository = parentRepository;
1694
- this.collectionName = 'variants';
1695
- this.parentIdField = 'productId';
1696
- this.model = Variant;
1697
2320
  }
1698
2321
  }
1699
2322
 
1700
2323
  class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1701
- constructor(firestore) {
1702
- super();
1703
- this.firestore = firestore;
1704
- this.collectionName = 'subscriptionProducts';
1705
- this.model = Product;
2324
+ constructor({ firestore, interceptors }) {
2325
+ super({
2326
+ firestore,
2327
+ collectionName: 'subscriptionProducts',
2328
+ model: Product,
2329
+ interceptors,
2330
+ });
2331
+ }
2332
+ }
2333
+
2334
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2335
+ constructor({ firestore, interceptors }) {
2336
+ super({
2337
+ firestore,
2338
+ collectionName: 'buy2win',
2339
+ model: Buy2Win,
2340
+ interceptors,
2341
+ });
2342
+ }
2343
+ }
2344
+
2345
+ class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2346
+ constructor({ firestore, interceptors, }) {
2347
+ super({
2348
+ firestore,
2349
+ collectionName: 'dashboardCampaignsAuto',
2350
+ model: CampaignDashboard,
2351
+ interceptors,
2352
+ });
2353
+ }
2354
+ }
2355
+
2356
+ class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2357
+ constructor({ firestore, interceptors, }) {
2358
+ super({
2359
+ firestore,
2360
+ collectionName: 'hashtagCampaignsAuto',
2361
+ model: CampaignHashtag,
2362
+ interceptors,
2363
+ });
1706
2364
  }
1707
2365
  }
1708
2366
 
1709
2367
  class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1710
- constructor(firestore) {
1711
- super();
1712
- this.firestore = firestore;
1713
- this.collectionName = 'checkouts';
1714
- this.model = Checkout;
2368
+ constructor({ firestore, interceptors }) {
2369
+ super({
2370
+ firestore,
2371
+ collectionName: 'checkouts',
2372
+ model: Checkout,
2373
+ interceptors,
2374
+ });
2375
+ }
2376
+ }
2377
+
2378
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2379
+ constructor({ firestore, interceptors, }) {
2380
+ super({
2381
+ firestore,
2382
+ collectionName: 'checkoutsSubscription',
2383
+ model: CheckoutSubscription,
2384
+ interceptors,
2385
+ });
1715
2386
  }
1716
2387
  }
1717
2388
 
1718
2389
  class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1719
- constructor(firestore) {
1720
- super();
1721
- this.firestore = firestore;
1722
- this.collectionName = 'coupons';
1723
- this.model = Coupon;
2390
+ constructor({ firestore, interceptors }) {
2391
+ super({
2392
+ firestore,
2393
+ collectionName: 'coupons',
2394
+ model: Coupon,
2395
+ interceptors,
2396
+ });
1724
2397
  }
1725
2398
  buildModelInstance() {
1726
2399
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1742,9 +2415,16 @@ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirest
1742
2415
  }
1743
2416
 
1744
2417
  class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1745
- constructor(firestore) {
1746
- super();
1747
- this.firestore = firestore;
2418
+ constructor({ firestore, interceptors }) {
2419
+ super({
2420
+ firestore,
2421
+ collectionName: 'orders',
2422
+ model: Order,
2423
+ interceptors,
2424
+ fields: {
2425
+ status: FirestoreFieldType.String,
2426
+ },
2427
+ });
1748
2428
  this.orderFromFirestore = (order) => {
1749
2429
  if (!!order?.lineItems?.length) {
1750
2430
  order.lineItems = order.lineItems.map((lineItem) => {
@@ -1757,11 +2437,6 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1757
2437
  }
1758
2438
  return order;
1759
2439
  };
1760
- this.collectionName = 'orders';
1761
- this.model = Order;
1762
- this.fields = {
1763
- status: FirestoreFieldType.String,
1764
- };
1765
2440
  }
1766
2441
  buildModelInstance() {
1767
2442
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1775,84 +2450,58 @@ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFiresto
1775
2450
  }
1776
2451
  }
1777
2452
 
1778
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1779
- constructor(firestore) {
1780
- super();
1781
- this.firestore = firestore;
1782
- this.collectionName = 'payments';
1783
- this.model = Payment;
2453
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
2454
+ constructor({ firestore, interceptors }) {
2455
+ super({
2456
+ firestore,
2457
+ interceptors,
2458
+ });
2459
+ this.collectionName = 'legacyOrders';
1784
2460
  }
1785
2461
  }
1786
2462
 
1787
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1788
- constructor(firestore) {
1789
- super();
1790
- this.firestore = firestore;
1791
- this.collectionName = 'checkoutsSubscription';
1792
- this.model = CheckoutSubscription;
2463
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2464
+ constructor({ firestore, interceptors }) {
2465
+ super({
2466
+ firestore,
2467
+ collectionName: 'payments',
2468
+ model: Payment,
2469
+ interceptors,
2470
+ });
1793
2471
  }
1794
2472
  }
1795
2473
 
1796
2474
  class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1797
- constructor(firestore) {
1798
- super();
1799
- this.firestore = firestore;
1800
- this.collectionName = 'subscriptionPlans';
1801
- this.model = SubscriptionPlan;
1802
- }
1803
- }
1804
-
1805
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1806
- constructor(firestore) {
1807
- super();
1808
- this.firestore = firestore;
1809
- this.collectionName = 'buy2win';
1810
- this.model = Buy2Win;
1811
- }
1812
- }
1813
-
1814
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1815
- constructor(firestore) {
1816
- super(firestore);
1817
- this.firestore = firestore;
1818
- this.collectionName = 'legacyOrders';
2475
+ constructor({ firestore, interceptors, }) {
2476
+ super({
2477
+ firestore,
2478
+ collectionName: 'subscriptionPlans',
2479
+ model: SubscriptionPlan,
2480
+ interceptors,
2481
+ });
1819
2482
  }
1820
2483
  }
1821
2484
 
1822
2485
  class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1823
- constructor(firestore) {
1824
- super();
1825
- this.firestore = firestore;
1826
- this.homeToFirestore = (home) => {
1827
- if (home.data?.data) {
1828
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
1829
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.homeCategoryGroupToPlain);
1830
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.homeCategoryGroupToPlain);
1831
- }
1832
- return home;
1833
- };
2486
+ constructor({ firestore, interceptors }) {
2487
+ super({
2488
+ firestore,
2489
+ collectionName: 'dms',
2490
+ model: Home,
2491
+ interceptors,
2492
+ });
1834
2493
  this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
1835
- category: homeCategoryGroup.category.toPlain(),
1836
- products: homeCategoryGroup.products.map((product) => product.toPlain()),
1837
- });
1838
- this.homeFromFirestore = (home) => {
1839
- if (home.data?.data) {
1840
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
1841
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
1842
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
1843
- home.data.createdAt =
1844
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
1845
- home.data.expiresAt =
1846
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
1847
- }
1848
- return home;
1849
- };
2494
+ category: homeCategoryGroup?.category?.toPlain
2495
+ ? homeCategoryGroup?.category?.toPlain()
2496
+ : homeCategoryGroup?.category,
2497
+ products: homeCategoryGroup?.products
2498
+ ?.map((product) => (product?.toPlain ? product?.toPlain() : product))
2499
+ .filter(Boolean) || [],
2500
+ });
1850
2501
  this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
1851
- category: Category.toInstance(homeCategoryGroup.category),
1852
- products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
2502
+ category: Category.toInstance(homeCategoryGroup?.category),
2503
+ products: homeCategoryGroup.products?.map((product) => Product.toInstance(product)),
1853
2504
  });
1854
- this.collectionName = 'dms';
1855
- this.model = Home;
1856
2505
  }
1857
2506
  buildModelInstance() {
1858
2507
  const { fromFirestore, toFirestore } = super.buildModelInstance();
@@ -1867,14 +2516,47 @@ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestor
1867
2516
  },
1868
2517
  };
1869
2518
  }
2519
+ homeToFirestore(home) {
2520
+ if (home.data?.data) {
2521
+ home.data.data.discoverProducts = home.data.data.discoverProducts?.map(this.homeCategoryGroupToPlain) || [];
2522
+ home.data.data.featuredProducts = home.data.data.featuredProducts?.map(this.homeCategoryGroupToPlain) || [];
2523
+ home.data.data.verticalProducts = home.data.data.verticalProducts?.map(this.homeCategoryGroupToPlain) || [];
2524
+ }
2525
+ return home;
2526
+ }
2527
+ homeFromFirestore(home) {
2528
+ if (home.data?.data) {
2529
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
2530
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
2531
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
2532
+ home.data.createdAt =
2533
+ home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
2534
+ home.data.expiresAt =
2535
+ home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
2536
+ }
2537
+ return home;
2538
+ }
1870
2539
  }
1871
2540
 
1872
2541
  class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1873
- constructor(firestore) {
1874
- super();
1875
- this.firestore = firestore;
1876
- this.collectionName = 'shopMenus';
1877
- this.model = ShopMenu;
2542
+ constructor({ firestore, interceptors }) {
2543
+ super({
2544
+ firestore,
2545
+ collectionName: 'shopMenus',
2546
+ model: ShopMenu,
2547
+ interceptors,
2548
+ });
2549
+ }
2550
+ }
2551
+
2552
+ class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2553
+ constructor({ firestore, interceptors, }) {
2554
+ super({
2555
+ firestore,
2556
+ collectionName: 'shopSettings',
2557
+ model: ShopSettings,
2558
+ interceptors,
2559
+ });
1878
2560
  }
1879
2561
  }
1880
2562
 
@@ -1951,7 +2633,7 @@ class AttributeOptionHelper {
1951
2633
  }
1952
2634
  AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
1953
2635
  if (fields.includes(attributeName))
1954
- return { columnName: attributeName.toString(), attributeName };
2636
+ return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
1955
2637
  const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
1956
2638
  const fieldOption = is(field)?.[attributeName];
1957
2639
  if (isNil(fieldOption))
@@ -2053,11 +2735,12 @@ BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter)
2053
2735
  }, {});
2054
2736
  BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2055
2737
  const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2056
- if (!Array.isArray(options) &&
2738
+ const isNestedField = !Array.isArray(options) &&
2057
2739
  isObject(options) &&
2058
2740
  isNil(options?.operator) &&
2059
2741
  isNil(options?.value) &&
2060
- isNil(fieldSentenceOptions?.to))
2742
+ isNil(fieldSentenceOptions?.to);
2743
+ if (isNestedField)
2061
2744
  return Object.keys(options).reduce((variables, key) => {
2062
2745
  const fieldOptions = AttributeOptionHelper.FindByAttribute(key, fieldSentenceOptions?.fields || fields);
2063
2746
  const columnName = fieldOptions.columnName;
@@ -2071,7 +2754,7 @@ BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2071
2754
  return {
2072
2755
  [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
2073
2756
  };
2074
- if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2757
+ if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2075
2758
  options = Object.values(options)[0];
2076
2759
  return Array.isArray(options)
2077
2760
  ? options.reduce((whereSentence, option) => ({
@@ -2107,28 +2790,14 @@ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
2107
2790
  if (field === 'affected_rows')
2108
2791
  return field;
2109
2792
  const fieldName = Object.keys(field).shift();
2110
- const fieldValue = field[fieldName];
2793
+ const fieldValue = is(field[fieldName]);
2111
2794
  if (Array.isArray(fieldValue))
2112
2795
  return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
2113
2796
  if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
2114
- return null;
2115
- if (fieldValue.fields)
2116
- return !fieldValue.filters
2117
- ? {
2118
- [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2119
- }
2120
- : {
2121
- operation: fieldValue.columnName || fieldName,
2122
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2123
- variables: {
2124
- [`${fieldValue.columnName}_where`]: {
2125
- name: 'where',
2126
- type: fieldValue.filters.filterType,
2127
- value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2128
- required: true,
2129
- },
2130
- },
2131
- };
2797
+ return;
2798
+ const isNestedField = !!fieldValue.fields;
2799
+ if (isNestedField)
2800
+ return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
2132
2801
  return fieldValue.columnName;
2133
2802
  })
2134
2803
  .filter((field) => !!field);
@@ -2153,7 +2822,10 @@ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).r
2153
2822
  }
2154
2823
  if (!!from)
2155
2824
  return { ...result, [attributeName]: from(data[columnName], data) };
2156
- return { ...result, [attributeName]: parseDateTime(data[columnName].toString()) };
2825
+ return {
2826
+ ...result,
2827
+ [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName],
2828
+ };
2157
2829
  }, {});
2158
2830
  GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2159
2831
  const data = instance.toPlain?.() || instance;
@@ -2169,10 +2841,13 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2169
2841
  if (!!foreignKeyColumn &&
2170
2842
  !isEmpty(foreignKeyColumn) &&
2171
2843
  !Object.keys(foreignKeyColumn).filter((key) => !is(data[attributeName])?.[key]).length)
2172
- return Object.keys(foreignKeyColumn).reduce((object, current) => ({
2173
- ...object,
2174
- [foreignKeyColumn[current]]: data[attributeName]?.[current],
2175
- }), { ...result });
2844
+ return Object.keys(foreignKeyColumn).reduce((object, current) => {
2845
+ const { columnName: foreignColumnName } = AttributeOptionHelper.FindByAttribute(foreignKeyColumn[current], fields);
2846
+ return {
2847
+ ...object,
2848
+ [foreignColumnName]: data[attributeName]?.[current],
2849
+ };
2850
+ }, { ...result });
2176
2851
  if (update &&
2177
2852
  isObject(data[attributeName]) &&
2178
2853
  !isNil(attributeFields) &&
@@ -2205,6 +2880,25 @@ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2205
2880
  return { ...result, [columnName]: data[attributeName] };
2206
2881
  }, {});
2207
2882
  };
2883
+ GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
2884
+ const hasCustomFilters = !!fieldValue.filters;
2885
+ if (hasCustomFilters)
2886
+ return {
2887
+ operation: fieldValue.columnName || fieldName,
2888
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2889
+ variables: {
2890
+ [`${fieldValue.columnName}_where`]: {
2891
+ name: 'where',
2892
+ type: fieldValue.filters.filterType,
2893
+ value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2894
+ required: true,
2895
+ },
2896
+ },
2897
+ };
2898
+ return {
2899
+ [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2900
+ };
2901
+ };
2208
2902
 
2209
2903
  const withCreateHasuraGraphQL = (MixinBase) => {
2210
2904
  return class CreateHasuraGraphQLMixin extends MixinBase {
@@ -2215,6 +2909,7 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2215
2909
  this.insertGraphQLObjectType = options?.insertGraphQLObjectType || `${this.tableName}_insert_input`;
2216
2910
  }
2217
2911
  async create(data) {
2912
+ this.logger = DebugHelper.from(this, 'create');
2218
2913
  const newData = await this.save(this.model.toInstance(data));
2219
2914
  return this.model.toInstance(newData);
2220
2915
  }
@@ -2225,10 +2920,10 @@ const withCreateHasuraGraphQL = (MixinBase) => {
2225
2920
  const columnOptions = Object.values(field).shift();
2226
2921
  return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
2227
2922
  columnOptions.foreignKeyColumn && [
2228
- ...Object.values(columnOptions.foreignKeyColumn),
2923
+ ...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => AttributeOptionHelper.FindByAttribute(foreignKeyName, this.fields)?.columnName),
2229
2924
  {
2230
- [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)?.columnName ||
2231
- foreignKeyField),
2925
+ [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)
2926
+ ?.columnName || foreignKeyField),
2232
2927
  },
2233
2928
  ]);
2234
2929
  })
@@ -2250,9 +2945,11 @@ const withDeleteHasuraGraphQL = (MixinBase) => {
2250
2945
  this.deleteGraphQLOperation = options?.deleteGraphQLOperation || `delete_${this.tableName}_by_pk`;
2251
2946
  }
2252
2947
  async delete(identifiers) {
2948
+ this.logger = DebugHelper.from(this, 'delete');
2253
2949
  const instance = this.model.toInstance(identifiers);
2254
2950
  await this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
2255
- if (isNil(instance[identifier]))
2951
+ const identifierBinded = identifier;
2952
+ if (isNil(instance.identifier[identifierBinded]))
2256
2953
  return ids;
2257
2954
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2258
2955
  const value = columnOption.to(identifiers[identifier], instance);
@@ -2279,15 +2976,19 @@ const withHasuraGraphQL = (MixinBase) => {
2279
2976
  this.authOptions = options.authOptions;
2280
2977
  this.model = options.model;
2281
2978
  this.fields = options.fields || this.model.identifiersFields;
2979
+ this.logger = DebugHelper.from(this);
2282
2980
  }
2283
2981
  get headers() {
2284
2982
  return {
2285
2983
  'Content-Type': 'application/json',
2286
- ...(isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken }),
2287
- ...(isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret }),
2288
- ...(isNil(this.authOptions.authRole)
2984
+ ...(isNil(this.authOptions?.authToken) ? {} : { Authorization: this.authOptions?.authToken }),
2985
+ ...(isNil(this.authOptions?.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions?.adminSecret }),
2986
+ ...(isNil(this.authOptions?.authRole)
2289
2987
  ? {}
2290
- : { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }),
2988
+ : {
2989
+ 'X-Hasura-Role': this.authOptions.authRole.role,
2990
+ 'X-Hasura-User-Id': this.authOptions?.authRole?.userId,
2991
+ }),
2291
2992
  };
2292
2993
  }
2293
2994
  async mutation(operation, fields, variables) {
@@ -2299,29 +3000,28 @@ const withHasuraGraphQL = (MixinBase) => {
2299
3000
  return this.fetch(resultQuery);
2300
3001
  }
2301
3002
  async query(operation, fields, variables) {
2302
- const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2303
- ? query$1(operation.map((option) => ({
2304
- operation: option.operation,
2305
- variables: option.variables,
2306
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2307
- })))
2308
- : query$1({
2309
- operation,
2310
- variables,
2311
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2312
- });
2313
- return this.fetch(resultQuery);
3003
+ const builded = this.buildHasuraQueryFields({
3004
+ operation,
3005
+ fields: fields,
3006
+ variables,
3007
+ });
3008
+ const interpected = (await this.interceptors?.request?.(builded)) || builded;
3009
+ const resultQuery = query$1(interpected);
3010
+ const result = await this.fetch(resultQuery);
3011
+ return (await this.interceptors?.response?.(result, interpected)) || result;
2314
3012
  }
2315
3013
  async fetch(params) {
3014
+ this.logger.with('params').log(params);
2316
3015
  const headers = this.headers;
2317
- const response = await fetch(`${this.endpoint}`, {
3016
+ const { data: result } = await axios({
3017
+ url: `${this.endpoint}`,
2318
3018
  method: 'POST',
2319
- body: JSON.stringify(params),
3019
+ data: params,
2320
3020
  headers,
2321
3021
  });
2322
- const result = await response.json();
2323
3022
  if (!isNil(result.errors))
2324
3023
  throw new Error(JSON.stringify(result.errors));
3024
+ this.logger.with('returns').log(result);
2325
3025
  return result.data;
2326
3026
  }
2327
3027
  getAttributeGraphQLTypeOf(value) {
@@ -2347,13 +3047,26 @@ const withHasuraGraphQL = (MixinBase) => {
2347
3047
  return value;
2348
3048
  return date;
2349
3049
  }
2350
- convertDataFromHasura(data) {
2351
- const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
3050
+ convertDataFromHasura(data, fields) {
3051
+ const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
2352
3052
  return this.model.toInstance(plain);
2353
3053
  }
2354
3054
  convertDataToHasura(instance, update = false) {
2355
3055
  return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
2356
3056
  }
3057
+ buildHasuraQueryFields({ operation, fields, variables, }) {
3058
+ return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
3059
+ ? operation.map((option) => ({
3060
+ operation: option.operation,
3061
+ variables: option.variables,
3062
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
3063
+ }))
3064
+ : {
3065
+ operation,
3066
+ variables,
3067
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
3068
+ };
3069
+ }
2357
3070
  };
2358
3071
  };
2359
3072
 
@@ -2376,6 +3089,7 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2376
3089
  this.updateGraphQLPKType = options?.updateGraphQLPKType || `${this.tableName}_pk_columns_input`;
2377
3090
  }
2378
3091
  async update(data) {
3092
+ this.logger = DebugHelper.from(this, 'update');
2379
3093
  const plainData = this.paramsToPlain(data);
2380
3094
  await this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
2381
3095
  _set: {
@@ -2401,10 +3115,11 @@ const withUpdateHasuraGraphQL = (MixinBase) => {
2401
3115
  getUpdateModelKeys(data) {
2402
3116
  const instance = this.model.toInstance(data);
2403
3117
  return this.model.identifiersFields.reduce((ids, identifier) => {
2404
- if (isNil(instance[identifier]))
3118
+ const identifierBinded = identifier;
3119
+ if (isNil(instance.identifier[identifierBinded]))
2405
3120
  return ids;
2406
- const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2407
- const value = columnOption?.to?.(data[identifier], instance) || data[columnOption.attributeName];
3121
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
3122
+ const value = columnOption?.to?.(data[identifierBinded], instance) || data[columnOption.attributeName];
2408
3123
  return {
2409
3124
  ...ids,
2410
3125
  [columnOption.columnName]: value,
@@ -2422,9 +3137,11 @@ const withGetHasuraGraphQL = (MixinBase) => {
2422
3137
  this.getGraphQLOperation = options?.getGraphQLOperation || `${this.tableName}_by_pk`;
2423
3138
  }
2424
3139
  async get(identifiers) {
3140
+ this.logger = DebugHelper.from(this, 'get');
2425
3141
  const instance = this.model.toInstance(identifiers);
2426
3142
  const result = await this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
2427
- if (isNil(instance[identifier]))
3143
+ const identifierBinded = identifier;
3144
+ if (isNil(instance[identifierBinded]))
2428
3145
  return ids;
2429
3146
  const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2430
3147
  const value = columnOption?.to?.(identifiers[identifier], instance) ||
@@ -2448,10 +3165,28 @@ const withGetHasuraGraphQL = (MixinBase) => {
2448
3165
 
2449
3166
  const withFindHasuraGraphQL = (MixinBase) => {
2450
3167
  return class FindHasuraGraphQLMixin extends MixinBase {
2451
- async find(options) {
2452
- const { filters, limits, orderBy } = options || {};
3168
+ constructor() {
3169
+ super(...arguments);
3170
+ this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => ({
3171
+ ...acc,
3172
+ [AttributeOptionHelper.FindByAttribute(current, fields)
3173
+ .columnName]: orderBy[current],
3174
+ }), {});
3175
+ }
3176
+ async find(params) {
3177
+ this.logger = DebugHelper.from(this, 'find');
3178
+ const { filters, limits, orderBy, options } = params || {};
3179
+ const enableCount = options?.enableCount ?? true;
2453
3180
  const variablesCount = {
2454
- ...(isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } }),
3181
+ ...(isNil(orderBy)
3182
+ ? {}
3183
+ : {
3184
+ order_by: {
3185
+ type: `${this.tableName}_order_by!`,
3186
+ list: true,
3187
+ value: this.bindOrderByAttributes(orderBy, this.fields),
3188
+ },
3189
+ }),
2455
3190
  ...(isNil(filters)
2456
3191
  ? {}
2457
3192
  : {
@@ -2469,23 +3204,26 @@ const withFindHasuraGraphQL = (MixinBase) => {
2469
3204
  const result = await this.query([
2470
3205
  {
2471
3206
  operation: this.tableName,
2472
- fields: options.fields
2473
- ? options.fields
3207
+ fields: params.fields
3208
+ ? params.fields
2474
3209
  .map((fieldName) => this.fields.find((fieldOption) => fieldOption === fieldName) ??
2475
3210
  this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName))
2476
3211
  .filter(Boolean)
2477
3212
  : this.fields,
2478
3213
  variables,
2479
3214
  },
2480
- {
2481
- operation: `${this.tableName}_aggregate`,
2482
- fields: [{ aggregate: ['count'] }],
2483
- variables: variablesCount,
2484
- },
3215
+ ...(enableCount
3216
+ ? [
3217
+ {
3218
+ operation: `${this.tableName}_aggregate`,
3219
+ fields: [{ aggregate: ['count'] }],
3220
+ variables: variablesCount,
3221
+ },
3222
+ ]
3223
+ : []),
2485
3224
  ]);
2486
3225
  const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
2487
- const count = result[`${this.tableName}_aggregate`].aggregate.count;
2488
- return { count, data };
3226
+ return { data, count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity };
2489
3227
  }
2490
3228
  };
2491
3229
  };
@@ -2524,13 +3262,102 @@ class VariantHasuraGraphQL extends Variant {
2524
3262
  }
2525
3263
  }
2526
3264
 
3265
+ class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3266
+ constructor(endpoint, authOptions) {
3267
+ super({
3268
+ tableName: 'category_collection_children',
3269
+ model: CategoryCollectionChildren,
3270
+ endpoint,
3271
+ authOptions,
3272
+ fields: [
3273
+ { collectionId: { columnName: 'collection_id' } },
3274
+ { categoryId: { columnName: 'category_id' } },
3275
+ 'name',
3276
+ 'slug',
3277
+ 'reference',
3278
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
3279
+ { parentCategoryId: { columnName: 'parent_category_id' } },
3280
+ {
3281
+ parent: {
3282
+ columnName: 'parent',
3283
+ foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
3284
+ fields: [
3285
+ { collectionId: { columnName: 'collection_id' } },
3286
+ { categoryId: { columnName: 'category_id' } },
3287
+ 'name',
3288
+ 'slug',
3289
+ 'reference',
3290
+ { parentCollectionId: { columnName: 'parent_collection_id' } },
3291
+ { parentCategoryId: { columnName: 'parent_category_id' } },
3292
+ ],
3293
+ },
3294
+ },
3295
+ ],
3296
+ });
3297
+ }
3298
+ }
3299
+
3300
+ class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3301
+ constructor({ endpoint, authOptions, interceptors, }) {
3302
+ super({
3303
+ tableName: 'category_filter',
3304
+ model: CategoryFilter,
3305
+ endpoint,
3306
+ authOptions,
3307
+ interceptors,
3308
+ fields: [
3309
+ 'id',
3310
+ { filterId: { columnName: 'filter_id' } },
3311
+ { categoryId: { columnName: 'category_id' } },
3312
+ {
3313
+ filter: {
3314
+ columnName: 'filter',
3315
+ foreignKeyColumn: { id: 'filterId' },
3316
+ fields: [
3317
+ 'id',
3318
+ 'description',
3319
+ 'slug',
3320
+ 'enabled',
3321
+ { createdAt: { columnName: 'created_at' } },
3322
+ { updatedAt: { columnName: 'updated_at' } },
3323
+ {
3324
+ options: {
3325
+ columnName: 'options',
3326
+ foreignKeyColumn: { filterId: 'id' },
3327
+ fields: [
3328
+ 'id',
3329
+ { filterId: { columnName: 'filter_id' } },
3330
+ 'description',
3331
+ { createdAt: { columnName: 'created_at' } },
3332
+ { updatedAt: { columnName: 'updated_at' } },
3333
+ ],
3334
+ },
3335
+ },
3336
+ ],
3337
+ },
3338
+ },
3339
+ ],
3340
+ });
3341
+ }
3342
+ deleteByCategoryAndFilter(categoryId, filterId) {
3343
+ return this.mutation('delete_category_filter', ['affected_rows'], {
3344
+ where: {
3345
+ type: 'category_filter_bool_exp',
3346
+ required: true,
3347
+ value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
3348
+ },
3349
+ });
3350
+ }
3351
+ }
3352
+
2527
3353
  class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2528
- constructor(endpoint, authOptions, productRepository) {
3354
+ constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
2529
3355
  super({
2530
3356
  tableName: 'category',
2531
3357
  model: Category,
2532
3358
  endpoint,
2533
3359
  authOptions,
3360
+ interceptors,
2534
3361
  fields: [
2535
3362
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
2536
3363
  { firestoreId: { columnName: 'firestore_id' } },
@@ -2539,6 +3366,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2539
3366
  'image',
2540
3367
  'published',
2541
3368
  'shop',
3369
+ { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
2542
3370
  'slug',
2543
3371
  { brandCategory: { columnName: 'brand_category' } },
2544
3372
  { brandCategoryBanner: { columnName: 'brand_banner' } },
@@ -2567,7 +3395,17 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2567
3395
  },
2568
3396
  },
2569
3397
  },
2570
- 'filters',
3398
+ {
3399
+ filters: {
3400
+ columnName: 'filters',
3401
+ foreignKeyColumn: { filter_id: 'id' },
3402
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
3403
+ bindPersistData: (value) => ({
3404
+ filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
3405
+ }),
3406
+ from: (filters) => filters?.map((filter) => filter?.filter) || [],
3407
+ },
3408
+ },
2571
3409
  { createdAt: { columnName: 'created_at' } },
2572
3410
  { updatedAt: { columnName: 'updated_at' } },
2573
3411
  {
@@ -2589,9 +3427,20 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2589
3427
  }),
2590
3428
  },
2591
3429
  },
3430
+ { isCollection: { columnName: 'is_collection' } },
3431
+ 'reference',
3432
+ { parentId: { columnName: 'parent_id' } },
3433
+ {
3434
+ parent: {
3435
+ columnName: 'parent',
3436
+ foreignKeyColumn: { id: 'parentId' },
3437
+ fields: ['id', 'name', 'reference', 'slug'],
3438
+ },
3439
+ },
2592
3440
  ],
2593
3441
  });
2594
3442
  this.productRepository = productRepository;
3443
+ this.categoryFilterRepository = categoryFilterRepository;
2595
3444
  }
2596
3445
  async create(params) {
2597
3446
  const { metadata, ...data } = params;
@@ -2599,29 +3448,53 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2599
3448
  }
2600
3449
  async get(identifiers) {
2601
3450
  return Number.isNaN(+identifiers.id)
2602
- ? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
3451
+ ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
2603
3452
  : super.get(identifiers);
2604
3453
  }
2605
3454
  async update(params) {
2606
- const { products, id: checkId, metadata, ...data } = params;
3455
+ const { products, id: checkId, metadata, filters, ...data } = params;
2607
3456
  const plainData = this.paramsToPlain({ id: checkId });
2608
3457
  const id = await this.getId(plainData.id);
2609
3458
  const category = await super.update({ id, ...data });
2610
3459
  category.products = products && (await this.updateProducts(+id, { products }));
2611
3460
  category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
3461
+ category.filters = filters && (await this.updateFilters(+id, { filters }));
2612
3462
  return category;
2613
3463
  }
2614
3464
  async getCategoryBySlug(slug, shop) {
2615
3465
  if (!slug)
2616
3466
  return null;
2617
- const { data, count } = await this.find({ filters: { slug, shop, published: true } });
2618
- if (count > 1)
2619
- throw new DuplicatedResultsError('Query returned duplicated values');
2620
- if (!count)
3467
+ const { data } = await this.find({
3468
+ filters: {
3469
+ slug,
3470
+ shops: { operator: Where.IN, value: [shop] },
3471
+ published: { operator: Where.EQUALS, value: true },
3472
+ },
3473
+ options: {
3474
+ enableCount: false,
3475
+ },
3476
+ });
3477
+ if (!data.length)
2621
3478
  throw new NotFoundError(`Category with slug ${slug} not found`);
3479
+ if (data.length > 1)
3480
+ throw new DuplicatedResultsError('Query returned duplicated values');
2622
3481
  return data.shift();
2623
3482
  }
2624
- async getCategoriesForHome(categoryIds, limit = 4) {
3483
+ async getCategoryByShop(shop) {
3484
+ if (!shop)
3485
+ return;
3486
+ const { data } = await this.find({
3487
+ filters: {
3488
+ shops: { operator: Where.IN, value: [shop] },
3489
+ published: { operator: Where.EQUALS, value: true },
3490
+ },
3491
+ options: {
3492
+ enableCount: false,
3493
+ },
3494
+ });
3495
+ return data;
3496
+ }
3497
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
2625
3498
  if (!categoryIds?.length)
2626
3499
  return [];
2627
3500
  const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
@@ -2639,7 +3512,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2639
3512
  return [];
2640
3513
  const homeSections = await Promise.all(categories.map(async (category) => ({
2641
3514
  category,
2642
- products: await this.mountCategory(category, { limit, hasStock: true }),
3515
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
2643
3516
  })));
2644
3517
  return homeSections;
2645
3518
  }
@@ -2652,6 +3525,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2652
3525
  id: { operator: Where.IN, value: category.products },
2653
3526
  published: true,
2654
3527
  ...(options?.hasStock ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {}),
3528
+ ...(options?.gender ? { tags: { operator: Where.IN, value: [options?.gender] } } : {}),
2655
3529
  },
2656
3530
  fields: [
2657
3531
  'id',
@@ -2677,8 +3551,11 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2677
3551
  'tags',
2678
3552
  'type',
2679
3553
  'shoppingCount',
3554
+ 'gender',
3555
+ 'createdAt',
2680
3556
  ],
2681
3557
  ...(options?.limit ? { limits: { limit: options?.limit } } : {}),
3558
+ options: { enableCount: false },
2682
3559
  });
2683
3560
  products.push(...productsData);
2684
3561
  return products;
@@ -2686,7 +3563,7 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2686
3563
  async getId(id) {
2687
3564
  if (!Number.isNaN(+id))
2688
3565
  return id;
2689
- const { data } = await this.find({ filters: { firestoreId: id } });
3566
+ const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
2690
3567
  if (data?.[0]?.id)
2691
3568
  return data?.[0]?.id;
2692
3569
  throw new NotFoundError(`Category with id ${id} not found`);
@@ -2739,15 +3616,218 @@ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGr
2739
3616
  });
2740
3617
  return plainData.metadata;
2741
3618
  }
3619
+ async updateFilters(categoryId, { filters }) {
3620
+ if ('action' in filters && filters.action === 'remove' && filters.value.length) {
3621
+ for (let i = 0; i < filters.value.length; i++) {
3622
+ await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
3623
+ }
3624
+ return [];
3625
+ }
3626
+ if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3627
+ let filtersList = [];
3628
+ for (let i = 0; i < filters.value.length; i++) {
3629
+ try {
3630
+ const hasFilter = await this.categoryFilterRepository
3631
+ .find({
3632
+ filters: {
3633
+ categoryId,
3634
+ filterId: filters.value[i].id,
3635
+ },
3636
+ })
3637
+ .then((data) => data.data.shift()?.filter);
3638
+ if (hasFilter) {
3639
+ filtersList.push(hasFilter);
3640
+ }
3641
+ else {
3642
+ await this.categoryFilterRepository.create({
3643
+ filterId: filters.value[i].id,
3644
+ categoryId,
3645
+ });
3646
+ filtersList.push(filters.value[i]);
3647
+ }
3648
+ }
3649
+ catch (error) {
3650
+ console.log('catch error: ', error);
3651
+ }
3652
+ }
3653
+ return filtersList;
3654
+ }
3655
+ if (Array.isArray(filters) && filters.length) {
3656
+ let filtersList = [];
3657
+ for (let i = 0; i < filters.length; i++) {
3658
+ try {
3659
+ const hasFilter = await this.categoryFilterRepository
3660
+ .find({
3661
+ filters: {
3662
+ categoryId,
3663
+ filterId: filters[i].id,
3664
+ },
3665
+ })
3666
+ .then((data) => data.data.shift()?.filter);
3667
+ if (hasFilter) {
3668
+ filtersList.push(hasFilter);
3669
+ }
3670
+ else {
3671
+ await this.categoryFilterRepository.create({
3672
+ filterId: filters[i].id,
3673
+ categoryId,
3674
+ });
3675
+ filtersList.push(filters[i]);
3676
+ }
3677
+ }
3678
+ catch (error) {
3679
+ console.log('catch error: ', error);
3680
+ }
3681
+ }
3682
+ return filtersList;
3683
+ }
3684
+ return [];
3685
+ }
3686
+ async getChildren(parentId) {
3687
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id'], {
3688
+ args: {
3689
+ type: 'category_tree_args',
3690
+ value: { parentid: parentId },
3691
+ required: true,
3692
+ },
3693
+ });
3694
+ return category_tree.map((category) => Category.toInstance(category));
3695
+ }
3696
+ async isChild(id, parentId) {
3697
+ const categoryTree = await this.getChildren(parentId);
3698
+ return categoryTree.some((c) => c.id == id.toString());
3699
+ }
3700
+ }
3701
+
3702
+ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3703
+ constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
3704
+ super({
3705
+ tableName: 'filter',
3706
+ model: Filter,
3707
+ endpoint,
3708
+ authOptions,
3709
+ interceptors,
3710
+ fields: [
3711
+ 'id',
3712
+ 'description',
3713
+ 'slug',
3714
+ 'enabled',
3715
+ { createdAt: { columnName: 'created_at' } },
3716
+ { updatedAt: { columnName: 'updated_at' } },
3717
+ {
3718
+ options: {
3719
+ columnName: 'options',
3720
+ foreignKeyColumn: { filterId: 'id' },
3721
+ fields: [
3722
+ 'id',
3723
+ { filterId: { columnName: 'filter_id' } },
3724
+ 'description',
3725
+ { createdAt: { columnName: 'created_at' } },
3726
+ { updatedAt: { columnName: 'updated_at' } },
3727
+ ],
3728
+ },
3729
+ },
3730
+ ],
3731
+ });
3732
+ this.filterOptionRepository = filterOptionRepository;
3733
+ this.categoryFilterRepository = categoryFilterRepository;
3734
+ }
3735
+ async update(params) {
3736
+ const { options, ...data } = params;
3737
+ const filter = await super.update(data);
3738
+ filter.options = await this.updateOptions(+data.id, { options });
3739
+ return filter;
3740
+ }
3741
+ async updateOptions(filterId, { options }) {
3742
+ if (!options)
3743
+ return [];
3744
+ if ('action' in options && options.action === 'remove' && options.value.length) {
3745
+ for (let i = 0; i < options.value.length; i++) {
3746
+ await this.filterOptionRepository.delete({ id: options.value[i].id });
3747
+ }
3748
+ return [];
3749
+ }
3750
+ if ('action' in options && options.action === 'merge' && options.value.length) {
3751
+ let filterOptions = [];
3752
+ for (let i = 0; i < options.value.length; i++) {
3753
+ try {
3754
+ const hasFilter = await this.filterOptionRepository.get({ id: options.value[i].id });
3755
+ if (hasFilter)
3756
+ filterOptions.push(hasFilter);
3757
+ }
3758
+ catch (error) {
3759
+ const newOption = await this.filterOptionRepository.create({ ...options.value[i], filterId });
3760
+ filterOptions.push(newOption);
3761
+ }
3762
+ }
3763
+ return filterOptions;
3764
+ }
3765
+ if (Array.isArray(options) && options.length) {
3766
+ let filterOptions = [];
3767
+ for (let i = 0; i < options.length; i++) {
3768
+ try {
3769
+ const hasFilter = await this.filterOptionRepository.get({ id: options[i].id });
3770
+ if (hasFilter)
3771
+ filterOptions.push(hasFilter);
3772
+ }
3773
+ catch (error) {
3774
+ const newOption = await this.filterOptionRepository.create({ ...options[i], filterId });
3775
+ filterOptions.push(newOption);
3776
+ }
3777
+ }
3778
+ }
3779
+ return [];
3780
+ }
3781
+ async delete(params) {
3782
+ const { data: categoryFilters } = await this.categoryFilterRepository.find({
3783
+ filters: {
3784
+ filterId: params.id,
3785
+ },
3786
+ });
3787
+ if (categoryFilters.length)
3788
+ throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
3789
+ await this.deleteOptions(+params.id);
3790
+ await super.delete({ id: +params.id });
3791
+ return;
3792
+ }
3793
+ async deleteOptions(filterId) {
3794
+ await this.mutation('delete_filter_option', ['affected_rows'], {
3795
+ where: {
3796
+ type: 'filter_option_bool_exp',
3797
+ required: true,
3798
+ value: { filter_id: { _eq: filterId } },
3799
+ },
3800
+ });
3801
+ }
3802
+ }
3803
+
3804
+ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3805
+ constructor({ endpoint, authOptions, interceptors, }) {
3806
+ super({
3807
+ tableName: 'filter_option',
3808
+ model: FilterOption,
3809
+ endpoint,
3810
+ authOptions,
3811
+ interceptors,
3812
+ fields: [
3813
+ 'id',
3814
+ 'description',
3815
+ { filterId: { columnName: 'filter_id' } },
3816
+ { createdAt: { columnName: 'created_at' } },
3817
+ { updatedAt: { columnName: 'updated_at' } },
3818
+ ],
3819
+ });
3820
+ }
2742
3821
  }
2743
3822
 
2744
3823
  class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2745
- constructor(endpoint, authOptions) {
3824
+ constructor({ endpoint, authOptions, interceptors, }) {
2746
3825
  super({
2747
3826
  tableName: 'product',
2748
3827
  model: ProductHasuraGraphQL,
2749
3828
  endpoint,
2750
3829
  authOptions,
3830
+ interceptors,
2751
3831
  fields: [],
2752
3832
  });
2753
3833
  this.bindReviewToModel = (plain) => ({
@@ -2780,6 +3860,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2780
3860
  whoMustUse: data.who_must_use,
2781
3861
  howToUse: data.how_to_use,
2782
3862
  brand: data.brand_description,
3863
+ ingredients: data.ingredients,
2783
3864
  }),
2784
3865
  bindFindFilter: (sentence) => {
2785
3866
  const filters = Object.values(sentence).shift();
@@ -2795,6 +3876,9 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2795
3876
  ...(filters.brand && {
2796
3877
  brand_description: filters.brand,
2797
3878
  }),
3879
+ ...(filters.ingredients && {
3880
+ ingredients: filters.ingredients,
3881
+ }),
2798
3882
  };
2799
3883
  },
2800
3884
  bindPersistData: (descriptionData) => ({
@@ -2805,6 +3889,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2805
3889
  }),
2806
3890
  ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
2807
3891
  ...(descriptionData.brand && { brand_description: descriptionData.brand }),
3892
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
2808
3893
  }),
2809
3894
  },
2810
3895
  },
@@ -2812,6 +3897,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2812
3897
  { whoMustUse: { columnName: 'who_must_use' } },
2813
3898
  { howToUse: { columnName: 'how_to_use' } },
2814
3899
  { brandDescription: { columnName: 'brand_description' } },
3900
+ { ingredients: { columnName: 'ingredients' } },
2815
3901
  { hasVariants: { columnName: 'has_variants' } },
2816
3902
  {
2817
3903
  images: {
@@ -2876,21 +3962,21 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2876
3962
  'weight',
2877
3963
  'gender',
2878
3964
  { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
3965
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
2879
3966
  { isKit: { columnName: 'is_kit' } },
2880
3967
  { createdAt: { columnName: 'created_at' } },
2881
3968
  { updatedAt: { columnName: 'updated_at' } },
3969
+ { rate: { columnName: 'rating' } },
3970
+ { reviewsTotal: { columnName: 'reviews_total' } },
3971
+ { shoppingCount: { columnName: 'shopping_count' } },
3972
+ { categoryId: { columnName: 'category_id' } },
2882
3973
  {
2883
- rate: {
2884
- columnName: 'reviews_aggregate',
2885
- filters: {
2886
- filters: { status: true },
2887
- filterType: 'product_review_bool_exp',
2888
- },
2889
- fields: [{ aggregate: [{ avg: ['rate'] }] }],
2890
- from: (value) => value.aggregate.avg.rate,
3974
+ category: {
3975
+ columnName: 'category',
3976
+ foreignKeyColumn: { id: 'categoryId' },
3977
+ fields: ['id', 'name', 'reference', 'slug'],
2891
3978
  },
2892
3979
  },
2893
- { shoppingCount: { columnName: 'shopping_count' } },
2894
3980
  ];
2895
3981
  this.fields = [
2896
3982
  ...commonFields,
@@ -2967,7 +4053,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2967
4053
  }
2968
4054
  async get(identifiers) {
2969
4055
  const product = Number.isNaN(+identifiers.id)
2970
- ? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
4056
+ ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
2971
4057
  : await super.get(identifiers);
2972
4058
  if (product.productId)
2973
4059
  throw new NotFoundError('Product not found, it is a variant');
@@ -2983,7 +4069,16 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2983
4069
  return super.find({
2984
4070
  ...options,
2985
4071
  filters: { ...filters, productId: { operator: Where.ISNULL } },
2986
- fields: bindFields,
4072
+ fields: [
4073
+ ...bindFields,
4074
+ ...(bindFields.includes('price')
4075
+ ? [
4076
+ 'subscriberPrice',
4077
+ 'subscriberDiscountPercentage',
4078
+ 'fullPrice',
4079
+ ]
4080
+ : []),
4081
+ ],
2987
4082
  });
2988
4083
  }
2989
4084
  async getBySlug(slug) {
@@ -2991,9 +4086,13 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
2991
4086
  filters: {
2992
4087
  slug,
2993
4088
  },
4089
+ fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
4090
+ options: {
4091
+ enableCount: false,
4092
+ },
2994
4093
  });
2995
4094
  const product = result?.data?.shift();
2996
- product.reviews = await this.findReviewsByProduct(+product.id);
4095
+ RoundProductPricesHelper.roundProductPrices(product);
2997
4096
  return product;
2998
4097
  }
2999
4098
  async update(params) {
@@ -3143,7 +4242,7 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3143
4242
  async getId(id) {
3144
4243
  if (!Number.isNaN(+id))
3145
4244
  return id;
3146
- const { data } = await this.find({ filters: { firestoreId: id } });
4245
+ const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3147
4246
  if (data?.[0]?.id)
3148
4247
  return data?.[0]?.id;
3149
4248
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3199,15 +4298,29 @@ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3199
4298
  });
3200
4299
  return data && data[0] && this.bindReviewToModel(data[0]);
3201
4300
  }
4301
+ async cleanShoppingCountFromIds(ids) {
4302
+ return await this.mutation('update_product', ['affected_rows'], {
4303
+ where: {
4304
+ value: { id: { _nin: ids } },
4305
+ type: 'product_bool_exp',
4306
+ required: true,
4307
+ },
4308
+ _set: {
4309
+ value: { shopping_count: 0 },
4310
+ type: 'product_set_input',
4311
+ },
4312
+ });
4313
+ }
3202
4314
  }
3203
4315
 
3204
4316
  class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3205
- constructor(endpoint, authOptions) {
4317
+ constructor({ endpoint, authOptions, interceptors, }) {
3206
4318
  super({
3207
4319
  tableName: 'product',
3208
4320
  model: VariantHasuraGraphQL,
3209
4321
  endpoint,
3210
4322
  authOptions,
4323
+ interceptors,
3211
4324
  fields: [
3212
4325
  { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
3213
4326
  { firestoreId: { columnName: 'firestore_id' } },
@@ -3243,12 +4356,12 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3243
4356
  };
3244
4357
  },
3245
4358
  bindPersistData: (priceData) => ({
3246
- ...(priceData?.price >= 0 && { price: priceData.price }),
3247
- ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
3248
- ...(priceData.subscriberDiscountPercentage >= 0 && {
4359
+ ...((priceData?.price || 0) >= 0 && { price: priceData.price }),
4360
+ ...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
4361
+ ...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
3249
4362
  subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
3250
4363
  }),
3251
- ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
4364
+ ...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
3252
4365
  }),
3253
4366
  },
3254
4367
  },
@@ -3300,7 +4413,7 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3300
4413
  async getId(id) {
3301
4414
  if (!Number.isNaN(+id))
3302
4415
  return id;
3303
- const { data } = await this.find({ filters: { firestoreId: id } });
4416
+ const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3304
4417
  if (data?.[0]?.id)
3305
4418
  return data?.[0]?.id;
3306
4419
  throw new NotFoundError(`Product with id ${id} not found`);
@@ -3311,5 +4424,5 @@ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGra
3311
4424
  * Generated bundle index. Do not edit.
3312
4425
  */
3313
4426
 
3314
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, chunk, get, is, isBoolean, isDate, isEmpty, isInteger, isNaN$1 as isNaN, isNil, isNumber, isObject, isString, isUUID, now, omit, parseDateTime, pick, set, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
4427
+ 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, get, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
3315
4428
  //# sourceMappingURL=infrab4a-connect.mjs.map