@infrab4a/connect 4.0.0 → 4.0.1-beta.0

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 (800) hide show
  1. package/README.md +24 -24
  2. package/bundles/infrab4a-connect.umd.js +5108 -0
  3. package/bundles/infrab4a-connect.umd.js.map +1 -0
  4. package/domain/catalog/index.d.ts +2 -3
  5. package/domain/catalog/models/category.d.ts +24 -7
  6. package/domain/catalog/models/enums/index.d.ts +2 -2
  7. package/domain/catalog/models/enums/product-genders.enum.d.ts +5 -5
  8. package/domain/catalog/models/enums/shops.enum.d.ts +6 -6
  9. package/domain/catalog/models/index.d.ts +6 -11
  10. package/domain/catalog/models/kit-product.d.ts +12 -12
  11. package/domain/catalog/models/product.d.ts +39 -9
  12. package/domain/catalog/models/types/category-condition.type.d.ts +4 -4
  13. package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
  14. package/domain/catalog/models/types/category-metadata.type.d.ts +4 -4
  15. package/domain/catalog/models/types/index.d.ts +10 -11
  16. package/domain/catalog/models/types/product-gender.type.d.ts +1 -1
  17. package/domain/catalog/models/types/product-metadata.type.d.ts +4 -4
  18. package/domain/catalog/models/types/product-review.type.d.ts +17 -17
  19. package/domain/catalog/models/types/shop-description.type.d.ts +7 -8
  20. package/domain/catalog/models/types/shop-price.type.d.ts +6 -6
  21. package/domain/catalog/models/types/stock.type.d.ts +3 -3
  22. package/domain/catalog/models/types/variant-grade.type.d.ts +4 -4
  23. package/domain/catalog/models/variant.d.ts +18 -17
  24. package/domain/catalog/repositories/category.repository.d.ts +15 -18
  25. package/domain/catalog/repositories/index.d.ts +4 -9
  26. package/domain/catalog/repositories/product.repository.d.ts +12 -15
  27. package/domain/catalog/repositories/subscription-product.repository.d.ts +4 -4
  28. package/domain/catalog/repositories/variant.repository.d.ts +4 -4
  29. package/domain/generic/index.d.ts +2 -2
  30. package/domain/generic/model/base.model.d.ts +10 -14
  31. package/domain/generic/model/identifier-fields.d.ts +4 -4
  32. package/domain/generic/model/index.d.ts +3 -3
  33. package/domain/generic/model/types/base-model-builder.type.d.ts +15 -17
  34. package/domain/generic/model/types/identifier-model.type.d.ts +7 -8
  35. package/domain/generic/model/types/index.d.ts +5 -5
  36. package/domain/generic/model/types/model-base-structure.type.d.ts +6 -12
  37. package/domain/generic/model/types/non-function-properties.type.d.ts +12 -12
  38. package/domain/generic/model/types/non-function-property-name.type.d.ts +4 -13
  39. package/domain/generic/repository/create.repository.d.ts +8 -8
  40. package/domain/generic/repository/crud.repository.d.ts +19 -19
  41. package/domain/generic/repository/delete.repository.d.ts +7 -7
  42. package/domain/generic/repository/enums/index.d.ts +2 -2
  43. package/domain/generic/repository/enums/update-option-actions.enum.d.ts +7 -7
  44. package/domain/generic/repository/enums/where.enum.d.ts +14 -14
  45. package/domain/generic/repository/find.repository.d.ts +11 -17
  46. package/domain/generic/repository/get.repository.d.ts +5 -5
  47. package/domain/generic/repository/index.d.ts +9 -9
  48. package/domain/generic/repository/read.repository.d.ts +14 -14
  49. package/domain/generic/repository/types/index.d.ts +6 -6
  50. package/domain/generic/repository/types/repository-find-filters.type.d.ts +13 -13
  51. package/domain/generic/repository/types/repository-find-result.type.d.ts +4 -14
  52. package/domain/generic/repository/types/repository-limit-options.type.d.ts +4 -4
  53. package/domain/generic/repository/types/repository-order-by-list.type.d.ts +5 -5
  54. package/domain/generic/repository/types/repository-update-params.type.d.ts +11 -11
  55. package/domain/generic/repository/types/where-options.type.d.ts +2 -2
  56. package/domain/generic/repository/update.repository.d.ts +6 -6
  57. package/domain/index.d.ts +6 -6
  58. package/domain/location/index.d.ts +1 -1
  59. package/domain/location/models/address.d.ts +22 -24
  60. package/domain/location/models/index.d.ts +2 -2
  61. package/domain/location/models/types/index.d.ts +3 -3
  62. package/domain/location/models/types/location-bound.type.d.ts +6 -6
  63. package/domain/location/models/types/location-geometry.type.d.ts +7 -7
  64. package/domain/location/models/types/location-lat-lng.type.d.ts +4 -4
  65. package/domain/shop-settings/enums/filter-type.enum.d.ts +19 -19
  66. package/domain/shop-settings/enums/index.d.ts +2 -2
  67. package/domain/shop-settings/enums/questions-filters.enum.d.ts +19 -19
  68. package/domain/shop-settings/helpers/beauty-questions.helper.d.ts +9 -9
  69. package/domain/shop-settings/helpers/index.d.ts +1 -1
  70. package/domain/shop-settings/index.d.ts +4 -4
  71. package/domain/shop-settings/models/home.d.ts +18 -18
  72. package/domain/shop-settings/models/index.d.ts +4 -4
  73. package/domain/shop-settings/models/shop-menu.d.ts +7 -7
  74. package/domain/shop-settings/models/shop-settings.d.ts +9 -9
  75. package/domain/shop-settings/models/types/banner.type.d.ts +6 -6
  76. package/domain/shop-settings/models/types/benefit.type.d.ts +5 -5
  77. package/domain/shop-settings/models/types/home-data.type.d.ts +15 -15
  78. package/domain/shop-settings/models/types/index.d.ts +10 -10
  79. package/domain/shop-settings/models/types/menu-nav.type.d.ts +8 -8
  80. package/domain/shop-settings/models/types/shop-banner.type.d.ts +11 -12
  81. package/domain/shop-settings/models/types/shop-brands.type.d.ts +10 -10
  82. package/domain/shop-settings/models/types/shop-carousel.type.d.ts +5 -5
  83. package/domain/shop-settings/models/types/shop-collection.type.d.ts +9 -9
  84. package/domain/shop-settings/models/types/shop-section.type.d.ts +9 -9
  85. package/domain/shop-settings/models/types/sub-menu.type.d.ts +8 -8
  86. package/domain/shop-settings/repositories/home.repository.d.ts +4 -4
  87. package/domain/shop-settings/repositories/index.d.ts +3 -3
  88. package/domain/shop-settings/repositories/shop-menu.repository.d.ts +4 -4
  89. package/domain/shop-settings/repositories/shop-settings.repository.d.ts +4 -4
  90. package/domain/shopping/index.d.ts +2 -2
  91. package/domain/shopping/models/buy-2-win.d.ts +16 -18
  92. package/domain/shopping/models/checkout.d.ts +27 -26
  93. package/domain/shopping/models/coupons/coupon.d.ts +32 -60
  94. package/domain/shopping/models/coupons/enums/coupon-club-mens.enum.d.ts +5 -5
  95. package/domain/shopping/models/coupons/enums/coupon-subtypes.enum.d.ts +4 -4
  96. package/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +4 -4
  97. package/domain/shopping/models/coupons/enums/exclusivities.enum.d.ts +8 -8
  98. package/domain/shopping/models/coupons/enums/index.d.ts +3 -3
  99. package/domain/shopping/models/coupons/index.d.ts +2 -2
  100. package/domain/shopping/models/enums/checkout-types.enum.d.ts +5 -5
  101. package/domain/shopping/models/enums/index.d.ts +2 -2
  102. package/domain/shopping/models/enums/order-status.enum.d.ts +10 -10
  103. package/domain/shopping/models/index.d.ts +11 -12
  104. package/domain/shopping/models/line-item.d.ts +8 -8
  105. package/domain/shopping/models/order.d.ts +9 -10
  106. package/domain/shopping/models/payment.d.ts +67 -67
  107. package/domain/shopping/models/shipping-method.d.ts +16 -17
  108. package/domain/shopping/models/subscription/checkout.d.ts +21 -20
  109. package/domain/shopping/models/subscription/index.d.ts +2 -2
  110. package/domain/shopping/models/subscription/plan.d.ts +10 -10
  111. package/domain/shopping/models/types/index.d.ts +7 -7
  112. package/domain/shopping/models/types/payment-address.type.d.ts +12 -12
  113. package/domain/shopping/models/types/payment-billing.type.d.ts +7 -7
  114. package/domain/shopping/models/types/payment-card.type.d.ts +14 -14
  115. package/domain/shopping/models/types/payment-customer.type.d.ts +18 -18
  116. package/domain/shopping/models/types/payment-document.type.d.ts +6 -6
  117. package/domain/shopping/models/types/payment-item.type.d.ts +11 -11
  118. package/domain/shopping/models/types/payment-shipping.type.d.ts +10 -10
  119. package/domain/shopping/repositories/buy-2-win.repository.d.ts +4 -4
  120. package/domain/shopping/repositories/checkout.repository.d.ts +4 -4
  121. package/domain/shopping/repositories/coupon.repository.d.ts +4 -4
  122. package/domain/shopping/repositories/index.d.ts +7 -9
  123. package/domain/shopping/repositories/legacy-order.repository.d.ts +3 -3
  124. package/domain/shopping/repositories/order.repository.d.ts +4 -4
  125. package/domain/shopping/repositories/payment.repository.d.ts +4 -4
  126. package/domain/shopping/repositories/subscription/checkout.repository.d.ts +4 -4
  127. package/domain/shopping/repositories/subscription/index.d.ts +2 -2
  128. package/domain/shopping/repositories/subscription/plan.repository.d.ts +4 -4
  129. package/domain/users/errors/index.d.ts +3 -3
  130. package/domain/users/errors/unauthorized.error.d.ts +5 -4
  131. package/domain/users/errors/user-already-registered.error.d.ts +5 -4
  132. package/domain/users/errors/weak-password.error.d.ts +5 -4
  133. package/domain/users/index.d.ts +5 -5
  134. package/domain/users/models/beauty-profile.d.ts +11 -11
  135. package/domain/users/models/enums/accessory-importances.enum.d.ts +5 -5
  136. package/domain/users/models/enums/area.enum.d.ts +11 -11
  137. package/domain/users/models/enums/beard-problems.enum.d.ts +9 -9
  138. package/domain/users/models/enums/beard-sizes.enum.d.ts +7 -7
  139. package/domain/users/models/enums/beauty-product-importances.enum.d.ts +6 -6
  140. package/domain/users/models/enums/body-problems.enum.d.ts +11 -11
  141. package/domain/users/models/enums/body-shapes.enum.d.ts +7 -7
  142. package/domain/users/models/enums/body-tattoos.enum.d.ts +5 -5
  143. package/domain/users/models/enums/face-skin-oilinesses.enum.d.ts +7 -7
  144. package/domain/users/models/enums/face-skin-problems.enum.d.ts +10 -10
  145. package/domain/users/models/enums/face-skin-tones.enum.d.ts +8 -8
  146. package/domain/users/models/enums/family-incomes.enum.d.ts +8 -8
  147. package/domain/users/models/enums/fragrance-importances.enum.d.ts +5 -5
  148. package/domain/users/models/enums/hair-colors.enum.d.ts +10 -10
  149. package/domain/users/models/enums/hair-problems.enum.d.ts +10 -10
  150. package/domain/users/models/enums/hair-strands.enum.d.ts +8 -8
  151. package/domain/users/models/enums/hair-types.enum.d.ts +7 -7
  152. package/domain/users/models/enums/index.d.ts +20 -20
  153. package/domain/users/models/enums/office-position.enum.d.ts +6 -6
  154. package/domain/users/models/enums/product-spents.enum.d.ts +8 -8
  155. package/domain/users/models/enums/user-type.enum.d.ts +8 -8
  156. package/domain/users/models/index.d.ts +7 -7
  157. package/domain/users/models/lead.d.ts +7 -8
  158. package/domain/users/models/subscription/edition.d.ts +16 -16
  159. package/domain/users/models/subscription/enums/billing-status.enum.d.ts +3 -3
  160. package/domain/users/models/subscription/enums/edition-status.enum.d.ts +4 -4
  161. package/domain/users/models/subscription/enums/index.d.ts +4 -4
  162. package/domain/users/models/subscription/enums/payment-type.enum.d.ts +5 -5
  163. package/domain/users/models/subscription/enums/status.enum.d.ts +4 -4
  164. package/domain/users/models/subscription/index.d.ts +4 -4
  165. package/domain/users/models/subscription/payment.d.ts +13 -13
  166. package/domain/users/models/subscription/subscription.d.ts +28 -28
  167. package/domain/users/models/user-address.d.ts +7 -6
  168. package/domain/users/models/user-payment-method.d.ts +14 -14
  169. package/domain/users/models/user.d.ts +28 -27
  170. package/domain/users/repositories/beauty-profile.repository.d.ts +4 -4
  171. package/domain/users/repositories/edition.repository.d.ts +4 -4
  172. package/domain/users/repositories/index.d.ts +8 -8
  173. package/domain/users/repositories/lead.repository.d.ts +4 -4
  174. package/domain/users/repositories/subscription-payment.repository.d.ts +4 -4
  175. package/domain/users/repositories/subscription.repository.d.ts +4 -4
  176. package/domain/users/repositories/user-address.repository.d.ts +4 -4
  177. package/domain/users/repositories/user-payment-method.repository.d.ts +4 -4
  178. package/domain/users/repositories/user.repository.d.ts +6 -6
  179. package/domain/users/services/authentication.service.d.ts +12 -12
  180. package/domain/users/services/index.d.ts +3 -3
  181. package/domain/users/services/register.service.d.ts +7 -7
  182. package/domain/users/services/types/basic-user-data.type.d.ts +4 -4
  183. package/domain/users/services/types/index.d.ts +1 -1
  184. package/domain/users/use-cases/authentication.d.ts +21 -21
  185. package/domain/users/use-cases/index.d.ts +4 -4
  186. package/domain/users/use-cases/recovery-password.d.ts +6 -6
  187. package/domain/users/use-cases/register.d.ts +13 -13
  188. package/domain/users/use-cases/signout.d.ts +6 -6
  189. package/errors/duplicated-results.error.d.ts +5 -4
  190. package/errors/index.d.ts +4 -4
  191. package/errors/invalid-argument.error.d.ts +5 -4
  192. package/errors/not-found.error.d.ts +5 -4
  193. package/errors/required-argument.error.d.ts +6 -6
  194. package/{esm2020/domain/catalog/index.mjs → esm2015/domain/catalog/index.js} +3 -4
  195. package/esm2015/domain/catalog/models/category.js +10 -0
  196. package/{esm2020/domain/catalog/models/enums/index.mjs → esm2015/domain/catalog/models/enums/index.js} +3 -3
  197. package/{esm2020/domain/catalog/models/enums/product-genders.enum.mjs → esm2015/domain/catalog/models/enums/product-genders.enum.js} +7 -7
  198. package/{esm2020/domain/catalog/models/enums/shops.enum.mjs → esm2015/domain/catalog/models/enums/shops.enum.js} +8 -8
  199. package/esm2015/domain/catalog/models/index.js +7 -0
  200. package/esm2015/domain/catalog/models/kit-product.js +18 -0
  201. package/esm2015/domain/catalog/models/product.js +17 -0
  202. package/{esm2020/domain/catalog/models/types/category-condition.type.mjs → esm2015/domain/catalog/models/types/category-condition.type.js} +2 -2
  203. package/esm2015/domain/catalog/models/types/category-filter.type.js +2 -0
  204. package/{esm2020/domain/catalog/models/types/category-metadata.type.mjs → esm2015/domain/catalog/models/types/category-metadata.type.js} +2 -2
  205. package/esm2015/domain/catalog/models/types/index.js +11 -0
  206. package/{esm2020/domain/catalog/models/types/product-gender.type.mjs → esm2015/domain/catalog/models/types/product-gender.type.js} +2 -2
  207. package/{esm2020/domain/catalog/models/types/product-metadata.type.mjs → esm2015/domain/catalog/models/types/product-metadata.type.js} +2 -2
  208. package/esm2015/domain/catalog/models/types/product-review.type.js +2 -0
  209. package/{esm2020/domain/catalog/models/types/shop-description.type.mjs → esm2015/domain/catalog/models/types/shop-description.type.js} +2 -2
  210. package/{esm2020/domain/catalog/models/types/shop-price.type.mjs → esm2015/domain/catalog/models/types/shop-price.type.js} +2 -2
  211. package/{esm2020/domain/catalog/models/types/stock.type.mjs → esm2015/domain/catalog/models/types/stock.type.js} +2 -2
  212. package/{esm2020/domain/catalog/models/types/variant-grade.type.mjs → esm2015/domain/catalog/models/types/variant-grade.type.js} +2 -2
  213. package/esm2015/domain/catalog/models/variant.js +10 -0
  214. package/esm2015/domain/catalog/repositories/category.repository.js +2 -0
  215. package/esm2015/domain/catalog/repositories/index.js +5 -0
  216. package/esm2015/domain/catalog/repositories/product.repository.js +2 -0
  217. package/{esm2020/domain/catalog/repositories/subscription-product.repository.mjs → esm2015/domain/catalog/repositories/subscription-product.repository.js} +2 -2
  218. package/{esm2020/domain/catalog/repositories/variant.repository.mjs → esm2015/domain/catalog/repositories/variant.repository.js} +2 -2
  219. package/{esm2020/domain/generic/index.mjs → esm2015/domain/generic/index.js} +3 -3
  220. package/esm2015/domain/generic/model/base.model.js +23 -0
  221. package/{esm2020/domain/generic/model/identifier-fields.mjs → esm2015/domain/generic/model/identifier-fields.js} +2 -2
  222. package/{esm2020/domain/generic/model/index.mjs → esm2015/domain/generic/model/index.js} +4 -4
  223. package/esm2015/domain/generic/model/types/base-model-builder.type.js +2 -0
  224. package/esm2015/domain/generic/model/types/identifier-model.type.js +2 -0
  225. package/{esm2020/domain/generic/model/types/index.mjs → esm2015/domain/generic/model/types/index.js} +6 -6
  226. package/esm2015/domain/generic/model/types/model-base-structure.type.js +2 -0
  227. package/esm2015/domain/generic/model/types/non-function-properties.type.js +2 -0
  228. package/esm2015/domain/generic/model/types/non-function-property-name.type.js +2 -0
  229. package/esm2015/domain/generic/repository/create.repository.js +2 -0
  230. package/esm2015/domain/generic/repository/crud.repository.js +2 -0
  231. package/esm2015/domain/generic/repository/delete.repository.js +2 -0
  232. package/{esm2020/domain/generic/repository/enums/index.mjs → esm2015/domain/generic/repository/enums/index.js} +3 -3
  233. package/{esm2020/domain/generic/repository/enums/update-option-actions.enum.mjs → esm2015/domain/generic/repository/enums/update-option-actions.enum.js} +9 -9
  234. package/{esm2020/domain/generic/repository/enums/where.enum.mjs → esm2015/domain/generic/repository/enums/where.enum.js} +16 -16
  235. package/esm2015/domain/generic/repository/find.repository.js +2 -0
  236. package/esm2015/domain/generic/repository/get.repository.js +2 -0
  237. package/{esm2020/domain/generic/repository/index.mjs → esm2015/domain/generic/repository/index.js} +10 -10
  238. package/esm2015/domain/generic/repository/read.repository.js +2 -0
  239. package/{esm2020/domain/generic/repository/types/index.mjs → esm2015/domain/generic/repository/types/index.js} +7 -7
  240. package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +2 -0
  241. package/esm2015/domain/generic/repository/types/repository-find-result.type.js +2 -0
  242. package/{esm2020/domain/generic/repository/types/repository-limit-options.type.mjs → esm2015/domain/generic/repository/types/repository-limit-options.type.js} +2 -2
  243. package/{esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs → esm2015/domain/generic/repository/types/repository-order-by-list.type.js} +2 -2
  244. package/esm2015/domain/generic/repository/types/repository-update-params.type.js +2 -0
  245. package/{esm2020/domain/generic/repository/types/where-options.type.mjs → esm2015/domain/generic/repository/types/where-options.type.js} +2 -2
  246. package/esm2015/domain/generic/repository/update.repository.js +2 -0
  247. package/{esm2020/domain/index.mjs → esm2015/domain/index.js} +7 -7
  248. package/{esm2020/domain/location/index.mjs → esm2015/domain/location/index.js} +2 -2
  249. package/esm2015/domain/location/models/address.js +7 -0
  250. package/{esm2020/domain/location/models/index.mjs → esm2015/domain/location/models/index.js} +3 -3
  251. package/{esm2020/domain/location/models/types/index.mjs → esm2015/domain/location/models/types/index.js} +4 -4
  252. package/{esm2020/domain/location/models/types/location-bound.type.mjs → esm2015/domain/location/models/types/location-bound.type.js} +2 -2
  253. package/{esm2020/domain/location/models/types/location-geometry.type.mjs → esm2015/domain/location/models/types/location-geometry.type.js} +2 -2
  254. package/{esm2020/domain/location/models/types/location-lat-lng.type.mjs → esm2015/domain/location/models/types/location-lat-lng.type.js} +2 -2
  255. package/{esm2020/domain/shop-settings/enums/filter-type.enum.mjs → esm2015/domain/shop-settings/enums/filter-type.enum.js} +21 -21
  256. package/{esm2020/domain/shop-settings/enums/index.mjs → esm2015/domain/shop-settings/enums/index.js} +3 -3
  257. package/{esm2020/domain/shop-settings/enums/questions-filters.enum.mjs → esm2015/domain/shop-settings/enums/questions-filters.enum.js} +21 -21
  258. package/{esm2020/domain/shop-settings/helpers/beauty-questions.helper.mjs → esm2015/domain/shop-settings/helpers/beauty-questions.helper.js} +46 -47
  259. package/{esm2020/domain/shop-settings/helpers/index.mjs → esm2015/domain/shop-settings/helpers/index.js} +2 -2
  260. package/{esm2020/domain/shop-settings/index.mjs → esm2015/domain/shop-settings/index.js} +5 -5
  261. package/esm2015/domain/shop-settings/models/home.js +7 -0
  262. package/{esm2020/domain/shop-settings/models/index.mjs → esm2015/domain/shop-settings/models/index.js} +5 -5
  263. package/{esm2020/domain/shop-settings/models/shop-menu.mjs → esm2015/domain/shop-settings/models/shop-menu.js} +7 -7
  264. package/{esm2020/domain/shop-settings/models/shop-settings.mjs → esm2015/domain/shop-settings/models/shop-settings.js} +7 -7
  265. package/{esm2020/domain/shop-settings/models/types/banner.type.mjs → esm2015/domain/shop-settings/models/types/banner.type.js} +2 -2
  266. package/{esm2020/domain/shop-settings/models/types/benefit.type.mjs → esm2015/domain/shop-settings/models/types/benefit.type.js} +2 -2
  267. package/esm2015/domain/shop-settings/models/types/home-data.type.js +2 -0
  268. package/{esm2020/domain/shop-settings/models/types/index.mjs → esm2015/domain/shop-settings/models/types/index.js} +11 -11
  269. package/{esm2020/domain/shop-settings/models/types/menu-nav.type.mjs → esm2015/domain/shop-settings/models/types/menu-nav.type.js} +2 -2
  270. package/{esm2020/domain/shop-settings/models/types/shop-banner.type.mjs → esm2015/domain/shop-settings/models/types/shop-banner.type.js} +2 -2
  271. package/{esm2020/domain/shop-settings/models/types/shop-brands.type.mjs → esm2015/domain/shop-settings/models/types/shop-brands.type.js} +2 -2
  272. package/{esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs → esm2015/domain/shop-settings/models/types/shop-carousel.type.js} +2 -2
  273. package/{esm2020/domain/shop-settings/models/types/shop-collection.type.mjs → esm2015/domain/shop-settings/models/types/shop-collection.type.js} +2 -2
  274. package/{esm2020/domain/shop-settings/models/types/shop-section.type.mjs → esm2015/domain/shop-settings/models/types/shop-section.type.js} +2 -2
  275. package/{esm2020/domain/shop-settings/models/types/sub-menu.type.mjs → esm2015/domain/shop-settings/models/types/sub-menu.type.js} +2 -2
  276. package/{esm2020/domain/shop-settings/repositories/home.repository.mjs → esm2015/domain/shop-settings/repositories/home.repository.js} +2 -2
  277. package/{esm2020/domain/shop-settings/repositories/index.mjs → esm2015/domain/shop-settings/repositories/index.js} +4 -4
  278. package/{esm2020/domain/shop-settings/repositories/shop-menu.repository.mjs → esm2015/domain/shop-settings/repositories/shop-menu.repository.js} +2 -2
  279. package/{esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs → esm2015/domain/shop-settings/repositories/shop-settings.repository.js} +2 -2
  280. package/{esm2020/domain/shopping/index.mjs → esm2015/domain/shopping/index.js} +3 -3
  281. package/esm2015/domain/shopping/models/buy-2-win.js +14 -0
  282. package/esm2015/domain/shopping/models/checkout.js +38 -0
  283. package/esm2015/domain/shopping/models/coupons/coupon.js +38 -0
  284. package/{esm2020/domain/shopping/models/coupons/enums/coupon-club-mens.enum.mjs → esm2015/domain/shopping/models/coupons/enums/coupon-club-mens.enum.js} +7 -7
  285. package/{esm2020/domain/shopping/models/coupons/enums/coupon-subtypes.enum.mjs → esm2015/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js} +6 -6
  286. package/{esm2020/domain/shopping/models/coupons/enums/coupon-types.enum.mjs → esm2015/domain/shopping/models/coupons/enums/coupon-types.enum.js} +10 -10
  287. package/{esm2020/domain/shopping/models/coupons/enums/exclusivities.enum.mjs → esm2015/domain/shopping/models/coupons/enums/exclusivities.enum.js} +10 -10
  288. package/{esm2020/domain/shopping/models/coupons/enums/index.mjs → esm2015/domain/shopping/models/coupons/enums/index.js} +4 -4
  289. package/{esm2020/domain/shopping/models/coupons/index.mjs → esm2015/domain/shopping/models/coupons/index.js} +3 -3
  290. package/{esm2020/domain/shopping/models/enums/checkout-types.enum.mjs → esm2015/domain/shopping/models/enums/checkout-types.enum.js} +7 -7
  291. package/{esm2020/domain/shopping/models/enums/index.mjs → esm2015/domain/shopping/models/enums/index.js} +3 -3
  292. package/{esm2020/domain/shopping/models/enums/order-status.enum.mjs → esm2015/domain/shopping/models/enums/order-status.enum.js} +12 -12
  293. package/esm2015/domain/shopping/models/index.js +12 -0
  294. package/{esm2020/domain/shopping/models/line-item.mjs → esm2015/domain/shopping/models/line-item.js} +4 -4
  295. package/{esm2020/domain/shopping/models/order.mjs → esm2015/domain/shopping/models/order.js} +11 -11
  296. package/esm2015/domain/shopping/models/payment.js +169 -0
  297. package/esm2015/domain/shopping/models/shipping-method.js +7 -0
  298. package/esm2015/domain/shopping/models/subscription/checkout.js +28 -0
  299. package/{esm2020/domain/shopping/models/subscription/index.mjs → esm2015/domain/shopping/models/subscription/index.js} +3 -3
  300. package/{esm2020/domain/shopping/models/subscription/plan.mjs → esm2015/domain/shopping/models/subscription/plan.js} +7 -7
  301. package/{esm2020/domain/shopping/models/types/index.mjs → esm2015/domain/shopping/models/types/index.js} +8 -8
  302. package/esm2015/domain/shopping/models/types/payment-address.type.js +2 -0
  303. package/{esm2020/domain/shopping/models/types/payment-billing.type.mjs → esm2015/domain/shopping/models/types/payment-billing.type.js} +2 -2
  304. package/esm2015/domain/shopping/models/types/payment-card.type.js +2 -0
  305. package/esm2015/domain/shopping/models/types/payment-customer.type.js +2 -0
  306. package/{esm2020/domain/shopping/models/types/payment-document.type.mjs → esm2015/domain/shopping/models/types/payment-document.type.js} +2 -2
  307. package/{esm2020/domain/shopping/models/types/payment-item.type.mjs → esm2015/domain/shopping/models/types/payment-item.type.js} +2 -2
  308. package/{esm2020/domain/shopping/models/types/payment-shipping.type.mjs → esm2015/domain/shopping/models/types/payment-shipping.type.js} +2 -2
  309. package/{esm2020/domain/shopping/repositories/buy-2-win.repository.mjs → esm2015/domain/shopping/repositories/buy-2-win.repository.js} +2 -2
  310. package/{esm2020/domain/shopping/repositories/checkout.repository.mjs → esm2015/domain/shopping/repositories/checkout.repository.js} +2 -2
  311. package/{esm2020/domain/shopping/repositories/coupon.repository.mjs → esm2015/domain/shopping/repositories/coupon.repository.js} +2 -2
  312. package/esm2015/domain/shopping/repositories/index.js +8 -0
  313. package/{esm2020/domain/shopping/repositories/legacy-order.repository.mjs → esm2015/domain/shopping/repositories/legacy-order.repository.js} +2 -2
  314. package/{esm2020/domain/shopping/repositories/order.repository.mjs → esm2015/domain/shopping/repositories/order.repository.js} +2 -2
  315. package/{esm2020/domain/shopping/repositories/payment.repository.mjs → esm2015/domain/shopping/repositories/payment.repository.js} +2 -2
  316. package/{esm2020/domain/shopping/repositories/subscription/checkout.repository.mjs → esm2015/domain/shopping/repositories/subscription/checkout.repository.js} +2 -2
  317. package/{esm2020/domain/shopping/repositories/subscription/index.mjs → esm2015/domain/shopping/repositories/subscription/index.js} +3 -3
  318. package/{esm2020/domain/shopping/repositories/subscription/plan.repository.mjs → esm2015/domain/shopping/repositories/subscription/plan.repository.js} +2 -2
  319. package/{esm2020/domain/users/errors/index.mjs → esm2015/domain/users/errors/index.js} +4 -4
  320. package/{esm2020/domain/users/errors/unauthorized.error.mjs → esm2015/domain/users/errors/unauthorized.error.js} +8 -7
  321. package/{esm2020/domain/users/errors/user-already-registered.error.mjs → esm2015/domain/users/errors/user-already-registered.error.js} +8 -7
  322. package/{esm2020/domain/users/errors/weak-password.error.mjs → esm2015/domain/users/errors/weak-password.error.js} +8 -7
  323. package/{esm2020/domain/users/index.mjs → esm2015/domain/users/index.js} +6 -6
  324. package/esm2015/domain/users/models/beauty-profile.js +12 -0
  325. package/{esm2020/domain/users/models/enums/accessory-importances.enum.mjs → esm2015/domain/users/models/enums/accessory-importances.enum.js} +7 -7
  326. package/{esm2020/domain/users/models/enums/area.enum.mjs → esm2015/domain/users/models/enums/area.enum.js} +13 -13
  327. package/{esm2020/domain/users/models/enums/beard-problems.enum.mjs → esm2015/domain/users/models/enums/beard-problems.enum.js} +11 -11
  328. package/{esm2020/domain/users/models/enums/beard-sizes.enum.mjs → esm2015/domain/users/models/enums/beard-sizes.enum.js} +9 -9
  329. package/{esm2020/domain/users/models/enums/beauty-product-importances.enum.mjs → esm2015/domain/users/models/enums/beauty-product-importances.enum.js} +8 -8
  330. package/{esm2020/domain/users/models/enums/body-problems.enum.mjs → esm2015/domain/users/models/enums/body-problems.enum.js} +13 -13
  331. package/{esm2020/domain/users/models/enums/body-shapes.enum.mjs → esm2015/domain/users/models/enums/body-shapes.enum.js} +9 -9
  332. package/{esm2020/domain/users/models/enums/body-tattoos.enum.mjs → esm2015/domain/users/models/enums/body-tattoos.enum.js} +7 -7
  333. package/{esm2020/domain/users/models/enums/face-skin-oilinesses.enum.mjs → esm2015/domain/users/models/enums/face-skin-oilinesses.enum.js} +9 -9
  334. package/{esm2020/domain/users/models/enums/face-skin-problems.enum.mjs → esm2015/domain/users/models/enums/face-skin-problems.enum.js} +12 -12
  335. package/{esm2020/domain/users/models/enums/face-skin-tones.enum.mjs → esm2015/domain/users/models/enums/face-skin-tones.enum.js} +10 -10
  336. package/{esm2020/domain/users/models/enums/family-incomes.enum.mjs → esm2015/domain/users/models/enums/family-incomes.enum.js} +10 -10
  337. package/{esm2020/domain/users/models/enums/fragrance-importances.enum.mjs → esm2015/domain/users/models/enums/fragrance-importances.enum.js} +7 -7
  338. package/{esm2020/domain/users/models/enums/hair-colors.enum.mjs → esm2015/domain/users/models/enums/hair-colors.enum.js} +12 -12
  339. package/{esm2020/domain/users/models/enums/hair-problems.enum.mjs → esm2015/domain/users/models/enums/hair-problems.enum.js} +12 -12
  340. package/{esm2020/domain/users/models/enums/hair-strands.enum.mjs → esm2015/domain/users/models/enums/hair-strands.enum.js} +10 -10
  341. package/{esm2020/domain/users/models/enums/hair-types.enum.mjs → esm2015/domain/users/models/enums/hair-types.enum.js} +9 -9
  342. package/{esm2020/domain/users/models/enums/index.mjs → esm2015/domain/users/models/enums/index.js} +21 -21
  343. package/{esm2020/domain/users/models/enums/office-position.enum.mjs → esm2015/domain/users/models/enums/office-position.enum.js} +8 -8
  344. package/{esm2020/domain/users/models/enums/product-spents.enum.mjs → esm2015/domain/users/models/enums/product-spents.enum.js} +10 -10
  345. package/{esm2020/domain/users/models/enums/user-type.enum.mjs → esm2015/domain/users/models/enums/user-type.enum.js} +10 -10
  346. package/{esm2020/domain/users/models/index.mjs → esm2015/domain/users/models/index.js} +8 -8
  347. package/{esm2020/domain/users/models/lead.mjs → esm2015/domain/users/models/lead.js} +7 -7
  348. package/esm2015/domain/users/models/subscription/edition.js +7 -0
  349. package/{esm2020/domain/users/models/subscription/enums/billing-status.enum.mjs → esm2015/domain/users/models/subscription/enums/billing-status.enum.js} +5 -5
  350. package/{esm2020/domain/users/models/subscription/enums/edition-status.enum.mjs → esm2015/domain/users/models/subscription/enums/edition-status.enum.js} +6 -6
  351. package/{esm2020/domain/users/models/subscription/enums/index.mjs → esm2015/domain/users/models/subscription/enums/index.js} +5 -5
  352. package/{esm2020/domain/users/models/subscription/enums/payment-type.enum.mjs → esm2015/domain/users/models/subscription/enums/payment-type.enum.js} +7 -7
  353. package/{esm2020/domain/users/models/subscription/enums/status.enum.mjs → esm2015/domain/users/models/subscription/enums/status.enum.js} +6 -6
  354. package/{esm2020/domain/users/models/subscription/index.mjs → esm2015/domain/users/models/subscription/index.js} +5 -5
  355. package/esm2015/domain/users/models/subscription/payment.js +14 -0
  356. package/esm2015/domain/users/models/subscription/subscription.js +43 -0
  357. package/{esm2020/domain/users/models/user-address.mjs → esm2015/domain/users/models/user-address.js} +7 -7
  358. package/esm2015/domain/users/models/user-payment-method.js +7 -0
  359. package/esm2015/domain/users/models/user.js +26 -0
  360. package/{esm2020/domain/users/repositories/beauty-profile.repository.mjs → esm2015/domain/users/repositories/beauty-profile.repository.js} +2 -2
  361. package/{esm2020/domain/users/repositories/edition.repository.mjs → esm2015/domain/users/repositories/edition.repository.js} +2 -2
  362. package/{esm2020/domain/users/repositories/index.mjs → esm2015/domain/users/repositories/index.js} +9 -9
  363. package/{esm2020/domain/users/repositories/lead.repository.mjs → esm2015/domain/users/repositories/lead.repository.js} +2 -2
  364. package/{esm2020/domain/users/repositories/subscription-payment.repository.mjs → esm2015/domain/users/repositories/subscription-payment.repository.js} +2 -2
  365. package/{esm2020/domain/users/repositories/subscription.repository.mjs → esm2015/domain/users/repositories/subscription.repository.js} +2 -2
  366. package/{esm2020/domain/users/repositories/user-address.repository.mjs → esm2015/domain/users/repositories/user-address.repository.js} +2 -2
  367. package/{esm2020/domain/users/repositories/user-payment-method.repository.mjs → esm2015/domain/users/repositories/user-payment-method.repository.js} +2 -2
  368. package/esm2015/domain/users/repositories/user.repository.js +2 -0
  369. package/esm2015/domain/users/services/authentication.service.js +2 -0
  370. package/{esm2020/domain/users/services/index.mjs → esm2015/domain/users/services/index.js} +4 -4
  371. package/{esm2020/domain/users/services/register.service.mjs → esm2015/domain/users/services/register.service.js} +2 -2
  372. package/{esm2020/domain/users/services/types/basic-user-data.type.mjs → esm2015/domain/users/services/types/basic-user-data.type.js} +2 -2
  373. package/{esm2020/domain/users/services/types/index.mjs → esm2015/domain/users/services/types/index.js} +2 -2
  374. package/esm2015/domain/users/use-cases/authentication.js +40 -0
  375. package/{esm2020/domain/users/use-cases/index.mjs → esm2015/domain/users/use-cases/index.js} +5 -5
  376. package/esm2015/domain/users/use-cases/recovery-password.js +12 -0
  377. package/esm2015/domain/users/use-cases/register.js +34 -0
  378. package/esm2015/domain/users/use-cases/signout.js +12 -0
  379. package/{esm2020/errors/duplicated-results.error.mjs → esm2015/errors/duplicated-results.error.js} +8 -7
  380. package/{esm2020/errors/index.mjs → esm2015/errors/index.js} +5 -5
  381. package/{esm2020/errors/invalid-argument.error.mjs → esm2015/errors/invalid-argument.error.js} +8 -7
  382. package/{esm2020/errors/not-found.error.mjs → esm2015/errors/not-found.error.js} +8 -7
  383. package/{esm2020/errors/required-argument.error.mjs → esm2015/errors/required-argument.error.js} +9 -9
  384. package/{esm2020/index.mjs → esm2015/index.js} +6 -6
  385. package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +57 -0
  386. package/esm2015/infra/elasticsearch/adapters/elastic-search.adapter.js +2 -0
  387. package/{esm2020/infra/elasticsearch/adapters/index.mjs → esm2015/infra/elasticsearch/adapters/index.js} +3 -3
  388. package/{esm2020/infra/elasticsearch/index.mjs → esm2015/infra/elasticsearch/index.js} +4 -4
  389. package/{esm2020/infra/elasticsearch/indexes/index.mjs → esm2015/infra/elasticsearch/indexes/index.js} +2 -2
  390. package/esm2015/infra/elasticsearch/indexes/products-index.js +93 -0
  391. package/{esm2020/infra/elasticsearch/types/elastic-search-result.mjs → esm2015/infra/elasticsearch/types/elastic-search-result.js} +2 -2
  392. package/{esm2020/infra/elasticsearch/types/index.mjs → esm2015/infra/elasticsearch/types/index.js} +2 -2
  393. package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +52 -0
  394. package/{esm2020/infra/firebase/auth/index.mjs → esm2015/infra/firebase/auth/index.js} +3 -3
  395. package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +26 -0
  396. package/{esm2020/infra/firebase/auth/types/firebase-user-with-id.type.mjs → esm2015/infra/firebase/auth/types/firebase-user-with-id.type.js} +2 -2
  397. package/{esm2020/infra/firebase/firestore/enums/firestore-field-type.enum.mjs → esm2015/infra/firebase/firestore/enums/firestore-field-type.enum.js} +10 -10
  398. package/{esm2020/infra/firebase/firestore/enums/index.mjs → esm2015/infra/firebase/firestore/enums/index.js} +2 -2
  399. package/{esm2020/infra/firebase/firestore/index.mjs → esm2015/infra/firebase/firestore/index.js} +4 -4
  400. package/{esm2020/infra/firebase/firestore/mixins/index.mjs → esm2015/infra/firebase/firestore/mixins/index.js} +10 -10
  401. package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +31 -0
  402. package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +10 -0
  403. package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +18 -0
  404. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +96 -0
  405. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +49 -0
  406. package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +24 -0
  407. package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +17 -0
  408. package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +11 -0
  409. package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +45 -0
  410. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +71 -0
  411. package/{esm2020/infra/firebase/firestore/repositories/catalog/index.mjs → esm2015/infra/firebase/firestore/repositories/catalog/index.js} +5 -5
  412. package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +52 -0
  413. package/esm2015/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +14 -0
  414. package/esm2015/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +12 -0
  415. package/{esm2020/infra/firebase/firestore/repositories/index.mjs → esm2015/infra/firebase/firestore/repositories/index.js} +5 -5
  416. package/esm2015/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +56 -0
  417. package/{esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs → esm2015/infra/firebase/firestore/repositories/shop-settings/index.js} +4 -4
  418. package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +12 -0
  419. package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.js +12 -0
  420. package/esm2015/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +12 -0
  421. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +12 -0
  422. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +12 -0
  423. package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +29 -0
  424. package/esm2015/infra/firebase/firestore/repositories/shopping/index.js +9 -0
  425. package/esm2015/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +9 -0
  426. package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +40 -0
  427. package/esm2015/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +12 -0
  428. package/esm2015/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +12 -0
  429. package/{esm2020/infra/firebase/firestore/repositories/users/index.mjs → esm2015/infra/firebase/firestore/repositories/users/index.js} +9 -9
  430. package/esm2015/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +12 -0
  431. package/esm2015/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +14 -0
  432. package/esm2015/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +12 -0
  433. package/esm2015/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +14 -0
  434. package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +14 -0
  435. package/esm2015/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +14 -0
  436. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +68 -0
  437. package/esm2015/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +14 -0
  438. package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +2 -0
  439. package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +2 -0
  440. package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +2 -0
  441. package/esm2015/infra/firebase/firestore/types/index.js +4 -0
  442. package/{esm2020/infra/firebase/index.mjs → esm2015/infra/firebase/index.js} +3 -3
  443. package/{esm2020/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.mjs → esm2015/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.js} +13 -13
  444. package/{esm2020/infra/hasura-graphql/enums/hasura-graphql-where.enum.mjs → esm2015/infra/hasura-graphql/enums/hasura-graphql-where.enum.js} +15 -17
  445. package/{esm2020/infra/hasura-graphql/enums/index.mjs → esm2015/infra/hasura-graphql/enums/index.js} +3 -3
  446. package/{esm2020/infra/hasura-graphql/index.mjs → esm2015/infra/hasura-graphql/index.js} +5 -5
  447. package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +31 -0
  448. package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +53 -0
  449. package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +22 -0
  450. package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +86 -0
  451. package/{esm2020/infra/hasura-graphql/mixins/helpers/index.mjs → esm2015/infra/hasura-graphql/mixins/helpers/index.js} +5 -5
  452. package/{esm2020/infra/hasura-graphql/mixins/index.mjs → esm2015/infra/hasura-graphql/mixins/index.js} +8 -8
  453. package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +45 -0
  454. package/esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js +10 -0
  455. package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +29 -0
  456. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +45 -0
  457. package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +35 -0
  458. package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +94 -0
  459. package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +56 -0
  460. package/{esm2020/infra/hasura-graphql/models/category-hasura-graphql.mjs → esm2015/infra/hasura-graphql/models/category-hasura-graphql.js} +4 -4
  461. package/{esm2020/infra/hasura-graphql/models/index.mjs → esm2015/infra/hasura-graphql/models/index.js} +5 -5
  462. package/{esm2020/infra/hasura-graphql/models/kit-product-hasura-graphql.mjs → esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js} +15 -15
  463. package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +11 -0
  464. package/{esm2020/infra/hasura-graphql/models/variant-hasura-graphql.mjs → esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js} +9 -9
  465. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +241 -0
  466. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +4 -0
  467. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +462 -0
  468. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +116 -0
  469. package/{esm2020/infra/hasura-graphql/repositories/index.mjs → esm2015/infra/hasura-graphql/repositories/index.js} +2 -2
  470. package/{esm2020/infra/hasura-graphql/types/fields.type.mjs → esm2015/infra/hasura-graphql/types/fields.type.js} +2 -2
  471. package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +2 -0
  472. package/{esm2020/infra/hasura-graphql/types/hasura-graphql-auth-options.type.mjs → esm2015/infra/hasura-graphql/types/hasura-graphql-auth-options.type.js} +2 -2
  473. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +2 -0
  474. package/{esm2020/infra/hasura-graphql/types/hasura-graphql-headers.type.mjs → esm2015/infra/hasura-graphql/types/hasura-graphql-headers.type.js} +2 -2
  475. package/{esm2020/infra/hasura-graphql/types/index.mjs → esm2015/infra/hasura-graphql/types/index.js} +9 -9
  476. package/{esm2020/infra/hasura-graphql/types/nested-field.type.mjs → esm2015/infra/hasura-graphql/types/nested-field.type.js} +2 -2
  477. package/{esm2020/infra/hasura-graphql/types/query-builder-options.type.mjs → esm2015/infra/hasura-graphql/types/query-builder-options.type.js} +2 -2
  478. package/{esm2020/infra/hasura-graphql/types/variable-options.type.mjs → esm2015/infra/hasura-graphql/types/variable-options.type.js} +2 -2
  479. package/{esm2020/infra/index.mjs → esm2015/infra/index.js} +4 -4
  480. package/{esm2020/infrab4a-connect.mjs → esm2015/infrab4a-connect.js} +4 -4
  481. package/esm2015/utils/index.js +8 -0
  482. package/{esm2020/utils/is-uuid.mjs → esm2015/utils/is-uuid.js} +3 -3
  483. package/{esm2020/utils/mixins/base.mixin.mjs → esm2015/utils/mixins/base.mixin.js} +6 -6
  484. package/{esm2020/utils/mixins/index.mjs → esm2015/utils/mixins/index.js} +4 -4
  485. package/{esm2020/utils/mixins/merge-constructor-params.type.mjs → esm2015/utils/mixins/merge-constructor-params.type.js} +2 -2
  486. package/{esm2020/utils/mixins/mixin-ctor.type.mjs → esm2015/utils/mixins/mixin-ctor.type.js} +2 -2
  487. package/{esm2020/utils/parse-datetime.mjs → esm2015/utils/parse-datetime.js} +14 -14
  488. package/{esm2020/utils/types/array-element.type.mjs → esm2015/utils/types/array-element.type.js} +2 -2
  489. package/{esm2020/utils/types/index.mjs → esm2015/utils/types/index.js} +3 -3
  490. package/{esm2020/utils/types/prop.type.mjs → esm2015/utils/types/prop.type.js} +2 -2
  491. package/fesm2015/{infrab4a-connect.mjs → infrab4a-connect.js} +3178 -4788
  492. package/fesm2015/infrab4a-connect.js.map +1 -0
  493. package/index.d.ts +5 -5
  494. package/infra/elasticsearch/adapters/axios.adapter.d.ts +14 -16
  495. package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +7 -8
  496. package/infra/elasticsearch/adapters/index.d.ts +2 -2
  497. package/infra/elasticsearch/index.d.ts +3 -3
  498. package/infra/elasticsearch/indexes/index.d.ts +1 -1
  499. package/infra/elasticsearch/indexes/products-index.d.ts +15 -13
  500. package/infra/elasticsearch/types/elastic-search-result.d.ts +7 -9
  501. package/infra/elasticsearch/types/index.d.ts +1 -1
  502. package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +12 -12
  503. package/infra/firebase/auth/index.d.ts +2 -2
  504. package/infra/firebase/auth/register-firebase-auth.service.d.ts +8 -8
  505. package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +3 -5
  506. package/infra/firebase/firestore/enums/firestore-field-type.enum.d.ts +8 -8
  507. package/infra/firebase/firestore/enums/index.d.ts +1 -1
  508. package/infra/firebase/firestore/index.d.ts +3 -3
  509. package/infra/firebase/firestore/mixins/index.d.ts +9 -9
  510. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +4 -4
  511. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +4 -5
  512. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +4 -4
  513. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +4 -4
  514. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +4 -13
  515. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +4 -4
  516. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +11 -11
  517. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +7 -11
  518. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +7 -7
  519. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +17 -20
  520. package/infra/firebase/firestore/repositories/catalog/index.d.ts +4 -4
  521. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +11 -12
  522. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +13 -12
  523. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +8 -7
  524. package/infra/firebase/firestore/repositories/index.d.ts +4 -4
  525. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +16 -16
  526. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +3 -3
  527. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +8 -7
  528. package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +8 -7
  529. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +8 -7
  530. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +8 -7
  531. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +8 -7
  532. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +12 -12
  533. package/infra/firebase/firestore/repositories/shopping/index.d.ts +8 -10
  534. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +7 -6
  535. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +13 -13
  536. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +8 -7
  537. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +8 -7
  538. package/infra/firebase/firestore/repositories/users/index.d.ts +8 -8
  539. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +8 -7
  540. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +13 -12
  541. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +8 -7
  542. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +13 -12
  543. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +13 -12
  544. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +13 -12
  545. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +17 -17
  546. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +13 -12
  547. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +6 -6
  548. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +8 -8
  549. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +14 -16
  550. package/infra/firebase/firestore/types/index.d.ts +3 -4
  551. package/infra/firebase/index.d.ts +2 -2
  552. package/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.d.ts +11 -11
  553. package/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +13 -15
  554. package/infra/hasura-graphql/enums/index.d.ts +2 -2
  555. package/infra/hasura-graphql/index.d.ts +4 -4
  556. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +13 -19
  557. package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +10 -10
  558. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +6 -8
  559. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +8 -12
  560. package/infra/hasura-graphql/mixins/helpers/index.d.ts +4 -4
  561. package/infra/hasura-graphql/mixins/index.d.ts +7 -7
  562. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +8 -9
  563. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +11 -11
  564. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +7 -7
  565. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +25 -34
  566. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +24 -25
  567. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +11 -23
  568. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +14 -14
  569. package/infra/hasura-graphql/models/category-hasura-graphql.d.ts +6 -6
  570. package/infra/hasura-graphql/models/index.d.ts +4 -4
  571. package/infra/hasura-graphql/models/kit-product-hasura-graphql.d.ts +6 -6
  572. package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +14 -18
  573. package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +9 -10
  574. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +27 -34
  575. package/infra/hasura-graphql/repositories/catalog/index.d.ts +3 -8
  576. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +28 -30
  577. package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +14 -14
  578. package/infra/hasura-graphql/repositories/index.d.ts +1 -1
  579. package/infra/hasura-graphql/types/fields.type.d.ts +2 -2
  580. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +21 -24
  581. package/infra/hasura-graphql/types/hasura-graphql-auth-options.type.d.ts +8 -8
  582. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +40 -44
  583. package/infra/hasura-graphql/types/hasura-graphql-headers.type.d.ts +7 -7
  584. package/infra/hasura-graphql/types/index.d.ts +8 -8
  585. package/infra/hasura-graphql/types/nested-field.type.d.ts +7 -7
  586. package/infra/hasura-graphql/types/query-builder-options.type.d.ts +7 -7
  587. package/infra/hasura-graphql/types/variable-options.type.d.ts +9 -9
  588. package/infra/index.d.ts +3 -3
  589. package/infrab4a-connect.d.ts +5 -0
  590. package/package.json +9 -23
  591. package/utils/index.d.ts +7 -13
  592. package/utils/is-uuid.d.ts +1 -1
  593. package/utils/mixins/base.mixin.d.ts +3 -3
  594. package/utils/mixins/index.d.ts +3 -3
  595. package/utils/mixins/merge-constructor-params.type.d.ts +3 -3
  596. package/utils/mixins/mixin-ctor.type.d.ts +1 -1
  597. package/utils/parse-datetime.d.ts +1 -1
  598. package/utils/types/array-element.type.d.ts +1 -1
  599. package/utils/types/index.d.ts +2 -2
  600. package/utils/types/prop.type.d.ts +1 -1
  601. package/domain/catalog/helpers/index.d.ts +0 -1
  602. package/domain/catalog/helpers/round-product-price.helper.d.ts +0 -4
  603. package/domain/catalog/models/category-base.d.ts +0 -30
  604. package/domain/catalog/models/category-collection-children.d.ts +0 -13
  605. package/domain/catalog/models/category-filter.d.ts +0 -13
  606. package/domain/catalog/models/category-for-product.d.ts +0 -5
  607. package/domain/catalog/models/filter-option.d.ts +0 -9
  608. package/domain/catalog/models/filter.d.ts +0 -12
  609. package/domain/catalog/models/product-base.d.ts +0 -40
  610. package/domain/catalog/models/product-for-category.d.ts +0 -7
  611. package/domain/catalog/models/product-for-kit.d.ts +0 -7
  612. package/domain/catalog/models/types/category-product.d.ts +0 -4
  613. package/domain/catalog/models/types/product-evaluation.type.d.ts +0 -6
  614. package/domain/catalog/models/wishlist.d.ts +0 -6
  615. package/domain/catalog/repositories/category-collection-children.repository.d.ts +0 -4
  616. package/domain/catalog/repositories/category-filter.repository.d.ts +0 -6
  617. package/domain/catalog/repositories/filter-option.repository.d.ts +0 -4
  618. package/domain/catalog/repositories/filter.repository.d.ts +0 -4
  619. package/domain/catalog/repositories/wishlist.repository.d.ts +0 -6
  620. package/domain/shopping/models/campaign-dashboard.d.ts +0 -15
  621. package/domain/shopping/models/campaign-hashtag.d.ts +0 -18
  622. package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +0 -4
  623. package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +0 -4
  624. package/esm2020/domain/catalog/helpers/index.mjs +0 -2
  625. package/esm2020/domain/catalog/helpers/round-product-price.helper.mjs +0 -15
  626. package/esm2020/domain/catalog/models/category-base.mjs +0 -18
  627. package/esm2020/domain/catalog/models/category-collection-children.mjs +0 -13
  628. package/esm2020/domain/catalog/models/category-filter.mjs +0 -19
  629. package/esm2020/domain/catalog/models/category-for-product.mjs +0 -7
  630. package/esm2020/domain/catalog/models/category.mjs +0 -14
  631. package/esm2020/domain/catalog/models/filter-option.mjs +0 -7
  632. package/esm2020/domain/catalog/models/filter.mjs +0 -7
  633. package/esm2020/domain/catalog/models/index.mjs +0 -12
  634. package/esm2020/domain/catalog/models/kit-product.mjs +0 -18
  635. package/esm2020/domain/catalog/models/product-base.mjs +0 -25
  636. package/esm2020/domain/catalog/models/product-for-category.mjs +0 -14
  637. package/esm2020/domain/catalog/models/product-for-kit.mjs +0 -14
  638. package/esm2020/domain/catalog/models/product.mjs +0 -19
  639. package/esm2020/domain/catalog/models/types/category-product.mjs +0 -2
  640. package/esm2020/domain/catalog/models/types/index.mjs +0 -12
  641. package/esm2020/domain/catalog/models/types/product-evaluation.type.mjs +0 -2
  642. package/esm2020/domain/catalog/models/types/product-review.type.mjs +0 -2
  643. package/esm2020/domain/catalog/models/variant.mjs +0 -7
  644. package/esm2020/domain/catalog/models/wishlist.mjs +0 -7
  645. package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +0 -2
  646. package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +0 -2
  647. package/esm2020/domain/catalog/repositories/category.repository.mjs +0 -2
  648. package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +0 -2
  649. package/esm2020/domain/catalog/repositories/filter.repository.mjs +0 -2
  650. package/esm2020/domain/catalog/repositories/index.mjs +0 -10
  651. package/esm2020/domain/catalog/repositories/product.repository.mjs +0 -2
  652. package/esm2020/domain/catalog/repositories/wishlist.repository.mjs +0 -2
  653. package/esm2020/domain/generic/model/base.model.mjs +0 -24
  654. package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +0 -2
  655. package/esm2020/domain/generic/model/types/identifier-model.type.mjs +0 -2
  656. package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +0 -2
  657. package/esm2020/domain/generic/model/types/non-function-properties.type.mjs +0 -2
  658. package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +0 -2
  659. package/esm2020/domain/generic/repository/create.repository.mjs +0 -2
  660. package/esm2020/domain/generic/repository/crud.repository.mjs +0 -2
  661. package/esm2020/domain/generic/repository/delete.repository.mjs +0 -2
  662. package/esm2020/domain/generic/repository/find.repository.mjs +0 -2
  663. package/esm2020/domain/generic/repository/get.repository.mjs +0 -2
  664. package/esm2020/domain/generic/repository/read.repository.mjs +0 -2
  665. package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +0 -2
  666. package/esm2020/domain/generic/repository/types/repository-find-result.type.mjs +0 -2
  667. package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +0 -2
  668. package/esm2020/domain/generic/repository/update.repository.mjs +0 -2
  669. package/esm2020/domain/location/models/address.mjs +0 -7
  670. package/esm2020/domain/shop-settings/models/home.mjs +0 -7
  671. package/esm2020/domain/shop-settings/models/types/home-data.type.mjs +0 -2
  672. package/esm2020/domain/shopping/models/buy-2-win.mjs +0 -14
  673. package/esm2020/domain/shopping/models/campaign-dashboard.mjs +0 -7
  674. package/esm2020/domain/shopping/models/campaign-hashtag.mjs +0 -7
  675. package/esm2020/domain/shopping/models/checkout.mjs +0 -37
  676. package/esm2020/domain/shopping/models/coupons/coupon.mjs +0 -38
  677. package/esm2020/domain/shopping/models/index.mjs +0 -13
  678. package/esm2020/domain/shopping/models/payment.mjs +0 -169
  679. package/esm2020/domain/shopping/models/shipping-method.mjs +0 -7
  680. package/esm2020/domain/shopping/models/subscription/checkout.mjs +0 -28
  681. package/esm2020/domain/shopping/models/types/payment-address.type.mjs +0 -2
  682. package/esm2020/domain/shopping/models/types/payment-card.type.mjs +0 -2
  683. package/esm2020/domain/shopping/models/types/payment-customer.type.mjs +0 -2
  684. package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +0 -2
  685. package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +0 -2
  686. package/esm2020/domain/shopping/repositories/index.mjs +0 -10
  687. package/esm2020/domain/users/models/beauty-profile.mjs +0 -12
  688. package/esm2020/domain/users/models/subscription/edition.mjs +0 -7
  689. package/esm2020/domain/users/models/subscription/payment.mjs +0 -14
  690. package/esm2020/domain/users/models/subscription/subscription.mjs +0 -43
  691. package/esm2020/domain/users/models/user-payment-method.mjs +0 -7
  692. package/esm2020/domain/users/models/user.mjs +0 -26
  693. package/esm2020/domain/users/repositories/user.repository.mjs +0 -2
  694. package/esm2020/domain/users/services/authentication.service.mjs +0 -2
  695. package/esm2020/domain/users/use-cases/authentication.mjs +0 -43
  696. package/esm2020/domain/users/use-cases/recovery-password.mjs +0 -9
  697. package/esm2020/domain/users/use-cases/register.mjs +0 -38
  698. package/esm2020/domain/users/use-cases/signout.mjs +0 -9
  699. package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +0 -67
  700. package/esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs +0 -2
  701. package/esm2020/infra/elasticsearch/indexes/products-index.mjs +0 -104
  702. package/esm2020/infra/firebase/auth/authentication-firebase-auth.service.mjs +0 -41
  703. package/esm2020/infra/firebase/auth/register-firebase-auth.service.mjs +0 -33
  704. package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +0 -31
  705. package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +0 -10
  706. package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +0 -18
  707. package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +0 -110
  708. package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +0 -80
  709. package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +0 -23
  710. package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +0 -17
  711. package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +0 -13
  712. package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +0 -51
  713. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +0 -67
  714. package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +0 -54
  715. package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +0 -16
  716. package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +0 -14
  717. package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +0 -60
  718. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +0 -14
  719. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +0 -14
  720. package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +0 -14
  721. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +0 -14
  722. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +0 -14
  723. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +0 -14
  724. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +0 -14
  725. package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +0 -31
  726. package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +0 -11
  727. package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +0 -11
  728. package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +0 -40
  729. package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +0 -14
  730. package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +0 -14
  731. package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +0 -14
  732. package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +0 -16
  733. package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +0 -14
  734. package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +0 -16
  735. package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +0 -16
  736. package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +0 -16
  737. package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +0 -50
  738. package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +0 -16
  739. package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +0 -2
  740. package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +0 -2
  741. package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +0 -2
  742. package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +0 -2
  743. package/esm2020/infra/firebase/firestore/types/index.mjs +0 -5
  744. package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +0 -35
  745. package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +0 -71
  746. package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +0 -22
  747. package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +0 -125
  748. package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +0 -39
  749. package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +0 -10
  750. package/esm2020/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.mjs +0 -31
  751. package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +0 -152
  752. package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +0 -37
  753. package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +0 -108
  754. package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +0 -62
  755. package/esm2020/infra/hasura-graphql/models/product-hasura-graphql.mjs +0 -11
  756. package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +0 -39
  757. package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +0 -107
  758. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +0 -339
  759. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +0 -105
  760. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +0 -22
  761. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +0 -9
  762. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +0 -516
  763. package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +0 -114
  764. package/esm2020/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.mjs +0 -236
  765. package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +0 -2
  766. package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +0 -2
  767. package/esm2020/utils/decorators/debug.class.decorator.mjs +0 -7
  768. package/esm2020/utils/decorators/index.mjs +0 -3
  769. package/esm2020/utils/decorators/trace.method.decorator.mjs +0 -81
  770. package/esm2020/utils/get.mjs +0 -3
  771. package/esm2020/utils/helpers/class-name.helper.mjs +0 -15
  772. package/esm2020/utils/helpers/debug-decorator.helper.mjs +0 -18
  773. package/esm2020/utils/helpers/debug.helper.mjs +0 -150
  774. package/esm2020/utils/helpers/index.mjs +0 -5
  775. package/esm2020/utils/helpers/reflect.helper.mjs +0 -165
  776. package/esm2020/utils/index.mjs +0 -13
  777. package/esm2020/utils/is.mjs +0 -4
  778. package/esm2020/utils/log.utils.mjs +0 -9
  779. package/fesm2015/infrab4a-connect.mjs.map +0 -1
  780. package/fesm2020/infrab4a-connect.mjs +0 -4856
  781. package/fesm2020/infrab4a-connect.mjs.map +0 -1
  782. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +0 -8
  783. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +0 -8
  784. package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +0 -14
  785. package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +0 -10
  786. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +0 -12
  787. package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +0 -18
  788. package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +0 -10
  789. package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +0 -27
  790. package/utils/decorators/debug.class.decorator.d.ts +0 -2
  791. package/utils/decorators/index.d.ts +0 -2
  792. package/utils/decorators/trace.method.decorator.d.ts +0 -14
  793. package/utils/get.d.ts +0 -1
  794. package/utils/helpers/class-name.helper.d.ts +0 -3
  795. package/utils/helpers/debug-decorator.helper.d.ts +0 -9
  796. package/utils/helpers/debug.helper.d.ts +0 -60
  797. package/utils/helpers/index.d.ts +0 -4
  798. package/utils/helpers/reflect.helper.d.ts +0 -50
  799. package/utils/is.d.ts +0 -1
  800. package/utils/log.utils.d.ts +0 -7
@@ -1,4856 +0,0 @@
1
- import 'reflect-metadata';
2
- import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transformer';
3
- import { __decorate, __metadata } from 'tslib';
4
- import { parseISO } from 'date-fns';
5
- export { add, addBusinessDays, addDays, addMonths, addYears, endOfDay, format, formatISO9075, parseISO, startOfDay, sub } from 'date-fns';
6
- import { isNil, isArray, first, last, flatten, compact, get as get$1, isString, each, unset, isObject, isNumber, isDate, set, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
7
- export { chunk, each, get, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set, unset } from 'lodash';
8
- import { Subject } from 'rxjs';
9
- import { debug } from 'debug';
10
- import { CustomError } from 'ts-custom-error';
11
- import axios from 'axios';
12
- import { collection, getDoc, doc, where, orderBy, getDocs, query, startAfter, startAt, limit, addDoc, setDoc, deleteField, arrayUnion, arrayRemove, deleteDoc, Timestamp } from 'firebase/firestore';
13
- import { signInWithEmailAndPassword, signInWithPopup, GoogleAuthProvider, signInAnonymously, sendPasswordResetEmail, createUserWithEmailAndPassword, sendEmailVerification } from 'firebase/auth';
14
- import { mutation, query as query$1 } from 'gql-query-builder';
15
-
16
- class BaseModel {
17
- get identifier() {
18
- const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
19
- const data = this;
20
- return fields.reduce((object, field) => ({ ...object, [field]: data[field] }), {});
21
- }
22
- get identifiersFields() {
23
- return this.constructor.identifiersFields;
24
- }
25
- constructor(args) {
26
- Object.assign(this, args);
27
- }
28
- static toInstance(data) {
29
- return plainToInstance(this, data || {});
30
- }
31
- static isModel(value) {
32
- return value instanceof this;
33
- }
34
- toPlain() {
35
- return instanceToPlain(this);
36
- }
37
- }
38
-
39
- var Where;
40
- (function (Where) {
41
- Where["EQUALS"] = "==";
42
- Where["NOTEQUALS"] = "!=";
43
- Where["GT"] = ">";
44
- Where["GTE"] = ">=";
45
- Where["IN"] = "in";
46
- Where["NOTIN"] = "not in";
47
- Where["LT"] = "<";
48
- Where["LTE"] = "<=";
49
- Where["LIKE"] = "like";
50
- Where["NOTLIKE"] = "not like";
51
- Where["ISNULL"] = "is null";
52
- Where["ISNOTNULL"] = "is not null";
53
- })(Where || (Where = {}));
54
-
55
- var UpdateOptionActions;
56
- (function (UpdateOptionActions) {
57
- UpdateOptionActions["UPDATE"] = "update";
58
- UpdateOptionActions["MERGE"] = "merge";
59
- UpdateOptionActions["REMOVE"] = "remove";
60
- UpdateOptionActions["REMOVE_FIELD"] = "removeField";
61
- UpdateOptionActions["NULL"] = "null";
62
- })(UpdateOptionActions || (UpdateOptionActions = {}));
63
-
64
- var AccessoryImportances;
65
- (function (AccessoryImportances) {
66
- AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
67
- AccessoryImportances["LIKE_RARELY_USE"] = "Gosto, mas uso poucos";
68
- AccessoryImportances["LIKE_ALWAYS_FOLLOW_FASHION"] = "Gosto muito de acess\u00F3rios e sempre procuro acompanhar a moda";
69
- })(AccessoryImportances || (AccessoryImportances = {}));
70
-
71
- var Area;
72
- (function (Area) {
73
- Area["GP"] = "Geral";
74
- Area["CRM"] = "CRM";
75
- Area["MediaProd"] = "Media Production";
76
- Area["Tech"] = "Tecnologia";
77
- Area["Transactional"] = "Transacional";
78
- Area["Operations"] = "Opera\u00E7\u00F5es";
79
- Area["Sales"] = "Comercial";
80
- Area["Finantial"] = "Financeiro";
81
- Area["HR"] = "RH";
82
- })(Area || (Area = {}));
83
-
84
- var BeardProblems;
85
- (function (BeardProblems) {
86
- BeardProblems["NO_PROBLEMS"] = "Sem problemas";
87
- BeardProblems["DRY"] = "Barba Seca";
88
- BeardProblems["OILY"] = "Barba Oleaosa";
89
- BeardProblems["DANCRUFF"] = "Barba com Caspa";
90
- BeardProblems["INGROWN_HAIRS"] = "P\u00EAlos Encravados";
91
- BeardProblems["DOESNT_GROW"] = "N\u00E3o Cresce";
92
- BeardProblems["SPARSE_BEARD"] = "Barba Rala";
93
- })(BeardProblems || (BeardProblems = {}));
94
-
95
- var BeardSizes;
96
- (function (BeardSizes) {
97
- BeardSizes["BIG"] = "Grande";
98
- BeardSizes["MEDIUM"] = "M\u00E9dia";
99
- BeardSizes["SHORT"] = "Curta";
100
- BeardSizes["MUSTACHE"] = "Bigode";
101
- BeardSizes["NOTHING"] = "Sem Barba";
102
- })(BeardSizes || (BeardSizes = {}));
103
-
104
- var BeautyProductImportances;
105
- (function (BeautyProductImportances) {
106
- BeautyProductImportances["KNOW_LITTLE_ABOUT"] = "Conhe\u00E7o bem pouco de produtos de beleza e rotinas de cuidados";
107
- BeautyProductImportances["ALREADY_BOUGHT_NOTHING_SPECIALIZED"] = "J\u00E1 comprei alguns produtos b\u00E1sicos para cuidar de mim, mas nada muito especializado";
108
- BeautyProductImportances["GOOD_CARE_MYSELF"] = "Me considero um homem que se cuida bem. Conhe\u00E7o sobre produtos especializados e me preocupo em ter uma rotina de cuidados";
109
- BeautyProductImportances["PERSONAL_CARE_EXPERT"] = "Sou um expert em cuidados pessoais";
110
- })(BeautyProductImportances || (BeautyProductImportances = {}));
111
-
112
- var BodyProblems;
113
- (function (BodyProblems) {
114
- BodyProblems["NO_WORRIES"] = "Sem preocupa\u00E7\u00F5es";
115
- BodyProblems["FLACCIDITY"] = "Flacidez";
116
- BodyProblems["LOCALIZED_FAT"] = "Gordura Localizada";
117
- BodyProblems["STRETCH_MARKS"] = "Estrias";
118
- BodyProblems["SENSITIVE_SKIN"] = "Pele Sens\u00EDvel";
119
- BodyProblems["DRY_SKIN"] = "Pele Seca";
120
- BodyProblems["OILY_ACNE"] = "Oleosa/Acne";
121
- BodyProblems["SKIN_FRECKLES"] = "Pele com Sardas";
122
- BodyProblems["PHOTOSENSITIVE_SKIN"] = "Pele Fotossens\u00EDvel";
123
- })(BodyProblems || (BodyProblems = {}));
124
-
125
- var BodyShapes;
126
- (function (BodyShapes) {
127
- BodyShapes["LEAN"] = "Magro";
128
- BodyShapes["REGULAR"] = "Regular";
129
- BodyShapes["OVERWEIGHT"] = "Acima do Peso";
130
- BodyShapes["ATHLETIC"] = "Atl\u00E9tico";
131
- BodyShapes["MUSCULAR"] = "Musculoso";
132
- })(BodyShapes || (BodyShapes = {}));
133
-
134
- var BodyTattoos;
135
- (function (BodyTattoos) {
136
- BodyTattoos["NONE"] = "Nenhuma";
137
- BodyTattoos["HAS_DOESNT_CARE"] = "Tenho mas n\u00E3o cuido";
138
- BodyTattoos["HAS_CARE_LOT"] = "Tenho e cuido bastante";
139
- })(BodyTattoos || (BodyTattoos = {}));
140
-
141
- var FaceSkinOilinesses;
142
- (function (FaceSkinOilinesses) {
143
- FaceSkinOilinesses["DRY"] = "Seca";
144
- FaceSkinOilinesses["OILY"] = "Oleaosa";
145
- FaceSkinOilinesses["MIXED"] = "Mista";
146
- FaceSkinOilinesses["NORMAL"] = "Normal";
147
- FaceSkinOilinesses["DONT_KNOW"] = "Eu n\u00E3o sei como dizer";
148
- })(FaceSkinOilinesses || (FaceSkinOilinesses = {}));
149
-
150
- var FaceSkinProblems;
151
- (function (FaceSkinProblems) {
152
- FaceSkinProblems["NO_PROBLEMS"] = "Sem problemas";
153
- FaceSkinProblems["DARK_CIRCLES"] = "Olheiras";
154
- FaceSkinProblems["WRINKLES"] = "Rugas";
155
- FaceSkinProblems["BLACKHEADS_PIMPLES"] = "Cravos e Espinhas";
156
- FaceSkinProblems["STAINS"] = "Manchas";
157
- FaceSkinProblems["FRECKLES"] = "Sardas";
158
- FaceSkinProblems["SENSITIVE"] = "Sens\u00EDvel";
159
- FaceSkinProblems["PHOTOSENSITIVE"] = "Fotossens\u00EDvel";
160
- })(FaceSkinProblems || (FaceSkinProblems = {}));
161
-
162
- var FaceSkinTones;
163
- (function (FaceSkinTones) {
164
- FaceSkinTones["VERY_CLEAR"] = "Muito Clara";
165
- FaceSkinTones["CLEAR"] = "Clara";
166
- FaceSkinTones["MEDIUM_LIGHT"] = "Clara M\u00E9dia";
167
- FaceSkinTones["MEDIUM_DARK"] = "Escura M\u00E9dia";
168
- FaceSkinTones["DARK"] = "Escura";
169
- FaceSkinTones["VERY_DARK"] = "Muito Escura";
170
- })(FaceSkinTones || (FaceSkinTones = {}));
171
-
172
- var FamilyIncomes;
173
- (function (FamilyIncomes) {
174
- FamilyIncomes["UNTIL_3000"] = "At\u00E9 R$3.000";
175
- FamilyIncomes["SINCE_3001_TO_7000"] = "De R$3.001 a R$7.000";
176
- FamilyIncomes["SINCE_7001_TO_10000"] = "De R$7.001 a R$10.000";
177
- FamilyIncomes["SINCE_10001_TO_15000"] = "De R$10.001 a R$15.000";
178
- FamilyIncomes["GRAN_THAN_15000"] = "Mais de R$15.000";
179
- FamilyIncomes["NOW_ANSWER"] = "Prefiro nao responder";
180
- })(FamilyIncomes || (FamilyIncomes = {}));
181
-
182
- var FragranceImportances;
183
- (function (FragranceImportances) {
184
- FragranceImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
185
- FragranceImportances["LIKE_ALWAYS_USE_SAME"] = "Gosto de perfumes, mas uso sempre os mesmos";
186
- FragranceImportances["LIKE_INNOVATE"] = "Gosto de inovar e conhecer novas fragr\u00E2ncias";
187
- })(FragranceImportances || (FragranceImportances = {}));
188
-
189
- var HairColors;
190
- (function (HairColors) {
191
- HairColors["BLACK"] = "Preto";
192
- HairColors["DARK_BROWN"] = "Castanho Escuro";
193
- HairColors["LIGHT_BROWN"] = "Castanho Claro";
194
- HairColors["DARK_BLONDE"] = "Loiro Escuro";
195
- HairColors["LIGHT_BLONDE"] = "Loiro Claro";
196
- HairColors["WHITE_GRAY"] = "Branco/Grisalho";
197
- HairColors["REDHEAD"] = "Ruivo";
198
- HairColors["OTHER"] = "RuiOutroo";
199
- })(HairColors || (HairColors = {}));
200
-
201
- var HairProblems;
202
- (function (HairProblems) {
203
- HairProblems["NO_PROBLEMS"] = "Sem problemas";
204
- HairProblems["DANCRUFF"] = "Caspa";
205
- HairProblems["LOSS"] = "Queda";
206
- HairProblems["OILY"] = "Oleosidade";
207
- HairProblems["DRYNESS"] = "Ressecamento";
208
- HairProblems["CHEMICAL"] = "Quimica";
209
- HairProblems["WHITE_HAIR"] = "Cabelos Brancos";
210
- HairProblems["REBEL_WIRES"] = "Fios Rebeldes";
211
- })(HairProblems || (HairProblems = {}));
212
-
213
- var HairStrands;
214
- (function (HairStrands) {
215
- HairStrands["NORMAL"] = "Fio Normal";
216
- HairStrands["DRY"] = "Fio Seco";
217
- HairStrands["OILY"] = "Fio Oleoso";
218
- HairStrands["MIXED"] = "Fio Misto";
219
- HairStrands["FINE"] = "Fio Fino";
220
- HairStrands["THICK"] = "Fio Grosso";
221
- })(HairStrands || (HairStrands = {}));
222
-
223
- var HairTypes;
224
- (function (HairTypes) {
225
- HairTypes["Smooth"] = "Liso";
226
- HairTypes["WAVY"] = "Ondulado";
227
- HairTypes["CURLY"] = "Cacheado";
228
- HairTypes["FRIZZY"] = "Crespo";
229
- HairTypes["BALD"] = "Sou careca";
230
- })(HairTypes || (HairTypes = {}));
231
-
232
- var OfficePosition;
233
- (function (OfficePosition) {
234
- OfficePosition["Intern"] = "Estagi\u00E1rio";
235
- OfficePosition["Analyst"] = "Analista";
236
- OfficePosition["Manager"] = "Gerente";
237
- OfficePosition["Director"] = "Diretor";
238
- })(OfficePosition || (OfficePosition = {}));
239
-
240
- var ProductSpents;
241
- (function (ProductSpents) {
242
- ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
243
- ProductSpents["SINCE_51_TO_100"] = "De R$51 a R$100";
244
- ProductSpents["SINCE_101_TO_200"] = "De R$101 a R$200";
245
- ProductSpents["SINCE_201_TO_300"] = "De R$201 a R$300";
246
- ProductSpents["GRAN_THAN_300"] = "Mais de R$300";
247
- ProductSpents["NOW_ANSWER"] = "Prefiro nao responder";
248
- })(ProductSpents || (ProductSpents = {}));
249
-
250
- var UserType;
251
- (function (UserType) {
252
- UserType["B2C"] = "Cliente Transacional";
253
- UserType["GlamGirl"] = "Glamgirl";
254
- UserType["MensBoy"] = "Mensboy";
255
- UserType["B2B"] = "Company";
256
- UserType["Collaborator"] = "Funcion\u00E1rio";
257
- UserType["Influencer"] = "Influencer";
258
- })(UserType || (UserType = {}));
259
-
260
- var BillingStatus;
261
- (function (BillingStatus) {
262
- BillingStatus["PAYED"] = "PAGO";
263
- })(BillingStatus || (BillingStatus = {}));
264
-
265
- var EditionStatus;
266
- (function (EditionStatus) {
267
- EditionStatus["ALLOCATION_WAITING"] = "Aguardando aloca\u00E7\u00E3o";
268
- EditionStatus["SHIPPED"] = "Enviado";
269
- })(EditionStatus || (EditionStatus = {}));
270
-
271
- var PaymentType;
272
- (function (PaymentType) {
273
- PaymentType["AQUISITION"] = "Aquisi\u00E7\u00E3o";
274
- PaymentType["RENEWAL"] = "Renova\u00E7\u00E3o";
275
- PaymentType["FREIGHT"] = "mudan\u00E7a de endere\u00E7o, Frete";
276
- })(PaymentType || (PaymentType = {}));
277
-
278
- var Status;
279
- (function (Status) {
280
- Status["ACTIVE"] = "active";
281
- Status["CANCELLED"] = "Cancelado";
282
- })(Status || (Status = {}));
283
-
284
- class Edition extends BaseModel {
285
- static get identifiersFields() {
286
- return ['id', 'subscriptionId'];
287
- }
288
- }
289
-
290
- class Payment extends BaseModel {
291
- static get identifiersFields() {
292
- return ['id'];
293
- }
294
- }
295
- __decorate([
296
- Expose({ name: 'refuse_reason' }),
297
- __metadata("design:type", String)
298
- ], Payment.prototype, "refuseReason", void 0);
299
- __decorate([
300
- Expose({ name: 'status_reason' }),
301
- __metadata("design:type", String)
302
- ], Payment.prototype, "statusReason", void 0);
303
- __decorate([
304
- Expose({ name: 'acquirer_response_code' }),
305
- __metadata("design:type", String)
306
- ], Payment.prototype, "acquirerResponseCode", void 0);
307
- __decorate([
308
- Expose({ name: 'acquirer_name' }),
309
- __metadata("design:type", String)
310
- ], Payment.prototype, "acquirerName", void 0);
311
- __decorate([
312
- Expose({ name: 'acquirer_id' }),
313
- __metadata("design:type", String)
314
- ], Payment.prototype, "acquirerId", void 0);
315
- __decorate([
316
- Expose({ name: 'authorization_code' }),
317
- __metadata("design:type", String)
318
- ], Payment.prototype, "authorizationCode", void 0);
319
- __decorate([
320
- Expose({ name: 'soft_descriptor' }),
321
- __metadata("design:type", String)
322
- ], Payment.prototype, "softDescriptor", void 0);
323
- __decorate([
324
- Expose({ name: 'date_created' }),
325
- __metadata("design:type", String)
326
- ], Payment.prototype, "dateCreated", void 0);
327
- __decorate([
328
- Expose({ name: 'date_updated' }),
329
- __metadata("design:type", String)
330
- ], Payment.prototype, "dateUpdated", void 0);
331
- __decorate([
332
- Expose({ name: 'authorized_amount' }),
333
- __metadata("design:type", Number)
334
- ], Payment.prototype, "authorizedAmount", void 0);
335
- __decorate([
336
- Expose({ name: 'paid_amount' }),
337
- __metadata("design:type", Number)
338
- ], Payment.prototype, "paidAmount", void 0);
339
- __decorate([
340
- Expose({ name: 'refunded_amount' }),
341
- __metadata("design:type", Number)
342
- ], Payment.prototype, "refundedAmount", void 0);
343
- __decorate([
344
- Expose({ name: 'card_holder_name' }),
345
- __metadata("design:type", String)
346
- ], Payment.prototype, "cardHolderName", void 0);
347
- __decorate([
348
- Expose({ name: 'card_last_digits' }),
349
- __metadata("design:type", String)
350
- ], Payment.prototype, "cardLastDigits", void 0);
351
- __decorate([
352
- Expose({ name: 'card_first_digits' }),
353
- __metadata("design:type", String)
354
- ], Payment.prototype, "cardFirstDigits", void 0);
355
- __decorate([
356
- Expose({ name: 'card_brand' }),
357
- __metadata("design:type", String)
358
- ], Payment.prototype, "cardBrand", void 0);
359
- __decorate([
360
- Expose({ name: 'card_pin_mode' }),
361
- __metadata("design:type", String)
362
- ], Payment.prototype, "cardPinMode", void 0);
363
- __decorate([
364
- Expose({ name: 'card_magstripe_fallback' }),
365
- __metadata("design:type", Boolean)
366
- ], Payment.prototype, "cardMagstripeFallback", void 0);
367
- __decorate([
368
- Expose({ name: 'cvm_pin' }),
369
- __metadata("design:type", Boolean)
370
- ], Payment.prototype, "cvmPin", void 0);
371
- __decorate([
372
- Expose({ name: 'postback_url' }),
373
- __metadata("design:type", String)
374
- ], Payment.prototype, "postbackUrl", void 0);
375
- __decorate([
376
- Expose({ name: 'payment_method' }),
377
- __metadata("design:type", String)
378
- ], Payment.prototype, "paymentMethod", void 0);
379
- __decorate([
380
- Expose({ name: 'capture_method' }),
381
- __metadata("design:type", String)
382
- ], Payment.prototype, "captureMethod", void 0);
383
- __decorate([
384
- Expose({ name: 'antifraud_score' }),
385
- __metadata("design:type", String)
386
- ], Payment.prototype, "antifraudScore", void 0);
387
- __decorate([
388
- Expose({ name: 'boleto_url' }),
389
- __metadata("design:type", String)
390
- ], Payment.prototype, "boletoUrl", void 0);
391
- __decorate([
392
- Expose({ name: 'boleto_barcode' }),
393
- __metadata("design:type", String)
394
- ], Payment.prototype, "boletoBarcode", void 0);
395
- __decorate([
396
- Expose({ name: 'boleto_expiration_date' }),
397
- __metadata("design:type", String)
398
- ], Payment.prototype, "boletoExpirationDate", void 0);
399
- __decorate([
400
- Expose({ name: 'subscription_id' }),
401
- __metadata("design:type", String)
402
- ], Payment.prototype, "subscriptionId", void 0);
403
- __decorate([
404
- Expose({ name: 'split_rules' }),
405
- __metadata("design:type", String)
406
- ], Payment.prototype, "splitRules", void 0);
407
- __decorate([
408
- Expose({ name: 'antifraud_metadata' }),
409
- __metadata("design:type", Object)
410
- ], Payment.prototype, "antifraudMetadata", void 0);
411
- __decorate([
412
- Expose({ name: 'reference_key' }),
413
- __metadata("design:type", String)
414
- ], Payment.prototype, "referenceKey", void 0);
415
- __decorate([
416
- Expose({ name: 'local_transaction_id' }),
417
- __metadata("design:type", String)
418
- ], Payment.prototype, "localTransactionId", void 0);
419
- __decorate([
420
- Expose({ name: 'local_time' }),
421
- __metadata("design:type", String)
422
- ], Payment.prototype, "localTime", void 0);
423
- __decorate([
424
- Expose({ name: 'fraud_covered' }),
425
- __metadata("design:type", Boolean)
426
- ], Payment.prototype, "fraudCovered", void 0);
427
- __decorate([
428
- Expose({ name: 'fraud_reimbursed' }),
429
- __metadata("design:type", String)
430
- ], Payment.prototype, "fraudReimbursed", void 0);
431
- __decorate([
432
- Expose({ name: 'order_id' }),
433
- __metadata("design:type", String)
434
- ], Payment.prototype, "orderId", void 0);
435
- __decorate([
436
- Expose({ name: 'risk_level' }),
437
- __metadata("design:type", String)
438
- ], Payment.prototype, "riskLevel", void 0);
439
- __decorate([
440
- Expose({ name: 'receipt_url' }),
441
- __metadata("design:type", String)
442
- ], Payment.prototype, "receiptUrl", void 0);
443
- __decorate([
444
- Expose({ name: 'private_label' }),
445
- __metadata("design:type", String)
446
- ], Payment.prototype, "privateLabel", void 0);
447
- __decorate([
448
- Expose({ name: 'pix_qr_code' }),
449
- __metadata("design:type", String)
450
- ], Payment.prototype, "pixQrCode", void 0);
451
- __decorate([
452
- Expose({ name: 'pix_expiration_date' }),
453
- __metadata("design:type", String)
454
- ], Payment.prototype, "pixExpirationDate", void 0);
455
-
456
- class SubscriptionPayment extends BaseModel {
457
- static get identifiersFields() {
458
- return ['id', 'subscriptionId'];
459
- }
460
- }
461
- __decorate([
462
- Type(() => Payment),
463
- __metadata("design:type", Payment)
464
- ], SubscriptionPayment.prototype, "payment", void 0);
465
-
466
- var DebugNamespaces;
467
- (function (DebugNamespaces) {
468
- DebugNamespaces["ROOT"] = "connect";
469
- DebugNamespaces["TRACE"] = "trace";
470
- DebugNamespaces["ERROR"] = "error";
471
- })(DebugNamespaces || (DebugNamespaces = {}));
472
- const Logger = debug(DebugNamespaces.ROOT);
473
-
474
- class ReflectHelper {
475
- static get items() {
476
- return this._items;
477
- }
478
- static get keys() {
479
- return Object.keys(ReflectHelper.items);
480
- }
481
- static has(key, target, property) {
482
- return (!isNil(key) &&
483
- !isNil(ReflectHelper.items[key]) &&
484
- (isNil(target) ||
485
- (!isNil(ReflectHelper.items[key][target]) &&
486
- (isNil(property) || !isNil(ReflectHelper.items[key][target][String(property)])))));
487
- }
488
- static get({ key, target, property, own = true }) {
489
- try {
490
- if (own) {
491
- return Reflect.getOwnMetadata(key, target, property) || null;
492
- }
493
- else {
494
- return Reflect.getMetadata(key, target, property) || null;
495
- }
496
- }
497
- catch (_err) {
498
- return null;
499
- }
500
- }
501
- static first({ key, target, property, own = true }) {
502
- const values = ReflectHelper.get({ key, target, property, own });
503
- return isArray(values) ? first(values) : values;
504
- }
505
- static last({ key, target, property, own = true }) {
506
- const values = ReflectHelper.get({ key, target, property, own });
507
- return isArray(values) ? last(values) : values;
508
- }
509
- static set({ key, target, property, value, propertyDescriptor }) {
510
- Reflect.defineMetadata(key, value, target, property);
511
- ReflectHelper.put({ key, target, property, value, propertyDescriptor });
512
- }
513
- static add({ key, target, property, value, propertyDescriptor }) {
514
- let values = ReflectHelper.get({ key, target, property }) || new Array();
515
- if (!Array.isArray(values))
516
- values = [values];
517
- values.push(value);
518
- ReflectHelper.set({ key, target, property, value: values, propertyDescriptor });
519
- }
520
- static all({ key }) {
521
- const items = ReflectHelper.items[key] || {};
522
- return flatten(Object.keys(items).map((item) => flatten(this.allFrom(key, items[item]))));
523
- }
524
- static allFrom(key, target) {
525
- return Object.keys(target)
526
- .filter((property) => property !== 'object')
527
- .map((property) => this.allValuesFrom(key, target, property));
528
- }
529
- static allValuesFrom(key, target, property) {
530
- const values = target[property];
531
- let value = values.value;
532
- const propertyDescriptor = values.propertyDescriptor;
533
- if (!isArray(value))
534
- value = [value];
535
- return flatten(value.map((val) => {
536
- return {
537
- key,
538
- target: target.object,
539
- property,
540
- value: val,
541
- propertyDescriptor,
542
- };
543
- }));
544
- }
545
- static delete({ key, target, property }) {
546
- Reflect.deleteMetadata(key, target, property);
547
- return ReflectHelper.remove(key, target, property);
548
- }
549
- static clear(key) {
550
- if (!key) {
551
- ReflectHelper.keys.forEach((storedKey) => {
552
- ReflectHelper.clear(storedKey);
553
- });
554
- }
555
- else {
556
- if (ReflectHelper.keys.includes(key)) {
557
- Object.values(ReflectHelper.items[key]).forEach((target) => {
558
- if (ReflectHelper.has(key, target)) {
559
- Object.values(ReflectHelper.items[key][target.toString()]).forEach((property) => {
560
- ReflectHelper.delete({
561
- key,
562
- target: target.object,
563
- property: String(property),
564
- });
565
- ReflectHelper.remove(key, target, String(property));
566
- });
567
- }
568
- ReflectHelper.delete({ key, target: target.object });
569
- ReflectHelper.remove(key, target);
570
- });
571
- }
572
- }
573
- }
574
- static getType({ target, propertyKey }) {
575
- return Reflect.getMetadata('design:type', target, propertyKey);
576
- }
577
- static getReturntype({ target, propertyKey }) {
578
- return Reflect.getMetadata('design:returntype', target, propertyKey);
579
- }
580
- static getAllMethods(target) {
581
- const props = [];
582
- let obj = target;
583
- do {
584
- props.push(...Object.getOwnPropertyNames(obj));
585
- } while ((obj = Object.getPrototypeOf(obj)));
586
- return props.sort().filter((e, i, arr) => {
587
- if ([
588
- '__defineGetter__',
589
- '__defineSetter__',
590
- '__lookupGetter__',
591
- '__lookupSetter__',
592
- 'constructor',
593
- 'hasOwnProperty',
594
- 'isPrototypeOf',
595
- 'propertyIsEnumerable',
596
- 'toLocaleString',
597
- 'toString',
598
- 'valueOf',
599
- ].includes(e))
600
- return false;
601
- if (e != arr[i + 1] && typeof target[e] === 'function')
602
- return true;
603
- });
604
- }
605
- static put({ key, target, property, value, propertyDescriptor }) {
606
- const index = target.constructor.name;
607
- ReflectHelper.items[key] = ReflectHelper.items[key] || {};
608
- ReflectHelper.items[key][index] = ReflectHelper.items[key][index] || {};
609
- ReflectHelper.items[key][index].object = target;
610
- if (isNil(property)) {
611
- ReflectHelper.items[key][index].value = {
612
- value,
613
- propertyDescriptor,
614
- };
615
- }
616
- else {
617
- ReflectHelper.items[key][index][String(property)] = ReflectHelper.items[key][index][String(property)] || {};
618
- ReflectHelper.items[key][index][String(property)] = {
619
- value,
620
- propertyDescriptor,
621
- };
622
- }
623
- }
624
- static remove(key, target, property) {
625
- if (ReflectHelper.has(key, target, property))
626
- return delete ReflectHelper.items[key][target][String(property)];
627
- else if (ReflectHelper.has(key, target))
628
- return delete ReflectHelper.items[key][target];
629
- else if (ReflectHelper.has(key))
630
- return delete ReflectHelper.items[key];
631
- else
632
- return false;
633
- }
634
- }
635
- ReflectHelper._items = {};
636
-
637
- class DebugDecoratorHelper {
638
- static set(target, options) {
639
- ReflectHelper.add({
640
- key: DebugDecoratorHelper.DebugNamingMetadataKey,
641
- target,
642
- value: options,
643
- });
644
- }
645
- static get(target) {
646
- return ReflectHelper.first({
647
- key: DebugDecoratorHelper.DebugNamingMetadataKey,
648
- target,
649
- });
650
- }
651
- }
652
- DebugDecoratorHelper.DebugNamingMetadataKey = 'model:naming:decorator';
653
-
654
- class ClassNameHelper {
655
- static get(clazz) {
656
- if (!clazz)
657
- return null;
658
- const prototype = Object.getPrototypeOf(clazz);
659
- const names = compact([
660
- get$1(clazz, 'constructor.name'),
661
- get$1(prototype, 'constructor.name'),
662
- get$1(prototype, '__proto__.constructor.name'),
663
- ]);
664
- return names.find((name) => name !== 'class_1');
665
- }
666
- }
667
-
668
- const isDebuggable = (object) => {
669
- return 'debug' in object;
670
- };
671
- class DebugHelper {
672
- constructor(...namespace) {
673
- this.namespaces = new Set();
674
- this.push(...namespace);
675
- }
676
- static namespacesFor(target) {
677
- if (isNil(target))
678
- return [];
679
- const decorator = DebugDecoratorHelper.get(Object.getPrototypeOf(target));
680
- const namespaces = get$1(decorator, 'namespaces', []);
681
- const name = get$1(decorator, 'name', ClassNameHelper.get(target));
682
- return [...namespaces, name];
683
- }
684
- static as(...namespaces) {
685
- return new DebugHelper(...namespaces);
686
- }
687
- static for(target, ...namespaces) {
688
- const targetNamespaces = this.namespacesFor(target);
689
- return new DebugHelper(...targetNamespaces, ...namespaces);
690
- }
691
- static from(target, ...namespaces) {
692
- if (this.isDebuggable(target)) {
693
- const debug = target.debug;
694
- if (namespaces)
695
- debug.push(...namespaces);
696
- return debug;
697
- }
698
- return DebugHelper.for(target, ...namespaces);
699
- }
700
- static clonedFrom(target, ...namespaces) {
701
- if (this.isDebuggable(target)) {
702
- namespaces.push(...target.debug.entries);
703
- }
704
- else if (!isNil(target)) {
705
- namespaces.push(...this.namespacesFor(target));
706
- }
707
- return DebugHelper.for(target, ...namespaces);
708
- }
709
- static clone(target, ...namespaces) {
710
- let original;
711
- if (this.isDebuggable(target)) {
712
- original = target.debug;
713
- namespaces.push(...original.entries);
714
- }
715
- return {
716
- original,
717
- debug: DebugHelper.for(target, ...namespaces),
718
- };
719
- }
720
- static replace(target, attrs) {
721
- if (this.isDebuggable(target))
722
- target.debug = attrs.with;
723
- }
724
- static mock(target, ...namespaces) {
725
- const { original, debug } = DebugHelper.clone(target, ...namespaces);
726
- DebugHelper.replace(target, { with: debug });
727
- return { original, debug };
728
- }
729
- get entries() {
730
- return Array.from(get$1(this, 'namespaces', []));
731
- }
732
- get namespace() {
733
- return compact(flatten(this.entries)).join(':');
734
- }
735
- log(message, ...args) {
736
- this.logger(JSON.stringify(message), ...args.map((element) => JSON.stringify(element)));
737
- DebugHelper.logs$.next({ namespace: this.namespace, message, args });
738
- return this;
739
- }
740
- trace(message, ...args) {
741
- this.logger.extend(DebugNamespaces.TRACE)(message, ...args);
742
- DebugHelper.traces$.next({ namespace: this.namespace, message, args });
743
- return this;
744
- }
745
- error(error, ...args) {
746
- this.logger.extend(DebugNamespaces.ERROR)(JSON.stringify(error), ...args.map((element) => JSON.stringify(element)));
747
- DebugHelper.errors$.next({ namespace: this.namespace, error, args });
748
- return this;
749
- }
750
- build() {
751
- this.logger = Logger;
752
- this.tracer = Logger;
753
- this.err = Logger;
754
- this.entries.forEach((namespace) => {
755
- this.logger = this.logger.extend(namespace);
756
- this.tracer = this.tracer.extend(namespace);
757
- this.err = this.err.extend(namespace);
758
- });
759
- return this;
760
- }
761
- with(...namespace) {
762
- return new DebugHelper(...this.entries, ...namespace);
763
- }
764
- push(...namespace) {
765
- if (namespace) {
766
- namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.add(item));
767
- }
768
- return this.build();
769
- }
770
- unshift(...namespace) {
771
- if (namespace) {
772
- return this.reset(...namespace, ...this.entries);
773
- }
774
- return this;
775
- }
776
- reset(...namespace) {
777
- this.namespaces = new Set(flatten(compact(namespace)));
778
- return this.build();
779
- }
780
- startWith(...namespace) {
781
- const current = this.namespaces;
782
- this.namespaces = new Set(flatten([compact(namespace), ...current]));
783
- return this.build();
784
- }
785
- shift() {
786
- const list = this.entries;
787
- list.shift();
788
- return this.reset(...list);
789
- }
790
- pop() {
791
- const list = this.entries;
792
- list.pop();
793
- return this.reset(...list);
794
- }
795
- clear() {
796
- return this.reset();
797
- }
798
- remove(...namespace) {
799
- if (namespace) {
800
- namespace.filter((item) => Boolean(item)).forEach((item) => this.namespaces.delete(item));
801
- }
802
- return this.build();
803
- }
804
- puts(...args) {
805
- return [`[${this.namespace}]`, ...args].join(' ');
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
- };
837
- }
838
- const traceCall = function ({ target, propertyKey, propertyDescriptor, args }) {
839
- if (!target.debug)
840
- target.debug = DebugHelper.for(target, propertyKey);
841
- return target.debug.push(propertyKey).trace('called', { target, propertyKey, propertyDescriptor, args });
842
- };
843
- const promiseTracer = function ({ options, method, propertyKey, propertyDescriptor }) {
844
- return function (...args) {
845
- return new Promise((resolve, reject) => {
846
- const debug = traceCall({ target: this, propertyDescriptor, propertyKey, args });
847
- if (get$1(options, 'level', '') === 'log') {
848
- debug.with('params').log(args);
849
- }
850
- return method
851
- .apply(this, args)
852
- .then((result) => {
853
- if (options.callbackFn) {
854
- options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
855
- }
856
- if (get$1(options, 'level', '') === 'log') {
857
- debug.with('returns').log(result === undefined ? 'void' : result);
858
- }
859
- return resolve(result);
860
- })
861
- .catch((error) => {
862
- debug.error(error, ...args);
863
- debug.with('stack').error(error.stack).pop();
864
- return reject(error);
865
- })
866
- .finally(() => {
867
- return debug.trace('finally', { args }).pop();
868
- });
869
- });
870
- };
871
- };
872
- const functionTracer = function ({ options, target, method, propertyKey, propertyDescriptor, }) {
873
- return function (...args) {
874
- const debug = traceCall({ target: this || target, propertyDescriptor, propertyKey, args });
875
- if (get$1(options, 'level', '') === 'log') {
876
- debug.with('params').log(args);
877
- }
878
- let result;
879
- try {
880
- result = method.apply(this, args);
881
- if (options.callbackFn)
882
- options.callbackFn({ target: this, result, args, namespace: [propertyKey] });
883
- if (get$1(options, 'level', '') === 'log') {
884
- debug.with('returns').log(result === undefined ? 'void' : result);
885
- }
886
- return result;
887
- }
888
- catch (error) {
889
- debug.error(error, ...args).pop();
890
- throw error;
891
- }
892
- finally {
893
- debug.trace('finally', { args }).pop();
894
- }
895
- };
896
- };
897
-
898
- const get = (object, path, defaultValue) => get$1(object, path, defaultValue);
899
-
900
- function is(value) {
901
- return value;
902
- }
903
-
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);
905
-
906
- class Base {
907
- constructor(...args) {
908
- Object.assign(this, ...args);
909
- }
910
- }
911
-
912
- const parseDateTime = (value) => {
913
- if (!isString(value))
914
- return value;
915
- if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
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))
917
- return value;
918
- const date = parseISO(value);
919
- if (isNaN(date.getTime()))
920
- return value;
921
- return date;
922
- };
923
-
924
- var CheckoutTypes;
925
- (function (CheckoutTypes) {
926
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
927
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
928
- CheckoutTypes[CheckoutTypes["ALL"] = 3] = "ALL";
929
- })(CheckoutTypes || (CheckoutTypes = {}));
930
-
931
- var CouponTypes;
932
- (function (CouponTypes) {
933
- CouponTypes[CouponTypes["ABSOLUTE"] = 1] = "ABSOLUTE";
934
- CouponTypes[CouponTypes["PERCENTAGE"] = 2] = "PERCENTAGE";
935
- // FINANCIAL = 1,
936
- // PRODUCT,
937
- // GIFTCARD,
938
- // VOUCHER,
939
- })(CouponTypes || (CouponTypes = {}));
940
-
941
- var CouponSubtypes;
942
- (function (CouponSubtypes) {
943
- CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
944
- CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
945
- })(CouponSubtypes || (CouponSubtypes = {}));
946
-
947
- var Exclusivities;
948
- (function (Exclusivities) {
949
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
950
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
951
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
952
- Exclusivities[Exclusivities["ACTIVE_SUBSCRIBER"] = 4] = "ACTIVE_SUBSCRIBER";
953
- Exclusivities[Exclusivities["INACTIVE_SUBSCRIBER"] = 5] = "INACTIVE_SUBSCRIBER";
954
- Exclusivities[Exclusivities["NON_SUBSCRIBER"] = 6] = "NON_SUBSCRIBER";
955
- })(Exclusivities || (Exclusivities = {}));
956
-
957
- const COUPON_EXPIRATION = +1000 * 60 * 60 * 24 * 30;
958
- class Coupon extends BaseModel {
959
- get isInfluencer() {
960
- return !isNil(this.influencerEmail);
961
- }
962
- static get identifiersFields() {
963
- return ['id'];
964
- }
965
- static createCoupon(userId) {
966
- return this.toInstance({
967
- nickname: `${Date.now()}`,
968
- checkoutType: CheckoutTypes.ECOMMERCE,
969
- discount: {
970
- subscriber: {
971
- type: CouponTypes.ABSOLUTE,
972
- value: 10,
973
- },
974
- non_subscriber: {
975
- type: CouponTypes.ABSOLUTE,
976
- value: 10,
977
- },
978
- subscription: {
979
- type: CouponTypes.ABSOLUTE,
980
- value: 10,
981
- },
982
- },
983
- user: userId,
984
- createdAt: new Date(Date.now()),
985
- beginAt: new Date(Date.now()),
986
- expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
987
- });
988
- }
989
- }
990
-
991
- class SubscriptionPlan extends BaseModel {
992
- static get identifiersFields() {
993
- return ['id'];
994
- }
995
- }
996
-
997
- class BeautyProfile extends BaseModel {
998
- toPlain() {
999
- const plain = super.toPlain();
1000
- delete plain.id;
1001
- return plain;
1002
- }
1003
- static get identifiersFields() {
1004
- return ['id', 'userId'];
1005
- }
1006
- }
1007
-
1008
- class User extends BaseModel {
1009
- static toInstance(data) {
1010
- const instance = super.toInstance(data);
1011
- if (!isNil(data.firstName))
1012
- instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
1013
- return instance;
1014
- }
1015
- toPlain() {
1016
- const plain = super.toPlain();
1017
- delete plain.beautyProfile;
1018
- return plain;
1019
- }
1020
- static get identifiersFields() {
1021
- return ['id'];
1022
- }
1023
- }
1024
- __decorate([
1025
- Type(() => BeautyProfile),
1026
- __metadata("design:type", BeautyProfile)
1027
- ], User.prototype, "beautyProfile", void 0);
1028
-
1029
- class Address extends BaseModel {
1030
- static get identifiersFields() {
1031
- return ['id'];
1032
- }
1033
- }
1034
-
1035
- class UserAddress extends Address {
1036
- static get identifiersFields() {
1037
- return ['id', 'userId'];
1038
- }
1039
- }
1040
-
1041
- class Subscription extends BaseModel {
1042
- static get identifiersFields() {
1043
- return ['id'];
1044
- }
1045
- }
1046
- __decorate([
1047
- Type(() => User),
1048
- __metadata("design:type", User)
1049
- ], Subscription.prototype, "user", void 0);
1050
- __decorate([
1051
- Type(() => SubscriptionPlan),
1052
- __metadata("design:type", SubscriptionPlan)
1053
- ], Subscription.prototype, "subscriptionPlan", void 0);
1054
- __decorate([
1055
- Type(() => UserAddress),
1056
- __metadata("design:type", UserAddress)
1057
- ], Subscription.prototype, "shippingAddress", void 0);
1058
- __decorate([
1059
- Type(() => UserAddress),
1060
- __metadata("design:type", UserAddress)
1061
- ], Subscription.prototype, "billingAddress", void 0);
1062
- __decorate([
1063
- Type(() => Coupon),
1064
- __metadata("design:type", Coupon)
1065
- ], Subscription.prototype, "coupon", void 0);
1066
- __decorate([
1067
- Type(() => Edition),
1068
- __metadata("design:type", Array)
1069
- ], Subscription.prototype, "editions", void 0);
1070
- __decorate([
1071
- Type(() => SubscriptionPayment),
1072
- __metadata("design:type", Array)
1073
- ], Subscription.prototype, "payment", void 0);
1074
-
1075
- class UserPaymentMethod extends BaseModel {
1076
- static get identifiersFields() {
1077
- return ['id', 'userId'];
1078
- }
1079
- }
1080
-
1081
- class Lead extends BaseModel {
1082
- static get identifiersFields() {
1083
- return ['id'];
1084
- }
1085
- }
1086
-
1087
- class UnauthorizedError extends CustomError {
1088
- constructor(message) {
1089
- super(message);
1090
- }
1091
- }
1092
-
1093
- var SignInMethods;
1094
- (function (SignInMethods) {
1095
- SignInMethods["EMAIL_PASSWORD"] = "email_password";
1096
- SignInMethods["GOOGLE"] = "google";
1097
- })(SignInMethods || (SignInMethods = {}));
1098
- class Authentication {
1099
- constructor(authService, userRepository) {
1100
- this.authService = authService;
1101
- this.userRepository = userRepository;
1102
- }
1103
- async signIn({ email, password }, signInMethod) {
1104
- const method = this.getServiceByMethod(signInMethod);
1105
- const userAuth = await this.authService[method]({ email, password });
1106
- const user = this.userRepository.get({ id: userAuth.id });
1107
- if (!isNil(user))
1108
- return user;
1109
- if (/^.+@b4a.com.br$/.test(userAuth.email))
1110
- return this.createsUserByCredential(userAuth);
1111
- throw new UnauthorizedError('Invalid credentials');
1112
- }
1113
- getServiceByMethod(signInMethod) {
1114
- return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
1115
- }
1116
- async createsUserByCredential(user) {
1117
- const [firstName, lastName] = user.displayName?.split(/\s/);
1118
- const person = User.toInstance({
1119
- ...user,
1120
- cpf: '',
1121
- birthday: new Date(),
1122
- firstName,
1123
- lastName,
1124
- acceptsNewsletter: false,
1125
- area: Area.Transactional,
1126
- officePosition: OfficePosition.Intern,
1127
- type: UserType.Collaborator,
1128
- });
1129
- return this.userRepository.create(person);
1130
- }
1131
- }
1132
-
1133
- class UserAlreadyRegisteredError extends CustomError {
1134
- constructor(message) {
1135
- super(message);
1136
- }
1137
- }
1138
-
1139
- class WeakPasswordError extends CustomError {
1140
- constructor(message = 'Weak password') {
1141
- super(message);
1142
- }
1143
- }
1144
-
1145
- class Register {
1146
- constructor(registerService, userRepository) {
1147
- this.registerService = registerService;
1148
- this.userRepository = userRepository;
1149
- }
1150
- async register(params) {
1151
- const email = params.email.toLocaleLowerCase();
1152
- const displayName = `${params.firstName} ${params.lastName}`;
1153
- if (await this.userRepository.checkIfExistsByField('cpf', params.cpf))
1154
- throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} já registrado.`);
1155
- if (await this.userRepository.checkIfExistsByField('email', params.email))
1156
- throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} já registrado.`);
1157
- const auth = await this.registerService.register({
1158
- birthday: params.birthday,
1159
- email,
1160
- firstName: params.firstName,
1161
- lastName: params.lastName,
1162
- cpf: params.cpf,
1163
- displayName,
1164
- phone: params.phone,
1165
- password: params.password,
1166
- });
1167
- delete params.password;
1168
- const user = await this.userRepository.create({
1169
- ...params,
1170
- id: auth.id,
1171
- email,
1172
- displayName,
1173
- type: UserType.B2C,
1174
- dateCreated: new Date(),
1175
- dateModified: new Date(),
1176
- });
1177
- return user;
1178
- }
1179
- }
1180
-
1181
- class SignOut {
1182
- constructor(authService) {
1183
- this.authService = authService;
1184
- }
1185
- async signOut() {
1186
- await this.authService.signOut();
1187
- }
1188
- }
1189
-
1190
- class RecoveryPassword {
1191
- constructor(authService) {
1192
- this.authService = authService;
1193
- }
1194
- async sendEmail(email) {
1195
- await this.authService.sendPasswordResetEmail(email);
1196
- }
1197
- }
1198
-
1199
- class Filter extends BaseModel {
1200
- static get identifiersFields() {
1201
- return ['id'];
1202
- }
1203
- }
1204
-
1205
- class CategoryBase extends BaseModel {
1206
- static get identifiersFields() {
1207
- return ['id'];
1208
- }
1209
- }
1210
- __decorate([
1211
- Type(() => CategoryBase),
1212
- __metadata("design:type", CategoryBase)
1213
- ], CategoryBase.prototype, "parent", void 0);
1214
- __decorate([
1215
- Type(() => Filter),
1216
- __metadata("design:type", Array)
1217
- ], CategoryBase.prototype, "filters", void 0);
1218
-
1219
- class CategoryForProduct extends CategoryBase {
1220
- static get identifiersFields() {
1221
- return ['id'];
1222
- }
1223
- }
1224
-
1225
- class ProductBase extends BaseModel {
1226
- get evaluation() {
1227
- return {
1228
- reviews: this.reviews,
1229
- count: this.reviewsTotal,
1230
- rating: this.rate,
1231
- };
1232
- }
1233
- set evaluation(evaluation) {
1234
- if (!evaluation) {
1235
- this.reviews = null;
1236
- this.reviewsTotal = null;
1237
- this.rate = null;
1238
- return;
1239
- }
1240
- this.reviews = evaluation.reviews || this.reviews;
1241
- this.reviewsTotal = evaluation.count || this.reviewsTotal;
1242
- this.rate = evaluation.rating || this.rate;
1243
- }
1244
- static get identifiersFields() {
1245
- return ['id'];
1246
- }
1247
- }
1248
-
1249
- class ProductForKit extends ProductBase {
1250
- static get identifiersFields() {
1251
- return ['id'];
1252
- }
1253
- }
1254
- __decorate([
1255
- Type(() => CategoryForProduct),
1256
- __metadata("design:type", CategoryForProduct)
1257
- ], ProductForKit.prototype, "category", void 0);
1258
-
1259
- class KitProduct extends BaseModel {
1260
- static get identifiersFields() {
1261
- return ['productId', 'kitProductId'];
1262
- }
1263
- }
1264
- __decorate([
1265
- Type(() => ProductForKit),
1266
- __metadata("design:type", ProductForKit)
1267
- ], KitProduct.prototype, "kit", void 0);
1268
- __decorate([
1269
- Type(() => ProductForKit),
1270
- __metadata("design:type", ProductForKit)
1271
- ], KitProduct.prototype, "product", void 0);
1272
-
1273
- class ProductForCategory extends ProductBase {
1274
- static get identifiersFields() {
1275
- return ['id'];
1276
- }
1277
- }
1278
- __decorate([
1279
- Type(() => KitProduct),
1280
- __metadata("design:type", Array)
1281
- ], ProductForCategory.prototype, "kitProducts", void 0);
1282
-
1283
- class Category extends CategoryBase {
1284
- static get identifiersFields() {
1285
- return ['id'];
1286
- }
1287
- }
1288
- __decorate([
1289
- Type(() => ProductForCategory),
1290
- __metadata("design:type", Array)
1291
- ], Category.prototype, "childrenProducts", void 0);
1292
-
1293
- class CategoryCollectionChildren extends BaseModel {
1294
- static get identifiersFields() {
1295
- return ['collectionId', 'categoryId'];
1296
- }
1297
- }
1298
- __decorate([
1299
- Type(() => CategoryCollectionChildren),
1300
- __metadata("design:type", CategoryCollectionChildren)
1301
- ], CategoryCollectionChildren.prototype, "parent", void 0);
1302
-
1303
- class CategoryFilter extends BaseModel {
1304
- static get identifiersFields() {
1305
- return ['id'];
1306
- }
1307
- }
1308
- __decorate([
1309
- Type(() => Filter),
1310
- __metadata("design:type", Filter)
1311
- ], CategoryFilter.prototype, "filter", void 0);
1312
- __decorate([
1313
- Type(() => Category),
1314
- __metadata("design:type", Category)
1315
- ], CategoryFilter.prototype, "category", void 0);
1316
-
1317
- var GenderDestination;
1318
- (function (GenderDestination) {
1319
- GenderDestination["FEMALE"] = "female";
1320
- GenderDestination["MALE"] = "male";
1321
- GenderDestination["UNISEX"] = "unisex";
1322
- })(GenderDestination || (GenderDestination = {}));
1323
-
1324
- var Shops;
1325
- (function (Shops) {
1326
- Shops["MENSMARKET"] = "mensmarket";
1327
- Shops["GLAMSHOP"] = "Glamshop";
1328
- Shops["GLAMPOINTS"] = "Glampoints";
1329
- Shops["ALL"] = "ALL";
1330
- })(Shops || (Shops = {}));
1331
-
1332
- class FilterOption extends BaseModel {
1333
- static get identifiersFields() {
1334
- return ['id'];
1335
- }
1336
- }
1337
-
1338
- class Product extends ProductBase {
1339
- static get identifiersFields() {
1340
- return ['id'];
1341
- }
1342
- }
1343
- __decorate([
1344
- Type(() => CategoryForProduct),
1345
- __metadata("design:type", CategoryForProduct)
1346
- ], Product.prototype, "category", void 0);
1347
- __decorate([
1348
- Type(() => KitProduct),
1349
- __metadata("design:type", Array)
1350
- ], Product.prototype, "kitProducts", void 0);
1351
-
1352
- class Variant extends BaseModel {
1353
- static get identifiersFields() {
1354
- return ['id', 'productId'];
1355
- }
1356
- }
1357
-
1358
- class Wishlist extends Category {
1359
- static get identifiersFields() {
1360
- return ['id'];
1361
- }
1362
- }
1363
-
1364
- class Buy2Win extends BaseModel {
1365
- static get identifiersFields() {
1366
- return ['id'];
1367
- }
1368
- }
1369
- __decorate([
1370
- Type(() => Category),
1371
- __metadata("design:type", Array)
1372
- ], Buy2Win.prototype, "categories", void 0);
1373
-
1374
- class CampaignDashboard extends BaseModel {
1375
- static get identifiersFields() {
1376
- return ['id'];
1377
- }
1378
- }
1379
-
1380
- class CampaignHashtag extends BaseModel {
1381
- static get identifiersFields() {
1382
- return ['id'];
1383
- }
1384
- }
1385
-
1386
- class LineItem extends Product {
1387
- }
1388
-
1389
- class ShippingMethod extends BaseModel {
1390
- static get identifiersFields() {
1391
- return ['id'];
1392
- }
1393
- }
1394
-
1395
- class Checkout extends BaseModel {
1396
- static get identifiersFields() {
1397
- return ['id'];
1398
- }
1399
- }
1400
- __decorate([
1401
- Type(() => LineItem),
1402
- __metadata("design:type", Array)
1403
- ], Checkout.prototype, "lineItems", void 0);
1404
- __decorate([
1405
- Type(() => User),
1406
- __metadata("design:type", User)
1407
- ], Checkout.prototype, "user", void 0);
1408
- __decorate([
1409
- Type(() => UserAddress),
1410
- __metadata("design:type", UserAddress)
1411
- ], Checkout.prototype, "shippingAddress", void 0);
1412
- __decorate([
1413
- Type(() => UserAddress),
1414
- __metadata("design:type", UserAddress)
1415
- ], Checkout.prototype, "billingAddress", void 0);
1416
- __decorate([
1417
- Type(() => ShippingMethod),
1418
- __metadata("design:type", ShippingMethod)
1419
- ], Checkout.prototype, "shipping", void 0);
1420
- __decorate([
1421
- Type(() => Coupon),
1422
- __metadata("design:type", Coupon)
1423
- ], Checkout.prototype, "coupon", void 0);
1424
-
1425
- var OrderStatus;
1426
- (function (OrderStatus) {
1427
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
1428
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
1429
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
1430
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
1431
- OrderStatus["ENVIADO"] = "Enviado";
1432
- OrderStatus["ENTREGUE"] = "Entregue";
1433
- OrderStatus["CANCELADO"] = "Cancelado";
1434
- OrderStatus["CREDIT_CARD"] = "credit_card";
1435
- })(OrderStatus || (OrderStatus = {}));
1436
-
1437
- class Order extends Checkout {
1438
- }
1439
- __decorate([
1440
- Type(() => Payment),
1441
- __metadata("design:type", Payment)
1442
- ], Order.prototype, "payment", void 0);
1443
-
1444
- class CheckoutSubscription extends BaseModel {
1445
- static get identifiersFields() {
1446
- return ['id'];
1447
- }
1448
- }
1449
- __decorate([
1450
- Type(() => UserAddress),
1451
- __metadata("design:type", UserAddress)
1452
- ], CheckoutSubscription.prototype, "shippingAddress", void 0);
1453
- __decorate([
1454
- Type(() => UserAddress),
1455
- __metadata("design:type", UserAddress)
1456
- ], CheckoutSubscription.prototype, "billingAddress", void 0);
1457
- __decorate([
1458
- Type(() => SubscriptionPlan),
1459
- __metadata("design:type", SubscriptionPlan)
1460
- ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
1461
- __decorate([
1462
- Type(() => Coupon),
1463
- __metadata("design:type", Coupon)
1464
- ], CheckoutSubscription.prototype, "coupon", void 0);
1465
-
1466
- class RoundProductPricesHelper {
1467
- static roundProductPrices(product) {
1468
- product.price.price = Number(product.price.price.toFixed(2));
1469
- product.price.fullPrice = Number(product.price.fullPrice.toFixed(2));
1470
- if (product.price.subscriberPrice) {
1471
- product.price.subscriberPrice = Number(product.price.subscriberPrice.toFixed(2));
1472
- }
1473
- if (product instanceof LineItem && product.pricePaid) {
1474
- product.pricePaid = Number(product.pricePaid.toFixed(2));
1475
- }
1476
- return product;
1477
- }
1478
- }
1479
-
1480
- var FilterType;
1481
- (function (FilterType) {
1482
- FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
1483
- FilterType["BEARD_PROBLEMS"] = "beardProblems";
1484
- FilterType["BEARD_SIZE"] = "beardSize";
1485
- FilterType["BEAUTY_PRODUCT_IMPORTANCE"] = "beautyProductImportance";
1486
- FilterType["BODY_PROBLEMS"] = "bodyProblems";
1487
- FilterType["BODY_SHAPE"] = "bodyShape";
1488
- FilterType["BODY_TATTOOS"] = "bodyTattoos";
1489
- FilterType["FACE_SKIN_OILINESS"] = "faceSkinOiliness";
1490
- FilterType["FACE_SKIN_PROBLEMS"] = "faceSkinProblems";
1491
- FilterType["FACE_SKIN_TONE"] = "faceSkinTone";
1492
- FilterType["FAMILY_INCOME"] = "familyIncome";
1493
- FilterType["FRAGRANCE_IMPORTANCE"] = "fragranceImportance";
1494
- FilterType["HAIR_COLOR"] = "hairColor";
1495
- FilterType["HAIR_PROBLEMS"] = "hairProblems";
1496
- FilterType["HAIR_STRANDS"] = "hairStrands";
1497
- FilterType["HAIR_TYPE"] = "hairType";
1498
- FilterType["PRODUCT_SPENT"] = "productSpent";
1499
- })(FilterType || (FilterType = {}));
1500
-
1501
- var QuestionsFilters;
1502
- (function (QuestionsFilters) {
1503
- QuestionsFilters["ACCESSORY_IMPORTANCE"] = "Voc\u00EA gosta de usar acess\u00F3rios masculinos?";
1504
- QuestionsFilters["BEARD_PROBLEMS"] = "Quais problemas de barba voc\u00EA tem?";
1505
- QuestionsFilters["BEARD_SIZE"] = "Quais caracteristicas se aplicam \u00E0 sua BARBA/BIGODE?";
1506
- QuestionsFilters["BEAUTY_PRODUCT_IMPORTANCE"] = "O que descreve melhor a sua rela\u00E7\u00E3o com produtos de beleza e cuidados pessoais?";
1507
- QuestionsFilters["BODY_PROBLEMS"] = "Qual ou quais preocupa\u00E7\u00F5es voc\u00EA tem com a pele do seu corpo?";
1508
- QuestionsFilters["BODY_SHAPE"] = "Qual e seu tipo de CORPO?";
1509
- QuestionsFilters["BODY_TATTOOS"] = "Voc\u00EA tem alguma tatuagem?";
1510
- QuestionsFilters["FACE_SKIN_OILINESS"] = "Quais caracteristicas se aplicam \u00E0 pele do seu ROSTO?";
1511
- QuestionsFilters["FACE_SKIN_PROBLEMS"] = "Quais problemas a pele do seu rosto tem?";
1512
- QuestionsFilters["FACE_SKIN_TONE"] = "Qual seu tom de pele?";
1513
- QuestionsFilters["FAMILY_INCOME"] = "Qual a sua renda familiar mensal (considerando a renda de todas as pessoas que moram com voc\u00EA)?";
1514
- QuestionsFilters["FRAGRANCE_IMPORTANCE"] = "O quanto voc\u00EA gosta de experimentar perfumes?";
1515
- QuestionsFilters["HAIR_COLOR"] = "Seu cabelo \u00E9 naturalmente de qual COR?";
1516
- QuestionsFilters["HAIR_PROBLEMS"] = "Qual ou quais problemas/caracter\u00EDstica de cabelo te preocupam?";
1517
- QuestionsFilters["HAIR_STRANDS"] = "Como s\u00E3o seus fios?";
1518
- QuestionsFilters["HAIR_TYPE"] = "Como \u00E9 o seu cabelo?";
1519
- QuestionsFilters["PRODUCT_SPENT"] = "Qual \u00E9 o seu nivel de gasto mensal em produtos de beleza e cuidados pessoais?";
1520
- })(QuestionsFilters || (QuestionsFilters = {}));
1521
-
1522
- class BeautyQuestionsHelper {
1523
- static getAnswers(filter) {
1524
- switch (filter) {
1525
- case FilterType.ACCESSORY_IMPORTANCE:
1526
- return AccessoryImportances;
1527
- case FilterType.BEARD_PROBLEMS:
1528
- return BeardProblems;
1529
- case FilterType.BEARD_SIZE:
1530
- return BeardSizes;
1531
- case FilterType.BEAUTY_PRODUCT_IMPORTANCE:
1532
- return BeautyProductImportances;
1533
- case FilterType.BODY_PROBLEMS:
1534
- return BodyProblems;
1535
- case FilterType.BODY_SHAPE:
1536
- return BodyShapes;
1537
- case FilterType.BODY_TATTOOS:
1538
- return BodyTattoos;
1539
- case FilterType.FACE_SKIN_OILINESS:
1540
- return FaceSkinOilinesses;
1541
- case FilterType.FACE_SKIN_PROBLEMS:
1542
- return FaceSkinProblems;
1543
- case FilterType.FACE_SKIN_TONE:
1544
- return FaceSkinTones;
1545
- case FilterType.FAMILY_INCOME:
1546
- return FamilyIncomes;
1547
- case FilterType.FRAGRANCE_IMPORTANCE:
1548
- return FragranceImportances;
1549
- case FilterType.HAIR_COLOR:
1550
- return HairColors;
1551
- case FilterType.HAIR_PROBLEMS:
1552
- return HairProblems;
1553
- case FilterType.HAIR_STRANDS:
1554
- return HairStrands;
1555
- case FilterType.HAIR_TYPE:
1556
- return HairTypes;
1557
- case FilterType.PRODUCT_SPENT:
1558
- return ProductSpents;
1559
- }
1560
- }
1561
- static getQuestions(filter) {
1562
- const filterKey = Object.keys(FilterType)[Object.values(FilterType).indexOf(filter)];
1563
- return QuestionsFilters[filterKey];
1564
- }
1565
- }
1566
-
1567
- class Home extends BaseModel {
1568
- static get identifiersFields() {
1569
- return ['id'];
1570
- }
1571
- }
1572
-
1573
- class ShopMenu extends BaseModel {
1574
- static get identifiersFields() {
1575
- return ['id'];
1576
- }
1577
- }
1578
-
1579
- class ShopSettings extends BaseModel {
1580
- static get identifiersFields() {
1581
- return ['id'];
1582
- }
1583
- }
1584
-
1585
- class InvalidArgumentError extends CustomError {
1586
- constructor(message) {
1587
- super(message);
1588
- }
1589
- }
1590
-
1591
- class RequiredArgumentError extends CustomError {
1592
- constructor(args) {
1593
- super(`Required arguments: ${args.join(', ')}`);
1594
- this.args = args;
1595
- this.arguments = args;
1596
- }
1597
- }
1598
-
1599
- class NotFoundError extends CustomError {
1600
- constructor(message) {
1601
- super(message);
1602
- }
1603
- }
1604
-
1605
- class DuplicatedResultsError extends CustomError {
1606
- constructor(message) {
1607
- super(message);
1608
- }
1609
- }
1610
-
1611
- class AxiosAdapter {
1612
- constructor(config) {
1613
- this.config = config;
1614
- }
1615
- async get(index, id) {
1616
- try {
1617
- const { data } = await axios({
1618
- url: `${this.config.url}/${index}/_doc/${id}`,
1619
- method: 'GET',
1620
- responseType: 'json',
1621
- headers: {
1622
- 'Content-Type': 'application/json',
1623
- Authorization: `ApiKey ${this.config.credential}`,
1624
- },
1625
- });
1626
- return data._source;
1627
- }
1628
- catch (error) {
1629
- if (!(error instanceof Error))
1630
- throw error;
1631
- throw new NotFoundError(error.message);
1632
- }
1633
- }
1634
- async query(index, query) {
1635
- const { data } = await axios({
1636
- url: `${this.config.url}/${index}/_search`,
1637
- method: 'POST',
1638
- responseType: 'json',
1639
- headers: {
1640
- Accept: 'application/vnd.elasticsearch+json;compatible-with=7',
1641
- 'Content-Type': 'application/vnd.elasticsearch+json;compatible-with=7',
1642
- Authorization: `ApiKey ${this.config.credential}`,
1643
- },
1644
- data: query,
1645
- });
1646
- return {
1647
- total: data.hits.total.value,
1648
- hits: data.hits.hits,
1649
- };
1650
- }
1651
- async save(index, data) {
1652
- await axios({
1653
- url: `${this.config.url}/${index}/_doc`,
1654
- method: 'POST',
1655
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1656
- data,
1657
- });
1658
- }
1659
- async update(index, id, data) {
1660
- await axios({
1661
- url: `${this.config.url}/${index}/_update/${id}`,
1662
- method: 'PUT',
1663
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1664
- data,
1665
- });
1666
- }
1667
- async delete(index, id) {
1668
- await axios({
1669
- url: `${this.config.url}/${index}/_doc/${id}`,
1670
- method: 'DELETE',
1671
- headers: { Authorization: `ApiKey ${this.config.credential}` },
1672
- });
1673
- }
1674
- }
1675
-
1676
- class ProductsIndex {
1677
- constructor(adapter) {
1678
- this.adapter = adapter;
1679
- this.index = `products`;
1680
- }
1681
- async getById(id) {
1682
- const data = await this.adapter.get(this.index, id);
1683
- return Product.toInstance(data);
1684
- }
1685
- async search(searchTerm, total, shop) {
1686
- const size = total || 9;
1687
- const fields = [
1688
- 'EAN',
1689
- 'brand',
1690
- 'id',
1691
- 'images',
1692
- 'miniatures',
1693
- 'name',
1694
- 'price',
1695
- 'sku',
1696
- 'stock',
1697
- 'slug',
1698
- 'reviews',
1699
- 'hasVariants',
1700
- 'rate',
1701
- ];
1702
- const filter = [{ term: { published: true } }];
1703
- if (size > 9) {
1704
- fields.push(...['pricePaid', 'isGift', 'stock', 'weight', 'tags']);
1705
- }
1706
- else {
1707
- filter.push({ term: { tags: shop == Shops.GLAMSHOP ? 'feminino' : 'masculino' } });
1708
- }
1709
- const search = await this.adapter.query(this.index, {
1710
- size,
1711
- _source: fields,
1712
- query: {
1713
- bool: {
1714
- must: {
1715
- multi_match: {
1716
- query: `${searchTerm}`,
1717
- type: 'bool_prefix',
1718
- fields: [
1719
- 'name',
1720
- 'name.folded',
1721
- 'name.search',
1722
- 'description',
1723
- 'description.search',
1724
- 'description.folded',
1725
- 'brand',
1726
- 'brand.search',
1727
- 'brand.folded',
1728
- ],
1729
- fuzziness: 2,
1730
- },
1731
- },
1732
- should: {
1733
- match_phrase_prefix: {
1734
- 'name.search': {
1735
- query: `${searchTerm}`,
1736
- slop: 10,
1737
- },
1738
- },
1739
- },
1740
- filter,
1741
- },
1742
- },
1743
- });
1744
- search.hits = search.hits
1745
- .filter((e) => e._source.name !== '')
1746
- .map((hit) => {
1747
- RoundProductPricesHelper.roundProductPrices(hit._source);
1748
- return hit;
1749
- });
1750
- return search;
1751
- }
1752
- async save(product) {
1753
- try {
1754
- const { createdAt, updatedAt, kitProducts, ...data } = product;
1755
- this.adapter.save(this.index, data);
1756
- }
1757
- catch (error) {
1758
- console.error(error);
1759
- }
1760
- }
1761
- async update(product) {
1762
- try {
1763
- await this.adapter.update(this.index, product.id, product);
1764
- }
1765
- catch (error) {
1766
- console.error(error);
1767
- }
1768
- }
1769
- async delete(id) {
1770
- try {
1771
- await this.adapter.delete(this.index, id);
1772
- }
1773
- catch (error) {
1774
- console.error(error);
1775
- }
1776
- }
1777
- }
1778
-
1779
- const withFirestore = (MixinBase) => {
1780
- const isObjectsAndNoDate = (data) => data &&
1781
- !Array.isArray(data) &&
1782
- typeof data === 'object' &&
1783
- data?.constructor.name !== 'Timestamp' &&
1784
- !('seconds' in data);
1785
- const bindDate = (data, keyName) => {
1786
- if (data?.constructor.name === 'Timestamp')
1787
- return data.toDate();
1788
- if (data && typeof data === 'object' && 'seconds' in data)
1789
- return new Date(data.seconds * 1000);
1790
- if (typeof data === 'number' && ['createdAt', 'updatedAt'].includes(keyName))
1791
- return new Date(data);
1792
- return data;
1793
- };
1794
- const bindAllDateFromObject = (data) => {
1795
- return Object.keys(data).reduce((object, key) => ({
1796
- ...object,
1797
- [key]: isObjectsAndNoDate(data[key])
1798
- ? bindAllDateFromObject(data[key])
1799
- : Array.isArray(data[key])
1800
- ? data[key].map((element) => (isObjectsAndNoDate(element) ? bindAllDateFromObject(element) : element))
1801
- : bindDate(data[key], key),
1802
- }), {});
1803
- };
1804
- const omitByRecursivelyInPlace = (value, iteratee) => {
1805
- each(value, (v, k) => {
1806
- if (iteratee(v, k)) {
1807
- unset(value, k);
1808
- }
1809
- else if (isObject(v)) {
1810
- omitByRecursivelyInPlace(v, iteratee);
1811
- }
1812
- });
1813
- return value;
1814
- };
1815
- return class extends MixinBase {
1816
- constructor(...params) {
1817
- super(...params);
1818
- this.fields = {};
1819
- this.interceptors = {};
1820
- this.collectionName = '';
1821
- const options = params[0];
1822
- this.firestore = options.firestore;
1823
- this.collectionName = options.collectionName;
1824
- this.model = options.model;
1825
- this.fields = options.fields;
1826
- this.interceptors = options.interceptors;
1827
- }
1828
- collection(path) {
1829
- return collection(this.firestore, path || this.collectionName).withConverter(this.buildModelInstance());
1830
- }
1831
- buildModelInstance() {
1832
- return {
1833
- toFirestore: (data) => {
1834
- const plain = data?.toPlain ? data.toPlain() : data;
1835
- return omitByRecursivelyInPlace(plain, (value) => value === undefined);
1836
- },
1837
- fromFirestore: (snap) => {
1838
- const data = snap.data();
1839
- let bindedData = null;
1840
- try {
1841
- const ids = { id: snap.id };
1842
- bindedData = bindAllDateFromObject(data);
1843
- return this.model.toInstance({ ...bindedData, ...ids });
1844
- }
1845
- catch (error) {
1846
- console.info('id', snap.id);
1847
- console.info('data', JSON.stringify(bindedData));
1848
- console.error(error);
1849
- throw error;
1850
- }
1851
- },
1852
- };
1853
- }
1854
- };
1855
- };
1856
-
1857
- const withHelpers = (MixinBase) => {
1858
- return class extends MixinBase {
1859
- toArray(snapShot) {
1860
- if (Array.isArray(snapShot)) {
1861
- return snapShot.map((doc) => doc.data());
1862
- }
1863
- else {
1864
- return snapShot.docs.map((doc) => doc.data());
1865
- }
1866
- }
1867
- isSubCollection(repository) {
1868
- return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
1869
- }
1870
- };
1871
- };
1872
-
1873
- const withGetFirestore = (MixinBase) => {
1874
- return class GetFirestore extends MixinBase {
1875
- async get(identifiers) {
1876
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
1877
- const intercepted = await this.interceptors?.request?.({ instance });
1878
- const builded = intercepted?.instance || instance;
1879
- const docRef = await getDoc(doc(await this.collection(this.buildCollectionPathForGet(identifiers)), Object.values(builded.identifier).shift().toString()));
1880
- const data = docRef.data();
1881
- if (isNil(data))
1882
- throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1883
- return this.interceptors?.response?.(data, intercepted) || data;
1884
- }
1885
- buildCollectionPathForGet(identifiers) {
1886
- return this.isSubCollection(this)
1887
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
1888
- : this.collectionName;
1889
- }
1890
- };
1891
- };
1892
-
1893
- var FirestoreFieldType;
1894
- (function (FirestoreFieldType) {
1895
- FirestoreFieldType["String"] = "string";
1896
- FirestoreFieldType["Number"] = "number";
1897
- FirestoreFieldType["Boolean"] = "boolean";
1898
- FirestoreFieldType["Timestamp"] = "timestamp";
1899
- FirestoreFieldType["Array"] = "array";
1900
- FirestoreFieldType["Map"] = "map";
1901
- })(FirestoreFieldType || (FirestoreFieldType = {}));
1902
-
1903
- const withFindFirestore = (MixinBase) => {
1904
- const checkIfIsFilterOption = (filter) => !isNil(filter?.operator);
1905
- const getValueFromFilter = (filter) => {
1906
- return checkIfIsFilterOption(filter) ? filter.value : filter;
1907
- };
1908
- const getFinalValueFrom = (value) => isNumber(value) || isString(value) || isDate(value) || Array.isArray(value)
1909
- ? value
1910
- : Object.values(getFinalValueFrom);
1911
- return class FindFirestore extends MixinBase {
1912
- constructor() {
1913
- super(...arguments);
1914
- this.makeFirestoreWhere = (filter) => Object.keys(filter).reduce((queries, fieldName) => [
1915
- ...queries,
1916
- ...this.buildWhereSentence(fieldName, is(filter[fieldName])),
1917
- ], []);
1918
- this.buildWhereSentence = (fieldName, options) => {
1919
- if (this.isSubCollection(this) && fieldName === this.parentIdField)
1920
- return [];
1921
- const value = options?.value || options;
1922
- const object = {};
1923
- set(object, fieldName, value);
1924
- const plainInstance = new this.model(object).toPlain();
1925
- const firestoreFieldName = fieldName.toString().indexOf('.') > -1
1926
- ? fieldName.toString()
1927
- : Object.keys(plainInstance).find((key) => plainInstance[key]);
1928
- if (options?.operator === Where.LIKE) {
1929
- if (Array.isArray(options?.value) &&
1930
- (this.fields[firestoreFieldName] ===
1931
- FirestoreFieldType.Array ||
1932
- !this.fields[firestoreFieldName]))
1933
- return [where(firestoreFieldName, 'array-contains-any', options.value)];
1934
- return [where(firestoreFieldName, '>=', options.value), where(firestoreFieldName, '<=', `${options.value}~`)];
1935
- }
1936
- if (options?.operator === Where.IN &&
1937
- Array.isArray(options?.value) &&
1938
- (this.fields[firestoreFieldName] === FirestoreFieldType.Array ||
1939
- !this.fields[firestoreFieldName]))
1940
- return [where(firestoreFieldName, 'array-contains', options.value)];
1941
- if (isObject(options) && isNil(options?.operator) && isNil(options?.value)) {
1942
- return Object.keys(options).reduce((queries, key) => [
1943
- ...queries,
1944
- ...this.buildWhereSentence(`${fieldName.toString()}.${key}`, is(options)[key]),
1945
- ], []);
1946
- }
1947
- return [where(firestoreFieldName, options?.operator || '==', options?.value || options)];
1948
- };
1949
- this.makeFirestoreOrderBy = (filters, fieldsToOrderBy) => {
1950
- const orderByKeys = Object.keys(fieldsToOrderBy || {});
1951
- if (!orderByKeys.length)
1952
- return [];
1953
- const filtersKeysWithUnordered = Object.keys(filters || {}).filter((filterKey) => !orderByKeys.includes(filterKey));
1954
- if (filtersKeysWithUnordered.length)
1955
- filtersKeysWithUnordered.forEach((filterKey) => (fieldsToOrderBy = {
1956
- ...(![Where.EQUALS].includes(is(filters[filterKey]).operator)
1957
- ? { [filterKey]: 'asc' }
1958
- : {}),
1959
- ...fieldsToOrderBy,
1960
- }));
1961
- return Object.keys(fieldsToOrderBy).map((fieldName) => orderBy(fieldName, fieldsToOrderBy[fieldName]));
1962
- };
1963
- }
1964
- async find(find = {}) {
1965
- const collection = this.collection(this.buildCollectionPathForFind(find.filters));
1966
- const enableCount = find?.options?.enableCount ?? true;
1967
- const intercepted = await this.interceptors?.request?.({ find });
1968
- const { filters, limits, orderBy } = intercepted.find || find;
1969
- const queries = this.makeFirestoreWhere(filters || {});
1970
- const ordination = this.makeFirestoreOrderBy(filters, orderBy);
1971
- const offsets = await this.defineLimits(filters, limits);
1972
- const queryArgumments = [...queries, ...ordination, ...offsets];
1973
- const docs = await getDocs(query(collection, ...queryArgumments));
1974
- const data = docs.docs.map((doc) => doc.data());
1975
- return {
1976
- data: (await this.interceptors?.response?.(data, intercepted)) || data,
1977
- count: enableCount ? this.calculateCount(data, limits) : Infinity,
1978
- };
1979
- }
1980
- buildCollectionPathForFind(filters) {
1981
- if (!this.isSubCollection(this))
1982
- return this.collectionName;
1983
- const parentIdField = this.parentIdField;
1984
- const parentId = getValueFromFilter(filters?.[parentIdField]);
1985
- return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
1986
- }
1987
- async defineLimits(filters, limits) {
1988
- const queries = [];
1989
- if (limits?.offset) {
1990
- if (this.model.isModel(limits.offset))
1991
- queries.push(startAfter(await getDoc(doc(this.collection(this.buildCollectionPathForFind(filters)), Object.values(limits.offset.identifier).shift()?.toString()))));
1992
- else if (isNumber(limits.offset) || isString(limits.offset))
1993
- queries.push(startAt(limits.offset));
1994
- }
1995
- if (limits?.limit)
1996
- queries.push(limit(limits.limit));
1997
- return queries;
1998
- }
1999
- calculateCount(data, limits) {
2000
- if (data.length <= 0)
2001
- return 0;
2002
- if (data.length < limits?.limit)
2003
- return data.length;
2004
- return Infinity;
2005
- }
2006
- };
2007
- };
2008
-
2009
- const withCreateFirestore = (MixinBase) => {
2010
- return class CreateFirestore extends MixinBase {
2011
- async create(data) {
2012
- const instance = this.model.toInstance(data);
2013
- const intercepted = await this.interceptors?.request?.({ instance });
2014
- const builded = intercepted?.instance || instance;
2015
- const docRef = await this.save(builded);
2016
- const doc = await getDoc(docRef);
2017
- const docBuilded = (await this.interceptors?.response?.(doc.data(), intercepted)) || doc.data();
2018
- return docBuilded;
2019
- }
2020
- async save(data) {
2021
- const id = Object.values(data.identifier)?.shift()?.toString();
2022
- const collectionPath = this.buildCollectionPathForAdd(data);
2023
- const collection = this.collection(collectionPath);
2024
- if (isEmpty(id))
2025
- return addDoc(collection, data);
2026
- const docRef = doc(collection, id);
2027
- await setDoc(docRef, data);
2028
- return docRef;
2029
- }
2030
- buildCollectionPathForAdd(identifiers) {
2031
- return this.isSubCollection(this)
2032
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
2033
- : this.collectionName;
2034
- }
2035
- };
2036
- };
2037
-
2038
- const withUpdateFirestore = (MixinBase) => {
2039
- const getValueFromParams = (params, field) => (isNil(is(params[field])?.value)
2040
- ? is(params[field])
2041
- : is(params[field]).value) || null;
2042
- const getValueByAction = (options) => {
2043
- if (isNil(options?.action))
2044
- return options;
2045
- if (options?.action === UpdateOptionActions.REMOVE_FIELD)
2046
- return deleteField();
2047
- if (options?.action === UpdateOptionActions.NULL)
2048
- return null;
2049
- if (Array.isArray(options?.value)) {
2050
- if (options?.action === UpdateOptionActions.MERGE)
2051
- return arrayUnion(...options.value);
2052
- if (options?.action === UpdateOptionActions.REMOVE)
2053
- return arrayRemove(...options.value);
2054
- }
2055
- return options?.value;
2056
- };
2057
- return class UpdateFirestore extends MixinBase {
2058
- async update(data) {
2059
- const model = new this.model();
2060
- const keyField = model.identifiersFields.shift();
2061
- const docRef = doc(this.collection(this.buildCollectionPathForUpdate(data)), getValueFromParams(data, keyField).toString());
2062
- const plainFromData = this.model.toInstance(this.paramsToPlain(data));
2063
- const intercepted = await this.interceptors?.request?.({ instance: plainFromData });
2064
- const builded = intercepted?.instance || plainFromData;
2065
- await setDoc(docRef, builded.toPlain(), { merge: true });
2066
- const docData = await getDoc(docRef).then((doc) => doc.data());
2067
- return this.interceptors?.response?.(docData, intercepted) || docData;
2068
- }
2069
- buildCollectionPathForUpdate(identifiers) {
2070
- return this.isSubCollection(this)
2071
- ? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
2072
- : this.collectionName;
2073
- }
2074
- paramsToPlain(params) {
2075
- const model = this.model;
2076
- if (model.isModel(params))
2077
- return params.toPlain();
2078
- return Object.keys(params).reduce((data, currentKey) => ({
2079
- ...data,
2080
- ...((value) => (value === undefined ? {} : { [currentKey]: value }))(getValueByAction(params[currentKey])),
2081
- }), {});
2082
- }
2083
- };
2084
- };
2085
-
2086
- const withDeleteFirestore = (MixinBase) => {
2087
- return class DeleteFirestore extends MixinBase {
2088
- async delete(identifiers) {
2089
- const instance = this.model.toInstance(this.model.identifiersFields.reduce((acc, field) => ({ ...acc, [field]: identifiers[field] }), {}));
2090
- const intercepted = await this.interceptors?.request?.({ instance });
2091
- const builded = intercepted?.instance || instance;
2092
- await deleteDoc(doc(this.collection(this.buildCollectionPathForRemove(identifiers)), Object.values(builded.identifier).shift().toString()));
2093
- await this.interceptors?.response?.(instance, intercepted);
2094
- }
2095
- buildCollectionPathForRemove(identifiers) {
2096
- return this.isSubCollection(this)
2097
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
2098
- : this.collectionName;
2099
- }
2100
- };
2101
- };
2102
-
2103
- const withSubCollection = (MixinBase, ParentModel) => {
2104
- return class SubCollectionMix extends MixinBase {
2105
- constructor(...params) {
2106
- const options = params[0];
2107
- super(...params);
2108
- this.parentIdField = options.parentIdField;
2109
- }
2110
- collection(path) {
2111
- return super.collection(path);
2112
- }
2113
- };
2114
- };
2115
-
2116
- const withCrudFirestore = (MixinBase) => {
2117
- return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
2118
- };
2119
- };
2120
-
2121
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2122
- constructor({ firestore, interceptors }) {
2123
- super({
2124
- firestore,
2125
- collectionName: 'leads',
2126
- model: Lead,
2127
- interceptors,
2128
- });
2129
- }
2130
- }
2131
-
2132
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
2133
- constructor({ firestore, interceptors }, parentRepository) {
2134
- super({
2135
- firestore,
2136
- collectionName: 'editions',
2137
- parentIdField: 'subscriptionId',
2138
- model: Edition,
2139
- interceptors,
2140
- });
2141
- this.parentRepository = parentRepository;
2142
- }
2143
- }
2144
-
2145
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2146
- constructor({ firestore, interceptors, }) {
2147
- super({
2148
- firestore,
2149
- collectionName: 'subscription',
2150
- model: Subscription,
2151
- interceptors,
2152
- });
2153
- }
2154
- }
2155
-
2156
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
2157
- constructor({ firestore, interceptors }, parentRepository) {
2158
- super({
2159
- firestore,
2160
- collectionName: 'payments',
2161
- parentIdField: 'subscriptionId',
2162
- model: SubscriptionPayment,
2163
- interceptors,
2164
- });
2165
- this.parentRepository = parentRepository;
2166
- }
2167
- }
2168
-
2169
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
2170
- constructor({ firestore, interceptors }, parentRepository) {
2171
- super({
2172
- firestore,
2173
- collectionName: 'address',
2174
- parentIdField: 'userId',
2175
- model: UserAddress,
2176
- interceptors,
2177
- });
2178
- this.parentRepository = parentRepository;
2179
- }
2180
- }
2181
-
2182
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
2183
- constructor({ firestore, interceptors }, parentRepository) {
2184
- super({
2185
- firestore,
2186
- collectionName: 'CX',
2187
- parentIdField: 'userId',
2188
- model: BeautyProfile,
2189
- interceptors,
2190
- });
2191
- this.parentRepository = parentRepository;
2192
- }
2193
- }
2194
-
2195
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2196
- constructor({ firestore, interceptors }) {
2197
- super({
2198
- firestore,
2199
- collectionName: 'users',
2200
- model: User,
2201
- interceptors,
2202
- });
2203
- }
2204
- async get(identifiers) {
2205
- const user = await super.get({ id: identifiers.id });
2206
- user.beautyProfile = await this.getBeautyProfile(user.id);
2207
- user.isSubscriber = await this.checkIfIsSubscriber(user.id);
2208
- return user;
2209
- }
2210
- async checkIfExistsByField(field, value) {
2211
- const result = await this.find({ filters: { [field]: value } });
2212
- return result.count > 0;
2213
- }
2214
- buildModelInstance() {
2215
- const { fromFirestore, toFirestore } = super.buildModelInstance();
2216
- return {
2217
- toFirestore: (data) => {
2218
- const plain = toFirestore(data);
2219
- delete plain.isSubscriber;
2220
- return plain;
2221
- },
2222
- fromFirestore,
2223
- };
2224
- }
2225
- async getBeautyProfile(userId) {
2226
- const beautyProfile = await getDoc(doc(this.collection(`${this.collectionName}/${userId}/CX`).withConverter(this.buildBeautyProfileModelInstance()), 'beautyProfile'));
2227
- return beautyProfile.data();
2228
- }
2229
- async checkIfIsSubscriber(userId) {
2230
- const docs = await getDocs(query(this.collection('subscription'), where('user.id', '==', userId), where('status', '==', 'active')));
2231
- return !!docs && !!docs.size;
2232
- }
2233
- buildBeautyProfileModelInstance() {
2234
- return {
2235
- toFirestore: (data) => data.toPlain(),
2236
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
2237
- };
2238
- }
2239
- }
2240
-
2241
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
2242
- constructor({ firestore, interceptors }, parentRepository) {
2243
- super({
2244
- firestore,
2245
- collectionName: 'payment_method',
2246
- parentIdField: 'userId',
2247
- model: UserPaymentMethod,
2248
- interceptors,
2249
- });
2250
- this.parentRepository = parentRepository;
2251
- }
2252
- }
2253
-
2254
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2255
- constructor({ firestore, interceptors }) {
2256
- super({
2257
- firestore,
2258
- collectionName: 'categories',
2259
- model: Category,
2260
- interceptors,
2261
- });
2262
- }
2263
- async getCategoryBySlug(slug, shop) {
2264
- const categoryDocs = await getDocs(query(this.collection(this.collectionName), where('slug', '==', slug), where('shop', '==', shop), where('published', '==', true)));
2265
- if (categoryDocs.size > 1)
2266
- throw new DuplicatedResultsError('Query returned duplicated values');
2267
- if (categoryDocs.empty)
2268
- throw new NotFoundError(`Document with slug ${slug} not found`);
2269
- return categoryDocs.docs[0].data();
2270
- }
2271
- async getCategoriesForHome(categoryIds, limit = 4, gender) {
2272
- const categorySnap = await getDocs(query(this.collection(this.collectionName), where('id', 'in', categoryIds.filter(Boolean)), where('published', '==', true)));
2273
- if (categorySnap.empty)
2274
- throw new NotFoundError('Categories not found');
2275
- const categories = categorySnap.docs.map((doc) => doc.data());
2276
- const homeSections = await Promise.all(categories.map(async (category) => ({
2277
- category,
2278
- products: await this.mountCategory(category, { limit, hasStock: true, gender }),
2279
- })));
2280
- return homeSections;
2281
- }
2282
- async mountCategory(category, options) {
2283
- if (!category.products)
2284
- throw new RequiredArgumentError(['Category products is empty']);
2285
- const chunks = chunk(category.products, 10);
2286
- const products = [];
2287
- const wheres = [];
2288
- for (const productIds of chunks) {
2289
- if (options?.limit && products.length >= options?.limit)
2290
- break;
2291
- wheres.push(where('published', '==', true), where('id', 'in', productIds));
2292
- if (options?.hasStock)
2293
- wheres.push(where('stock.quantity', '>', 0));
2294
- if (options?.gender)
2295
- wheres.push(where('tags', 'array-contains', options?.gender));
2296
- if (options?.limit)
2297
- wheres.push(limit(options?.limit));
2298
- const productSnap = await getDocs(query(this.collection('productsErpVitrine'), ...wheres));
2299
- if (productSnap.empty)
2300
- continue;
2301
- products.push(...productSnap.docs);
2302
- }
2303
- return is(products);
2304
- }
2305
- getCategoryByShop(shop) {
2306
- return;
2307
- }
2308
- getChildren(parentId) {
2309
- return;
2310
- }
2311
- isChild(id, parentId) {
2312
- return;
2313
- }
2314
- }
2315
-
2316
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2317
- constructor({ firestore, interceptors }) {
2318
- super({
2319
- firestore,
2320
- collectionName: 'productsErpVitrine',
2321
- model: Product,
2322
- interceptors,
2323
- });
2324
- this.reviews = {};
2325
- }
2326
- async getBySlug(slug) {
2327
- const result = await this.find({
2328
- filters: {
2329
- slug: { operator: Where.EQUALS, value: slug },
2330
- },
2331
- });
2332
- return result?.data?.shift();
2333
- }
2334
- async fetchReviews(status) {
2335
- const { data: products } = await this.find();
2336
- products.forEach((product) => {
2337
- if ([undefined, 0].includes(product.reviews?.length))
2338
- return;
2339
- const productInfo = {
2340
- productId: product.id,
2341
- productName: product.name,
2342
- productSku: product.sku,
2343
- };
2344
- this.reviews.pending = [];
2345
- this.reviews.approved = [];
2346
- this.reviews.rejected = [];
2347
- product.reviews.forEach((review) => {
2348
- if ([null, undefined].includes(review.status))
2349
- return this.reviews.pending.push({ ...review, ...productInfo });
2350
- if (review.status === false)
2351
- return this.reviews.rejected.push({ ...review, ...productInfo });
2352
- if (!!review.status)
2353
- return this.reviews.approved.push({ ...review, ...productInfo });
2354
- return review;
2355
- });
2356
- });
2357
- return this.reviews[status];
2358
- }
2359
- cleanShoppingCountFromIds() {
2360
- return;
2361
- }
2362
- findCatalog(params) {
2363
- return this.find(params);
2364
- }
2365
- }
2366
-
2367
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
2368
- constructor({ firestore, interceptors }, parentRepository) {
2369
- super({
2370
- firestore,
2371
- collectionName: 'variants',
2372
- parentIdField: 'productId',
2373
- model: Variant,
2374
- interceptors,
2375
- });
2376
- this.parentRepository = parentRepository;
2377
- }
2378
- }
2379
-
2380
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2381
- constructor({ firestore, interceptors }) {
2382
- super({
2383
- firestore,
2384
- collectionName: 'subscriptionProducts',
2385
- model: Product,
2386
- interceptors,
2387
- });
2388
- }
2389
- }
2390
-
2391
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2392
- constructor({ firestore, interceptors }) {
2393
- super({
2394
- firestore,
2395
- collectionName: 'buy2win',
2396
- model: Buy2Win,
2397
- interceptors,
2398
- });
2399
- }
2400
- }
2401
-
2402
- class CampaignDashboardFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2403
- constructor({ firestore, interceptors, }) {
2404
- super({
2405
- firestore,
2406
- collectionName: 'dashboardCampaignsAuto',
2407
- model: CampaignDashboard,
2408
- interceptors,
2409
- });
2410
- }
2411
- }
2412
-
2413
- class CampaignHashtagFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2414
- constructor({ firestore, interceptors, }) {
2415
- super({
2416
- firestore,
2417
- collectionName: 'hashtagCampaignsAuto',
2418
- model: CampaignHashtag,
2419
- interceptors,
2420
- });
2421
- }
2422
- }
2423
-
2424
- class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2425
- constructor({ firestore, interceptors }) {
2426
- super({
2427
- firestore,
2428
- collectionName: 'checkouts',
2429
- model: Checkout,
2430
- interceptors,
2431
- });
2432
- }
2433
- }
2434
-
2435
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2436
- constructor({ firestore, interceptors, }) {
2437
- super({
2438
- firestore,
2439
- collectionName: 'checkoutsSubscription',
2440
- model: CheckoutSubscription,
2441
- interceptors,
2442
- });
2443
- }
2444
- }
2445
-
2446
- class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2447
- constructor({ firestore, interceptors }) {
2448
- super({
2449
- firestore,
2450
- collectionName: 'coupons',
2451
- model: Coupon,
2452
- interceptors,
2453
- });
2454
- }
2455
- buildModelInstance() {
2456
- const { fromFirestore, toFirestore } = super.buildModelInstance();
2457
- return {
2458
- toFirestore: (data) => {
2459
- const plain = toFirestore(data);
2460
- if (!!data.expiresIn)
2461
- plain.expiresIn = data.expiresIn.getTime();
2462
- return plain;
2463
- },
2464
- fromFirestore: (snap) => {
2465
- const instance = fromFirestore(snap);
2466
- if (!isNil(instance.expiresIn))
2467
- instance.expiresIn = new Date(snap.data().expiresIn);
2468
- return instance;
2469
- },
2470
- };
2471
- }
2472
- }
2473
-
2474
- class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2475
- constructor({ firestore, interceptors }) {
2476
- super({
2477
- firestore,
2478
- collectionName: 'orders',
2479
- model: Order,
2480
- interceptors,
2481
- fields: {
2482
- status: FirestoreFieldType.String,
2483
- },
2484
- });
2485
- this.orderFromFirestore = (order) => {
2486
- if (!!order?.lineItems?.length) {
2487
- order.lineItems = order.lineItems.map((lineItem) => {
2488
- const prices = !!lineItem.price;
2489
- const shopPrice = prices[order.shop];
2490
- if (!!shopPrice)
2491
- lineItem.price = shopPrice;
2492
- return lineItem;
2493
- });
2494
- }
2495
- return order;
2496
- };
2497
- }
2498
- buildModelInstance() {
2499
- const { fromFirestore, toFirestore } = super.buildModelInstance();
2500
- return {
2501
- toFirestore: (data) => toFirestore(data?.toPlain ? data.toPlain() : data),
2502
- fromFirestore: (snap) => {
2503
- const instance = fromFirestore(snap);
2504
- return this.orderFromFirestore(instance);
2505
- },
2506
- };
2507
- }
2508
- }
2509
-
2510
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
2511
- constructor({ firestore, interceptors }) {
2512
- super({
2513
- firestore,
2514
- interceptors,
2515
- });
2516
- this.collectionName = 'legacyOrders';
2517
- }
2518
- }
2519
-
2520
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2521
- constructor({ firestore, interceptors }) {
2522
- super({
2523
- firestore,
2524
- collectionName: 'payments',
2525
- model: Payment,
2526
- interceptors,
2527
- });
2528
- }
2529
- }
2530
-
2531
- class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2532
- constructor({ firestore, interceptors, }) {
2533
- super({
2534
- firestore,
2535
- collectionName: 'subscriptionPlans',
2536
- model: SubscriptionPlan,
2537
- interceptors,
2538
- });
2539
- }
2540
- }
2541
-
2542
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2543
- constructor({ firestore, interceptors }) {
2544
- super({
2545
- firestore,
2546
- collectionName: 'dms',
2547
- model: Home,
2548
- interceptors,
2549
- });
2550
- this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
2551
- category: homeCategoryGroup?.category?.toPlain
2552
- ? homeCategoryGroup?.category?.toPlain()
2553
- : homeCategoryGroup?.category,
2554
- products: homeCategoryGroup?.products
2555
- ?.map((product) => (product?.toPlain ? product?.toPlain() : product))
2556
- .filter(Boolean) || [],
2557
- });
2558
- this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
2559
- category: Category.toInstance(homeCategoryGroup?.category),
2560
- products: homeCategoryGroup.products?.map((product) => Product.toInstance(product)),
2561
- });
2562
- }
2563
- buildModelInstance() {
2564
- const { fromFirestore, toFirestore } = super.buildModelInstance();
2565
- return {
2566
- toFirestore: (data) => {
2567
- const modifiedData = this.homeToFirestore(data);
2568
- return toFirestore(modifiedData);
2569
- },
2570
- fromFirestore: (snap) => {
2571
- const instance = fromFirestore(snap);
2572
- return this.homeFromFirestore(instance);
2573
- },
2574
- };
2575
- }
2576
- homeToFirestore(home) {
2577
- if (home.data?.data) {
2578
- home.data.data.discoverProducts = home.data.data.discoverProducts?.map(this.homeCategoryGroupToPlain) || [];
2579
- home.data.data.featuredProducts = home.data.data.featuredProducts?.map(this.homeCategoryGroupToPlain) || [];
2580
- home.data.data.verticalProducts = home.data.data.verticalProducts?.map(this.homeCategoryGroupToPlain) || [];
2581
- }
2582
- return home;
2583
- }
2584
- homeFromFirestore(home) {
2585
- if (home.data?.data) {
2586
- home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
2587
- home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
2588
- home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
2589
- home.data.createdAt =
2590
- home.data.createdAt instanceof Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
2591
- home.data.expiresAt =
2592
- home.data.expiresAt instanceof Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
2593
- }
2594
- return home;
2595
- }
2596
- }
2597
-
2598
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2599
- constructor({ firestore, interceptors }) {
2600
- super({
2601
- firestore,
2602
- collectionName: 'shopMenus',
2603
- model: ShopMenu,
2604
- interceptors,
2605
- });
2606
- }
2607
- }
2608
-
2609
- class ShopSettingsFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
2610
- constructor({ firestore, interceptors, }) {
2611
- super({
2612
- firestore,
2613
- collectionName: 'shopSettings',
2614
- model: ShopSettings,
2615
- interceptors,
2616
- });
2617
- }
2618
- }
2619
-
2620
- class AuthenticationFirebaseAuthService {
2621
- constructor(firebaseAuth) {
2622
- this.firebaseAuth = firebaseAuth;
2623
- }
2624
- async signInWithEmailAndPassword(data) {
2625
- const credentials = await signInWithEmailAndPassword(this.firebaseAuth, data.email, data.password);
2626
- const user = credentials.user;
2627
- return {
2628
- id: user.uid,
2629
- displayName: user.displayName,
2630
- email: user.email,
2631
- phone: user.phoneNumber,
2632
- isAnonymous: false,
2633
- };
2634
- }
2635
- async signInWithGoogle() {
2636
- const credentials = await signInWithPopup(this.firebaseAuth, new GoogleAuthProvider());
2637
- const user = credentials.user;
2638
- return {
2639
- id: user.uid,
2640
- displayName: user.displayName,
2641
- email: user.email,
2642
- phone: user.phoneNumber,
2643
- isAnonymous: false,
2644
- };
2645
- }
2646
- async signOut() {
2647
- this.firebaseAuth.signOut();
2648
- }
2649
- async signInAnonymously() {
2650
- const auth = await signInAnonymously(this.firebaseAuth);
2651
- const user = auth.user;
2652
- user.id = auth.user.uid;
2653
- return user;
2654
- }
2655
- async sendPasswordResetEmail(email) {
2656
- return sendPasswordResetEmail(this.firebaseAuth, email);
2657
- }
2658
- }
2659
-
2660
- class RegisterFirebaseAuthService {
2661
- constructor(firebaseAuth) {
2662
- this.firebaseAuth = firebaseAuth;
2663
- }
2664
- async register(params) {
2665
- if (!params.email)
2666
- throw new RequiredArgumentError(['email']);
2667
- try {
2668
- const auth = await createUserWithEmailAndPassword(this.firebaseAuth, params.email, params.password);
2669
- const user = is(auth.user);
2670
- if (!user)
2671
- throw new Error('User not created');
2672
- await sendEmailVerification(user);
2673
- user.id = user.uid;
2674
- return user;
2675
- }
2676
- catch (error) {
2677
- if (!(error instanceof Error))
2678
- throw error;
2679
- const firebaseError = error;
2680
- if (firebaseError.code === 'auth/email-already-in-use')
2681
- throw new UserAlreadyRegisteredError('Email already registered');
2682
- if (firebaseError.code === 'auth/weak-password')
2683
- throw new WeakPasswordError();
2684
- throw error;
2685
- }
2686
- }
2687
- }
2688
-
2689
- class AttributeOptionHelper {
2690
- }
2691
- AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
2692
- if (fields.includes(attributeName))
2693
- return { columnName: attributeName.toString(), attributeName, to: (value) => value, from: (value) => value };
2694
- const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
2695
- const fieldOption = is(field)?.[attributeName];
2696
- if (isNil(fieldOption))
2697
- return { columnName: attributeName.toString(), attributeName };
2698
- if (Array.isArray(fieldOption))
2699
- return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
2700
- return { attributeName, columnName: attributeName.toString(), ...fieldOption };
2701
- };
2702
- AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue?.columnName;
2703
- AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
2704
- if (fields.includes(columnName))
2705
- return { columnName, attributeName: columnName };
2706
- const field = is(fields.find((field) => {
2707
- if (!isObject(field))
2708
- return false;
2709
- const columnOption = Object.values(field).find((option) => AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName ? option : {});
2710
- return AttributeOptionHelper.CheckIsColumnOption(columnOption) && columnOption?.columnName === columnName;
2711
- }) || {});
2712
- const attributeName = Object.keys(field).find((fieldOptionFromList) => AttributeOptionHelper.CheckIsColumnOption(field[fieldOptionFromList]) || Array.isArray(field[fieldOptionFromList]));
2713
- const fieldOption = field?.[attributeName];
2714
- if (Array.isArray(fieldOption))
2715
- return { attributeName: attributeName, fields: fieldOption };
2716
- return {
2717
- attributeName: attributeName || columnName,
2718
- columnName,
2719
- ...fieldOption,
2720
- };
2721
- };
2722
-
2723
- var HasuraGraphQLWhere;
2724
- (function (HasuraGraphQLWhere) {
2725
- HasuraGraphQLWhere["EQUALS"] = "_eq";
2726
- HasuraGraphQLWhere["GT"] = "_gt";
2727
- HasuraGraphQLWhere["GTE"] = "_gte";
2728
- HasuraGraphQLWhere["IN"] = "_in";
2729
- HasuraGraphQLWhere["NOTIN"] = "_nin";
2730
- HasuraGraphQLWhere["LT"] = "_lt";
2731
- HasuraGraphQLWhere["LTE"] = "_lte";
2732
- HasuraGraphQLWhere["LIKE"] = "_like";
2733
- HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
2734
- HasuraGraphQLWhere["ISNULL"] = "_is_null";
2735
- HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
2736
- HasuraGraphQLWhere["JSON_CONTAINS"] = "_contains";
2737
- HasuraGraphQLWhere["JSON_HAS_KEYS_ANY"] = "_has_keys_any";
2738
- })(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
2739
-
2740
- var HasuraGraphQLColumnType;
2741
- (function (HasuraGraphQLColumnType) {
2742
- HasuraGraphQLColumnType["Int"] = "Int";
2743
- HasuraGraphQLColumnType["Float"] = "Float";
2744
- HasuraGraphQLColumnType["Boolean"] = "Boolean";
2745
- HasuraGraphQLColumnType["String"] = "String";
2746
- HasuraGraphQLColumnType["DateTime"] = "timestampz";
2747
- HasuraGraphQLColumnType["Json"] = "json";
2748
- HasuraGraphQLColumnType["Jsonb"] = "jsonb";
2749
- HasuraGraphQLColumnType["Enum"] = "enum";
2750
- HasuraGraphQLColumnType["Uuid"] = "uuid";
2751
- })(HasuraGraphQLColumnType || (HasuraGraphQLColumnType = {}));
2752
-
2753
- class FilterOptionHelper {
2754
- }
2755
- FilterOptionHelper.CheckIfIsFilterOption = (filter) => !isNil(filter?.operator);
2756
- FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
2757
- if (!FilterOptionHelper.CheckIfIsFilterOption(filter))
2758
- return filter;
2759
- if (filter.operator === Where.ISNULL)
2760
- return true;
2761
- if (filter.operator === Where.ISNOTNULL)
2762
- return false;
2763
- const converter = fieldOption.to
2764
- ? fieldOption.to
2765
- : (value) => filter.operator === Where.LIKE && !Array.isArray(filter.value) && value.indexOf('%') < 0
2766
- ? `%${value}%`
2767
- : value;
2768
- return Array.isArray(filter.value) && !fieldOption.fields && [Where.IN, Where.NOTIN].includes(filter.operator)
2769
- ? filter.value.map((fieldValue) => converter(fieldValue))
2770
- : converter(filter.value);
2771
- };
2772
-
2773
- class BindFilterQueryHelper {
2774
- }
2775
- BindFilterQueryHelper.MakeGraphQLWhere = (filter, fields) => Object.keys(filter).reduce((variables, fieldName) => {
2776
- const columnOption = AttributeOptionHelper.FindByAttribute(fieldName, fields);
2777
- if (!columnOption.bindFindFilter)
2778
- return {
2779
- ...variables,
2780
- ...{
2781
- [columnOption.columnName]: BindFilterQueryHelper.BuildWhereSentence(fieldName, filter[fieldName], fields),
2782
- },
2783
- };
2784
- const builtFilter = columnOption.bindFindFilter(filter[fieldName]);
2785
- return {
2786
- ...variables,
2787
- ...Object.keys(builtFilter).reduce((variablesList, columnName) => ({
2788
- ...variablesList,
2789
- [columnName]: BindFilterQueryHelper.BuildWhereSentence(fieldName, builtFilter[columnName], fields),
2790
- }), {}),
2791
- };
2792
- }, {});
2793
- BindFilterQueryHelper.BuildWhereSentence = (field, options, fields) => {
2794
- const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2795
- const isNestedField = !Array.isArray(options) &&
2796
- isObject(options) &&
2797
- isNil(options?.operator) &&
2798
- isNil(options?.value) &&
2799
- isNil(fieldSentenceOptions?.to);
2800
- if (isNestedField)
2801
- return Object.keys(options).reduce((variables, key) => {
2802
- const fieldOptions = AttributeOptionHelper.FindByAttribute(key, fieldSentenceOptions?.fields || fields);
2803
- const columnName = fieldOptions.columnName;
2804
- const columnFields = fieldOptions.fields;
2805
- return {
2806
- ...variables,
2807
- [columnName]: BindFilterQueryHelper.BuildWhereSentence(key, is(is(options)[key]), fieldSentenceOptions?.fields || columnFields || fields),
2808
- };
2809
- }, {});
2810
- if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
2811
- return {
2812
- [fieldSentenceOptions.fields[0]]: BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions),
2813
- };
2814
- if (!Array.isArray(options) && isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2815
- options = Object.values(options)[0];
2816
- return Array.isArray(options)
2817
- ? options.reduce((whereSentence, option) => ({
2818
- ...whereSentence,
2819
- ...BindFilterQueryHelper.BuildOperatorSentence(option, fieldSentenceOptions),
2820
- }), {})
2821
- : BindFilterQueryHelper.BuildOperatorSentence(options, fieldSentenceOptions);
2822
- };
2823
- BindFilterQueryHelper.BuildOperatorSentence = (options, fieldOption) => ({
2824
- [BindFilterQueryHelper.GetHasuraOperator(options, fieldOption)]: FilterOptionHelper.GetValueFromFilter(options, fieldOption),
2825
- });
2826
- BindFilterQueryHelper.GetHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
2827
- ? fieldOption.type === HasuraGraphQLColumnType.Jsonb
2828
- ? BindFilterQueryHelper.GetHasuraJsonbOperator(options)
2829
- : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
2830
- Object.keys(Where).find((operator) => Where[operator] === options?.operator))]
2831
- : HasuraGraphQLWhere.EQUALS;
2832
- BindFilterQueryHelper.GetHasuraJsonbOperator = (options) => options.operator === Where.IN
2833
- ? HasuraGraphQLWhere.JSON_CONTAINS
2834
- : options.operator === Where.LIKE
2835
- ? HasuraGraphQLWhere.JSON_HAS_KEYS_ANY
2836
- : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator ===
2837
- Object.keys(Where).find((operator) => Where[operator] === options?.operator))];
2838
-
2839
- class GraphQLFieldHelper {
2840
- }
2841
- GraphQLFieldHelper.CheckIsGraphQLParams = (params) => !isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation;
2842
- GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
2843
- return fields
2844
- ?.map((field) => {
2845
- if (isString(field))
2846
- return field.toString();
2847
- if (field === 'affected_rows')
2848
- return field;
2849
- const fieldName = Object.keys(field).shift();
2850
- const fieldValue = is(field[fieldName]);
2851
- if (Array.isArray(fieldValue))
2852
- return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
2853
- if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
2854
- return;
2855
- const isNestedField = !!fieldValue.fields;
2856
- if (isNestedField)
2857
- return GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields(fieldName, fieldValue);
2858
- return fieldValue.columnName;
2859
- })
2860
- .filter((field) => !!field);
2861
- };
2862
- GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
2863
- const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
2864
- if (!!attributeFields && Array.isArray(attributeFields)) {
2865
- if (Array.isArray(data[columnName]))
2866
- return {
2867
- ...result,
2868
- [attributeName]: from
2869
- ? from(data[columnName], data)
2870
- : is(data[columnName]).map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(is(value), attributeFields)),
2871
- };
2872
- if (isObject(data[columnName]))
2873
- return {
2874
- ...result,
2875
- [attributeName]: !!from
2876
- ? from(data[columnName])
2877
- : GraphQLFieldHelper.ConvertFieldValueFrom(is(data[columnName]), attributeFields),
2878
- };
2879
- }
2880
- if (!!from)
2881
- return { ...result, [attributeName]: from(data[columnName], data) };
2882
- return {
2883
- ...result,
2884
- [attributeName]: isString(data[columnName]) ? parseDateTime(data[columnName].toString()) : data[columnName],
2885
- };
2886
- }, {});
2887
- GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
2888
- const data = instance.toPlain?.() || instance;
2889
- return Object.keys(data).reduce((result, attributeName) => {
2890
- const { columnName, fields: attributeFields, foreignKeyColumn, to, bindPersistData, } = AttributeOptionHelper.FindByAttribute(attributeName, fields);
2891
- if (bindPersistData)
2892
- return {
2893
- ...result,
2894
- ...bindPersistData(data[attributeName], instance),
2895
- };
2896
- if (isNil(columnName))
2897
- return result;
2898
- if (!!foreignKeyColumn &&
2899
- !isEmpty(foreignKeyColumn) &&
2900
- !Object.keys(foreignKeyColumn).filter((key) => !is(data[attributeName])?.[key]).length)
2901
- return Object.keys(foreignKeyColumn).reduce((object, current) => {
2902
- const { columnName: foreignColumnName } = AttributeOptionHelper.FindByAttribute(foreignKeyColumn[current], fields);
2903
- return {
2904
- ...object,
2905
- [foreignColumnName]: data[attributeName]?.[current],
2906
- };
2907
- }, { ...result });
2908
- if (update &&
2909
- isObject(data[attributeName]) &&
2910
- !isNil(attributeFields) &&
2911
- !isDate(data[attributeName]))
2912
- return result;
2913
- if (!!columnName &&
2914
- Array.isArray(attributeFields) &&
2915
- isObject(data[attributeName])) {
2916
- const converted = !isNil(columnName) && to
2917
- ? to(instance[attributeName], instance)
2918
- : data[attributeName];
2919
- return {
2920
- ...result,
2921
- ...(converted !== undefined
2922
- ? {
2923
- [columnName]: {
2924
- data: instance[attributeName] instanceof BaseModel
2925
- ? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
2926
- : converted,
2927
- },
2928
- }
2929
- : {}),
2930
- };
2931
- }
2932
- if (!!to)
2933
- return {
2934
- ...result,
2935
- [columnName]: to(instance[attributeName], instance),
2936
- };
2937
- return { ...result, [columnName]: data[attributeName] };
2938
- }, {});
2939
- };
2940
- GraphQLFieldHelper.ConvertNestedFieldsToGraphQLFields = (fieldName, fieldValue) => {
2941
- const hasCustomFilters = !!fieldValue.filters;
2942
- if (hasCustomFilters)
2943
- return {
2944
- operation: fieldValue.columnName || fieldName,
2945
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2946
- variables: {
2947
- [`${fieldValue.columnName}_where`]: {
2948
- name: 'where',
2949
- type: fieldValue.filters.filterType,
2950
- value: BindFilterQueryHelper.MakeGraphQLWhere(fieldValue.filters.filters, fieldValue.fields),
2951
- required: true,
2952
- },
2953
- },
2954
- };
2955
- return {
2956
- [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
2957
- };
2958
- };
2959
-
2960
- const withCreateHasuraGraphQL = (MixinBase) => {
2961
- return class CreateHasuraGraphQLMixin extends MixinBase {
2962
- constructor(...params) {
2963
- const options = params?.[0];
2964
- super(...params);
2965
- this.insertGraphQLOperation = options?.insertGraphQLOperation || `insert_${this.tableName}_one`;
2966
- this.insertGraphQLObjectType = options?.insertGraphQLObjectType || `${this.tableName}_insert_input`;
2967
- }
2968
- async create(data) {
2969
- this.logger = DebugHelper.from(this, 'create');
2970
- const newData = await this.save(this.model.toInstance(data));
2971
- return this.model.toInstance(newData);
2972
- }
2973
- async save(data) {
2974
- const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
2975
- const foreignKeyColumns = this.fields
2976
- .map((field) => {
2977
- const columnOptions = Object.values(field).shift();
2978
- return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
2979
- columnOptions.foreignKeyColumn && [
2980
- ...Object.values(columnOptions.foreignKeyColumn).map((foreignKeyName) => AttributeOptionHelper.FindByAttribute(foreignKeyName, this.fields)?.columnName),
2981
- {
2982
- [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions?.fields)
2983
- ?.columnName || foreignKeyField),
2984
- },
2985
- ]);
2986
- })
2987
- .filter(Boolean)
2988
- .reduce((keys, current) => [...keys, ...current], []);
2989
- const result = await this.mutation(this.insertGraphQLOperation, [...primaryKeyColumns, ...foreignKeyColumns], {
2990
- object: { type: this.insertGraphQLObjectType, required: true, value: this.convertDataToHasura(data) },
2991
- });
2992
- return { ...data.toPlain(), ...this.convertDataFromHasura(result[this.insertGraphQLOperation]).toPlain() };
2993
- }
2994
- };
2995
- };
2996
-
2997
- const withDeleteHasuraGraphQL = (MixinBase) => {
2998
- return class DeleteHasuraGraphQLMixin extends MixinBase {
2999
- constructor(...params) {
3000
- const options = params?.[0];
3001
- super(...params);
3002
- this.deleteGraphQLOperation = options?.deleteGraphQLOperation || `delete_${this.tableName}_by_pk`;
3003
- }
3004
- async delete(identifiers) {
3005
- this.logger = DebugHelper.from(this, 'delete');
3006
- const instance = this.model.toInstance(identifiers);
3007
- await this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
3008
- const identifierBinded = identifier;
3009
- if (isNil(instance.identifier[identifierBinded]))
3010
- return ids;
3011
- const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
3012
- const value = columnOption.to(identifiers[identifier], instance);
3013
- return {
3014
- ...ids,
3015
- [columnOption.columnName]: {
3016
- type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
3017
- value,
3018
- required: true,
3019
- },
3020
- };
3021
- }, {}));
3022
- }
3023
- };
3024
- };
3025
-
3026
- const withHasuraGraphQL = (MixinBase) => {
3027
- return class HasuraGraphQLMixin extends MixinBase {
3028
- constructor(...params) {
3029
- const options = params[0];
3030
- super(...params);
3031
- this.tableName = options.tableName;
3032
- this.endpoint = options.endpoint;
3033
- this.authOptions = options.authOptions;
3034
- this.model = options.model;
3035
- this.fields = options.fields || this.model.identifiersFields;
3036
- this.logger = DebugHelper.from(this);
3037
- }
3038
- get headers() {
3039
- return {
3040
- 'Content-Type': 'application/json',
3041
- ...(isNil(this.authOptions?.authToken) ? {} : { Authorization: this.authOptions?.authToken }),
3042
- ...(isNil(this.authOptions?.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions?.adminSecret }),
3043
- ...(isNil(this.authOptions?.authRole)
3044
- ? {}
3045
- : {
3046
- 'X-Hasura-Role': this.authOptions.authRole.role,
3047
- 'X-Hasura-User-Id': this.authOptions?.authRole?.userId,
3048
- }),
3049
- };
3050
- }
3051
- async mutation(operation, fields, variables) {
3052
- const resultQuery = mutation({
3053
- operation,
3054
- variables,
3055
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
3056
- });
3057
- return this.fetch(resultQuery);
3058
- }
3059
- async query(operation, fields, variables) {
3060
- const builded = this.buildHasuraQueryFields({
3061
- operation,
3062
- fields: fields,
3063
- variables,
3064
- });
3065
- const interpected = (await this.interceptors?.request?.(builded)) || builded;
3066
- const resultQuery = query$1(interpected);
3067
- const result = await this.fetch(resultQuery);
3068
- return (await this.interceptors?.response?.(result, interpected)) || result;
3069
- }
3070
- async fetch(params) {
3071
- this.logger.with('params').log(params);
3072
- const headers = this.headers;
3073
- const { data: result } = await axios({
3074
- url: `${this.endpoint}`,
3075
- method: 'POST',
3076
- data: params,
3077
- headers,
3078
- });
3079
- if (!isNil(result.errors))
3080
- throw new Error(JSON.stringify(result.errors));
3081
- this.logger.with('returns').log(result);
3082
- return result.data;
3083
- }
3084
- getAttributeGraphQLTypeOf(value) {
3085
- if (isUUID(value))
3086
- return 'uuid';
3087
- if (isString(value))
3088
- return 'String';
3089
- if (isBoolean(value))
3090
- return 'Boolean';
3091
- if (value instanceof Date)
3092
- return 'timestamptz';
3093
- if (isInteger(value))
3094
- return 'Int';
3095
- if (isNumber(value))
3096
- return 'numeric';
3097
- throw new Error('Type not implemented yet');
3098
- }
3099
- checkIfIsDateTimeAndParse(value) {
3100
- if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value))
3101
- return value;
3102
- const date = parseISO(value);
3103
- if (isNaN$1(date.getTime()))
3104
- return value;
3105
- return date;
3106
- }
3107
- convertDataFromHasura(data, fields) {
3108
- const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, fields || this.fields);
3109
- return this.model.toInstance(plain);
3110
- }
3111
- convertDataToHasura(instance, update = false) {
3112
- return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
3113
- }
3114
- buildHasuraQueryFields({ operation, fields, variables, }) {
3115
- return GraphQLFieldHelper.CheckIsGraphQLParams(operation)
3116
- ? operation.map((option) => ({
3117
- operation: option.operation,
3118
- variables: option.variables,
3119
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
3120
- }))
3121
- : {
3122
- operation,
3123
- variables,
3124
- fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
3125
- };
3126
- }
3127
- };
3128
- };
3129
-
3130
- const withUpdateHasuraGraphQL = (MixinBase) => {
3131
- const getValueByAction = (options) => {
3132
- if (options instanceof BaseModel)
3133
- return options.toPlain();
3134
- if (isNil(options?.action))
3135
- return options;
3136
- if ([UpdateOptionActions.REMOVE_FIELD.toString(), UpdateOptionActions.NULL.toString()].includes(options.action))
3137
- return null;
3138
- return options.value;
3139
- };
3140
- return class UpdateHasuraGraphQLMixin extends MixinBase {
3141
- constructor(...params) {
3142
- const options = params?.[0];
3143
- super(...params);
3144
- this.updateGraphQLOperation = options?.updateGraphQLOperation || `update_${this.tableName}_by_pk`;
3145
- this.updateGraphQLObjectType = options?.updateGraphQLObjectType || `${this.tableName}_set_input`;
3146
- this.updateGraphQLPKType = options?.updateGraphQLPKType || `${this.tableName}_pk_columns_input`;
3147
- }
3148
- async update(data) {
3149
- this.logger = DebugHelper.from(this, 'update');
3150
- const plainData = this.paramsToPlain(data);
3151
- await this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
3152
- _set: {
3153
- type: this.updateGraphQLObjectType,
3154
- value: this.convertDataToHasura(this.model.toInstance(plainData), true),
3155
- required: true,
3156
- },
3157
- pk_columns: { type: this.updateGraphQLPKType, value: this.getUpdateModelKeys(plainData), required: true },
3158
- });
3159
- return this.model.toInstance(plainData);
3160
- }
3161
- paramsToPlain(params) {
3162
- const model = this.model;
3163
- if (model.isModel(params))
3164
- return params.toPlain();
3165
- return Object.keys(params).reduce((data, currentKey) => ({
3166
- ...data,
3167
- ...(params[currentKey] !== undefined && {
3168
- [currentKey]: getValueByAction(is(params[currentKey])),
3169
- }),
3170
- }), {});
3171
- }
3172
- getUpdateModelKeys(data) {
3173
- const instance = this.model.toInstance(data);
3174
- return this.model.identifiersFields.reduce((ids, identifier) => {
3175
- const identifierBinded = identifier;
3176
- if (isNil(instance.identifier[identifierBinded]))
3177
- return ids;
3178
- const columnOption = AttributeOptionHelper.FindByAttribute(identifierBinded, this.fields);
3179
- const value = columnOption?.to?.(data[identifierBinded], instance) || data[columnOption.attributeName];
3180
- return {
3181
- ...ids,
3182
- [columnOption.columnName]: value,
3183
- };
3184
- }, {});
3185
- }
3186
- };
3187
- };
3188
-
3189
- const withGetHasuraGraphQL = (MixinBase) => {
3190
- return class GetHasuraGraphQLMixin extends MixinBase {
3191
- constructor(...params) {
3192
- const options = params?.[0];
3193
- super(...params);
3194
- this.getGraphQLOperation = options?.getGraphQLOperation || `${this.tableName}_by_pk`;
3195
- }
3196
- async get(identifiers) {
3197
- this.logger = DebugHelper.from(this, 'get');
3198
- const instance = this.model.toInstance(identifiers);
3199
- const result = await this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
3200
- const identifierBinded = identifier;
3201
- if (isNil(instance[identifierBinded]))
3202
- return ids;
3203
- const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
3204
- const value = columnOption?.to?.(identifiers[identifier], instance) ||
3205
- identifiers[identifier];
3206
- return {
3207
- ...ids,
3208
- [columnOption.columnName]: {
3209
- type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
3210
- value,
3211
- required: true,
3212
- },
3213
- };
3214
- }, {}));
3215
- const data = result[this.getGraphQLOperation];
3216
- if (isNil(data))
3217
- throw new NotFoundError(`${instance.constructor.name} not found`);
3218
- return this.convertDataFromHasura(result[this.getGraphQLOperation]);
3219
- }
3220
- };
3221
- };
3222
-
3223
- const withFindHasuraGraphQL = (MixinBase) => {
3224
- return class FindHasuraGraphQLMixin extends MixinBase {
3225
- constructor() {
3226
- super(...arguments);
3227
- this.bindOrderByAttributes = (orderBy, fields) => Object.keys(orderBy).reduce((acc, current) => [
3228
- ...acc,
3229
- {
3230
- [AttributeOptionHelper.FindByAttribute(current, fields)
3231
- .columnName]: orderBy[current] === 'asc'
3232
- ? 'asc_nulls_last'
3233
- : 'desc_nulls_last',
3234
- },
3235
- ], []);
3236
- this.bindAggretageAttributes = (aggregates, fields) => [
3237
- ...(aggregates?.minimal?.length
3238
- ? [
3239
- {
3240
- min: this.bindAttributesToColumns(aggregates?.minimal, fields),
3241
- },
3242
- ]
3243
- : []),
3244
- ...(aggregates?.maximum?.length
3245
- ? [
3246
- {
3247
- max: this.bindAttributesToColumns(aggregates?.maximum, fields),
3248
- },
3249
- ]
3250
- : []),
3251
- ];
3252
- this.bindDistinctAttributes = (distinct, fields) => this.bindAttributesToColumns(distinct, fields);
3253
- this.bindAttributesToColumns = (attributes, fields) => attributes.map((attr) => AttributeOptionHelper.FindByAttribute(attr.toString().split('.').pop(), fields)?.columnName || attr);
3254
- }
3255
- async find(params) {
3256
- this.logger = DebugHelper.from(this, 'find');
3257
- const { filters, limits, orderBy, options } = params || {};
3258
- const enableCount = options?.enableCount ?? true;
3259
- const variablesFilters = isNil(filters)
3260
- ? {}
3261
- : {
3262
- where: {
3263
- value: BindFilterQueryHelper.MakeGraphQLWhere(filters, this.fields),
3264
- type: `${this.tableName}_bool_exp`,
3265
- required: true,
3266
- },
3267
- };
3268
- const variablesCount = {
3269
- ...(isNil(orderBy)
3270
- ? {}
3271
- : {
3272
- order_by: {
3273
- type: `${this.tableName}_order_by!`,
3274
- list: true,
3275
- value: this.bindOrderByAttributes(orderBy, this.fields),
3276
- },
3277
- }),
3278
- ...variablesFilters,
3279
- };
3280
- const variables = {
3281
- ...(isNil(limits) ? {} : limits),
3282
- ...variablesCount,
3283
- };
3284
- const aggregateFields = [
3285
- ...(enableCount ? ['count'] : []),
3286
- ...this.bindAggretageAttributes(params.options, this.fields),
3287
- ];
3288
- const result = await this.query([
3289
- {
3290
- operation: this.tableName,
3291
- fields: params.fields
3292
- ? params.fields
3293
- .map((fieldName) => this.fields.find((fieldOption) => fieldOption === fieldName) ??
3294
- this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName))
3295
- .filter(Boolean)
3296
- : this.fields,
3297
- variables,
3298
- },
3299
- ...(aggregateFields.length > 0
3300
- ? [
3301
- {
3302
- operation: `${this.tableName}_aggregate`,
3303
- fields: [
3304
- {
3305
- aggregate: aggregateFields,
3306
- },
3307
- ],
3308
- variables: variablesCount,
3309
- },
3310
- ]
3311
- : []),
3312
- ...((!params.limits?.offset &&
3313
- params.options?.distinct?.map((distinct) => {
3314
- const distinctOption = this.fields.find((fieldOption) => fieldOption === distinct) ??
3315
- this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === distinct);
3316
- const fieldName = Object.values(distinctOption).shift()?.columnName || distinct;
3317
- return {
3318
- operation: {
3319
- name: `${this.tableName}`,
3320
- alias: `${this.tableName}_${distinct.toString()}_distinct`,
3321
- },
3322
- fields: [distinctOption],
3323
- variables: {
3324
- ...variablesFilters,
3325
- [`${this.tableName}_${fieldName}_distinct`]: {
3326
- type: `${this.tableName}_select_column!`,
3327
- list: true,
3328
- value: fieldName,
3329
- name: 'distinct_on',
3330
- },
3331
- },
3332
- };
3333
- })) ||
3334
- []),
3335
- ]);
3336
- const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
3337
- return {
3338
- data,
3339
- count: enableCount ? result[`${this.tableName}_aggregate`].aggregate.count : Infinity,
3340
- ...(options?.minimal?.length
3341
- ? {
3342
- minimal: options.minimal.reduce((minimals, current) => ({
3343
- ...minimals,
3344
- ...set(minimals, current, result[`${this.tableName}_aggregate`].aggregate.min[AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)?.columnName || current]),
3345
- }), {}),
3346
- }
3347
- : {}),
3348
- ...(options?.maximum?.length
3349
- ? {
3350
- maximum: options.maximum.reduce((maximums, current) => ({
3351
- ...maximums,
3352
- ...set(maximums, current, result[`${this.tableName}_aggregate`].aggregate.max[AttributeOptionHelper.FindByAttribute(current.toString().split('.').pop(), this.fields)?.columnName || current]),
3353
- }), {}),
3354
- }
3355
- : {}),
3356
- ...(!params.limits?.offset &&
3357
- options?.distinct?.length && {
3358
- distinct: options?.distinct.reduce((distinct, current) => {
3359
- const distinctOption = this.fields.find((fieldOption) => fieldOption === current) ??
3360
- this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === current);
3361
- const fieldName = Object.values(distinctOption).shift()?.columnName || current;
3362
- return {
3363
- ...distinct,
3364
- [current.toString()]: result[`${this.tableName}_${current.toString()}_distinct`].map((obj) => obj[fieldName]),
3365
- };
3366
- }, {}),
3367
- }),
3368
- };
3369
- }
3370
- };
3371
- };
3372
-
3373
- const withCrudHasuraGraphQL = (MixinBase) => {
3374
- return class CrudHasuraGraphQLMixin extends withUpdateHasuraGraphQL(withGetHasuraGraphQL(withFindHasuraGraphQL(withDeleteHasuraGraphQL(withCreateHasuraGraphQL(MixinBase))))) {
3375
- };
3376
- };
3377
-
3378
- class CategoryHasuraGraphQL extends Category {
3379
- }
3380
-
3381
- class ProductHasuraGraphQL extends Product {
3382
- }
3383
- __decorate([
3384
- Type(() => KitProductHasuraGraphQL),
3385
- __metadata("design:type", Array)
3386
- ], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
3387
-
3388
- class KitProductHasuraGraphQL extends KitProduct {
3389
- }
3390
- __decorate([
3391
- Type(() => ProductHasuraGraphQL),
3392
- __metadata("design:type", ProductHasuraGraphQL)
3393
- ], KitProductHasuraGraphQL.prototype, "kit", void 0);
3394
- __decorate([
3395
- Type(() => ProductHasuraGraphQL),
3396
- __metadata("design:type", ProductHasuraGraphQL)
3397
- ], KitProductHasuraGraphQL.prototype, "product", void 0);
3398
-
3399
- class VariantHasuraGraphQL extends Variant {
3400
- constructor() {
3401
- super(...arguments);
3402
- this.name = '';
3403
- this.hasVariants = false;
3404
- }
3405
- }
3406
-
3407
- class CategoryCollectionChildrenHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3408
- constructor({ endpoint, authOptions, interceptors, }) {
3409
- super({
3410
- tableName: 'category_collection_children',
3411
- model: CategoryCollectionChildren,
3412
- endpoint,
3413
- authOptions,
3414
- interceptors,
3415
- fields: [
3416
- { collectionId: { columnName: 'collection_id' } },
3417
- { categoryId: { columnName: 'category_id' } },
3418
- 'name',
3419
- 'slug',
3420
- 'reference',
3421
- { parentCollectionId: { columnName: 'parent_collection_id' } },
3422
- { parentCategoryId: { columnName: 'parent_category_id' } },
3423
- {
3424
- parent: {
3425
- columnName: 'parent',
3426
- foreignKeyColumn: { collectionId: 'parentCollectionId', categoryId: 'parentCategoryId' },
3427
- fields: [
3428
- { collectionId: { columnName: 'collection_id' } },
3429
- { categoryId: { columnName: 'category_id' } },
3430
- 'name',
3431
- 'slug',
3432
- 'reference',
3433
- { parentCollectionId: { columnName: 'parent_collection_id' } },
3434
- { parentCategoryId: { columnName: 'parent_category_id' } },
3435
- ],
3436
- },
3437
- },
3438
- ],
3439
- });
3440
- }
3441
- }
3442
-
3443
- class CategoryFilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3444
- constructor({ endpoint, authOptions, interceptors, }) {
3445
- super({
3446
- tableName: 'category_filter',
3447
- model: CategoryFilter,
3448
- endpoint,
3449
- authOptions,
3450
- interceptors,
3451
- fields: [
3452
- 'id',
3453
- { filterId: { columnName: 'filter_id' } },
3454
- { categoryId: { columnName: 'category_id' } },
3455
- {
3456
- filter: {
3457
- columnName: 'filter',
3458
- foreignKeyColumn: { id: 'filterId' },
3459
- fields: [
3460
- 'id',
3461
- 'description',
3462
- 'slug',
3463
- 'enabled',
3464
- { createdAt: { columnName: 'created_at' } },
3465
- { updatedAt: { columnName: 'updated_at' } },
3466
- {
3467
- options: {
3468
- columnName: 'options',
3469
- foreignKeyColumn: { filterId: 'id' },
3470
- fields: [
3471
- 'id',
3472
- { filterId: { columnName: 'filter_id' } },
3473
- 'description',
3474
- { createdAt: { columnName: 'created_at' } },
3475
- { updatedAt: { columnName: 'updated_at' } },
3476
- ],
3477
- },
3478
- },
3479
- ],
3480
- },
3481
- },
3482
- {
3483
- category: {
3484
- columnName: 'category',
3485
- foreignKeyColumn: { id: 'categoryId' },
3486
- fields: [
3487
- 'id',
3488
- 'description',
3489
- {
3490
- products: {
3491
- columnName: 'products',
3492
- fields: ['product_id'],
3493
- from: (value) => value.map((product) => product.product_id.toString()),
3494
- to: (productIds) => productIds.map((productId) => ({
3495
- product_id: +productId,
3496
- })),
3497
- },
3498
- },
3499
- {
3500
- childrenProducts: {
3501
- columnName: 'children_products',
3502
- foreignKeyColumn: { category_id: 'id' },
3503
- fields: [
3504
- 'id',
3505
- 'name',
3506
- 'slug',
3507
- {
3508
- categories: {
3509
- columnName: 'categories',
3510
- fields: ['category_id'],
3511
- bindPersistData: (value) => ({
3512
- categories: { data: value.map((category) => ({ category_id: +category })) },
3513
- }),
3514
- to: (categories) => categories.map((categoryId) => +categoryId),
3515
- from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
3516
- },
3517
- },
3518
- ],
3519
- },
3520
- },
3521
- ],
3522
- },
3523
- },
3524
- ],
3525
- });
3526
- }
3527
- deleteByCategory(categoryId) {
3528
- return this.mutation('delete_category_filter', ['affected_rows'], {
3529
- where: {
3530
- type: 'category_filter_bool_exp',
3531
- required: true,
3532
- value: { category_id: { _eq: categoryId } },
3533
- },
3534
- });
3535
- }
3536
- deleteByCategoryAndFilter(categoryId, filterId) {
3537
- return this.mutation('delete_category_filter', ['affected_rows'], {
3538
- where: {
3539
- type: 'category_filter_bool_exp',
3540
- required: true,
3541
- value: { category_id: { _eq: categoryId }, filter_id: { _eq: filterId } },
3542
- },
3543
- });
3544
- }
3545
- }
3546
-
3547
- class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3548
- constructor({ endpoint, authOptions, interceptors, }, productRepository, categoryFilterRepository) {
3549
- super({
3550
- tableName: 'category',
3551
- model: Category,
3552
- endpoint,
3553
- authOptions,
3554
- interceptors,
3555
- fields: [
3556
- { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
3557
- { firestoreId: { columnName: 'firestore_id' } },
3558
- 'name',
3559
- 'description',
3560
- 'image',
3561
- 'published',
3562
- 'shop',
3563
- { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
3564
- 'slug',
3565
- { brandCategory: { columnName: 'brand_category' } },
3566
- { brandCategoryBanner: { columnName: 'brand_banner' } },
3567
- { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
3568
- { brandLogo: { columnName: 'brand_logo' } },
3569
- { brandCondition: { columnName: 'brand_condition' } },
3570
- {
3571
- conditions: {
3572
- columnName: 'tag_condition',
3573
- type: HasuraGraphQLColumnType.Jsonb,
3574
- from: (tags, row) => ({
3575
- brand: row.brand_condition,
3576
- tags: Array.isArray(tags) ? tags : [],
3577
- }),
3578
- bindPersistData: (value) => {
3579
- return {
3580
- brand_condition: value.brand,
3581
- tag_condition: value?.tags || [],
3582
- };
3583
- },
3584
- bindFindFilter: (sentence) => {
3585
- return {
3586
- ...(sentence.brand ? { brand_condition: sentence.brand } : {}),
3587
- ...(sentence.tags ? { tag_condition: sentence.tags } : {}),
3588
- };
3589
- },
3590
- },
3591
- },
3592
- {
3593
- filters: {
3594
- columnName: 'filters',
3595
- foreignKeyColumn: { filter_id: 'id' },
3596
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
3597
- bindPersistData: (value) => ({
3598
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
3599
- }),
3600
- from: (filters) => filters?.map((filter) => filter?.filter) || [],
3601
- },
3602
- },
3603
- { createdAt: { columnName: 'created_at' } },
3604
- { updatedAt: { columnName: 'updated_at' } },
3605
- {
3606
- products: {
3607
- columnName: 'products',
3608
- fields: ['product_id'],
3609
- from: (value) => value.map((product) => product.product_id.toString()),
3610
- to: (productIds) => productIds.map((productId) => ({
3611
- product_id: +productId,
3612
- })),
3613
- },
3614
- },
3615
- {
3616
- metadata: {
3617
- columnName: 'metadata',
3618
- fields: ['title', 'description'],
3619
- bindPersistData: (value) => ({
3620
- metadata: { data: value },
3621
- }),
3622
- },
3623
- },
3624
- { isCollection: { columnName: 'is_collection' } },
3625
- { isWishlist: { columnName: 'is_wishlist' } },
3626
- 'reference',
3627
- { parentId: { columnName: 'parent_id' } },
3628
- {
3629
- parent: {
3630
- columnName: 'parent',
3631
- foreignKeyColumn: { id: 'parentId' },
3632
- fields: ['id', 'name', 'reference', 'slug'],
3633
- },
3634
- },
3635
- ],
3636
- });
3637
- this.productRepository = productRepository;
3638
- this.categoryFilterRepository = categoryFilterRepository;
3639
- }
3640
- async create(params) {
3641
- const { metadata, ...data } = params;
3642
- return super.create({ ...data, isWishlist: false, metadata: metadata || { description: null, title: null } });
3643
- }
3644
- async get(identifiers) {
3645
- return Number.isNaN(+identifiers.id)
3646
- ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
3647
- : super.get(identifiers);
3648
- }
3649
- async update(params) {
3650
- const { products, id: checkId, metadata, filters, ...data } = params;
3651
- const plainData = this.paramsToPlain({ id: checkId });
3652
- const id = await this.getId(plainData.id);
3653
- const category = await super.update({ id, ...data, isWishlist: false });
3654
- category.products = products && (await this.updateProducts(+id, { products }));
3655
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
3656
- category.filters = filters && (await this.updateFilters(+id, { filters }));
3657
- return category;
3658
- }
3659
- async getCategoryBySlug(slug, shop) {
3660
- if (!slug)
3661
- return null;
3662
- const { data } = await this.find({
3663
- filters: {
3664
- slug,
3665
- shops: { operator: Where.IN, value: [shop] },
3666
- published: { operator: Where.EQUALS, value: true },
3667
- isWishlist: { operator: Where.EQUALS, value: false },
3668
- },
3669
- options: {
3670
- enableCount: false,
3671
- },
3672
- });
3673
- if (!data.length)
3674
- throw new NotFoundError(`Category with slug ${slug} not found`);
3675
- if (data.length > 1)
3676
- throw new DuplicatedResultsError('Query returned duplicated values');
3677
- return data.shift();
3678
- }
3679
- async getCategoryByShop(shop) {
3680
- if (!shop)
3681
- return;
3682
- const { data } = await this.find({
3683
- filters: {
3684
- shops: { operator: Where.IN, value: [shop] },
3685
- published: { operator: Where.EQUALS, value: true },
3686
- isWishlist: { operator: Where.EQUALS, value: false },
3687
- },
3688
- options: {
3689
- enableCount: false,
3690
- },
3691
- });
3692
- return data;
3693
- }
3694
- async getCategoriesForHome(categoryIds, limit = 4, gender) {
3695
- if (!categoryIds?.length)
3696
- return [];
3697
- const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
3698
- const categoriesHasura = categoryIds.filter((categoryId) => +categoryId > 0);
3699
- const categories = [];
3700
- if (categoriesFirestore.length)
3701
- categories.push(...(await this.find({
3702
- filters: { firestoreId: { operator: Where.IN, value: categoriesFirestore.filter(Boolean) }, published: true },
3703
- }).then(({ data }) => data)));
3704
- if (categoriesHasura.length)
3705
- categories.push(...(await this.find({
3706
- filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
3707
- }).then(({ data }) => data)));
3708
- if (!categories.length)
3709
- return [];
3710
- const homeSections = await Promise.all(categories.map(async (category) => ({
3711
- category,
3712
- products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3713
- })));
3714
- return homeSections;
3715
- }
3716
- async mountCategory(category, options) {
3717
- if (!category?.products?.length)
3718
- return [];
3719
- const products = [];
3720
- const { data: productsData } = await this.productRepository.find({
3721
- filters: {
3722
- id: { operator: Where.IN, value: category.products },
3723
- published: true,
3724
- ...(options?.hasStock ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {}),
3725
- ...(options?.gender ? { tags: { operator: Where.IN, value: [options?.gender] } } : {}),
3726
- },
3727
- fields: [
3728
- 'id',
3729
- 'name',
3730
- 'slug',
3731
- 'images',
3732
- 'miniatures',
3733
- 'price',
3734
- 'fullPrice',
3735
- 'subscriberDiscountPercentage',
3736
- 'subscriberPrice',
3737
- 'stock',
3738
- 'published',
3739
- 'CEST',
3740
- 'EAN',
3741
- 'NCM',
3742
- 'brand',
3743
- 'costPrice',
3744
- 'hasVariants',
3745
- 'isKit',
3746
- 'sku',
3747
- 'rate',
3748
- 'tags',
3749
- 'type',
3750
- 'shoppingCount',
3751
- 'gender',
3752
- 'createdAt',
3753
- ],
3754
- ...(options?.limit ? { limits: { limit: options?.limit } } : {}),
3755
- options: { enableCount: false },
3756
- });
3757
- products.push(...productsData);
3758
- return products;
3759
- }
3760
- async getId(id) {
3761
- if (!Number.isNaN(+id))
3762
- return id;
3763
- const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3764
- if (data?.[0]?.id)
3765
- return data?.[0]?.id;
3766
- throw new NotFoundError(`Category with id ${id} not found`);
3767
- }
3768
- async updateProducts(categoryId, { products }) {
3769
- if ('action' in products && products.action === 'remove') {
3770
- await this.mutation('delete_category_product', ['affected_rows'], {
3771
- where: {
3772
- type: 'category_product_bool_exp',
3773
- required: true,
3774
- value: { category_id: { _eq: categoryId } },
3775
- },
3776
- });
3777
- return [];
3778
- }
3779
- const plainData = this.paramsToPlain({ products });
3780
- if (!plainData.products || plainData.products.length <= 0)
3781
- return [];
3782
- await this.mutation('delete_category_product', ['affected_rows'], {
3783
- where: {
3784
- type: 'category_product_bool_exp',
3785
- required: true,
3786
- value: { category_id: { _eq: categoryId } },
3787
- },
3788
- });
3789
- await this.mutation('insert_category_product', ['affected_rows'], {
3790
- objects: {
3791
- type: '[category_product_insert_input!]',
3792
- required: true,
3793
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
3794
- },
3795
- });
3796
- return plainData.products;
3797
- }
3798
- async updateMetadata(categoryId, { metadata }) {
3799
- const plainData = this.paramsToPlain({ metadata });
3800
- if (!plainData.metadata)
3801
- return null;
3802
- await this.mutation('update_category_metadata_by_pk', ['category_id'], {
3803
- pk_columns: {
3804
- value: { category_id: categoryId },
3805
- type: 'category_metadata_pk_columns_input',
3806
- required: true,
3807
- },
3808
- _set: {
3809
- value: omit(metadata, ['category_id']),
3810
- type: 'category_metadata_set_input',
3811
- required: true,
3812
- },
3813
- });
3814
- return plainData.metadata;
3815
- }
3816
- async updateFilters(categoryId, { filters }) {
3817
- if ('action' in filters && filters.action === 'remove' && filters.value.length) {
3818
- for (let i = 0; i < filters.value.length; i++) {
3819
- await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
3820
- }
3821
- return [];
3822
- }
3823
- if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3824
- let filtersList = [];
3825
- const currentFilters = await this.categoryFilterRepository
3826
- .find({
3827
- filters: {
3828
- categoryId,
3829
- },
3830
- })
3831
- .then((res) => res.data);
3832
- const currentFiltersId = currentFilters.map((f) => f.id);
3833
- const filtersUpdatedId = filters.value.map((f) => f.id);
3834
- const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
3835
- const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
3836
- for (const filter of filterToBeDeleted) {
3837
- const index = currentFilters.findIndex((f) => f.id == filter);
3838
- if (index != -1) {
3839
- currentFilters.splice(index, 1);
3840
- }
3841
- await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
3842
- }
3843
- for (const filter of filterToBeInserted) {
3844
- const newCategoryFilter = await this.categoryFilterRepository.create({
3845
- filterId: filter,
3846
- categoryId,
3847
- });
3848
- filtersList.push(filter);
3849
- }
3850
- return filters.value;
3851
- }
3852
- if (Array.isArray(filters) && filters.length) {
3853
- await this.categoryFilterRepository.deleteByCategory(categoryId);
3854
- let filtersList = [];
3855
- for (let i = 0; i < filters.length; i++) {
3856
- const newCategoryFilter = await this.categoryFilterRepository.create({
3857
- filterId: filters[i].id,
3858
- categoryId,
3859
- });
3860
- filtersList.push(newCategoryFilter);
3861
- }
3862
- return filters;
3863
- }
3864
- }
3865
- async getChildren(parentId) {
3866
- const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id'], {
3867
- args: {
3868
- type: 'category_tree_args',
3869
- value: { parentid: parentId },
3870
- required: true,
3871
- },
3872
- });
3873
- return category_tree.map((category) => Category.toInstance(category));
3874
- }
3875
- async isChild(id, parentId) {
3876
- const categoryTree = await this.getChildren(parentId);
3877
- return categoryTree.some((c) => c.id == id.toString());
3878
- }
3879
- }
3880
-
3881
- class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3882
- constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
3883
- super({
3884
- tableName: 'filter',
3885
- model: Filter,
3886
- endpoint,
3887
- authOptions,
3888
- interceptors,
3889
- fields: [
3890
- 'id',
3891
- 'description',
3892
- 'slug',
3893
- 'enabled',
3894
- { createdAt: { columnName: 'created_at' } },
3895
- { updatedAt: { columnName: 'updated_at' } },
3896
- {
3897
- options: {
3898
- columnName: 'options',
3899
- foreignKeyColumn: { filterId: 'id' },
3900
- fields: [
3901
- 'id',
3902
- { filterId: { columnName: 'filter_id' } },
3903
- 'description',
3904
- { createdAt: { columnName: 'created_at' } },
3905
- { updatedAt: { columnName: 'updated_at' } },
3906
- ],
3907
- },
3908
- },
3909
- ],
3910
- });
3911
- this.filterOptionRepository = filterOptionRepository;
3912
- this.categoryFilterRepository = categoryFilterRepository;
3913
- }
3914
- async update(params) {
3915
- const { options, ...data } = params;
3916
- const filter = await super.update(data);
3917
- filter.options = await this.updateOptions(+data.id, { options });
3918
- return filter;
3919
- }
3920
- async updateOptions(filterId, { options }) {
3921
- if (!options)
3922
- return [];
3923
- if ('action' in options && options.action === 'remove' && options.value.length) {
3924
- for (let i = 0; i < options.value.length; i++) {
3925
- await this.filterOptionRepository.delete({ id: options.value[i].id });
3926
- }
3927
- return [];
3928
- }
3929
- if ('action' in options && options.action === 'merge' && options.value.length) {
3930
- let filterOptions = [];
3931
- for (let i = 0; i < options.value.length; i++) {
3932
- try {
3933
- const hasFilter = await this.filterOptionRepository.get({ id: options.value[i].id });
3934
- if (hasFilter)
3935
- filterOptions.push(hasFilter);
3936
- }
3937
- catch (error) {
3938
- const newOption = await this.filterOptionRepository.create({ ...options.value[i], filterId });
3939
- filterOptions.push(newOption);
3940
- }
3941
- }
3942
- return filterOptions;
3943
- }
3944
- if (Array.isArray(options) && options.length) {
3945
- let filterOptions = [];
3946
- for (let i = 0; i < options.length; i++) {
3947
- try {
3948
- const hasFilter = await this.filterOptionRepository.get({ id: options[i].id });
3949
- if (hasFilter)
3950
- filterOptions.push(hasFilter);
3951
- }
3952
- catch (error) {
3953
- const newOption = await this.filterOptionRepository.create({ ...options[i], filterId });
3954
- filterOptions.push(newOption);
3955
- }
3956
- }
3957
- }
3958
- return [];
3959
- }
3960
- async delete(params) {
3961
- const { data: categoryFilters } = await this.categoryFilterRepository.find({
3962
- filters: {
3963
- filterId: params.id,
3964
- },
3965
- });
3966
- if (categoryFilters.length)
3967
- throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
3968
- await this.deleteOptions(+params.id);
3969
- await super.delete({ id: +params.id });
3970
- return;
3971
- }
3972
- async deleteOptions(filterId) {
3973
- await this.mutation('delete_filter_option', ['affected_rows'], {
3974
- where: {
3975
- type: 'filter_option_bool_exp',
3976
- required: true,
3977
- value: { filter_id: { _eq: filterId } },
3978
- },
3979
- });
3980
- }
3981
- }
3982
-
3983
- class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3984
- constructor({ endpoint, authOptions, interceptors, }) {
3985
- super({
3986
- tableName: 'filter_option',
3987
- model: FilterOption,
3988
- endpoint,
3989
- authOptions,
3990
- interceptors,
3991
- fields: [
3992
- 'id',
3993
- 'description',
3994
- { filterId: { columnName: 'filter_id' } },
3995
- { createdAt: { columnName: 'created_at' } },
3996
- { updatedAt: { columnName: 'updated_at' } },
3997
- ],
3998
- });
3999
- }
4000
- }
4001
-
4002
- class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4003
- constructor({ endpoint, authOptions, interceptors, }) {
4004
- super({
4005
- tableName: 'product',
4006
- model: ProductHasuraGraphQL,
4007
- endpoint,
4008
- authOptions,
4009
- interceptors,
4010
- fields: [],
4011
- });
4012
- this.bindReviewToModel = (plain) => ({
4013
- ...is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])),
4014
- createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at,
4015
- updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at,
4016
- personId: plain.person_id,
4017
- orderId: plain.order_id,
4018
- });
4019
- this.bindReviewToHasura = (review) => ({
4020
- ...is(omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])),
4021
- person_id: review.personId,
4022
- order_id: review.orderId,
4023
- });
4024
- const commonFields = [
4025
- { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4026
- { firestoreId: { columnName: 'firestore_id' } },
4027
- { productId: { columnName: 'main_product_id' } },
4028
- { CEST: { columnName: 'cest' } },
4029
- { EAN: { columnName: 'ean' } },
4030
- { NCM: { columnName: 'ncm' } },
4031
- 'brand',
4032
- { costPrice: { columnName: 'cost_price' } },
4033
- {
4034
- description: {
4035
- columnName: 'description',
4036
- from: (description, data) => ({
4037
- description,
4038
- differentials: data.differentials,
4039
- whoMustUse: data.who_must_use,
4040
- howToUse: data.how_to_use,
4041
- brand: data.brand_description,
4042
- ingredients: data.ingredients,
4043
- }),
4044
- bindFindFilter: (filters) => {
4045
- return {
4046
- ...(filters?.description && { description: filters.description }),
4047
- ...(filters.differentials && { differentials: filters.differentials }),
4048
- ...(filters.whoMustUse && {
4049
- who_must_use: filters.whoMustUse,
4050
- }),
4051
- ...(filters.howToUse && {
4052
- how_to_use: filters.howToUse,
4053
- }),
4054
- ...(filters.brand && {
4055
- brand_description: filters.brand,
4056
- }),
4057
- ...(filters.ingredients && {
4058
- ingredients: filters.ingredients,
4059
- }),
4060
- };
4061
- },
4062
- bindPersistData: (descriptionData) => ({
4063
- ...(descriptionData?.description && { description: descriptionData.description }),
4064
- ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
4065
- ...(descriptionData.whoMustUse && {
4066
- who_must_use: descriptionData.whoMustUse,
4067
- }),
4068
- ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
4069
- ...(descriptionData.brand && { brand_description: descriptionData.brand }),
4070
- ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
4071
- }),
4072
- },
4073
- },
4074
- { differentials: { columnName: 'differentials' } },
4075
- { whoMustUse: { columnName: 'who_must_use' } },
4076
- { howToUse: { columnName: 'how_to_use' } },
4077
- { brandDescription: { columnName: 'brand_description' } },
4078
- { ingredients: { columnName: 'ingredients' } },
4079
- { hasVariants: { columnName: 'has_variants' } },
4080
- {
4081
- images: {
4082
- columnName: 'images',
4083
- to: (value) => (value?.length > 0 ? `{"${value?.join?.(`","`) || ''}"}` : `{}`),
4084
- },
4085
- },
4086
- {
4087
- miniatures: {
4088
- columnName: 'miniatures',
4089
- to: (value) => (value?.length > 0 ? `{"${value?.join?.(`","`) || ''}"}` : `{}`),
4090
- },
4091
- },
4092
- 'name',
4093
- {
4094
- price: {
4095
- columnName: 'price',
4096
- from: (price, data) => ({
4097
- price,
4098
- fullPrice: data.full_price,
4099
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
4100
- subscriberPrice: data.subscriber_price,
4101
- }),
4102
- bindFindFilter: (filters) => {
4103
- return {
4104
- ...((filters?.price || filters?.price === 0) && { price: filters.price }),
4105
- ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
4106
- ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
4107
- subscriber_discount_percentage: filters.subscriberDiscountPercentage,
4108
- }),
4109
- ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
4110
- subscriber_price: filters.subscriberPrice,
4111
- }),
4112
- };
4113
- },
4114
- bindPersistData: (priceData) => ({
4115
- ...(priceData?.price >= 0 && { price: priceData.price }),
4116
- ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
4117
- ...(priceData.subscriberDiscountPercentage >= 0 && {
4118
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4119
- }),
4120
- ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
4121
- }),
4122
- },
4123
- },
4124
- { fullPrice: { columnName: 'full_price' } },
4125
- { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
4126
- { subscriberPrice: { columnName: 'subscriber_price' } },
4127
- 'published',
4128
- 'sku',
4129
- {
4130
- stock: {
4131
- columnName: 'stock',
4132
- from: (quantity) => ({ quantity }),
4133
- to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
4134
- },
4135
- },
4136
- { hasStock: { columnName: 'has_stock' } },
4137
- 'slug',
4138
- 'type',
4139
- 'video',
4140
- 'weight',
4141
- 'gender',
4142
- { intGender: { columnName: 'int_gender' } },
4143
- { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
4144
- { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
4145
- { isKit: { columnName: 'is_kit' } },
4146
- { createdAt: { columnName: 'created_at' } },
4147
- { updatedAt: { columnName: 'updated_at' } },
4148
- { rate: { columnName: 'rating' } },
4149
- { reviewsTotal: { columnName: 'reviews_total' } },
4150
- { shoppingCount: { columnName: 'shopping_count' } },
4151
- { categoryId: { columnName: 'category_id' } },
4152
- {
4153
- category: {
4154
- columnName: 'category',
4155
- foreignKeyColumn: { id: 'categoryId' },
4156
- fields: ['id', 'name', 'reference', 'slug'],
4157
- },
4158
- },
4159
- ];
4160
- this.fields = [
4161
- ...commonFields,
4162
- {
4163
- categories: {
4164
- columnName: 'categories',
4165
- fields: ['category_id'],
4166
- bindPersistData: (value) => ({
4167
- categories: { data: value.map((category) => ({ category_id: +category })) },
4168
- }),
4169
- to: (categories) => categories.map((categoryId) => +categoryId),
4170
- from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
4171
- },
4172
- },
4173
- {
4174
- kitProducts: {
4175
- columnName: 'kit_products',
4176
- foreignKeyColumn: { productId: 'id' },
4177
- fields: [
4178
- { productId: { columnName: 'product_id' } },
4179
- { kitProductId: { columnName: 'kit_product_id' } },
4180
- 'quantity',
4181
- { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
4182
- ],
4183
- },
4184
- },
4185
- {
4186
- reviews: {
4187
- columnName: 'reviews',
4188
- foreignKeyColumn: { product_id: 'id' },
4189
- fields: this.reviewsFields,
4190
- },
4191
- },
4192
- {
4193
- metadata: {
4194
- columnName: 'metadata',
4195
- fields: ['title', 'description'],
4196
- bindPersistData: (value) => ({
4197
- metadata: { data: value },
4198
- }),
4199
- },
4200
- },
4201
- ];
4202
- }
4203
- get reviewsFields() {
4204
- return [
4205
- 'id',
4206
- 'shop',
4207
- 'rate',
4208
- 'author',
4209
- 'email',
4210
- 'location',
4211
- 'review',
4212
- 'status',
4213
- 'title',
4214
- { personId: { columnName: 'person_id' } },
4215
- 'points',
4216
- { orderId: { columnName: 'order_id' } },
4217
- { createdAt: { columnName: 'created_at' } },
4218
- { updatedAt: { columnName: 'updated_at' } },
4219
- ];
4220
- }
4221
- async create(params) {
4222
- const { metadata, ...data } = params;
4223
- const product = await super.create(omit({ ...data, metadata: metadata || { description: null, title: null } }, ['reviews']));
4224
- try {
4225
- product.reviews = data.reviews && (await this.updateReviews(+product.id, data));
4226
- }
4227
- catch (error) {
4228
- await this.delete({ id: product.id });
4229
- throw error;
4230
- }
4231
- return product;
4232
- }
4233
- async get(identifiers) {
4234
- const product = Number.isNaN(+identifiers.id)
4235
- ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
4236
- : await super.get(identifiers);
4237
- if (product.productId)
4238
- throw new NotFoundError('Product not found, it is a variant');
4239
- product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id));
4240
- return product;
4241
- }
4242
- async find(params) {
4243
- const { filters, fields, ...options } = params || {};
4244
- const bindFields = fields ||
4245
- this.fields
4246
- .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
4247
- .filter((field) => field !== 'reviews');
4248
- if (options.options?.minimal?.includes('price'))
4249
- options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4250
- if (options.options?.maximum?.includes('price'))
4251
- options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4252
- options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
4253
- options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
4254
- return super.find({
4255
- ...options,
4256
- filters: { ...filters, productId: { operator: Where.ISNULL } },
4257
- fields: [
4258
- ...bindFields,
4259
- ...(bindFields.includes('price')
4260
- ? [
4261
- 'subscriberPrice',
4262
- 'subscriberDiscountPercentage',
4263
- 'fullPrice',
4264
- ]
4265
- : []),
4266
- ],
4267
- });
4268
- }
4269
- async getBySlug(slug) {
4270
- const result = await this.find({
4271
- filters: {
4272
- slug,
4273
- },
4274
- fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
4275
- options: {
4276
- enableCount: false,
4277
- },
4278
- });
4279
- const product = result?.data?.shift();
4280
- RoundProductPricesHelper.roundProductPrices(product);
4281
- return product;
4282
- }
4283
- async update(params) {
4284
- const { categories, kitProducts, reviews, id: checkId, rate, metadata, ...data } = params;
4285
- const plainData = this.paramsToPlain({ id: checkId });
4286
- const id = await this.getId(plainData.id);
4287
- const product = await super.update({ id, ...data });
4288
- product.categories = categories && (await this.updateCategories(+id, { categories }));
4289
- product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
4290
- product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
4291
- product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4292
- return product;
4293
- }
4294
- async fetchReviews(status) {
4295
- const reviewsExpression = {
4296
- status: status === 'pending'
4297
- ? { [HasuraGraphQLWhere.ISNULL]: true }
4298
- : { [HasuraGraphQLWhere.EQUALS]: status === 'approved' },
4299
- };
4300
- const { product: data } = await this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
4301
- where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
4302
- });
4303
- return data.reduce((reviews, product) => [
4304
- ...reviews,
4305
- ...product.reviews
4306
- .filter((review) => (status === 'pending' && [undefined, null].includes(review.status)) ||
4307
- (status === 'approved' && review.status === true) ||
4308
- (status === 'rejected' && review.status === false))
4309
- .map((review) => ({
4310
- ...this.bindReviewToModel(review),
4311
- productId: product.id,
4312
- productName: product.name,
4313
- productSku: product.sku,
4314
- })),
4315
- ], []);
4316
- }
4317
- async findCatalog(params, mainGender) {
4318
- return this.find({
4319
- ...params,
4320
- filters: { ...params.filters, published: true },
4321
- orderBy: {
4322
- hasStock: 'desc',
4323
- ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
4324
- ...omit(params.orderBy, ['hasStock', 'intGender']),
4325
- },
4326
- });
4327
- }
4328
- async updateCategories(productId, { categories }) {
4329
- if ('action' in categories && categories.action === 'remove') {
4330
- await this.mutation('delete_category_product', ['affected_rows'], {
4331
- where: {
4332
- type: 'category_product_bool_exp',
4333
- required: true,
4334
- value: { product_id: { _eq: productId } },
4335
- },
4336
- });
4337
- return [];
4338
- }
4339
- const plainData = this.paramsToPlain({ categories });
4340
- if (!plainData.categories || plainData.categories.length <= 0)
4341
- return [];
4342
- await this.mutation('delete_category_product', ['affected_rows'], {
4343
- where: {
4344
- type: 'category_product_bool_exp',
4345
- required: true,
4346
- value: { product_id: { _eq: productId } },
4347
- },
4348
- });
4349
- await this.mutation('insert_category_product', ['affected_rows'], {
4350
- objects: {
4351
- type: '[category_product_insert_input!]',
4352
- required: true,
4353
- value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4354
- },
4355
- });
4356
- return plainData.categories;
4357
- }
4358
- async updateKitProducts(productId, { kitProducts }) {
4359
- const plainData = this.paramsToPlain({ kitProducts });
4360
- await this.mutation('delete_product_kit', ['affected_rows'], {
4361
- where: {
4362
- type: 'product_kit_bool_exp',
4363
- required: true,
4364
- value: { kit_product_id: { _eq: productId } },
4365
- },
4366
- });
4367
- await this.mutation('insert_product_kit', ['affected_rows'], {
4368
- objects: {
4369
- type: '[product_kit_insert_input!]',
4370
- required: true,
4371
- value: plainData.kitProducts.map((kitProduct) => ({
4372
- kit_product_id: productId,
4373
- product_id: kitProduct.productId || kitProduct.product.id,
4374
- quantity: kitProduct.quantity,
4375
- })),
4376
- },
4377
- });
4378
- return plainData.kitProducts;
4379
- }
4380
- async updateReviews(productId, { reviews }) {
4381
- if (!reviews)
4382
- return [];
4383
- if ('action' in reviews && reviews.action === 'remove') {
4384
- const reviewIds = await Promise.all(reviews.value.map(async (reviewData) => {
4385
- const review = await this.findReview(reviewData, productId);
4386
- return review?.id;
4387
- }));
4388
- await this.mutation('delete_product_review', ['affected_rows'], {
4389
- where: { value: { id: { _in: reviewIds.filter(Boolean) } }, type: 'product_review_bool_exp', required: true },
4390
- });
4391
- return reviews.value.map((review, index) => !reviewIds[index] && review).filter(Boolean);
4392
- }
4393
- const plainData = this.paramsToPlain({ reviews });
4394
- if (!plainData.reviews || plainData.reviews.length <= 0)
4395
- return [];
4396
- return Promise.all(plainData.reviews.map(async (reviewData) => {
4397
- const review = await this.findReview(reviewData, productId);
4398
- if (review.id)
4399
- return this.bindReviewToModel((await this.mutation('update_product_review_by_pk', this.reviewsFields, {
4400
- pk_columns: {
4401
- value: { id: review.id },
4402
- type: 'product_review_pk_columns_input',
4403
- required: true,
4404
- },
4405
- _set: {
4406
- value: omit(this.bindReviewToHasura(reviewData), ['id', 'product_id']),
4407
- type: 'product_review_set_input',
4408
- required: true,
4409
- },
4410
- })).update_product_review_by_pk);
4411
- return this.bindReviewToModel((await this.mutation('insert_product_review_one', this.reviewsFields, {
4412
- object: {
4413
- value: omit({ ...this.bindReviewToHasura(reviewData), product_id: productId }, ['id']),
4414
- type: 'product_review_insert_input',
4415
- required: true,
4416
- },
4417
- })).insert_product_review_one);
4418
- }));
4419
- }
4420
- async updateMetadata(productId, { metadata }) {
4421
- const plainData = this.paramsToPlain({ metadata });
4422
- if (!plainData.metadata)
4423
- return null;
4424
- await this.mutation('update_product_metadata_by_pk', ['product_id'], {
4425
- pk_columns: {
4426
- value: { product_id: productId },
4427
- type: 'product_metadata_pk_columns_input',
4428
- required: true,
4429
- },
4430
- _set: {
4431
- value: omit(metadata, ['product_id']),
4432
- type: 'product_metadata_set_input',
4433
- required: true,
4434
- },
4435
- });
4436
- return plainData.metadata;
4437
- }
4438
- async getId(id) {
4439
- if (!Number.isNaN(+id))
4440
- return id;
4441
- const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
4442
- if (data?.[0]?.id)
4443
- return data?.[0]?.id;
4444
- throw new NotFoundError(`Product with id ${id} not found`);
4445
- }
4446
- async findReviewsByProduct(productId) {
4447
- const { product_review: data } = await this.query('product_review', this.reviewsFields, {
4448
- where: {
4449
- value: {
4450
- product_id: { _eq: productId },
4451
- },
4452
- type: 'product_review_bool_exp',
4453
- required: true,
4454
- },
4455
- });
4456
- return data && data.map((review) => this.bindReviewToModel(review));
4457
- }
4458
- async findReview(review, productId) {
4459
- if (review.id)
4460
- return review;
4461
- let loadedReview;
4462
- if (review.personId)
4463
- loadedReview = await this.getReviewByPersonId(review.personId, productId, review.orderId);
4464
- if (!loadedReview && review.author && review.email)
4465
- loadedReview = await this.getReviewByAuthorAndEmail(review.author, review.email, productId, review.orderId);
4466
- return loadedReview || review;
4467
- }
4468
- async getReviewByPersonId(personId, productId, orderId) {
4469
- const { product_review: data } = await this.query('product_review', this.reviewsFields, {
4470
- where: {
4471
- value: {
4472
- product_id: { _eq: productId },
4473
- person_id: { _eq: personId },
4474
- ...(orderId && { order_id: { _eq: orderId } }),
4475
- },
4476
- type: `product_review_bool_exp`,
4477
- required: true,
4478
- },
4479
- });
4480
- return data && data[0] && this.bindReviewToModel(data[0]);
4481
- }
4482
- async getReviewByAuthorAndEmail(author, email, productId, orderId) {
4483
- const { product_review: data } = await this.query('product_review', this.reviewsFields, {
4484
- where: {
4485
- value: {
4486
- product_id: { _eq: productId },
4487
- author: { _eq: author },
4488
- email: { _eq: email },
4489
- ...(orderId && { order_id: { _eq: orderId } }),
4490
- },
4491
- type: `product_review_bool_exp`,
4492
- required: true,
4493
- },
4494
- });
4495
- return data && data[0] && this.bindReviewToModel(data[0]);
4496
- }
4497
- async cleanShoppingCountFromIds(ids) {
4498
- return await this.mutation('update_product', ['affected_rows'], {
4499
- where: {
4500
- value: { id: { _nin: ids } },
4501
- type: 'product_bool_exp',
4502
- required: true,
4503
- },
4504
- _set: {
4505
- value: { shopping_count: 0 },
4506
- type: 'product_set_input',
4507
- },
4508
- });
4509
- }
4510
- }
4511
-
4512
- class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4513
- constructor({ endpoint, authOptions, interceptors, }) {
4514
- super({
4515
- tableName: 'product',
4516
- model: VariantHasuraGraphQL,
4517
- endpoint,
4518
- authOptions,
4519
- interceptors,
4520
- fields: [
4521
- { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4522
- { firestoreId: { columnName: 'firestore_id' } },
4523
- {
4524
- productId: {
4525
- columnName: 'main_product_id',
4526
- to: (value) => +value,
4527
- from: (value) => value?.toString(),
4528
- },
4529
- },
4530
- { EAN: { columnName: 'ean' } },
4531
- { costPrice: { columnName: 'cost_price' } },
4532
- {
4533
- price: {
4534
- columnName: 'price',
4535
- from: (price, data) => ({
4536
- price,
4537
- fullPrice: data.full_price,
4538
- subscriberDiscountPercentage: data.subscriber_discount_percentage,
4539
- subscriberPrice: data.subscriber_price,
4540
- }),
4541
- bindFindFilter: (sentence) => {
4542
- const filters = Object.values(sentence).shift();
4543
- return {
4544
- ...((filters?.price || filters?.price === 0) && { price: filters.price }),
4545
- ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
4546
- ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
4547
- subscriber_discount_percentage: filters.subscriberDiscountPercentage,
4548
- }),
4549
- ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
4550
- subscriber_price: filters.subscriberPrice,
4551
- }),
4552
- };
4553
- },
4554
- bindPersistData: (priceData) => ({
4555
- ...((priceData?.price || 0) >= 0 && { price: priceData.price }),
4556
- ...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
4557
- ...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
4558
- subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4559
- }),
4560
- ...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
4561
- }),
4562
- },
4563
- },
4564
- { fullPrice: { columnName: 'full_price' } },
4565
- { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
4566
- { subscriberPrice: { columnName: 'subscriber_price' } },
4567
- 'sku',
4568
- {
4569
- stock: {
4570
- columnName: 'stock',
4571
- from: (quantity) => ({ quantity }),
4572
- to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
4573
- },
4574
- },
4575
- { hasStock: { columnName: 'has_stock' } },
4576
- 'weight',
4577
- { name: { to: () => '', from: () => undefined } },
4578
- { hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
4579
- { createdAt: { columnName: 'created_at' } },
4580
- { updatedAt: { columnName: 'updated_at' } },
4581
- {
4582
- grade: {
4583
- columnName: 'grade',
4584
- type: HasuraGraphQLColumnType.Jsonb,
4585
- },
4586
- },
4587
- ],
4588
- });
4589
- }
4590
- async get(identifiers) {
4591
- const variant = Number.isNaN(+identifiers.id)
4592
- ? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
4593
- : await super.get(identifiers);
4594
- if (!variant.productId)
4595
- throw new NotFoundError(`Variant not found, it is a product`);
4596
- return variant;
4597
- }
4598
- async find(params) {
4599
- const { filters, ...options } = params || {};
4600
- return super.find({ ...options, filters: { productId: { operator: Where.ISNOTNULL }, ...filters } });
4601
- }
4602
- async update(params) {
4603
- const { productId, id: checkId, ...data } = params;
4604
- const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
4605
- const id = await this.getId(dataWithProductId.id);
4606
- const product = await super.update({ id, ...data });
4607
- product.productId = dataWithProductId.productId;
4608
- return product;
4609
- }
4610
- async getId(id) {
4611
- if (!Number.isNaN(+id))
4612
- return id;
4613
- const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
4614
- if (data?.[0]?.id)
4615
- return data?.[0]?.id;
4616
- throw new NotFoundError(`Product with id ${id} not found`);
4617
- }
4618
- }
4619
-
4620
- class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4621
- constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
4622
- super({
4623
- tableName: 'category',
4624
- model: Wishlist,
4625
- endpoint,
4626
- authOptions,
4627
- interceptors,
4628
- fields: [
4629
- { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4630
- { firestoreId: { columnName: 'firestore_id' } },
4631
- 'name',
4632
- 'description',
4633
- 'image',
4634
- 'published',
4635
- 'shop',
4636
- { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
4637
- 'slug',
4638
- { brandCategory: { columnName: 'brand_category' } },
4639
- { brandCategoryBanner: { columnName: 'brand_banner' } },
4640
- { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
4641
- { brandLogo: { columnName: 'brand_logo' } },
4642
- { brandCondition: { columnName: 'brand_condition' } },
4643
- {
4644
- conditions: {
4645
- columnName: 'tag_condition',
4646
- type: HasuraGraphQLColumnType.Jsonb,
4647
- from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
4648
- bindPersistData: (value) => {
4649
- return {
4650
- brand_condition: value.brand,
4651
- tag_condition: value?.tags || [],
4652
- };
4653
- },
4654
- bindFindFilter: (sentence) => {
4655
- return {
4656
- ...(sentence.brand ? { brand_condition: sentence.brand } : {}),
4657
- ...(sentence.tags ? { tag_condition: sentence.tags } : {}),
4658
- };
4659
- },
4660
- },
4661
- },
4662
- {
4663
- filters: {
4664
- columnName: 'filters',
4665
- foreignKeyColumn: { filter_id: 'id' },
4666
- fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4667
- bindPersistData: (value) => ({
4668
- filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4669
- }),
4670
- from: (filters) => filters?.map((filter) => filter?.filter) || [],
4671
- },
4672
- },
4673
- { createdAt: { columnName: 'created_at' } },
4674
- { updatedAt: { columnName: 'updated_at' } },
4675
- {
4676
- products: {
4677
- columnName: 'products',
4678
- fields: ['product_id'],
4679
- from: (value) => value.map((product) => product.product_id.toString()),
4680
- to: (productIds) => productIds.map((productId) => ({
4681
- product_id: +productId,
4682
- })),
4683
- },
4684
- },
4685
- {
4686
- metadata: {
4687
- columnName: 'metadata',
4688
- fields: ['title', 'description'],
4689
- bindPersistData: (value) => ({
4690
- metadata: { data: value },
4691
- }),
4692
- },
4693
- },
4694
- { isCollection: { columnName: 'is_collection' } },
4695
- { isWishlist: { columnName: 'is_wishlist' } },
4696
- 'reference',
4697
- { parentId: { columnName: 'parent_id' } },
4698
- {
4699
- parent: {
4700
- columnName: 'parent',
4701
- foreignKeyColumn: { id: 'parentId' },
4702
- fields: ['id', 'name', 'reference', 'slug'],
4703
- },
4704
- },
4705
- { personId: { columnName: 'person_id' } },
4706
- ],
4707
- });
4708
- this.categoryFilterRepository = categoryFilterRepository;
4709
- }
4710
- async create(params) {
4711
- const { metadata, ...data } = params;
4712
- return super.create({
4713
- ...data,
4714
- isWishlist: true,
4715
- isCollection: true,
4716
- brandCategory: false,
4717
- metadata: metadata || { description: data.description, title: data.name },
4718
- });
4719
- }
4720
- async get(identifiers) {
4721
- const data = await super.get(identifiers);
4722
- if (!data.isWishlist)
4723
- throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
4724
- return data;
4725
- }
4726
- async update(params) {
4727
- const { products, id: checkId, metadata, filters, ...data } = params;
4728
- const plainData = this.paramsToPlain({ id: checkId });
4729
- const id = plainData.id;
4730
- const category = await super.update({ id, ...data, isWishlist: true, isCollection: true, brandCategory: false });
4731
- category.products = products && (await this.updateProducts(+id, { products }));
4732
- category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4733
- return category;
4734
- }
4735
- async getWishlistBySlug(slug) {
4736
- if (!slug)
4737
- return;
4738
- const { data } = await this.find({
4739
- filters: {
4740
- slug,
4741
- isWishlist: { operator: Where.EQUALS, value: true },
4742
- },
4743
- options: {
4744
- enableCount: false,
4745
- },
4746
- });
4747
- if (!data.length)
4748
- throw new NotFoundError(`Wishlist with slug ${slug} not found`);
4749
- if (data.length > 1)
4750
- throw new DuplicatedResultsError('Query returned duplicated values');
4751
- return data.shift();
4752
- }
4753
- async getWishlistByPerson(personId) {
4754
- if (!personId)
4755
- return;
4756
- const { data } = await this.find({
4757
- filters: {
4758
- personId: { operator: Where.EQUALS, value: personId },
4759
- isWishlist: { operator: Where.EQUALS, value: true },
4760
- },
4761
- options: {
4762
- enableCount: false,
4763
- },
4764
- });
4765
- if (!data.length)
4766
- throw new NotFoundError(`Wishlists from person ${personId} not found`);
4767
- return data;
4768
- }
4769
- async updateProducts(categoryId, { products }) {
4770
- if ('action' in products && products.action === 'remove') {
4771
- await this.mutation('delete_category_product', ['affected_rows'], {
4772
- where: {
4773
- type: 'category_product_bool_exp',
4774
- required: true,
4775
- value: { category_id: { _eq: categoryId } },
4776
- },
4777
- });
4778
- await this.categoryFilterRepository.deleteByCategory(categoryId);
4779
- return [];
4780
- }
4781
- const plainData = this.paramsToPlain({ products });
4782
- if (!plainData.products || plainData.products.length <= 0)
4783
- return [];
4784
- await this.mutation('delete_category_product', ['affected_rows'], {
4785
- where: {
4786
- type: 'category_product_bool_exp',
4787
- required: true,
4788
- value: { category_id: { _eq: categoryId } },
4789
- },
4790
- });
4791
- await this.categoryFilterRepository.deleteByCategory(categoryId);
4792
- await this.mutation('insert_category_product', ['affected_rows'], {
4793
- objects: {
4794
- type: '[category_product_insert_input!]',
4795
- required: true,
4796
- value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4797
- },
4798
- });
4799
- return plainData.products;
4800
- }
4801
- async updateMetadata(categoryId, { metadata }) {
4802
- const plainData = this.paramsToPlain({ metadata });
4803
- if (!plainData.metadata)
4804
- return;
4805
- await this.mutation('update_category_metadata_by_pk', ['category_id'], {
4806
- pk_columns: {
4807
- value: { category_id: categoryId },
4808
- type: 'category_metadata_pk_columns_input',
4809
- required: true,
4810
- },
4811
- _set: {
4812
- value: omit(metadata, ['category_id']),
4813
- type: 'category_metadata_set_input',
4814
- required: true,
4815
- },
4816
- });
4817
- return plainData.metadata;
4818
- }
4819
- getCategoryBySlug(slug, _shop) {
4820
- return this.getWishlistBySlug(slug);
4821
- }
4822
- async getCategoryByShop(shop) {
4823
- if (!shop)
4824
- return;
4825
- const { data } = await this.find({
4826
- filters: {
4827
- shops: { operator: Where.IN, value: [shop] },
4828
- published: { operator: Where.EQUALS, value: true },
4829
- isWishlist: { operator: Where.EQUALS, value: true },
4830
- },
4831
- options: {
4832
- enableCount: false,
4833
- },
4834
- });
4835
- return data;
4836
- }
4837
- getCategoriesForHome(categoryIds, limit, gender) {
4838
- return;
4839
- }
4840
- mountCategory(category, options) {
4841
- return;
4842
- }
4843
- getChildren(parentId) {
4844
- return;
4845
- }
4846
- isChild(id, parentId) {
4847
- return;
4848
- }
4849
- }
4850
-
4851
- /**
4852
- * Generated bundle index. Do not edit.
4853
- */
4854
-
4855
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, CampaignDashboard, CampaignDashboardFirestoreRepository, CampaignHashtag, CampaignHashtagFirestoreRepository, Category, CategoryCollectionChildren, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryFilter, CategoryFilterHasuraGraphQLRepository, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClassNameHelper, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, Debug, DebugDecoratorHelper, DebugHelper, DebugNamespaces, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, Filter, FilterHasuraGraphQLRepository, FilterOption, FilterOptionHasuraGraphQLRepository, FilterType, FragranceImportances, GenderDestination, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, Log, Logger, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, ReflectHelper, Register, RegisterFirebaseAuthService, RequiredArgumentError, RoundProductPricesHelper, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, ShopSettings, ShopSettingsFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, Trace, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, Wishlist, WishlistHasuraGraphQLRepository, is, isDebuggable, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
4856
- //# sourceMappingURL=infrab4a-connect.mjs.map