@infrab4a/connect 4.0.1-beta.3 → 4.0.1

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/domain/catalog/helpers/index.d.ts +1 -0
  3. package/domain/catalog/helpers/round-product-price.helper.d.ts +4 -0
  4. package/domain/catalog/index.d.ts +3 -2
  5. package/domain/catalog/models/category-base.d.ts +30 -0
  6. package/domain/catalog/models/category-collection-children.d.ts +13 -0
  7. package/domain/catalog/models/category-filter.d.ts +13 -0
  8. package/domain/catalog/models/category-for-product.d.ts +5 -0
  9. package/domain/catalog/models/category.d.ts +7 -24
  10. package/domain/catalog/models/enums/index.d.ts +2 -2
  11. package/domain/catalog/models/enums/product-genders.enum.d.ts +5 -5
  12. package/domain/catalog/models/enums/shops.enum.d.ts +6 -6
  13. package/domain/catalog/models/filter-option.d.ts +9 -0
  14. package/domain/catalog/models/filter.d.ts +12 -0
  15. package/domain/catalog/models/index.d.ts +11 -6
  16. package/domain/catalog/models/kit-product.d.ts +12 -12
  17. package/domain/catalog/models/product-base.d.ts +40 -0
  18. package/domain/catalog/models/product-for-category.d.ts +7 -0
  19. package/domain/catalog/models/product-for-kit.d.ts +7 -0
  20. package/domain/catalog/models/product.d.ts +9 -39
  21. package/domain/catalog/models/types/category-condition.type.d.ts +4 -4
  22. package/domain/catalog/models/types/category-metadata.type.d.ts +4 -4
  23. package/domain/catalog/models/types/category-product.d.ts +4 -0
  24. package/domain/catalog/models/types/index.d.ts +11 -10
  25. package/domain/catalog/models/types/product-evaluation.type.d.ts +6 -0
  26. package/domain/catalog/models/types/product-gender.type.d.ts +1 -1
  27. package/domain/catalog/models/types/product-metadata.type.d.ts +4 -4
  28. package/domain/catalog/models/types/product-review.type.d.ts +17 -17
  29. package/domain/catalog/models/types/shop-description.type.d.ts +8 -7
  30. package/domain/catalog/models/types/shop-price.type.d.ts +6 -6
  31. package/domain/catalog/models/types/stock.type.d.ts +3 -3
  32. package/domain/catalog/models/types/variant-grade.type.d.ts +4 -4
  33. package/domain/catalog/models/variant.d.ts +17 -18
  34. package/domain/catalog/models/wishlist.d.ts +8 -0
  35. package/domain/catalog/repositories/category-collection-children.repository.d.ts +4 -0
  36. package/domain/catalog/repositories/category-filter.repository.d.ts +6 -0
  37. package/domain/catalog/repositories/category.repository.d.ts +18 -15
  38. package/domain/catalog/repositories/filter-option.repository.d.ts +4 -0
  39. package/domain/catalog/repositories/filter.repository.d.ts +4 -0
  40. package/domain/catalog/repositories/index.d.ts +9 -4
  41. package/domain/catalog/repositories/product.repository.d.ts +15 -12
  42. package/domain/catalog/repositories/subscription-product.repository.d.ts +4 -4
  43. package/domain/catalog/repositories/variant.repository.d.ts +4 -4
  44. package/domain/catalog/repositories/wishlist.repository.d.ts +6 -0
  45. package/domain/generic/index.d.ts +2 -2
  46. package/domain/generic/model/base.model.d.ts +14 -10
  47. package/domain/generic/model/identifier-fields.d.ts +4 -4
  48. package/domain/generic/model/index.d.ts +3 -3
  49. package/domain/generic/model/types/base-model-builder.type.d.ts +17 -15
  50. package/domain/generic/model/types/identifier-model.type.d.ts +8 -7
  51. package/domain/generic/model/types/index.d.ts +5 -5
  52. package/domain/generic/model/types/model-base-structure.type.d.ts +12 -6
  53. package/domain/generic/model/types/non-function-properties.type.d.ts +12 -12
  54. package/domain/generic/model/types/non-function-property-name.type.d.ts +13 -4
  55. package/domain/generic/repository/create.repository.d.ts +8 -8
  56. package/domain/generic/repository/crud.repository.d.ts +19 -19
  57. package/domain/generic/repository/delete.repository.d.ts +7 -7
  58. package/domain/generic/repository/enums/index.d.ts +2 -2
  59. package/domain/generic/repository/enums/update-option-actions.enum.d.ts +7 -7
  60. package/domain/generic/repository/enums/where.enum.d.ts +14 -14
  61. package/domain/generic/repository/find.repository.d.ts +17 -11
  62. package/domain/generic/repository/get.repository.d.ts +5 -5
  63. package/domain/generic/repository/index.d.ts +9 -9
  64. package/domain/generic/repository/read.repository.d.ts +14 -14
  65. package/domain/generic/repository/types/index.d.ts +6 -6
  66. package/domain/generic/repository/types/repository-find-filters.type.d.ts +13 -13
  67. package/domain/generic/repository/types/repository-find-result.type.d.ts +14 -4
  68. package/domain/generic/repository/types/repository-limit-options.type.d.ts +4 -4
  69. package/domain/generic/repository/types/repository-order-by-list.type.d.ts +5 -5
  70. package/domain/generic/repository/types/repository-update-params.type.d.ts +11 -11
  71. package/domain/generic/repository/types/where-options.type.d.ts +2 -2
  72. package/domain/generic/repository/update.repository.d.ts +6 -6
  73. package/domain/index.d.ts +6 -6
  74. package/domain/location/index.d.ts +1 -1
  75. package/domain/location/models/address.d.ts +24 -22
  76. package/domain/location/models/index.d.ts +2 -2
  77. package/domain/location/models/types/index.d.ts +3 -3
  78. package/domain/location/models/types/location-bound.type.d.ts +6 -6
  79. package/domain/location/models/types/location-geometry.type.d.ts +7 -7
  80. package/domain/location/models/types/location-lat-lng.type.d.ts +4 -4
  81. package/domain/shop-settings/enums/filter-type.enum.d.ts +19 -19
  82. package/domain/shop-settings/enums/index.d.ts +2 -2
  83. package/domain/shop-settings/enums/questions-filters.enum.d.ts +19 -19
  84. package/domain/shop-settings/helpers/beauty-questions.helper.d.ts +9 -9
  85. package/domain/shop-settings/helpers/index.d.ts +1 -1
  86. package/domain/shop-settings/index.d.ts +4 -4
  87. package/domain/shop-settings/models/home.d.ts +18 -18
  88. package/domain/shop-settings/models/index.d.ts +4 -4
  89. package/domain/shop-settings/models/shop-menu.d.ts +7 -7
  90. package/domain/shop-settings/models/shop-settings.d.ts +9 -9
  91. package/domain/shop-settings/models/types/banner.type.d.ts +6 -6
  92. package/domain/shop-settings/models/types/benefit.type.d.ts +5 -5
  93. package/domain/shop-settings/models/types/home-data.type.d.ts +15 -15
  94. package/domain/shop-settings/models/types/index.d.ts +10 -10
  95. package/domain/shop-settings/models/types/menu-nav.type.d.ts +8 -8
  96. package/domain/shop-settings/models/types/shop-banner.type.d.ts +12 -12
  97. package/domain/shop-settings/models/types/shop-brands.type.d.ts +10 -10
  98. package/domain/shop-settings/models/types/shop-carousel.type.d.ts +5 -5
  99. package/domain/shop-settings/models/types/shop-collection.type.d.ts +9 -9
  100. package/domain/shop-settings/models/types/shop-section.type.d.ts +9 -9
  101. package/domain/shop-settings/models/types/sub-menu.type.d.ts +8 -8
  102. package/domain/shop-settings/repositories/home.repository.d.ts +4 -4
  103. package/domain/shop-settings/repositories/index.d.ts +3 -3
  104. package/domain/shop-settings/repositories/shop-menu.repository.d.ts +4 -4
  105. package/domain/shop-settings/repositories/shop-settings.repository.d.ts +4 -4
  106. package/domain/shopping/index.d.ts +2 -2
  107. package/domain/shopping/models/buy-2-win.d.ts +18 -16
  108. package/domain/shopping/models/campaign-dashboard.d.ts +15 -0
  109. package/domain/shopping/models/campaign-hashtag.d.ts +18 -0
  110. package/domain/shopping/models/checkout.d.ts +26 -27
  111. package/domain/shopping/models/coupons/coupon.d.ts +60 -32
  112. package/domain/shopping/models/coupons/enums/coupon-club-mens.enum.d.ts +5 -5
  113. package/domain/shopping/models/coupons/enums/coupon-subtypes.enum.d.ts +4 -4
  114. package/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +4 -4
  115. package/domain/shopping/models/coupons/enums/exclusivities.enum.d.ts +8 -8
  116. package/domain/shopping/models/coupons/enums/index.d.ts +3 -3
  117. package/domain/shopping/models/coupons/index.d.ts +2 -2
  118. package/domain/shopping/models/enums/checkout-types.enum.d.ts +5 -5
  119. package/domain/shopping/models/enums/index.d.ts +2 -2
  120. package/domain/shopping/models/enums/order-status.enum.d.ts +10 -10
  121. package/domain/shopping/models/index.d.ts +12 -11
  122. package/domain/shopping/models/line-item.d.ts +8 -8
  123. package/domain/shopping/models/order.d.ts +10 -9
  124. package/domain/shopping/models/payment.d.ts +67 -67
  125. package/domain/shopping/models/shipping-method.d.ts +17 -16
  126. package/domain/shopping/models/subscription/checkout.d.ts +20 -21
  127. package/domain/shopping/models/subscription/index.d.ts +2 -2
  128. package/domain/shopping/models/subscription/plan.d.ts +10 -10
  129. package/domain/shopping/models/types/index.d.ts +7 -7
  130. package/domain/shopping/models/types/payment-address.type.d.ts +12 -12
  131. package/domain/shopping/models/types/payment-billing.type.d.ts +7 -7
  132. package/domain/shopping/models/types/payment-card.type.d.ts +14 -14
  133. package/domain/shopping/models/types/payment-customer.type.d.ts +18 -18
  134. package/domain/shopping/models/types/payment-document.type.d.ts +6 -6
  135. package/domain/shopping/models/types/payment-item.type.d.ts +11 -11
  136. package/domain/shopping/models/types/payment-shipping.type.d.ts +10 -10
  137. package/domain/shopping/repositories/buy-2-win.repository.d.ts +4 -4
  138. package/domain/shopping/repositories/campaign-dashboard.repository.d.ts +4 -0
  139. package/domain/shopping/repositories/campaign-hashtag.repository.d.ts +4 -0
  140. package/domain/shopping/repositories/checkout.repository.d.ts +4 -4
  141. package/domain/shopping/repositories/coupon.repository.d.ts +4 -4
  142. package/domain/shopping/repositories/index.d.ts +9 -7
  143. package/domain/shopping/repositories/legacy-order.repository.d.ts +3 -3
  144. package/domain/shopping/repositories/order.repository.d.ts +4 -4
  145. package/domain/shopping/repositories/payment.repository.d.ts +4 -4
  146. package/domain/shopping/repositories/subscription/checkout.repository.d.ts +4 -4
  147. package/domain/shopping/repositories/subscription/index.d.ts +2 -2
  148. package/domain/shopping/repositories/subscription/plan.repository.d.ts +4 -4
  149. package/domain/users/errors/index.d.ts +3 -3
  150. package/domain/users/errors/unauthorized.error.d.ts +4 -5
  151. package/domain/users/errors/user-already-registered.error.d.ts +4 -5
  152. package/domain/users/errors/weak-password.error.d.ts +4 -5
  153. package/domain/users/index.d.ts +5 -5
  154. package/domain/users/models/beauty-profile.d.ts +11 -11
  155. package/domain/users/models/enums/accessory-importances.enum.d.ts +5 -5
  156. package/domain/users/models/enums/area.enum.d.ts +11 -11
  157. package/domain/users/models/enums/beard-problems.enum.d.ts +9 -9
  158. package/domain/users/models/enums/beard-sizes.enum.d.ts +7 -7
  159. package/domain/users/models/enums/beauty-product-importances.enum.d.ts +6 -6
  160. package/domain/users/models/enums/body-problems.enum.d.ts +11 -11
  161. package/domain/users/models/enums/body-shapes.enum.d.ts +7 -7
  162. package/domain/users/models/enums/body-tattoos.enum.d.ts +5 -5
  163. package/domain/users/models/enums/face-skin-oilinesses.enum.d.ts +7 -7
  164. package/domain/users/models/enums/face-skin-problems.enum.d.ts +10 -10
  165. package/domain/users/models/enums/face-skin-tones.enum.d.ts +8 -8
  166. package/domain/users/models/enums/family-incomes.enum.d.ts +8 -8
  167. package/domain/users/models/enums/fragrance-importances.enum.d.ts +5 -5
  168. package/domain/users/models/enums/hair-colors.enum.d.ts +10 -10
  169. package/domain/users/models/enums/hair-problems.enum.d.ts +10 -10
  170. package/domain/users/models/enums/hair-strands.enum.d.ts +8 -8
  171. package/domain/users/models/enums/hair-types.enum.d.ts +7 -7
  172. package/domain/users/models/enums/index.d.ts +20 -20
  173. package/domain/users/models/enums/office-position.enum.d.ts +6 -6
  174. package/domain/users/models/enums/product-spents.enum.d.ts +8 -8
  175. package/domain/users/models/enums/user-type.enum.d.ts +8 -8
  176. package/domain/users/models/index.d.ts +7 -7
  177. package/domain/users/models/lead.d.ts +8 -7
  178. package/domain/users/models/subscription/edition.d.ts +16 -16
  179. package/domain/users/models/subscription/enums/billing-status.enum.d.ts +3 -3
  180. package/domain/users/models/subscription/enums/edition-status.enum.d.ts +4 -4
  181. package/domain/users/models/subscription/enums/index.d.ts +4 -4
  182. package/domain/users/models/subscription/enums/payment-type.enum.d.ts +5 -5
  183. package/domain/users/models/subscription/enums/status.enum.d.ts +4 -4
  184. package/domain/users/models/subscription/index.d.ts +4 -4
  185. package/domain/users/models/subscription/payment.d.ts +13 -13
  186. package/domain/users/models/subscription/subscription.d.ts +28 -28
  187. package/domain/users/models/user-address.d.ts +6 -7
  188. package/domain/users/models/user-payment-method.d.ts +14 -14
  189. package/domain/users/models/user.d.ts +27 -28
  190. package/domain/users/repositories/beauty-profile.repository.d.ts +4 -4
  191. package/domain/users/repositories/edition.repository.d.ts +4 -4
  192. package/domain/users/repositories/index.d.ts +8 -8
  193. package/domain/users/repositories/lead.repository.d.ts +4 -4
  194. package/domain/users/repositories/subscription-payment.repository.d.ts +4 -4
  195. package/domain/users/repositories/subscription.repository.d.ts +4 -4
  196. package/domain/users/repositories/user-address.repository.d.ts +4 -4
  197. package/domain/users/repositories/user-payment-method.repository.d.ts +4 -4
  198. package/domain/users/repositories/user.repository.d.ts +6 -6
  199. package/domain/users/services/authentication.service.d.ts +12 -12
  200. package/domain/users/services/index.d.ts +3 -3
  201. package/domain/users/services/register.service.d.ts +7 -7
  202. package/domain/users/services/types/basic-user-data.type.d.ts +4 -4
  203. package/domain/users/services/types/index.d.ts +1 -1
  204. package/domain/users/use-cases/authentication.d.ts +21 -21
  205. package/domain/users/use-cases/index.d.ts +4 -4
  206. package/domain/users/use-cases/recovery-password.d.ts +6 -6
  207. package/domain/users/use-cases/register.d.ts +13 -13
  208. package/domain/users/use-cases/signout.d.ts +6 -6
  209. package/errors/duplicated-results.error.d.ts +4 -5
  210. package/errors/index.d.ts +4 -4
  211. package/errors/invalid-argument.error.d.ts +4 -5
  212. package/errors/not-found.error.d.ts +4 -5
  213. package/errors/required-argument.error.d.ts +6 -6
  214. package/esm2020/domain/catalog/helpers/index.mjs +2 -0
  215. package/esm2020/domain/catalog/helpers/round-product-price.helper.mjs +15 -0
  216. package/{esm2015/domain/catalog/index.js → esm2020/domain/catalog/index.mjs} +4 -3
  217. package/esm2020/domain/catalog/models/category-base.mjs +18 -0
  218. package/esm2020/domain/catalog/models/category-collection-children.mjs +13 -0
  219. package/esm2020/domain/catalog/models/category-filter.mjs +19 -0
  220. package/esm2020/domain/catalog/models/category-for-product.mjs +7 -0
  221. package/esm2020/domain/catalog/models/category.mjs +14 -0
  222. package/{esm2015/domain/catalog/models/enums/index.js → esm2020/domain/catalog/models/enums/index.mjs} +3 -3
  223. package/{esm2015/domain/catalog/models/enums/product-genders.enum.js → esm2020/domain/catalog/models/enums/product-genders.enum.mjs} +7 -7
  224. package/{esm2015/domain/catalog/models/enums/shops.enum.js → esm2020/domain/catalog/models/enums/shops.enum.mjs} +8 -8
  225. package/esm2020/domain/catalog/models/filter-option.mjs +7 -0
  226. package/esm2020/domain/catalog/models/filter.mjs +7 -0
  227. package/esm2020/domain/catalog/models/index.mjs +12 -0
  228. package/esm2020/domain/catalog/models/kit-product.mjs +18 -0
  229. package/esm2020/domain/catalog/models/product-base.mjs +25 -0
  230. package/esm2020/domain/catalog/models/product-for-category.mjs +14 -0
  231. package/esm2020/domain/catalog/models/product-for-kit.mjs +14 -0
  232. package/esm2020/domain/catalog/models/product.mjs +19 -0
  233. package/{esm2015/domain/catalog/models/types/category-condition.type.js → esm2020/domain/catalog/models/types/category-condition.type.mjs} +2 -2
  234. package/{esm2015/domain/catalog/models/types/category-metadata.type.js → esm2020/domain/catalog/models/types/category-metadata.type.mjs} +2 -2
  235. package/esm2020/domain/catalog/models/types/category-product.mjs +2 -0
  236. package/esm2020/domain/catalog/models/types/index.mjs +12 -0
  237. package/esm2020/domain/catalog/models/types/product-evaluation.type.mjs +2 -0
  238. package/{esm2015/domain/catalog/models/types/product-gender.type.js → esm2020/domain/catalog/models/types/product-gender.type.mjs} +2 -2
  239. package/{esm2015/domain/catalog/models/types/product-metadata.type.js → esm2020/domain/catalog/models/types/product-metadata.type.mjs} +2 -2
  240. package/esm2020/domain/catalog/models/types/product-review.type.mjs +2 -0
  241. package/{esm2015/domain/catalog/models/types/shop-description.type.js → esm2020/domain/catalog/models/types/shop-description.type.mjs} +2 -2
  242. package/{esm2015/domain/catalog/models/types/shop-price.type.js → esm2020/domain/catalog/models/types/shop-price.type.mjs} +2 -2
  243. package/{esm2015/domain/catalog/models/types/stock.type.js → esm2020/domain/catalog/models/types/stock.type.mjs} +2 -2
  244. package/{esm2015/domain/catalog/models/types/variant-grade.type.js → esm2020/domain/catalog/models/types/variant-grade.type.mjs} +2 -2
  245. package/esm2020/domain/catalog/models/variant.mjs +7 -0
  246. package/esm2020/domain/catalog/models/wishlist.mjs +7 -0
  247. package/esm2020/domain/catalog/repositories/category-collection-children.repository.mjs +2 -0
  248. package/esm2020/domain/catalog/repositories/category-filter.repository.mjs +2 -0
  249. package/esm2020/domain/catalog/repositories/category.repository.mjs +2 -0
  250. package/esm2020/domain/catalog/repositories/filter-option.repository.mjs +2 -0
  251. package/esm2020/domain/catalog/repositories/filter.repository.mjs +2 -0
  252. package/esm2020/domain/catalog/repositories/index.mjs +10 -0
  253. package/esm2020/domain/catalog/repositories/product.repository.mjs +2 -0
  254. package/{esm2015/domain/catalog/repositories/subscription-product.repository.js → esm2020/domain/catalog/repositories/subscription-product.repository.mjs} +2 -2
  255. package/{esm2015/domain/catalog/repositories/variant.repository.js → esm2020/domain/catalog/repositories/variant.repository.mjs} +2 -2
  256. package/esm2020/domain/catalog/repositories/wishlist.repository.mjs +2 -0
  257. package/{esm2015/domain/generic/index.js → esm2020/domain/generic/index.mjs} +3 -3
  258. package/esm2020/domain/generic/model/base.model.mjs +24 -0
  259. package/{esm2015/domain/generic/model/identifier-fields.js → esm2020/domain/generic/model/identifier-fields.mjs} +2 -2
  260. package/{esm2015/domain/generic/model/index.js → esm2020/domain/generic/model/index.mjs} +4 -4
  261. package/esm2020/domain/generic/model/types/base-model-builder.type.mjs +2 -0
  262. package/esm2020/domain/generic/model/types/identifier-model.type.mjs +2 -0
  263. package/{esm2015/domain/generic/model/types/index.js → esm2020/domain/generic/model/types/index.mjs} +6 -6
  264. package/esm2020/domain/generic/model/types/model-base-structure.type.mjs +2 -0
  265. package/esm2020/domain/generic/model/types/non-function-properties.type.mjs +2 -0
  266. package/esm2020/domain/generic/model/types/non-function-property-name.type.mjs +2 -0
  267. package/esm2020/domain/generic/repository/create.repository.mjs +2 -0
  268. package/esm2020/domain/generic/repository/crud.repository.mjs +2 -0
  269. package/esm2020/domain/generic/repository/delete.repository.mjs +2 -0
  270. package/{esm2015/domain/generic/repository/enums/index.js → esm2020/domain/generic/repository/enums/index.mjs} +3 -3
  271. package/{esm2015/domain/generic/repository/enums/update-option-actions.enum.js → esm2020/domain/generic/repository/enums/update-option-actions.enum.mjs} +9 -9
  272. package/{esm2015/domain/generic/repository/enums/where.enum.js → esm2020/domain/generic/repository/enums/where.enum.mjs} +16 -16
  273. package/esm2020/domain/generic/repository/find.repository.mjs +2 -0
  274. package/esm2020/domain/generic/repository/get.repository.mjs +2 -0
  275. package/{esm2015/domain/generic/repository/index.js → esm2020/domain/generic/repository/index.mjs} +10 -10
  276. package/esm2020/domain/generic/repository/read.repository.mjs +2 -0
  277. package/{esm2015/domain/generic/repository/types/index.js → esm2020/domain/generic/repository/types/index.mjs} +7 -7
  278. package/esm2020/domain/generic/repository/types/repository-find-filters.type.mjs +2 -0
  279. package/esm2020/domain/generic/repository/types/repository-find-result.type.mjs +2 -0
  280. package/{esm2015/domain/generic/repository/types/repository-limit-options.type.js → esm2020/domain/generic/repository/types/repository-limit-options.type.mjs} +2 -2
  281. package/{esm2015/domain/generic/repository/types/repository-order-by-list.type.js → esm2020/domain/generic/repository/types/repository-order-by-list.type.mjs} +2 -2
  282. package/esm2020/domain/generic/repository/types/repository-update-params.type.mjs +2 -0
  283. package/{esm2015/domain/generic/repository/types/where-options.type.js → esm2020/domain/generic/repository/types/where-options.type.mjs} +2 -2
  284. package/esm2020/domain/generic/repository/update.repository.mjs +2 -0
  285. package/{esm2015/domain/index.js → esm2020/domain/index.mjs} +7 -7
  286. package/{esm2015/domain/location/index.js → esm2020/domain/location/index.mjs} +2 -2
  287. package/esm2020/domain/location/models/address.mjs +7 -0
  288. package/{esm2015/domain/location/models/index.js → esm2020/domain/location/models/index.mjs} +3 -3
  289. package/{esm2015/domain/location/models/types/index.js → esm2020/domain/location/models/types/index.mjs} +4 -4
  290. package/{esm2015/domain/location/models/types/location-bound.type.js → esm2020/domain/location/models/types/location-bound.type.mjs} +2 -2
  291. package/{esm2015/domain/location/models/types/location-geometry.type.js → esm2020/domain/location/models/types/location-geometry.type.mjs} +2 -2
  292. package/{esm2015/domain/location/models/types/location-lat-lng.type.js → esm2020/domain/location/models/types/location-lat-lng.type.mjs} +2 -2
  293. package/{esm2015/domain/shop-settings/enums/filter-type.enum.js → esm2020/domain/shop-settings/enums/filter-type.enum.mjs} +21 -21
  294. package/{esm2015/domain/shop-settings/enums/index.js → esm2020/domain/shop-settings/enums/index.mjs} +3 -3
  295. package/{esm2015/domain/shop-settings/enums/questions-filters.enum.js → esm2020/domain/shop-settings/enums/questions-filters.enum.mjs} +21 -21
  296. package/{esm2015/domain/shop-settings/helpers/beauty-questions.helper.js → esm2020/domain/shop-settings/helpers/beauty-questions.helper.mjs} +47 -46
  297. package/{esm2015/domain/shop-settings/helpers/index.js → esm2020/domain/shop-settings/helpers/index.mjs} +2 -2
  298. package/{esm2015/domain/shop-settings/index.js → esm2020/domain/shop-settings/index.mjs} +5 -5
  299. package/esm2020/domain/shop-settings/models/home.mjs +7 -0
  300. package/{esm2015/domain/shop-settings/models/index.js → esm2020/domain/shop-settings/models/index.mjs} +5 -5
  301. package/{esm2015/domain/shop-settings/models/shop-menu.js → esm2020/domain/shop-settings/models/shop-menu.mjs} +7 -7
  302. package/{esm2015/domain/shop-settings/models/shop-settings.js → esm2020/domain/shop-settings/models/shop-settings.mjs} +7 -7
  303. package/{esm2015/domain/shop-settings/models/types/banner.type.js → esm2020/domain/shop-settings/models/types/banner.type.mjs} +2 -2
  304. package/{esm2015/domain/shop-settings/models/types/benefit.type.js → esm2020/domain/shop-settings/models/types/benefit.type.mjs} +2 -2
  305. package/esm2020/domain/shop-settings/models/types/home-data.type.mjs +2 -0
  306. package/{esm2015/domain/shop-settings/models/types/index.js → esm2020/domain/shop-settings/models/types/index.mjs} +11 -11
  307. package/{esm2015/domain/shop-settings/models/types/menu-nav.type.js → esm2020/domain/shop-settings/models/types/menu-nav.type.mjs} +2 -2
  308. package/{esm2015/domain/shop-settings/models/types/shop-banner.type.js → esm2020/domain/shop-settings/models/types/shop-banner.type.mjs} +2 -2
  309. package/{esm2015/domain/shop-settings/models/types/shop-brands.type.js → esm2020/domain/shop-settings/models/types/shop-brands.type.mjs} +2 -2
  310. package/{esm2015/domain/shop-settings/models/types/shop-carousel.type.js → esm2020/domain/shop-settings/models/types/shop-carousel.type.mjs} +2 -2
  311. package/{esm2015/domain/shop-settings/models/types/shop-collection.type.js → esm2020/domain/shop-settings/models/types/shop-collection.type.mjs} +2 -2
  312. package/{esm2015/domain/shop-settings/models/types/shop-section.type.js → esm2020/domain/shop-settings/models/types/shop-section.type.mjs} +2 -2
  313. package/{esm2015/domain/shop-settings/models/types/sub-menu.type.js → esm2020/domain/shop-settings/models/types/sub-menu.type.mjs} +2 -2
  314. package/{esm2015/domain/shop-settings/repositories/home.repository.js → esm2020/domain/shop-settings/repositories/home.repository.mjs} +2 -2
  315. package/{esm2015/domain/shop-settings/repositories/index.js → esm2020/domain/shop-settings/repositories/index.mjs} +4 -4
  316. package/{esm2015/domain/shop-settings/repositories/shop-menu.repository.js → esm2020/domain/shop-settings/repositories/shop-menu.repository.mjs} +2 -2
  317. package/{esm2015/domain/shop-settings/repositories/shop-settings.repository.js → esm2020/domain/shop-settings/repositories/shop-settings.repository.mjs} +2 -2
  318. package/{esm2015/domain/shopping/index.js → esm2020/domain/shopping/index.mjs} +3 -3
  319. package/esm2020/domain/shopping/models/buy-2-win.mjs +14 -0
  320. package/esm2020/domain/shopping/models/campaign-dashboard.mjs +7 -0
  321. package/esm2020/domain/shopping/models/campaign-hashtag.mjs +7 -0
  322. package/esm2020/domain/shopping/models/checkout.mjs +37 -0
  323. package/esm2020/domain/shopping/models/coupons/coupon.mjs +38 -0
  324. package/{esm2015/domain/shopping/models/coupons/enums/coupon-club-mens.enum.js → esm2020/domain/shopping/models/coupons/enums/coupon-club-mens.enum.mjs} +7 -7
  325. package/{esm2015/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js → esm2020/domain/shopping/models/coupons/enums/coupon-subtypes.enum.mjs} +6 -6
  326. package/{esm2015/domain/shopping/models/coupons/enums/coupon-types.enum.js → esm2020/domain/shopping/models/coupons/enums/coupon-types.enum.mjs} +10 -10
  327. package/{esm2015/domain/shopping/models/coupons/enums/exclusivities.enum.js → esm2020/domain/shopping/models/coupons/enums/exclusivities.enum.mjs} +10 -10
  328. package/{esm2015/domain/shopping/models/coupons/enums/index.js → esm2020/domain/shopping/models/coupons/enums/index.mjs} +4 -4
  329. package/{esm2015/domain/shopping/models/coupons/index.js → esm2020/domain/shopping/models/coupons/index.mjs} +3 -3
  330. package/{esm2015/domain/shopping/models/enums/checkout-types.enum.js → esm2020/domain/shopping/models/enums/checkout-types.enum.mjs} +7 -7
  331. package/{esm2015/domain/shopping/models/enums/index.js → esm2020/domain/shopping/models/enums/index.mjs} +3 -3
  332. package/{esm2015/domain/shopping/models/enums/order-status.enum.js → esm2020/domain/shopping/models/enums/order-status.enum.mjs} +12 -12
  333. package/esm2020/domain/shopping/models/index.mjs +13 -0
  334. package/{esm2015/domain/shopping/models/line-item.js → esm2020/domain/shopping/models/line-item.mjs} +4 -4
  335. package/{esm2015/domain/shopping/models/order.js → esm2020/domain/shopping/models/order.mjs} +11 -11
  336. package/esm2020/domain/shopping/models/payment.mjs +169 -0
  337. package/esm2020/domain/shopping/models/shipping-method.mjs +7 -0
  338. package/esm2020/domain/shopping/models/subscription/checkout.mjs +28 -0
  339. package/{esm2015/domain/shopping/models/subscription/index.js → esm2020/domain/shopping/models/subscription/index.mjs} +3 -3
  340. package/{esm2015/domain/shopping/models/subscription/plan.js → esm2020/domain/shopping/models/subscription/plan.mjs} +7 -7
  341. package/{esm2015/domain/shopping/models/types/index.js → esm2020/domain/shopping/models/types/index.mjs} +8 -8
  342. package/esm2020/domain/shopping/models/types/payment-address.type.mjs +2 -0
  343. package/{esm2015/domain/shopping/models/types/payment-billing.type.js → esm2020/domain/shopping/models/types/payment-billing.type.mjs} +2 -2
  344. package/esm2020/domain/shopping/models/types/payment-card.type.mjs +2 -0
  345. package/esm2020/domain/shopping/models/types/payment-customer.type.mjs +2 -0
  346. package/{esm2015/domain/shopping/models/types/payment-document.type.js → esm2020/domain/shopping/models/types/payment-document.type.mjs} +2 -2
  347. package/{esm2015/domain/shopping/models/types/payment-item.type.js → esm2020/domain/shopping/models/types/payment-item.type.mjs} +2 -2
  348. package/{esm2015/domain/shopping/models/types/payment-shipping.type.js → esm2020/domain/shopping/models/types/payment-shipping.type.mjs} +2 -2
  349. package/{esm2015/domain/shopping/repositories/buy-2-win.repository.js → esm2020/domain/shopping/repositories/buy-2-win.repository.mjs} +2 -2
  350. package/esm2020/domain/shopping/repositories/campaign-dashboard.repository.mjs +2 -0
  351. package/esm2020/domain/shopping/repositories/campaign-hashtag.repository.mjs +2 -0
  352. package/{esm2015/domain/shopping/repositories/checkout.repository.js → esm2020/domain/shopping/repositories/checkout.repository.mjs} +2 -2
  353. package/{esm2015/domain/shopping/repositories/coupon.repository.js → esm2020/domain/shopping/repositories/coupon.repository.mjs} +2 -2
  354. package/esm2020/domain/shopping/repositories/index.mjs +10 -0
  355. package/{esm2015/domain/shopping/repositories/legacy-order.repository.js → esm2020/domain/shopping/repositories/legacy-order.repository.mjs} +2 -2
  356. package/{esm2015/domain/shopping/repositories/order.repository.js → esm2020/domain/shopping/repositories/order.repository.mjs} +2 -2
  357. package/{esm2015/domain/shopping/repositories/payment.repository.js → esm2020/domain/shopping/repositories/payment.repository.mjs} +2 -2
  358. package/{esm2015/domain/shopping/repositories/subscription/checkout.repository.js → esm2020/domain/shopping/repositories/subscription/checkout.repository.mjs} +2 -2
  359. package/{esm2015/domain/shopping/repositories/subscription/index.js → esm2020/domain/shopping/repositories/subscription/index.mjs} +3 -3
  360. package/{esm2015/domain/shopping/repositories/subscription/plan.repository.js → esm2020/domain/shopping/repositories/subscription/plan.repository.mjs} +2 -2
  361. package/{esm2015/domain/users/errors/index.js → esm2020/domain/users/errors/index.mjs} +4 -4
  362. package/{esm2015/domain/users/errors/unauthorized.error.js → esm2020/domain/users/errors/unauthorized.error.mjs} +7 -8
  363. package/{esm2015/domain/users/errors/user-already-registered.error.js → esm2020/domain/users/errors/user-already-registered.error.mjs} +7 -8
  364. package/{esm2015/domain/users/errors/weak-password.error.js → esm2020/domain/users/errors/weak-password.error.mjs} +7 -8
  365. package/{esm2015/domain/users/index.js → esm2020/domain/users/index.mjs} +6 -6
  366. package/esm2020/domain/users/models/beauty-profile.mjs +12 -0
  367. package/{esm2015/domain/users/models/enums/accessory-importances.enum.js → esm2020/domain/users/models/enums/accessory-importances.enum.mjs} +7 -7
  368. package/{esm2015/domain/users/models/enums/area.enum.js → esm2020/domain/users/models/enums/area.enum.mjs} +13 -13
  369. package/{esm2015/domain/users/models/enums/beard-problems.enum.js → esm2020/domain/users/models/enums/beard-problems.enum.mjs} +11 -11
  370. package/{esm2015/domain/users/models/enums/beard-sizes.enum.js → esm2020/domain/users/models/enums/beard-sizes.enum.mjs} +9 -9
  371. package/{esm2015/domain/users/models/enums/beauty-product-importances.enum.js → esm2020/domain/users/models/enums/beauty-product-importances.enum.mjs} +8 -8
  372. package/{esm2015/domain/users/models/enums/body-problems.enum.js → esm2020/domain/users/models/enums/body-problems.enum.mjs} +13 -13
  373. package/{esm2015/domain/users/models/enums/body-shapes.enum.js → esm2020/domain/users/models/enums/body-shapes.enum.mjs} +9 -9
  374. package/{esm2015/domain/users/models/enums/body-tattoos.enum.js → esm2020/domain/users/models/enums/body-tattoos.enum.mjs} +7 -7
  375. package/{esm2015/domain/users/models/enums/face-skin-oilinesses.enum.js → esm2020/domain/users/models/enums/face-skin-oilinesses.enum.mjs} +9 -9
  376. package/{esm2015/domain/users/models/enums/face-skin-problems.enum.js → esm2020/domain/users/models/enums/face-skin-problems.enum.mjs} +12 -12
  377. package/{esm2015/domain/users/models/enums/face-skin-tones.enum.js → esm2020/domain/users/models/enums/face-skin-tones.enum.mjs} +10 -10
  378. package/{esm2015/domain/users/models/enums/family-incomes.enum.js → esm2020/domain/users/models/enums/family-incomes.enum.mjs} +10 -10
  379. package/{esm2015/domain/users/models/enums/fragrance-importances.enum.js → esm2020/domain/users/models/enums/fragrance-importances.enum.mjs} +7 -7
  380. package/{esm2015/domain/users/models/enums/hair-colors.enum.js → esm2020/domain/users/models/enums/hair-colors.enum.mjs} +12 -12
  381. package/{esm2015/domain/users/models/enums/hair-problems.enum.js → esm2020/domain/users/models/enums/hair-problems.enum.mjs} +12 -12
  382. package/{esm2015/domain/users/models/enums/hair-strands.enum.js → esm2020/domain/users/models/enums/hair-strands.enum.mjs} +10 -10
  383. package/{esm2015/domain/users/models/enums/hair-types.enum.js → esm2020/domain/users/models/enums/hair-types.enum.mjs} +9 -9
  384. package/{esm2015/domain/users/models/enums/index.js → esm2020/domain/users/models/enums/index.mjs} +21 -21
  385. package/{esm2015/domain/users/models/enums/office-position.enum.js → esm2020/domain/users/models/enums/office-position.enum.mjs} +8 -8
  386. package/{esm2015/domain/users/models/enums/product-spents.enum.js → esm2020/domain/users/models/enums/product-spents.enum.mjs} +10 -10
  387. package/{esm2015/domain/users/models/enums/user-type.enum.js → esm2020/domain/users/models/enums/user-type.enum.mjs} +10 -10
  388. package/{esm2015/domain/users/models/index.js → esm2020/domain/users/models/index.mjs} +8 -8
  389. package/{esm2015/domain/users/models/lead.js → esm2020/domain/users/models/lead.mjs} +7 -7
  390. package/esm2020/domain/users/models/subscription/edition.mjs +7 -0
  391. package/{esm2015/domain/users/models/subscription/enums/billing-status.enum.js → esm2020/domain/users/models/subscription/enums/billing-status.enum.mjs} +5 -5
  392. package/{esm2015/domain/users/models/subscription/enums/edition-status.enum.js → esm2020/domain/users/models/subscription/enums/edition-status.enum.mjs} +6 -6
  393. package/{esm2015/domain/users/models/subscription/enums/index.js → esm2020/domain/users/models/subscription/enums/index.mjs} +5 -5
  394. package/{esm2015/domain/users/models/subscription/enums/payment-type.enum.js → esm2020/domain/users/models/subscription/enums/payment-type.enum.mjs} +7 -7
  395. package/{esm2015/domain/users/models/subscription/enums/status.enum.js → esm2020/domain/users/models/subscription/enums/status.enum.mjs} +6 -6
  396. package/{esm2015/domain/users/models/subscription/index.js → esm2020/domain/users/models/subscription/index.mjs} +5 -5
  397. package/esm2020/domain/users/models/subscription/payment.mjs +14 -0
  398. package/esm2020/domain/users/models/subscription/subscription.mjs +43 -0
  399. package/{esm2015/domain/users/models/user-address.js → esm2020/domain/users/models/user-address.mjs} +7 -7
  400. package/esm2020/domain/users/models/user-payment-method.mjs +7 -0
  401. package/esm2020/domain/users/models/user.mjs +26 -0
  402. package/{esm2015/domain/users/repositories/beauty-profile.repository.js → esm2020/domain/users/repositories/beauty-profile.repository.mjs} +2 -2
  403. package/{esm2015/domain/users/repositories/edition.repository.js → esm2020/domain/users/repositories/edition.repository.mjs} +2 -2
  404. package/{esm2015/domain/users/repositories/index.js → esm2020/domain/users/repositories/index.mjs} +9 -9
  405. package/{esm2015/domain/users/repositories/lead.repository.js → esm2020/domain/users/repositories/lead.repository.mjs} +2 -2
  406. package/{esm2015/domain/users/repositories/subscription-payment.repository.js → esm2020/domain/users/repositories/subscription-payment.repository.mjs} +2 -2
  407. package/{esm2015/domain/users/repositories/subscription.repository.js → esm2020/domain/users/repositories/subscription.repository.mjs} +2 -2
  408. package/{esm2015/domain/users/repositories/user-address.repository.js → esm2020/domain/users/repositories/user-address.repository.mjs} +2 -2
  409. package/{esm2015/domain/users/repositories/user-payment-method.repository.js → esm2020/domain/users/repositories/user-payment-method.repository.mjs} +2 -2
  410. package/esm2020/domain/users/repositories/user.repository.mjs +2 -0
  411. package/esm2020/domain/users/services/authentication.service.mjs +2 -0
  412. package/{esm2015/domain/users/services/index.js → esm2020/domain/users/services/index.mjs} +4 -4
  413. package/{esm2015/domain/users/services/register.service.js → esm2020/domain/users/services/register.service.mjs} +2 -2
  414. package/{esm2015/domain/users/services/types/basic-user-data.type.js → esm2020/domain/users/services/types/basic-user-data.type.mjs} +2 -2
  415. package/{esm2015/domain/users/services/types/index.js → esm2020/domain/users/services/types/index.mjs} +2 -2
  416. package/esm2020/domain/users/use-cases/authentication.mjs +43 -0
  417. package/{esm2015/domain/users/use-cases/index.js → esm2020/domain/users/use-cases/index.mjs} +5 -5
  418. package/esm2020/domain/users/use-cases/recovery-password.mjs +9 -0
  419. package/esm2020/domain/users/use-cases/register.mjs +38 -0
  420. package/esm2020/domain/users/use-cases/signout.mjs +9 -0
  421. package/{esm2015/errors/duplicated-results.error.js → esm2020/errors/duplicated-results.error.mjs} +7 -8
  422. package/{esm2015/errors/index.js → esm2020/errors/index.mjs} +5 -5
  423. package/{esm2015/errors/invalid-argument.error.js → esm2020/errors/invalid-argument.error.mjs} +7 -8
  424. package/{esm2015/errors/not-found.error.js → esm2020/errors/not-found.error.mjs} +7 -8
  425. package/{esm2015/errors/required-argument.error.js → esm2020/errors/required-argument.error.mjs} +9 -9
  426. package/{esm2015/index.js → esm2020/index.mjs} +6 -6
  427. package/esm2020/infra/elasticsearch/adapters/axios.adapter.mjs +67 -0
  428. package/esm2020/infra/elasticsearch/adapters/elastic-search.adapter.mjs +2 -0
  429. package/{esm2015/infra/elasticsearch/adapters/index.js → esm2020/infra/elasticsearch/adapters/index.mjs} +3 -3
  430. package/{esm2015/infra/elasticsearch/index.js → esm2020/infra/elasticsearch/index.mjs} +4 -4
  431. package/{esm2015/infra/elasticsearch/indexes/index.js → esm2020/infra/elasticsearch/indexes/index.mjs} +2 -2
  432. package/esm2020/infra/elasticsearch/indexes/products-index.mjs +104 -0
  433. package/{esm2015/infra/elasticsearch/types/elastic-search-result.js → esm2020/infra/elasticsearch/types/elastic-search-result.mjs} +2 -2
  434. package/{esm2015/infra/elasticsearch/types/index.js → esm2020/infra/elasticsearch/types/index.mjs} +2 -2
  435. package/esm2020/infra/firebase/auth/authentication-firebase-auth.service.mjs +41 -0
  436. package/{esm2015/infra/firebase/auth/index.js → esm2020/infra/firebase/auth/index.mjs} +3 -3
  437. package/esm2020/infra/firebase/auth/register-firebase-auth.service.mjs +33 -0
  438. package/{esm2015/infra/firebase/auth/types/firebase-user-with-id.type.js → esm2020/infra/firebase/auth/types/firebase-user-with-id.type.mjs} +2 -2
  439. package/{esm2015/infra/firebase/firestore/enums/firestore-field-type.enum.js → esm2020/infra/firebase/firestore/enums/firestore-field-type.enum.mjs} +10 -10
  440. package/{esm2015/infra/firebase/firestore/enums/index.js → esm2020/infra/firebase/firestore/enums/index.mjs} +2 -2
  441. package/{esm2015/infra/firebase/firestore/index.js → esm2020/infra/firebase/firestore/index.mjs} +4 -4
  442. package/{esm2015/infra/firebase/firestore/mixins/index.js → esm2020/infra/firebase/firestore/mixins/index.mjs} +10 -10
  443. package/esm2020/infra/firebase/firestore/mixins/with-create-firestore.mixin.mjs +31 -0
  444. package/esm2020/infra/firebase/firestore/mixins/with-crud-firestore.mixin.mjs +10 -0
  445. package/esm2020/infra/firebase/firestore/mixins/with-delete-firestore.mixin.mjs +18 -0
  446. package/esm2020/infra/firebase/firestore/mixins/with-find-firestore.mixin.mjs +110 -0
  447. package/esm2020/infra/firebase/firestore/mixins/with-firestore.mixin.mjs +80 -0
  448. package/esm2020/infra/firebase/firestore/mixins/with-get-firestore.mixin.mjs +23 -0
  449. package/esm2020/infra/firebase/firestore/mixins/with-helpers.mixin.mjs +17 -0
  450. package/esm2020/infra/firebase/firestore/mixins/with-sub-collection.mixin.mjs +13 -0
  451. package/esm2020/infra/firebase/firestore/mixins/with-update-firestore.mixin.mjs +51 -0
  452. package/esm2020/infra/firebase/firestore/repositories/catalog/category-firestore.repository.mjs +67 -0
  453. package/{esm2015/infra/firebase/firestore/repositories/catalog/index.js → esm2020/infra/firebase/firestore/repositories/catalog/index.mjs} +5 -5
  454. package/esm2020/infra/firebase/firestore/repositories/catalog/product-firestore.repository.mjs +54 -0
  455. package/esm2020/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.mjs +16 -0
  456. package/esm2020/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.mjs +14 -0
  457. package/{esm2015/infra/firebase/firestore/repositories/index.js → esm2020/infra/firebase/firestore/repositories/index.mjs} +5 -5
  458. package/esm2020/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.mjs +60 -0
  459. package/{esm2015/infra/firebase/firestore/repositories/shop-settings/index.js → esm2020/infra/firebase/firestore/repositories/shop-settings/index.mjs} +4 -4
  460. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.mjs +14 -0
  461. package/esm2020/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.mjs +14 -0
  462. package/esm2020/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.mjs +14 -0
  463. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.mjs +14 -0
  464. package/esm2020/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.mjs +14 -0
  465. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.mjs +14 -0
  466. package/esm2020/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.mjs +14 -0
  467. package/esm2020/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.mjs +31 -0
  468. package/esm2020/infra/firebase/firestore/repositories/shopping/index.mjs +11 -0
  469. package/esm2020/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.mjs +11 -0
  470. package/esm2020/infra/firebase/firestore/repositories/shopping/order-firestore.repository.mjs +40 -0
  471. package/esm2020/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.mjs +14 -0
  472. package/esm2020/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.mjs +14 -0
  473. package/{esm2015/infra/firebase/firestore/repositories/users/index.js → esm2020/infra/firebase/firestore/repositories/users/index.mjs} +9 -9
  474. package/esm2020/infra/firebase/firestore/repositories/users/lead-firestore.repository.mjs +14 -0
  475. package/esm2020/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.mjs +16 -0
  476. package/esm2020/infra/firebase/firestore/repositories/users/subscription-firestore.repository.mjs +14 -0
  477. package/esm2020/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.mjs +16 -0
  478. package/esm2020/infra/firebase/firestore/repositories/users/user-address-firestore.repository.mjs +16 -0
  479. package/esm2020/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.mjs +16 -0
  480. package/esm2020/infra/firebase/firestore/repositories/users/user-firestore.repository.mjs +50 -0
  481. package/esm2020/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.mjs +16 -0
  482. package/esm2020/infra/firebase/firestore/types/firestore-interceptors.type.mjs +2 -0
  483. package/esm2020/infra/firebase/firestore/types/firestore-sub.repository.type.mjs +2 -0
  484. package/esm2020/infra/firebase/firestore/types/firestore.helpers.type.mjs +2 -0
  485. package/esm2020/infra/firebase/firestore/types/firestore.repository.type.mjs +2 -0
  486. package/esm2020/infra/firebase/firestore/types/index.mjs +5 -0
  487. package/{esm2015/infra/firebase/index.js → esm2020/infra/firebase/index.mjs} +3 -3
  488. package/{esm2015/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.js → esm2020/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.mjs} +13 -13
  489. package/{esm2015/infra/hasura-graphql/enums/hasura-graphql-where.enum.js → esm2020/infra/hasura-graphql/enums/hasura-graphql-where.enum.mjs} +17 -15
  490. package/{esm2015/infra/hasura-graphql/enums/index.js → esm2020/infra/hasura-graphql/enums/index.mjs} +3 -3
  491. package/{esm2015/infra/hasura-graphql/index.js → esm2020/infra/hasura-graphql/index.mjs} +5 -5
  492. package/esm2020/infra/hasura-graphql/mixins/helpers/attribute-option.helper.mjs +35 -0
  493. package/esm2020/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.mjs +71 -0
  494. package/esm2020/infra/hasura-graphql/mixins/helpers/filter-option.helper.mjs +22 -0
  495. package/esm2020/infra/hasura-graphql/mixins/helpers/graphql-field.helper.mjs +125 -0
  496. package/{esm2015/infra/hasura-graphql/mixins/helpers/index.js → esm2020/infra/hasura-graphql/mixins/helpers/index.mjs} +5 -5
  497. package/{esm2015/infra/hasura-graphql/mixins/index.js → esm2020/infra/hasura-graphql/mixins/index.mjs} +8 -8
  498. package/esm2020/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.mjs +39 -0
  499. package/esm2020/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.mjs +10 -0
  500. package/esm2020/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.mjs +31 -0
  501. package/esm2020/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.mjs +152 -0
  502. package/esm2020/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.mjs +37 -0
  503. package/esm2020/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.mjs +108 -0
  504. package/esm2020/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.mjs +62 -0
  505. package/{esm2015/infra/hasura-graphql/models/category-hasura-graphql.js → esm2020/infra/hasura-graphql/models/category-hasura-graphql.mjs} +4 -4
  506. package/{esm2015/infra/hasura-graphql/models/index.js → esm2020/infra/hasura-graphql/models/index.mjs} +5 -5
  507. package/{esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js → esm2020/infra/hasura-graphql/models/kit-product-hasura-graphql.mjs} +15 -15
  508. package/esm2020/infra/hasura-graphql/models/product-hasura-graphql.mjs +11 -0
  509. package/{esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js → esm2020/infra/hasura-graphql/models/variant-hasura-graphql.mjs} +9 -9
  510. package/esm2020/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.mjs +39 -0
  511. package/esm2020/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.mjs +107 -0
  512. package/esm2020/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.mjs +338 -0
  513. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.mjs +105 -0
  514. package/esm2020/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.mjs +22 -0
  515. package/esm2020/infra/hasura-graphql/repositories/catalog/index.mjs +9 -0
  516. package/esm2020/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.mjs +516 -0
  517. package/esm2020/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.mjs +114 -0
  518. package/esm2020/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.mjs +238 -0
  519. package/{esm2015/infra/hasura-graphql/repositories/index.js → esm2020/infra/hasura-graphql/repositories/index.mjs} +2 -2
  520. package/{esm2015/infra/hasura-graphql/types/fields.type.js → esm2020/infra/hasura-graphql/types/fields.type.mjs} +2 -2
  521. package/esm2020/infra/hasura-graphql/types/graphql.repository.type.mjs +2 -0
  522. package/{esm2015/infra/hasura-graphql/types/hasura-graphql-auth-options.type.js → esm2020/infra/hasura-graphql/types/hasura-graphql-auth-options.type.mjs} +2 -2
  523. package/esm2020/infra/hasura-graphql/types/hasura-graphql-fields.type.mjs +2 -0
  524. package/{esm2015/infra/hasura-graphql/types/hasura-graphql-headers.type.js → esm2020/infra/hasura-graphql/types/hasura-graphql-headers.type.mjs} +2 -2
  525. package/{esm2015/infra/hasura-graphql/types/index.js → esm2020/infra/hasura-graphql/types/index.mjs} +9 -9
  526. package/{esm2015/infra/hasura-graphql/types/nested-field.type.js → esm2020/infra/hasura-graphql/types/nested-field.type.mjs} +2 -2
  527. package/{esm2015/infra/hasura-graphql/types/query-builder-options.type.js → esm2020/infra/hasura-graphql/types/query-builder-options.type.mjs} +2 -2
  528. package/{esm2015/infra/hasura-graphql/types/variable-options.type.js → esm2020/infra/hasura-graphql/types/variable-options.type.mjs} +2 -2
  529. package/{esm2015/infra/index.js → esm2020/infra/index.mjs} +4 -4
  530. package/{esm2015/infrab4a-connect.js → esm2020/infrab4a-connect.mjs} +4 -4
  531. package/esm2020/utils/decorators/debug.class.decorator.mjs +7 -0
  532. package/esm2020/utils/decorators/index.mjs +3 -0
  533. package/esm2020/utils/decorators/trace.method.decorator.mjs +81 -0
  534. package/esm2020/utils/get.mjs +3 -0
  535. package/esm2020/utils/helpers/class-name.helper.mjs +15 -0
  536. package/esm2020/utils/helpers/debug-decorator.helper.mjs +18 -0
  537. package/esm2020/utils/helpers/debug.helper.mjs +150 -0
  538. package/esm2020/utils/helpers/index.mjs +5 -0
  539. package/esm2020/utils/helpers/reflect.helper.mjs +165 -0
  540. package/esm2020/utils/index.mjs +13 -0
  541. package/{esm2015/utils/is-uuid.js → esm2020/utils/is-uuid.mjs} +3 -3
  542. package/esm2020/utils/is.mjs +4 -0
  543. package/esm2020/utils/log.utils.mjs +9 -0
  544. package/{esm2015/utils/mixins/base.mixin.js → esm2020/utils/mixins/base.mixin.mjs} +6 -6
  545. package/{esm2015/utils/mixins/index.js → esm2020/utils/mixins/index.mjs} +4 -4
  546. package/{esm2015/utils/mixins/merge-constructor-params.type.js → esm2020/utils/mixins/merge-constructor-params.type.mjs} +2 -2
  547. package/{esm2015/utils/mixins/mixin-ctor.type.js → esm2020/utils/mixins/mixin-ctor.type.mjs} +2 -2
  548. package/{esm2015/utils/parse-datetime.js → esm2020/utils/parse-datetime.mjs} +14 -14
  549. package/{esm2015/utils/types/array-element.type.js → esm2020/utils/types/array-element.type.mjs} +2 -2
  550. package/{esm2015/utils/types/index.js → esm2020/utils/types/index.mjs} +3 -3
  551. package/{esm2015/utils/types/prop.type.js → esm2020/utils/types/prop.type.mjs} +2 -2
  552. package/fesm2015/{infrab4a-connect.js → infrab4a-connect.mjs} +4789 -3178
  553. package/fesm2015/infrab4a-connect.mjs.map +1 -0
  554. package/fesm2020/infrab4a-connect.mjs +4857 -0
  555. package/fesm2020/infrab4a-connect.mjs.map +1 -0
  556. package/index.d.ts +5 -5
  557. package/infra/elasticsearch/adapters/axios.adapter.d.ts +16 -14
  558. package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +8 -7
  559. package/infra/elasticsearch/adapters/index.d.ts +2 -2
  560. package/infra/elasticsearch/index.d.ts +3 -3
  561. package/infra/elasticsearch/indexes/index.d.ts +1 -1
  562. package/infra/elasticsearch/indexes/products-index.d.ts +13 -15
  563. package/infra/elasticsearch/types/elastic-search-result.d.ts +9 -7
  564. package/infra/elasticsearch/types/index.d.ts +1 -1
  565. package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +12 -12
  566. package/infra/firebase/auth/index.d.ts +2 -2
  567. package/infra/firebase/auth/register-firebase-auth.service.d.ts +8 -8
  568. package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +5 -3
  569. package/infra/firebase/firestore/enums/firestore-field-type.enum.d.ts +8 -8
  570. package/infra/firebase/firestore/enums/index.d.ts +1 -1
  571. package/infra/firebase/firestore/index.d.ts +3 -3
  572. package/infra/firebase/firestore/mixins/index.d.ts +9 -9
  573. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +4 -4
  574. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +5 -4
  575. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +4 -4
  576. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +4 -4
  577. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +13 -4
  578. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +4 -4
  579. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +11 -11
  580. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +11 -7
  581. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +7 -7
  582. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +20 -17
  583. package/infra/firebase/firestore/repositories/catalog/index.d.ts +4 -4
  584. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +12 -11
  585. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +12 -13
  586. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +7 -8
  587. package/infra/firebase/firestore/repositories/index.d.ts +4 -4
  588. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +16 -16
  589. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +3 -3
  590. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +7 -8
  591. package/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.d.ts +7 -8
  592. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +7 -8
  593. package/infra/firebase/firestore/repositories/shopping/campaign-dashboard-firestore.repository.d.ts +8 -0
  594. package/infra/firebase/firestore/repositories/shopping/campaign-hashtag-firestore.repository.d.ts +8 -0
  595. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +7 -8
  596. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +7 -8
  597. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +12 -12
  598. package/infra/firebase/firestore/repositories/shopping/index.d.ts +10 -8
  599. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +6 -7
  600. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +13 -13
  601. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +7 -8
  602. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +7 -8
  603. package/infra/firebase/firestore/repositories/users/index.d.ts +8 -8
  604. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +7 -8
  605. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +12 -13
  606. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +7 -8
  607. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +12 -13
  608. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +12 -13
  609. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +12 -13
  610. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +17 -17
  611. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +12 -13
  612. package/infra/firebase/firestore/types/firestore-interceptors.type.d.ts +14 -0
  613. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +6 -6
  614. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +8 -8
  615. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +16 -14
  616. package/infra/firebase/firestore/types/index.d.ts +4 -3
  617. package/infra/firebase/index.d.ts +2 -2
  618. package/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.d.ts +11 -11
  619. package/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +15 -13
  620. package/infra/hasura-graphql/enums/index.d.ts +2 -2
  621. package/infra/hasura-graphql/index.d.ts +4 -4
  622. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +19 -13
  623. package/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.d.ts +10 -10
  624. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +8 -6
  625. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +12 -8
  626. package/infra/hasura-graphql/mixins/helpers/index.d.ts +4 -4
  627. package/infra/hasura-graphql/mixins/index.d.ts +7 -7
  628. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +9 -8
  629. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +11 -11
  630. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +7 -7
  631. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +34 -25
  632. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +25 -24
  633. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +23 -11
  634. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +14 -14
  635. package/infra/hasura-graphql/models/category-hasura-graphql.d.ts +6 -6
  636. package/infra/hasura-graphql/models/index.d.ts +4 -4
  637. package/infra/hasura-graphql/models/kit-product-hasura-graphql.d.ts +6 -6
  638. package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +18 -14
  639. package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +10 -9
  640. package/infra/hasura-graphql/repositories/catalog/category-collection-children-hasura-graphql.repository.d.ts +10 -0
  641. package/infra/hasura-graphql/repositories/catalog/category-filter-hasura-graphql.repository.d.ts +12 -0
  642. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +34 -27
  643. package/infra/hasura-graphql/repositories/catalog/filter-hasura-graphql.repository.d.ts +18 -0
  644. package/infra/hasura-graphql/repositories/catalog/filter-option-hasura-graphql.repository.d.ts +10 -0
  645. package/infra/hasura-graphql/repositories/catalog/index.d.ts +8 -3
  646. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +30 -28
  647. package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +14 -14
  648. package/infra/hasura-graphql/repositories/catalog/wishlist-hasura-graphql.repository.d.ts +27 -0
  649. package/infra/hasura-graphql/repositories/index.d.ts +1 -1
  650. package/infra/hasura-graphql/types/fields.type.d.ts +2 -2
  651. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +24 -21
  652. package/infra/hasura-graphql/types/hasura-graphql-auth-options.type.d.ts +8 -8
  653. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +44 -40
  654. package/infra/hasura-graphql/types/hasura-graphql-headers.type.d.ts +7 -7
  655. package/infra/hasura-graphql/types/index.d.ts +8 -8
  656. package/infra/hasura-graphql/types/nested-field.type.d.ts +7 -7
  657. package/infra/hasura-graphql/types/query-builder-options.type.d.ts +7 -7
  658. package/infra/hasura-graphql/types/variable-options.type.d.ts +9 -9
  659. package/infra/index.d.ts +3 -3
  660. package/package.json +23 -9
  661. package/utils/decorators/debug.class.decorator.d.ts +2 -0
  662. package/utils/decorators/index.d.ts +2 -0
  663. package/utils/decorators/trace.method.decorator.d.ts +14 -0
  664. package/utils/get.d.ts +1 -0
  665. package/utils/helpers/class-name.helper.d.ts +3 -0
  666. package/utils/helpers/debug-decorator.helper.d.ts +9 -0
  667. package/utils/helpers/debug.helper.d.ts +60 -0
  668. package/utils/helpers/index.d.ts +4 -0
  669. package/utils/helpers/reflect.helper.d.ts +50 -0
  670. package/utils/index.d.ts +13 -7
  671. package/utils/is-uuid.d.ts +1 -1
  672. package/utils/is.d.ts +1 -0
  673. package/utils/log.utils.d.ts +7 -0
  674. package/utils/mixins/base.mixin.d.ts +3 -3
  675. package/utils/mixins/index.d.ts +3 -3
  676. package/utils/mixins/merge-constructor-params.type.d.ts +3 -3
  677. package/utils/mixins/mixin-ctor.type.d.ts +1 -1
  678. package/utils/parse-datetime.d.ts +1 -1
  679. package/utils/types/array-element.type.d.ts +1 -1
  680. package/utils/types/index.d.ts +2 -2
  681. package/utils/types/prop.type.d.ts +1 -1
  682. package/bundles/infrab4a-connect.umd.js +0 -5175
  683. package/bundles/infrab4a-connect.umd.js.map +0 -1
  684. package/domain/catalog/models/types/category-filter.type.d.ts +0 -4
  685. package/esm2015/domain/catalog/models/category.js +0 -10
  686. package/esm2015/domain/catalog/models/index.js +0 -7
  687. package/esm2015/domain/catalog/models/kit-product.js +0 -18
  688. package/esm2015/domain/catalog/models/product.js +0 -17
  689. package/esm2015/domain/catalog/models/types/category-filter.type.js +0 -2
  690. package/esm2015/domain/catalog/models/types/index.js +0 -11
  691. package/esm2015/domain/catalog/models/types/product-review.type.js +0 -2
  692. package/esm2015/domain/catalog/models/variant.js +0 -10
  693. package/esm2015/domain/catalog/repositories/category.repository.js +0 -2
  694. package/esm2015/domain/catalog/repositories/index.js +0 -5
  695. package/esm2015/domain/catalog/repositories/product.repository.js +0 -2
  696. package/esm2015/domain/generic/model/base.model.js +0 -23
  697. package/esm2015/domain/generic/model/types/base-model-builder.type.js +0 -2
  698. package/esm2015/domain/generic/model/types/identifier-model.type.js +0 -2
  699. package/esm2015/domain/generic/model/types/model-base-structure.type.js +0 -2
  700. package/esm2015/domain/generic/model/types/non-function-properties.type.js +0 -2
  701. package/esm2015/domain/generic/model/types/non-function-property-name.type.js +0 -2
  702. package/esm2015/domain/generic/repository/create.repository.js +0 -2
  703. package/esm2015/domain/generic/repository/crud.repository.js +0 -2
  704. package/esm2015/domain/generic/repository/delete.repository.js +0 -2
  705. package/esm2015/domain/generic/repository/find.repository.js +0 -2
  706. package/esm2015/domain/generic/repository/get.repository.js +0 -2
  707. package/esm2015/domain/generic/repository/read.repository.js +0 -2
  708. package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +0 -2
  709. package/esm2015/domain/generic/repository/types/repository-find-result.type.js +0 -2
  710. package/esm2015/domain/generic/repository/types/repository-update-params.type.js +0 -2
  711. package/esm2015/domain/generic/repository/update.repository.js +0 -2
  712. package/esm2015/domain/location/models/address.js +0 -7
  713. package/esm2015/domain/shop-settings/models/home.js +0 -7
  714. package/esm2015/domain/shop-settings/models/types/home-data.type.js +0 -2
  715. package/esm2015/domain/shopping/models/buy-2-win.js +0 -14
  716. package/esm2015/domain/shopping/models/checkout.js +0 -38
  717. package/esm2015/domain/shopping/models/coupons/coupon.js +0 -38
  718. package/esm2015/domain/shopping/models/index.js +0 -12
  719. package/esm2015/domain/shopping/models/payment.js +0 -169
  720. package/esm2015/domain/shopping/models/shipping-method.js +0 -7
  721. package/esm2015/domain/shopping/models/subscription/checkout.js +0 -28
  722. package/esm2015/domain/shopping/models/types/payment-address.type.js +0 -2
  723. package/esm2015/domain/shopping/models/types/payment-card.type.js +0 -2
  724. package/esm2015/domain/shopping/models/types/payment-customer.type.js +0 -2
  725. package/esm2015/domain/shopping/repositories/index.js +0 -8
  726. package/esm2015/domain/users/models/beauty-profile.js +0 -12
  727. package/esm2015/domain/users/models/subscription/edition.js +0 -7
  728. package/esm2015/domain/users/models/subscription/payment.js +0 -14
  729. package/esm2015/domain/users/models/subscription/subscription.js +0 -43
  730. package/esm2015/domain/users/models/user-payment-method.js +0 -7
  731. package/esm2015/domain/users/models/user.js +0 -26
  732. package/esm2015/domain/users/repositories/user.repository.js +0 -2
  733. package/esm2015/domain/users/services/authentication.service.js +0 -2
  734. package/esm2015/domain/users/use-cases/authentication.js +0 -40
  735. package/esm2015/domain/users/use-cases/recovery-password.js +0 -12
  736. package/esm2015/domain/users/use-cases/register.js +0 -34
  737. package/esm2015/domain/users/use-cases/signout.js +0 -12
  738. package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +0 -57
  739. package/esm2015/infra/elasticsearch/adapters/elastic-search.adapter.js +0 -2
  740. package/esm2015/infra/elasticsearch/indexes/products-index.js +0 -93
  741. package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +0 -52
  742. package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +0 -26
  743. package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +0 -31
  744. package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +0 -10
  745. package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +0 -18
  746. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +0 -96
  747. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +0 -49
  748. package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +0 -24
  749. package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +0 -17
  750. package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +0 -11
  751. package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +0 -45
  752. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +0 -71
  753. package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +0 -52
  754. package/esm2015/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +0 -14
  755. package/esm2015/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +0 -12
  756. package/esm2015/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +0 -56
  757. package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +0 -12
  758. package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-settings-firestore.repository.js +0 -12
  759. package/esm2015/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +0 -12
  760. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +0 -12
  761. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +0 -12
  762. package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +0 -29
  763. package/esm2015/infra/firebase/firestore/repositories/shopping/index.js +0 -9
  764. package/esm2015/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +0 -9
  765. package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +0 -40
  766. package/esm2015/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +0 -12
  767. package/esm2015/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +0 -12
  768. package/esm2015/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +0 -12
  769. package/esm2015/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +0 -14
  770. package/esm2015/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +0 -12
  771. package/esm2015/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +0 -14
  772. package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +0 -14
  773. package/esm2015/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +0 -14
  774. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +0 -68
  775. package/esm2015/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +0 -14
  776. package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +0 -2
  777. package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +0 -2
  778. package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +0 -2
  779. package/esm2015/infra/firebase/firestore/types/index.js +0 -4
  780. package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +0 -31
  781. package/esm2015/infra/hasura-graphql/mixins/helpers/bind-filter-query.helper.js +0 -53
  782. package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +0 -22
  783. package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +0 -86
  784. package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +0 -45
  785. package/esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js +0 -10
  786. package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +0 -29
  787. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +0 -45
  788. package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +0 -35
  789. package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +0 -94
  790. package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +0 -56
  791. package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +0 -11
  792. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +0 -241
  793. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +0 -4
  794. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +0 -462
  795. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +0 -116
  796. package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +0 -2
  797. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +0 -2
  798. package/esm2015/utils/index.js +0 -8
  799. package/fesm2015/infrab4a-connect.js.map +0 -1
  800. package/infrab4a-connect.d.ts +0 -5
@@ -0,0 +1,4857 @@
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
+ },
3668
+ options: {
3669
+ enableCount: false,
3670
+ },
3671
+ });
3672
+ if (!data.length)
3673
+ throw new NotFoundError(`Category with slug ${slug} not found`);
3674
+ if (data.length > 1)
3675
+ throw new DuplicatedResultsError('Query returned duplicated values');
3676
+ return data.shift();
3677
+ }
3678
+ async getCategoryByShop(shop) {
3679
+ if (!shop)
3680
+ return;
3681
+ const { data } = await this.find({
3682
+ filters: {
3683
+ shops: { operator: Where.IN, value: [shop] },
3684
+ published: { operator: Where.EQUALS, value: true },
3685
+ isWishlist: { operator: Where.EQUALS, value: false },
3686
+ },
3687
+ options: {
3688
+ enableCount: false,
3689
+ },
3690
+ });
3691
+ return data;
3692
+ }
3693
+ async getCategoriesForHome(categoryIds, limit = 4, gender) {
3694
+ if (!categoryIds?.length)
3695
+ return [];
3696
+ const categoriesFirestore = categoryIds.filter((categoryId) => Number.isNaN(+categoryId));
3697
+ const categoriesHasura = categoryIds.filter((categoryId) => +categoryId > 0);
3698
+ const categories = [];
3699
+ if (categoriesFirestore.length)
3700
+ categories.push(...(await this.find({
3701
+ filters: { firestoreId: { operator: Where.IN, value: categoriesFirestore.filter(Boolean) }, published: true },
3702
+ }).then(({ data }) => data)));
3703
+ if (categoriesHasura.length)
3704
+ categories.push(...(await this.find({
3705
+ filters: { id: { operator: Where.IN, value: categoriesHasura.filter(Boolean) }, published: true },
3706
+ }).then(({ data }) => data)));
3707
+ if (!categories.length)
3708
+ return [];
3709
+ const homeSections = await Promise.all(categories.map(async (category) => ({
3710
+ category,
3711
+ products: await this.mountCategory(category, { limit, hasStock: true, gender }),
3712
+ })));
3713
+ return homeSections;
3714
+ }
3715
+ async mountCategory(category, options) {
3716
+ if (!category?.products?.length)
3717
+ return [];
3718
+ const products = [];
3719
+ const { data: productsData } = await this.productRepository.find({
3720
+ filters: {
3721
+ id: { operator: Where.IN, value: category.products },
3722
+ published: true,
3723
+ ...(options?.hasStock ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {}),
3724
+ ...(options?.gender ? { tags: { operator: Where.IN, value: [options?.gender] } } : {}),
3725
+ },
3726
+ fields: [
3727
+ 'id',
3728
+ 'name',
3729
+ 'slug',
3730
+ 'images',
3731
+ 'miniatures',
3732
+ 'price',
3733
+ 'fullPrice',
3734
+ 'subscriberDiscountPercentage',
3735
+ 'subscriberPrice',
3736
+ 'stock',
3737
+ 'published',
3738
+ 'CEST',
3739
+ 'EAN',
3740
+ 'NCM',
3741
+ 'brand',
3742
+ 'costPrice',
3743
+ 'hasVariants',
3744
+ 'isKit',
3745
+ 'sku',
3746
+ 'rate',
3747
+ 'tags',
3748
+ 'type',
3749
+ 'shoppingCount',
3750
+ 'gender',
3751
+ 'createdAt',
3752
+ ],
3753
+ ...(options?.limit ? { limits: { limit: options?.limit } } : {}),
3754
+ options: { enableCount: false },
3755
+ });
3756
+ products.push(...productsData);
3757
+ return products;
3758
+ }
3759
+ async getId(id) {
3760
+ if (!Number.isNaN(+id))
3761
+ return id;
3762
+ const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
3763
+ if (data?.[0]?.id)
3764
+ return data?.[0]?.id;
3765
+ throw new NotFoundError(`Category with id ${id} not found`);
3766
+ }
3767
+ async updateProducts(categoryId, { products }) {
3768
+ if ('action' in products && products.action === 'remove') {
3769
+ await this.mutation('delete_category_product', ['affected_rows'], {
3770
+ where: {
3771
+ type: 'category_product_bool_exp',
3772
+ required: true,
3773
+ value: { category_id: { _eq: categoryId } },
3774
+ },
3775
+ });
3776
+ return [];
3777
+ }
3778
+ const plainData = this.paramsToPlain({ products });
3779
+ if (!plainData.products || plainData.products.length <= 0)
3780
+ return [];
3781
+ await this.mutation('delete_category_product', ['affected_rows'], {
3782
+ where: {
3783
+ type: 'category_product_bool_exp',
3784
+ required: true,
3785
+ value: { category_id: { _eq: categoryId } },
3786
+ },
3787
+ });
3788
+ await this.mutation('insert_category_product', ['affected_rows'], {
3789
+ objects: {
3790
+ type: '[category_product_insert_input!]',
3791
+ required: true,
3792
+ value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
3793
+ },
3794
+ });
3795
+ return plainData.products;
3796
+ }
3797
+ async updateMetadata(categoryId, { metadata }) {
3798
+ const plainData = this.paramsToPlain({ metadata });
3799
+ if (!plainData.metadata)
3800
+ return null;
3801
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
3802
+ pk_columns: {
3803
+ value: { category_id: categoryId },
3804
+ type: 'category_metadata_pk_columns_input',
3805
+ required: true,
3806
+ },
3807
+ _set: {
3808
+ value: omit(metadata, ['category_id']),
3809
+ type: 'category_metadata_set_input',
3810
+ required: true,
3811
+ },
3812
+ });
3813
+ return plainData.metadata;
3814
+ }
3815
+ async updateFilters(categoryId, { filters }) {
3816
+ if ('action' in filters && filters.action === 'remove' && filters.value.length) {
3817
+ for (let i = 0; i < filters.value.length; i++) {
3818
+ await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filters.value[i].id);
3819
+ }
3820
+ return [];
3821
+ }
3822
+ if ('action' in filters && filters.action === 'merge' && filters.value.length) {
3823
+ let filtersList = [];
3824
+ const currentFilters = await this.categoryFilterRepository
3825
+ .find({
3826
+ filters: {
3827
+ categoryId,
3828
+ },
3829
+ })
3830
+ .then((res) => res.data);
3831
+ const currentFiltersId = currentFilters.map((f) => f.id);
3832
+ const filtersUpdatedId = filters.value.map((f) => f.id);
3833
+ const filterToBeDeleted = currentFiltersId.filter((c) => !filtersUpdatedId.includes(c));
3834
+ const filterToBeInserted = filtersUpdatedId.filter((c) => !currentFiltersId.includes(c));
3835
+ for (const filter of filterToBeDeleted) {
3836
+ const index = currentFilters.findIndex((f) => f.id == filter);
3837
+ if (index != -1) {
3838
+ currentFilters.splice(index, 1);
3839
+ }
3840
+ await this.categoryFilterRepository.deleteByCategoryAndFilter(categoryId, filter);
3841
+ }
3842
+ for (const filter of filterToBeInserted) {
3843
+ const newCategoryFilter = await this.categoryFilterRepository.create({
3844
+ filterId: filter,
3845
+ categoryId,
3846
+ });
3847
+ filtersList.push(filter);
3848
+ }
3849
+ return filters.value;
3850
+ }
3851
+ if (Array.isArray(filters) && filters.length) {
3852
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
3853
+ let filtersList = [];
3854
+ for (let i = 0; i < filters.length; i++) {
3855
+ const newCategoryFilter = await this.categoryFilterRepository.create({
3856
+ filterId: filters[i].id,
3857
+ categoryId,
3858
+ });
3859
+ filtersList.push(newCategoryFilter);
3860
+ }
3861
+ return filters;
3862
+ }
3863
+ }
3864
+ async getChildren(parentId) {
3865
+ const { category_tree } = await this.query('category_tree', ['id', 'name', 'parent_id'], {
3866
+ args: {
3867
+ type: 'category_tree_args',
3868
+ value: { parentid: parentId },
3869
+ required: true,
3870
+ },
3871
+ });
3872
+ return category_tree.map((category) => Category.toInstance(category));
3873
+ }
3874
+ async isChild(id, parentId) {
3875
+ const categoryTree = await this.getChildren(parentId);
3876
+ return categoryTree.some((c) => c.id == id.toString());
3877
+ }
3878
+ }
3879
+
3880
+ class FilterHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3881
+ constructor({ endpoint, authOptions, interceptors, }, filterOptionRepository, categoryFilterRepository) {
3882
+ super({
3883
+ tableName: 'filter',
3884
+ model: Filter,
3885
+ endpoint,
3886
+ authOptions,
3887
+ interceptors,
3888
+ fields: [
3889
+ 'id',
3890
+ 'description',
3891
+ 'slug',
3892
+ 'enabled',
3893
+ { createdAt: { columnName: 'created_at' } },
3894
+ { updatedAt: { columnName: 'updated_at' } },
3895
+ {
3896
+ options: {
3897
+ columnName: 'options',
3898
+ foreignKeyColumn: { filterId: 'id' },
3899
+ fields: [
3900
+ 'id',
3901
+ { filterId: { columnName: 'filter_id' } },
3902
+ 'description',
3903
+ { createdAt: { columnName: 'created_at' } },
3904
+ { updatedAt: { columnName: 'updated_at' } },
3905
+ ],
3906
+ },
3907
+ },
3908
+ ],
3909
+ });
3910
+ this.filterOptionRepository = filterOptionRepository;
3911
+ this.categoryFilterRepository = categoryFilterRepository;
3912
+ }
3913
+ async update(params) {
3914
+ const { options, ...data } = params;
3915
+ const filter = await super.update(data);
3916
+ filter.options = await this.updateOptions(+data.id, { options });
3917
+ return filter;
3918
+ }
3919
+ async updateOptions(filterId, { options }) {
3920
+ if (!options)
3921
+ return [];
3922
+ if ('action' in options && options.action === 'remove' && options.value.length) {
3923
+ for (let i = 0; i < options.value.length; i++) {
3924
+ await this.filterOptionRepository.delete({ id: options.value[i].id });
3925
+ }
3926
+ return [];
3927
+ }
3928
+ if ('action' in options && options.action === 'merge' && options.value.length) {
3929
+ let filterOptions = [];
3930
+ for (let i = 0; i < options.value.length; i++) {
3931
+ try {
3932
+ const hasFilter = await this.filterOptionRepository.get({ id: options.value[i].id });
3933
+ if (hasFilter)
3934
+ filterOptions.push(hasFilter);
3935
+ }
3936
+ catch (error) {
3937
+ const newOption = await this.filterOptionRepository.create({ ...options.value[i], filterId });
3938
+ filterOptions.push(newOption);
3939
+ }
3940
+ }
3941
+ return filterOptions;
3942
+ }
3943
+ if (Array.isArray(options) && options.length) {
3944
+ let filterOptions = [];
3945
+ for (let i = 0; i < options.length; i++) {
3946
+ try {
3947
+ const hasFilter = await this.filterOptionRepository.get({ id: options[i].id });
3948
+ if (hasFilter)
3949
+ filterOptions.push(hasFilter);
3950
+ }
3951
+ catch (error) {
3952
+ const newOption = await this.filterOptionRepository.create({ ...options[i], filterId });
3953
+ filterOptions.push(newOption);
3954
+ }
3955
+ }
3956
+ }
3957
+ return [];
3958
+ }
3959
+ async delete(params) {
3960
+ const { data: categoryFilters } = await this.categoryFilterRepository.find({
3961
+ filters: {
3962
+ filterId: params.id,
3963
+ },
3964
+ });
3965
+ if (categoryFilters.length)
3966
+ throw new Error('Erro: o filtro está associado a uma ou mais categoria(s)');
3967
+ await this.deleteOptions(+params.id);
3968
+ await super.delete({ id: +params.id });
3969
+ return;
3970
+ }
3971
+ async deleteOptions(filterId) {
3972
+ await this.mutation('delete_filter_option', ['affected_rows'], {
3973
+ where: {
3974
+ type: 'filter_option_bool_exp',
3975
+ required: true,
3976
+ value: { filter_id: { _eq: filterId } },
3977
+ },
3978
+ });
3979
+ }
3980
+ }
3981
+
3982
+ class FilterOptionHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
3983
+ constructor({ endpoint, authOptions, interceptors, }) {
3984
+ super({
3985
+ tableName: 'filter_option',
3986
+ model: FilterOption,
3987
+ endpoint,
3988
+ authOptions,
3989
+ interceptors,
3990
+ fields: [
3991
+ 'id',
3992
+ 'description',
3993
+ { filterId: { columnName: 'filter_id' } },
3994
+ { createdAt: { columnName: 'created_at' } },
3995
+ { updatedAt: { columnName: 'updated_at' } },
3996
+ ],
3997
+ });
3998
+ }
3999
+ }
4000
+
4001
+ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4002
+ constructor({ endpoint, authOptions, interceptors, }) {
4003
+ super({
4004
+ tableName: 'product',
4005
+ model: ProductHasuraGraphQL,
4006
+ endpoint,
4007
+ authOptions,
4008
+ interceptors,
4009
+ fields: [],
4010
+ });
4011
+ this.bindReviewToModel = (plain) => ({
4012
+ ...is(omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])),
4013
+ createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at,
4014
+ updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at,
4015
+ personId: plain.person_id,
4016
+ orderId: plain.order_id,
4017
+ });
4018
+ this.bindReviewToHasura = (review) => ({
4019
+ ...is(omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])),
4020
+ person_id: review.personId,
4021
+ order_id: review.orderId,
4022
+ });
4023
+ const commonFields = [
4024
+ { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4025
+ { firestoreId: { columnName: 'firestore_id' } },
4026
+ { productId: { columnName: 'main_product_id' } },
4027
+ { CEST: { columnName: 'cest' } },
4028
+ { EAN: { columnName: 'ean' } },
4029
+ { NCM: { columnName: 'ncm' } },
4030
+ 'brand',
4031
+ { costPrice: { columnName: 'cost_price' } },
4032
+ {
4033
+ description: {
4034
+ columnName: 'description',
4035
+ from: (description, data) => ({
4036
+ description,
4037
+ differentials: data.differentials,
4038
+ whoMustUse: data.who_must_use,
4039
+ howToUse: data.how_to_use,
4040
+ brand: data.brand_description,
4041
+ ingredients: data.ingredients,
4042
+ }),
4043
+ bindFindFilter: (filters) => {
4044
+ return {
4045
+ ...(filters?.description && { description: filters.description }),
4046
+ ...(filters.differentials && { differentials: filters.differentials }),
4047
+ ...(filters.whoMustUse && {
4048
+ who_must_use: filters.whoMustUse,
4049
+ }),
4050
+ ...(filters.howToUse && {
4051
+ how_to_use: filters.howToUse,
4052
+ }),
4053
+ ...(filters.brand && {
4054
+ brand_description: filters.brand,
4055
+ }),
4056
+ ...(filters.ingredients && {
4057
+ ingredients: filters.ingredients,
4058
+ }),
4059
+ };
4060
+ },
4061
+ bindPersistData: (descriptionData) => ({
4062
+ ...(descriptionData?.description && { description: descriptionData.description }),
4063
+ ...(descriptionData.differentials && { differentials: descriptionData.differentials }),
4064
+ ...(descriptionData.whoMustUse && {
4065
+ who_must_use: descriptionData.whoMustUse,
4066
+ }),
4067
+ ...(descriptionData.howToUse && { how_to_use: descriptionData.howToUse }),
4068
+ ...(descriptionData.brand && { brand_description: descriptionData.brand }),
4069
+ ...(descriptionData.ingredients && { ingredients: descriptionData.ingredients }),
4070
+ }),
4071
+ },
4072
+ },
4073
+ { differentials: { columnName: 'differentials' } },
4074
+ { whoMustUse: { columnName: 'who_must_use' } },
4075
+ { howToUse: { columnName: 'how_to_use' } },
4076
+ { brandDescription: { columnName: 'brand_description' } },
4077
+ { ingredients: { columnName: 'ingredients' } },
4078
+ { hasVariants: { columnName: 'has_variants' } },
4079
+ {
4080
+ images: {
4081
+ columnName: 'images',
4082
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.(`","`) || ''}"}` : `{}`),
4083
+ },
4084
+ },
4085
+ {
4086
+ miniatures: {
4087
+ columnName: 'miniatures',
4088
+ to: (value) => (value?.length > 0 ? `{"${value?.join?.(`","`) || ''}"}` : `{}`),
4089
+ },
4090
+ },
4091
+ 'name',
4092
+ {
4093
+ price: {
4094
+ columnName: 'price',
4095
+ from: (price, data) => ({
4096
+ price,
4097
+ fullPrice: data.full_price,
4098
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
4099
+ subscriberPrice: data.subscriber_price,
4100
+ }),
4101
+ bindFindFilter: (filters) => {
4102
+ return {
4103
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
4104
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
4105
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
4106
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
4107
+ }),
4108
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
4109
+ subscriber_price: filters.subscriberPrice,
4110
+ }),
4111
+ };
4112
+ },
4113
+ bindPersistData: (priceData) => ({
4114
+ ...(priceData?.price >= 0 && { price: priceData.price }),
4115
+ ...(priceData.fullPrice >= 0 && { full_price: priceData.fullPrice }),
4116
+ ...(priceData.subscriberDiscountPercentage >= 0 && {
4117
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4118
+ }),
4119
+ ...(priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }),
4120
+ }),
4121
+ },
4122
+ },
4123
+ { fullPrice: { columnName: 'full_price' } },
4124
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
4125
+ { subscriberPrice: { columnName: 'subscriber_price' } },
4126
+ 'published',
4127
+ 'sku',
4128
+ {
4129
+ stock: {
4130
+ columnName: 'stock',
4131
+ from: (quantity) => ({ quantity }),
4132
+ to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
4133
+ },
4134
+ },
4135
+ { hasStock: { columnName: 'has_stock' } },
4136
+ 'slug',
4137
+ 'type',
4138
+ 'video',
4139
+ 'weight',
4140
+ 'gender',
4141
+ { intGender: { columnName: 'int_gender' } },
4142
+ { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
4143
+ { filters: { columnName: 'filters', type: HasuraGraphQLColumnType.Jsonb } },
4144
+ { isKit: { columnName: 'is_kit' } },
4145
+ { createdAt: { columnName: 'created_at' } },
4146
+ { updatedAt: { columnName: 'updated_at' } },
4147
+ { rate: { columnName: 'rating' } },
4148
+ { reviewsTotal: { columnName: 'reviews_total' } },
4149
+ { shoppingCount: { columnName: 'shopping_count' } },
4150
+ { categoryId: { columnName: 'category_id' } },
4151
+ {
4152
+ category: {
4153
+ columnName: 'category',
4154
+ foreignKeyColumn: { id: 'categoryId' },
4155
+ fields: ['id', 'name', 'reference', 'slug'],
4156
+ },
4157
+ },
4158
+ ];
4159
+ this.fields = [
4160
+ ...commonFields,
4161
+ {
4162
+ categories: {
4163
+ columnName: 'categories',
4164
+ fields: ['category_id'],
4165
+ bindPersistData: (value) => ({
4166
+ categories: { data: value.map((category) => ({ category_id: +category })) },
4167
+ }),
4168
+ to: (categories) => categories.map((categoryId) => +categoryId),
4169
+ from: (categories) => categories?.map((category) => category?.category_id?.toString()) || [],
4170
+ },
4171
+ },
4172
+ {
4173
+ kitProducts: {
4174
+ columnName: 'kit_products',
4175
+ foreignKeyColumn: { productId: 'id' },
4176
+ fields: [
4177
+ { productId: { columnName: 'product_id' } },
4178
+ { kitProductId: { columnName: 'kit_product_id' } },
4179
+ 'quantity',
4180
+ { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
4181
+ ],
4182
+ },
4183
+ },
4184
+ {
4185
+ reviews: {
4186
+ columnName: 'reviews',
4187
+ foreignKeyColumn: { product_id: 'id' },
4188
+ fields: this.reviewsFields,
4189
+ },
4190
+ },
4191
+ {
4192
+ metadata: {
4193
+ columnName: 'metadata',
4194
+ fields: ['title', 'description'],
4195
+ bindPersistData: (value) => ({
4196
+ metadata: { data: value },
4197
+ }),
4198
+ },
4199
+ },
4200
+ ];
4201
+ }
4202
+ get reviewsFields() {
4203
+ return [
4204
+ 'id',
4205
+ 'shop',
4206
+ 'rate',
4207
+ 'author',
4208
+ 'email',
4209
+ 'location',
4210
+ 'review',
4211
+ 'status',
4212
+ 'title',
4213
+ { personId: { columnName: 'person_id' } },
4214
+ 'points',
4215
+ { orderId: { columnName: 'order_id' } },
4216
+ { createdAt: { columnName: 'created_at' } },
4217
+ { updatedAt: { columnName: 'updated_at' } },
4218
+ ];
4219
+ }
4220
+ async create(params) {
4221
+ const { metadata, ...data } = params;
4222
+ const product = await super.create(omit({ ...data, metadata: metadata || { description: null, title: null } }, ['reviews']));
4223
+ try {
4224
+ product.reviews = data.reviews && (await this.updateReviews(+product.id, data));
4225
+ }
4226
+ catch (error) {
4227
+ await this.delete({ id: product.id });
4228
+ throw error;
4229
+ }
4230
+ return product;
4231
+ }
4232
+ async get(identifiers) {
4233
+ const product = Number.isNaN(+identifiers.id)
4234
+ ? (await this.find({ filters: { firestoreId: identifiers.id }, options: { enableCount: false } })).data?.[0]
4235
+ : await super.get(identifiers);
4236
+ if (product.productId)
4237
+ throw new NotFoundError('Product not found, it is a variant');
4238
+ product.reviews = product.reviews || (await this.findReviewsByProduct(+product.id));
4239
+ return product;
4240
+ }
4241
+ async find(params) {
4242
+ const { filters, fields, ...options } = params || {};
4243
+ const bindFields = fields ||
4244
+ this.fields
4245
+ .map((field) => (typeof field === 'string' ? field : Object.keys(field).shift()))
4246
+ .filter((field) => field !== 'reviews');
4247
+ if (options.options?.minimal?.includes('price'))
4248
+ options.options?.minimal.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4249
+ if (options.options?.maximum?.includes('price'))
4250
+ options.options?.maximum.push('price.price', 'price.fullPrice', 'price.subscriberPrice');
4251
+ options.options?.minimal?.splice(options.options?.minimal.indexOf('price'), 1);
4252
+ options.options?.maximum?.splice(options.options?.maximum.indexOf('price'), 1);
4253
+ return super.find({
4254
+ ...options,
4255
+ filters: { ...filters, productId: { operator: Where.ISNULL } },
4256
+ fields: [
4257
+ ...bindFields,
4258
+ ...(bindFields.includes('price')
4259
+ ? [
4260
+ 'subscriberPrice',
4261
+ 'subscriberDiscountPercentage',
4262
+ 'fullPrice',
4263
+ ]
4264
+ : []),
4265
+ ],
4266
+ });
4267
+ }
4268
+ async getBySlug(slug) {
4269
+ const result = await this.find({
4270
+ filters: {
4271
+ slug,
4272
+ },
4273
+ fields: this.fields.map((field) => typeof field === 'string' ? field : Object.keys(field).shift()),
4274
+ options: {
4275
+ enableCount: false,
4276
+ },
4277
+ });
4278
+ const product = result?.data?.shift();
4279
+ RoundProductPricesHelper.roundProductPrices(product);
4280
+ return product;
4281
+ }
4282
+ async update(params) {
4283
+ const { categories, kitProducts, reviews, id: checkId, rate, metadata, ...data } = params;
4284
+ const plainData = this.paramsToPlain({ id: checkId });
4285
+ const id = await this.getId(plainData.id);
4286
+ const product = await super.update({ id, ...data });
4287
+ product.categories = categories && (await this.updateCategories(+id, { categories }));
4288
+ product.kitProducts = kitProducts && (await this.updateKitProducts(+id, { kitProducts }));
4289
+ product.reviews = reviews && (await this.updateReviews(+id, { reviews }));
4290
+ product.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4291
+ return product;
4292
+ }
4293
+ async fetchReviews(status) {
4294
+ const reviewsExpression = {
4295
+ status: status === 'pending'
4296
+ ? { [HasuraGraphQLWhere.ISNULL]: true }
4297
+ : { [HasuraGraphQLWhere.EQUALS]: status === 'approved' },
4298
+ };
4299
+ const { product: data } = await this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
4300
+ where: { value: { reviews: reviewsExpression }, type: 'product_bool_exp', required: true },
4301
+ });
4302
+ return data.reduce((reviews, product) => [
4303
+ ...reviews,
4304
+ ...product.reviews
4305
+ .filter((review) => (status === 'pending' && [undefined, null].includes(review.status)) ||
4306
+ (status === 'approved' && review.status === true) ||
4307
+ (status === 'rejected' && review.status === false))
4308
+ .map((review) => ({
4309
+ ...this.bindReviewToModel(review),
4310
+ productId: product.id,
4311
+ productName: product.name,
4312
+ productSku: product.sku,
4313
+ })),
4314
+ ], []);
4315
+ }
4316
+ async findCatalog(params, mainGender) {
4317
+ return this.find({
4318
+ ...params,
4319
+ filters: { ...params.filters, published: true },
4320
+ orderBy: {
4321
+ hasStock: 'desc',
4322
+ ...(!mainGender ? {} : { intGender: mainGender === 'female' ? 'desc' : 'asc' }),
4323
+ ...omit(params.orderBy, ['hasStock', 'intGender']),
4324
+ },
4325
+ });
4326
+ }
4327
+ async updateCategories(productId, { categories }) {
4328
+ if ('action' in categories && categories.action === 'remove') {
4329
+ await this.mutation('delete_category_product', ['affected_rows'], {
4330
+ where: {
4331
+ type: 'category_product_bool_exp',
4332
+ required: true,
4333
+ value: { product_id: { _eq: productId } },
4334
+ },
4335
+ });
4336
+ return [];
4337
+ }
4338
+ const plainData = this.paramsToPlain({ categories });
4339
+ if (!plainData.categories || plainData.categories.length <= 0)
4340
+ return [];
4341
+ await this.mutation('delete_category_product', ['affected_rows'], {
4342
+ where: {
4343
+ type: 'category_product_bool_exp',
4344
+ required: true,
4345
+ value: { product_id: { _eq: productId } },
4346
+ },
4347
+ });
4348
+ await this.mutation('insert_category_product', ['affected_rows'], {
4349
+ objects: {
4350
+ type: '[category_product_insert_input!]',
4351
+ required: true,
4352
+ value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
4353
+ },
4354
+ });
4355
+ return plainData.categories;
4356
+ }
4357
+ async updateKitProducts(productId, { kitProducts }) {
4358
+ const plainData = this.paramsToPlain({ kitProducts });
4359
+ await this.mutation('delete_product_kit', ['affected_rows'], {
4360
+ where: {
4361
+ type: 'product_kit_bool_exp',
4362
+ required: true,
4363
+ value: { kit_product_id: { _eq: productId } },
4364
+ },
4365
+ });
4366
+ await this.mutation('insert_product_kit', ['affected_rows'], {
4367
+ objects: {
4368
+ type: '[product_kit_insert_input!]',
4369
+ required: true,
4370
+ value: plainData.kitProducts.map((kitProduct) => ({
4371
+ kit_product_id: productId,
4372
+ product_id: kitProduct.productId || kitProduct.product.id,
4373
+ quantity: kitProduct.quantity,
4374
+ })),
4375
+ },
4376
+ });
4377
+ return plainData.kitProducts;
4378
+ }
4379
+ async updateReviews(productId, { reviews }) {
4380
+ if (!reviews)
4381
+ return [];
4382
+ if ('action' in reviews && reviews.action === 'remove') {
4383
+ const reviewIds = await Promise.all(reviews.value.map(async (reviewData) => {
4384
+ const review = await this.findReview(reviewData, productId);
4385
+ return review?.id;
4386
+ }));
4387
+ await this.mutation('delete_product_review', ['affected_rows'], {
4388
+ where: { value: { id: { _in: reviewIds.filter(Boolean) } }, type: 'product_review_bool_exp', required: true },
4389
+ });
4390
+ return reviews.value.map((review, index) => !reviewIds[index] && review).filter(Boolean);
4391
+ }
4392
+ const plainData = this.paramsToPlain({ reviews });
4393
+ if (!plainData.reviews || plainData.reviews.length <= 0)
4394
+ return [];
4395
+ return Promise.all(plainData.reviews.map(async (reviewData) => {
4396
+ const review = await this.findReview(reviewData, productId);
4397
+ if (review.id)
4398
+ return this.bindReviewToModel((await this.mutation('update_product_review_by_pk', this.reviewsFields, {
4399
+ pk_columns: {
4400
+ value: { id: review.id },
4401
+ type: 'product_review_pk_columns_input',
4402
+ required: true,
4403
+ },
4404
+ _set: {
4405
+ value: omit(this.bindReviewToHasura(reviewData), ['id', 'product_id']),
4406
+ type: 'product_review_set_input',
4407
+ required: true,
4408
+ },
4409
+ })).update_product_review_by_pk);
4410
+ return this.bindReviewToModel((await this.mutation('insert_product_review_one', this.reviewsFields, {
4411
+ object: {
4412
+ value: omit({ ...this.bindReviewToHasura(reviewData), product_id: productId }, ['id']),
4413
+ type: 'product_review_insert_input',
4414
+ required: true,
4415
+ },
4416
+ })).insert_product_review_one);
4417
+ }));
4418
+ }
4419
+ async updateMetadata(productId, { metadata }) {
4420
+ const plainData = this.paramsToPlain({ metadata });
4421
+ if (!plainData.metadata)
4422
+ return null;
4423
+ await this.mutation('update_product_metadata_by_pk', ['product_id'], {
4424
+ pk_columns: {
4425
+ value: { product_id: productId },
4426
+ type: 'product_metadata_pk_columns_input',
4427
+ required: true,
4428
+ },
4429
+ _set: {
4430
+ value: omit(metadata, ['product_id']),
4431
+ type: 'product_metadata_set_input',
4432
+ required: true,
4433
+ },
4434
+ });
4435
+ return plainData.metadata;
4436
+ }
4437
+ async getId(id) {
4438
+ if (!Number.isNaN(+id))
4439
+ return id;
4440
+ const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
4441
+ if (data?.[0]?.id)
4442
+ return data?.[0]?.id;
4443
+ throw new NotFoundError(`Product with id ${id} not found`);
4444
+ }
4445
+ async findReviewsByProduct(productId) {
4446
+ const { product_review: data } = await this.query('product_review', this.reviewsFields, {
4447
+ where: {
4448
+ value: {
4449
+ product_id: { _eq: productId },
4450
+ },
4451
+ type: 'product_review_bool_exp',
4452
+ required: true,
4453
+ },
4454
+ });
4455
+ return data && data.map((review) => this.bindReviewToModel(review));
4456
+ }
4457
+ async findReview(review, productId) {
4458
+ if (review.id)
4459
+ return review;
4460
+ let loadedReview;
4461
+ if (review.personId)
4462
+ loadedReview = await this.getReviewByPersonId(review.personId, productId, review.orderId);
4463
+ if (!loadedReview && review.author && review.email)
4464
+ loadedReview = await this.getReviewByAuthorAndEmail(review.author, review.email, productId, review.orderId);
4465
+ return loadedReview || review;
4466
+ }
4467
+ async getReviewByPersonId(personId, productId, orderId) {
4468
+ const { product_review: data } = await this.query('product_review', this.reviewsFields, {
4469
+ where: {
4470
+ value: {
4471
+ product_id: { _eq: productId },
4472
+ person_id: { _eq: personId },
4473
+ ...(orderId && { order_id: { _eq: orderId } }),
4474
+ },
4475
+ type: `product_review_bool_exp`,
4476
+ required: true,
4477
+ },
4478
+ });
4479
+ return data && data[0] && this.bindReviewToModel(data[0]);
4480
+ }
4481
+ async getReviewByAuthorAndEmail(author, email, productId, orderId) {
4482
+ const { product_review: data } = await this.query('product_review', this.reviewsFields, {
4483
+ where: {
4484
+ value: {
4485
+ product_id: { _eq: productId },
4486
+ author: { _eq: author },
4487
+ email: { _eq: email },
4488
+ ...(orderId && { order_id: { _eq: orderId } }),
4489
+ },
4490
+ type: `product_review_bool_exp`,
4491
+ required: true,
4492
+ },
4493
+ });
4494
+ return data && data[0] && this.bindReviewToModel(data[0]);
4495
+ }
4496
+ async cleanShoppingCountFromIds(ids) {
4497
+ return await this.mutation('update_product', ['affected_rows'], {
4498
+ where: {
4499
+ value: { id: { _nin: ids } },
4500
+ type: 'product_bool_exp',
4501
+ required: true,
4502
+ },
4503
+ _set: {
4504
+ value: { shopping_count: 0 },
4505
+ type: 'product_set_input',
4506
+ },
4507
+ });
4508
+ }
4509
+ }
4510
+
4511
+ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4512
+ constructor({ endpoint, authOptions, interceptors, }) {
4513
+ super({
4514
+ tableName: 'product',
4515
+ model: VariantHasuraGraphQL,
4516
+ endpoint,
4517
+ authOptions,
4518
+ interceptors,
4519
+ fields: [
4520
+ { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4521
+ { firestoreId: { columnName: 'firestore_id' } },
4522
+ {
4523
+ productId: {
4524
+ columnName: 'main_product_id',
4525
+ to: (value) => +value,
4526
+ from: (value) => value?.toString(),
4527
+ },
4528
+ },
4529
+ { EAN: { columnName: 'ean' } },
4530
+ { costPrice: { columnName: 'cost_price' } },
4531
+ {
4532
+ price: {
4533
+ columnName: 'price',
4534
+ from: (price, data) => ({
4535
+ price,
4536
+ fullPrice: data.full_price,
4537
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
4538
+ subscriberPrice: data.subscriber_price,
4539
+ }),
4540
+ bindFindFilter: (sentence) => {
4541
+ const filters = Object.values(sentence).shift();
4542
+ return {
4543
+ ...((filters?.price || filters?.price === 0) && { price: filters.price }),
4544
+ ...((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice }),
4545
+ ...((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
4546
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
4547
+ }),
4548
+ ...((filters.subscriberPrice || filters.subscriberPrice === 0) && {
4549
+ subscriber_price: filters.subscriberPrice,
4550
+ }),
4551
+ };
4552
+ },
4553
+ bindPersistData: (priceData) => ({
4554
+ ...((priceData?.price || 0) >= 0 && { price: priceData.price }),
4555
+ ...((priceData?.fullPrice || 0) >= 0 && { full_price: priceData.fullPrice }),
4556
+ ...((priceData?.subscriberDiscountPercentage || 0) >= 0 && {
4557
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4558
+ }),
4559
+ ...((priceData?.subscriberPrice || 0) >= 0 && { subscriber_price: priceData.subscriberPrice }),
4560
+ }),
4561
+ },
4562
+ },
4563
+ { fullPrice: { columnName: 'full_price' } },
4564
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
4565
+ { subscriberPrice: { columnName: 'subscriber_price' } },
4566
+ 'sku',
4567
+ {
4568
+ stock: {
4569
+ columnName: 'stock',
4570
+ from: (quantity) => ({ quantity }),
4571
+ to: (value) => (isNil(value?.quantity) ? value : value?.quantity),
4572
+ },
4573
+ },
4574
+ { hasStock: { columnName: 'has_stock' } },
4575
+ 'weight',
4576
+ { name: { to: () => '', from: () => undefined } },
4577
+ { hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
4578
+ { createdAt: { columnName: 'created_at' } },
4579
+ { updatedAt: { columnName: 'updated_at' } },
4580
+ {
4581
+ grade: {
4582
+ columnName: 'grade',
4583
+ type: HasuraGraphQLColumnType.Jsonb,
4584
+ },
4585
+ },
4586
+ ],
4587
+ });
4588
+ }
4589
+ async get(identifiers) {
4590
+ const variant = Number.isNaN(+identifiers.id)
4591
+ ? (await this.find({ filters: { firestoreId: identifiers.id } })).data?.[0]
4592
+ : await super.get(identifiers);
4593
+ if (!variant.productId)
4594
+ throw new NotFoundError(`Variant not found, it is a product`);
4595
+ return variant;
4596
+ }
4597
+ async find(params) {
4598
+ const { filters, ...options } = params || {};
4599
+ return super.find({ ...options, filters: { productId: { operator: Where.ISNOTNULL }, ...filters } });
4600
+ }
4601
+ async update(params) {
4602
+ const { productId, id: checkId, ...data } = params;
4603
+ const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
4604
+ const id = await this.getId(dataWithProductId.id);
4605
+ const product = await super.update({ id, ...data });
4606
+ product.productId = dataWithProductId.productId;
4607
+ return product;
4608
+ }
4609
+ async getId(id) {
4610
+ if (!Number.isNaN(+id))
4611
+ return id;
4612
+ const { data } = await this.find({ filters: { firestoreId: id }, options: { enableCount: false } });
4613
+ if (data?.[0]?.id)
4614
+ return data?.[0]?.id;
4615
+ throw new NotFoundError(`Product with id ${id} not found`);
4616
+ }
4617
+ }
4618
+
4619
+ class WishlistHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
4620
+ constructor({ endpoint, authOptions, interceptors, }, categoryFilterRepository) {
4621
+ super({
4622
+ tableName: 'category',
4623
+ model: Wishlist,
4624
+ endpoint,
4625
+ authOptions,
4626
+ interceptors,
4627
+ fields: [
4628
+ { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
4629
+ { firestoreId: { columnName: 'firestore_id' } },
4630
+ 'name',
4631
+ 'description',
4632
+ 'image',
4633
+ 'published',
4634
+ 'shop',
4635
+ { shops: { columnName: 'shops', type: HasuraGraphQLColumnType.Jsonb } },
4636
+ 'slug',
4637
+ { brandCategory: { columnName: 'brand_category' } },
4638
+ { brandCategoryBanner: { columnName: 'brand_banner' } },
4639
+ { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
4640
+ { brandLogo: { columnName: 'brand_logo' } },
4641
+ { brandCondition: { columnName: 'brand_condition' } },
4642
+ {
4643
+ conditions: {
4644
+ columnName: 'tag_condition',
4645
+ type: HasuraGraphQLColumnType.Jsonb,
4646
+ from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
4647
+ bindPersistData: (value) => {
4648
+ return {
4649
+ brand_condition: value.brand,
4650
+ tag_condition: value?.tags || [],
4651
+ };
4652
+ },
4653
+ bindFindFilter: (sentence) => {
4654
+ return {
4655
+ ...(sentence.brand ? { brand_condition: sentence.brand } : {}),
4656
+ ...(sentence.tags ? { tag_condition: sentence.tags } : {}),
4657
+ };
4658
+ },
4659
+ },
4660
+ },
4661
+ {
4662
+ filters: {
4663
+ columnName: 'filters',
4664
+ foreignKeyColumn: { filter_id: 'id' },
4665
+ fields: [{ filter: ['id', 'description', 'slug', 'enabled'] }],
4666
+ bindPersistData: (value) => ({
4667
+ filters: { data: value.map((filter) => ({ filter_id: filter.id })) },
4668
+ }),
4669
+ from: (filters) => filters?.map((filter) => filter?.filter) || [],
4670
+ },
4671
+ },
4672
+ { createdAt: { columnName: 'created_at' } },
4673
+ { updatedAt: { columnName: 'updated_at' } },
4674
+ {
4675
+ products: {
4676
+ columnName: 'products',
4677
+ fields: ['product_id'],
4678
+ from: (value) => value.map((product) => product.product_id.toString()),
4679
+ to: (productIds) => productIds.map((productId) => ({
4680
+ product_id: +productId,
4681
+ })),
4682
+ },
4683
+ },
4684
+ {
4685
+ metadata: {
4686
+ columnName: 'metadata',
4687
+ fields: ['title', 'description'],
4688
+ bindPersistData: (value) => ({
4689
+ metadata: { data: value },
4690
+ }),
4691
+ },
4692
+ },
4693
+ { isCollection: { columnName: 'is_collection' } },
4694
+ { isWishlist: { columnName: 'is_wishlist' } },
4695
+ 'reference',
4696
+ { parentId: { columnName: 'parent_id' } },
4697
+ {
4698
+ parent: {
4699
+ columnName: 'parent',
4700
+ foreignKeyColumn: { id: 'parentId' },
4701
+ fields: ['id', 'name', 'reference', 'slug'],
4702
+ },
4703
+ },
4704
+ { personId: { columnName: 'person_id' } },
4705
+ { personName: { columnName: 'person_name' } },
4706
+ { personPhoto: { columnName: 'person_photo' } },
4707
+ ],
4708
+ });
4709
+ this.categoryFilterRepository = categoryFilterRepository;
4710
+ }
4711
+ async create(params) {
4712
+ const { metadata, ...data } = params;
4713
+ return super.create({
4714
+ ...data,
4715
+ isWishlist: true,
4716
+ isCollection: true,
4717
+ brandCategory: false,
4718
+ metadata: metadata || { description: data.description, title: data.name },
4719
+ });
4720
+ }
4721
+ async get(identifiers) {
4722
+ const data = await super.get(identifiers);
4723
+ if (!data.isWishlist)
4724
+ throw new NotFoundError(`Category with id ${identifiers.id} is not a wishlist`);
4725
+ return data;
4726
+ }
4727
+ async update(params) {
4728
+ const { products, id: checkId, metadata, filters, ...data } = params;
4729
+ const plainData = this.paramsToPlain({ id: checkId });
4730
+ const id = plainData.id;
4731
+ const category = await super.update({ id, ...data, isWishlist: true, isCollection: true, brandCategory: false });
4732
+ category.products = products && (await this.updateProducts(+id, { products }));
4733
+ category.metadata = metadata && (await this.updateMetadata(+id, { metadata }));
4734
+ return category;
4735
+ }
4736
+ async getWishlistBySlug(slug) {
4737
+ if (!slug)
4738
+ return;
4739
+ const { data } = await this.find({
4740
+ filters: {
4741
+ slug,
4742
+ isWishlist: { operator: Where.EQUALS, value: true },
4743
+ },
4744
+ options: {
4745
+ enableCount: false,
4746
+ },
4747
+ });
4748
+ if (!data.length)
4749
+ throw new NotFoundError(`Wishlist with slug ${slug} not found`);
4750
+ if (data.length > 1)
4751
+ throw new DuplicatedResultsError('Query returned duplicated values');
4752
+ return data.shift();
4753
+ }
4754
+ async getWishlistByPerson(personId) {
4755
+ if (!personId)
4756
+ return;
4757
+ const { data } = await this.find({
4758
+ filters: {
4759
+ personId: { operator: Where.EQUALS, value: personId },
4760
+ isWishlist: { operator: Where.EQUALS, value: true },
4761
+ },
4762
+ options: {
4763
+ enableCount: false,
4764
+ },
4765
+ });
4766
+ if (!data.length)
4767
+ throw new NotFoundError(`Wishlists from person ${personId} not found`);
4768
+ return data;
4769
+ }
4770
+ async updateProducts(categoryId, { products }) {
4771
+ if ('action' in products && products.action === 'remove') {
4772
+ await this.mutation('delete_category_product', ['affected_rows'], {
4773
+ where: {
4774
+ type: 'category_product_bool_exp',
4775
+ required: true,
4776
+ value: { category_id: { _eq: categoryId } },
4777
+ },
4778
+ });
4779
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
4780
+ return [];
4781
+ }
4782
+ const plainData = this.paramsToPlain({ products });
4783
+ if (!plainData.products || plainData.products.length <= 0)
4784
+ return [];
4785
+ await this.mutation('delete_category_product', ['affected_rows'], {
4786
+ where: {
4787
+ type: 'category_product_bool_exp',
4788
+ required: true,
4789
+ value: { category_id: { _eq: categoryId } },
4790
+ },
4791
+ });
4792
+ await this.categoryFilterRepository.deleteByCategory(categoryId);
4793
+ await this.mutation('insert_category_product', ['affected_rows'], {
4794
+ objects: {
4795
+ type: '[category_product_insert_input!]',
4796
+ required: true,
4797
+ value: plainData.products.map((productId) => ({ category_id: categoryId, product_id: productId })),
4798
+ },
4799
+ });
4800
+ return plainData.products;
4801
+ }
4802
+ async updateMetadata(categoryId, { metadata }) {
4803
+ const plainData = this.paramsToPlain({ metadata });
4804
+ if (!plainData.metadata)
4805
+ return;
4806
+ await this.mutation('update_category_metadata_by_pk', ['category_id'], {
4807
+ pk_columns: {
4808
+ value: { category_id: categoryId },
4809
+ type: 'category_metadata_pk_columns_input',
4810
+ required: true,
4811
+ },
4812
+ _set: {
4813
+ value: omit(metadata, ['category_id']),
4814
+ type: 'category_metadata_set_input',
4815
+ required: true,
4816
+ },
4817
+ });
4818
+ return plainData.metadata;
4819
+ }
4820
+ getCategoryBySlug(slug, _shop) {
4821
+ return this.getWishlistBySlug(slug);
4822
+ }
4823
+ async getCategoryByShop(shop) {
4824
+ if (!shop)
4825
+ return;
4826
+ const { data } = await this.find({
4827
+ filters: {
4828
+ shops: { operator: Where.IN, value: [shop] },
4829
+ published: { operator: Where.EQUALS, value: true },
4830
+ isWishlist: { operator: Where.EQUALS, value: true },
4831
+ },
4832
+ options: {
4833
+ enableCount: false,
4834
+ },
4835
+ });
4836
+ return data;
4837
+ }
4838
+ getCategoriesForHome(categoryIds, limit, gender) {
4839
+ return;
4840
+ }
4841
+ mountCategory(category, options) {
4842
+ return;
4843
+ }
4844
+ getChildren(parentId) {
4845
+ return;
4846
+ }
4847
+ isChild(id, parentId) {
4848
+ return;
4849
+ }
4850
+ }
4851
+
4852
+ /**
4853
+ * Generated bundle index. Do not edit.
4854
+ */
4855
+
4856
+ 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 };
4857
+ //# sourceMappingURL=infrab4a-connect.mjs.map