@infrab4a/connect 4.0.2-beta.9 → 4.0.3-beta.0

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