@infrab4a/connect 4.1.7-beta.0 → 4.2.0-beta.2

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