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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1038) hide show
  1. package/README.md +24 -24
  2. package/bundles/infrab4a-connect.umd.js +4262 -2300
  3. package/bundles/infrab4a-connect.umd.js.map +1 -1
  4. package/domain/catalog/index.d.ts +2 -0
  5. package/domain/catalog/models/category.d.ts +23 -0
  6. package/domain/catalog/models/enums/index.d.ts +1 -0
  7. package/domain/catalog/models/enums/shops.enum.d.ts +5 -0
  8. package/domain/catalog/models/index.d.ts +6 -0
  9. package/domain/catalog/models/kit-product.d.ts +12 -0
  10. package/domain/catalog/models/product.d.ts +39 -0
  11. package/domain/catalog/models/types/category-condition.type.d.ts +4 -0
  12. package/domain/catalog/models/types/category-filter.type.d.ts +4 -0
  13. package/domain/catalog/models/types/index.d.ts +7 -0
  14. package/domain/catalog/models/types/product-review.type.d.ts +17 -0
  15. package/domain/catalog/models/types/shops-description.type.d.ts +7 -0
  16. package/domain/catalog/models/types/shops-price.type.d.ts +10 -0
  17. package/domain/catalog/models/types/stock.type.d.ts +3 -0
  18. package/domain/catalog/models/types/variant-grade.type.d.ts +4 -0
  19. package/domain/catalog/models/variant.d.ts +18 -0
  20. package/domain/catalog/repositories/category.repository.d.ts +15 -0
  21. package/domain/catalog/repositories/index.d.ts +4 -0
  22. package/domain/catalog/repositories/product.repository.d.ts +12 -0
  23. package/domain/catalog/repositories/subscription-product.repository.d.ts +4 -0
  24. package/domain/catalog/repositories/variant.repository.d.ts +4 -0
  25. package/domain/generic/index.d.ts +2 -0
  26. package/domain/generic/model/base.model.d.ts +10 -0
  27. package/domain/generic/model/identifier-fields.d.ts +4 -0
  28. package/domain/generic/model/index.d.ts +3 -0
  29. package/domain/generic/model/types/base-model-builder.type.d.ts +15 -0
  30. package/domain/generic/model/types/identifier-model.type.d.ts +7 -0
  31. package/domain/generic/model/types/index.d.ts +5 -0
  32. package/domain/generic/model/types/model-base-structure.type.d.ts +6 -0
  33. package/domain/generic/model/types/non-function-properties.type.d.ts +12 -0
  34. package/domain/generic/model/types/non-function-property-name.type.d.ts +4 -0
  35. package/domain/generic/repository/create.repository.d.ts +8 -0
  36. package/domain/generic/repository/crud.repository.d.ts +19 -0
  37. package/domain/generic/repository/delete.repository.d.ts +7 -0
  38. package/domain/generic/repository/enums/index.d.ts +2 -0
  39. package/domain/generic/repository/enums/update-option-actions.enum.d.ts +7 -0
  40. package/domain/generic/repository/enums/where.enum.d.ts +13 -0
  41. package/domain/generic/repository/find.repository.d.ts +11 -0
  42. package/domain/generic/repository/get.repository.d.ts +5 -0
  43. package/domain/generic/repository/index.d.ts +9 -0
  44. package/domain/generic/repository/read.repository.d.ts +14 -0
  45. package/domain/generic/repository/types/index.d.ts +6 -0
  46. package/domain/generic/repository/types/repository-find-filters.type.d.ts +13 -0
  47. package/domain/generic/repository/types/repository-find-result.type.d.ts +4 -0
  48. package/domain/generic/repository/types/repository-limit-options.type.d.ts +4 -0
  49. package/domain/generic/repository/types/repository-order-by-list.type.d.ts +5 -0
  50. package/domain/generic/repository/types/repository-update-params.type.d.ts +11 -0
  51. package/domain/generic/repository/types/where-options.type.d.ts +2 -0
  52. package/domain/generic/repository/update.repository.d.ts +6 -0
  53. package/domain/index.d.ts +6 -0
  54. package/domain/location/index.d.ts +1 -0
  55. package/domain/location/models/address.d.ts +22 -0
  56. package/domain/location/models/index.d.ts +2 -0
  57. package/domain/location/models/types/index.d.ts +3 -0
  58. package/domain/location/models/types/location-bound.type.d.ts +6 -0
  59. package/domain/location/models/types/location-geometry.type.d.ts +7 -0
  60. package/domain/location/models/types/location-lat-lng.type.d.ts +4 -0
  61. package/domain/shop-settings/enums/filter-type.enum.d.ts +19 -0
  62. package/domain/shop-settings/enums/index.d.ts +2 -0
  63. package/domain/shop-settings/enums/questions-filters.enum.d.ts +19 -0
  64. package/domain/shop-settings/helpers/beauty-questions.helper.d.ts +9 -0
  65. package/domain/shop-settings/helpers/index.d.ts +1 -0
  66. package/domain/shop-settings/index.d.ts +4 -0
  67. package/domain/shop-settings/models/home.d.ts +17 -0
  68. package/domain/shop-settings/models/index.d.ts +3 -0
  69. package/domain/shop-settings/models/shop-menu.d.ts +7 -0
  70. package/domain/shop-settings/models/types/banner.type.d.ts +6 -0
  71. package/domain/shop-settings/models/types/benefit.type.d.ts +5 -0
  72. package/domain/shop-settings/models/types/home-data.type.d.ts +15 -0
  73. package/domain/shop-settings/models/types/index.d.ts +5 -0
  74. package/domain/shop-settings/models/types/menu-nav.type.d.ts +8 -0
  75. package/domain/shop-settings/models/types/sub-menu.type.d.ts +8 -0
  76. package/domain/shop-settings/repositories/home.repository.d.ts +4 -0
  77. package/domain/shop-settings/repositories/index.d.ts +2 -0
  78. package/domain/shop-settings/repositories/shop-menu.repository.d.ts +4 -0
  79. package/domain/shopping/index.d.ts +2 -0
  80. package/domain/shopping/models/buy-2-win.d.ts +16 -0
  81. package/domain/shopping/models/checkout.d.ts +27 -0
  82. package/domain/shopping/models/coupons/coupon.d.ts +26 -0
  83. package/domain/shopping/models/coupons/enums/coupon-subtypes.enum.d.ts +4 -0
  84. package/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +6 -0
  85. package/domain/shopping/models/coupons/enums/exclusivities.enum.d.ts +5 -0
  86. package/domain/shopping/models/coupons/enums/index.d.ts +3 -0
  87. package/domain/shopping/models/coupons/financial-coupon.d.ts +9 -0
  88. package/domain/shopping/models/coupons/index.d.ts +3 -0
  89. package/domain/shopping/models/enums/checkout-types.enum.d.ts +4 -0
  90. package/domain/shopping/models/enums/index.d.ts +2 -0
  91. package/domain/shopping/models/enums/order-status.enum.d.ts +10 -0
  92. package/domain/shopping/models/index.d.ts +11 -0
  93. package/domain/shopping/models/line-item.d.ts +8 -0
  94. package/domain/shopping/models/order.d.ts +9 -0
  95. package/domain/shopping/models/payment.d.ts +67 -0
  96. package/domain/shopping/models/shipping-method.d.ts +16 -0
  97. package/domain/shopping/models/subscription/checkout.d.ts +21 -0
  98. package/domain/shopping/models/subscription/index.d.ts +2 -0
  99. package/domain/shopping/models/subscription/plan.d.ts +10 -0
  100. package/domain/shopping/models/types/index.d.ts +7 -0
  101. package/domain/shopping/models/types/payment-address.type.d.ts +12 -0
  102. package/domain/shopping/models/types/payment-billing.type.d.ts +7 -0
  103. package/domain/shopping/models/types/payment-card.type.d.ts +14 -0
  104. package/domain/shopping/models/types/payment-customer.type.d.ts +18 -0
  105. package/domain/shopping/models/types/payment-document.type.d.ts +6 -0
  106. package/domain/shopping/models/types/payment-item.type.d.ts +11 -0
  107. package/domain/shopping/models/types/payment-shipping.type.d.ts +10 -0
  108. package/domain/shopping/repositories/buy-2-win.repository.d.ts +4 -0
  109. package/domain/shopping/repositories/checkout.repository.d.ts +4 -0
  110. package/domain/shopping/repositories/coupon.repository.d.ts +4 -0
  111. package/domain/shopping/repositories/index.d.ts +7 -0
  112. package/domain/shopping/repositories/legacy-order.repository.d.ts +3 -0
  113. package/domain/shopping/repositories/order.repository.d.ts +4 -0
  114. package/domain/shopping/repositories/payment.repository.d.ts +4 -0
  115. package/domain/shopping/repositories/subscription/checkout.repository.d.ts +4 -0
  116. package/domain/shopping/repositories/subscription/index.d.ts +2 -0
  117. package/domain/shopping/repositories/subscription/plan.repository.d.ts +4 -0
  118. package/domain/users/errors/index.d.ts +3 -0
  119. package/domain/users/errors/unauthorized.error.d.ts +5 -0
  120. package/domain/users/errors/user-already-registered.error.d.ts +5 -0
  121. package/domain/users/errors/weak-password.error.d.ts +5 -0
  122. package/domain/users/index.d.ts +5 -0
  123. package/domain/users/models/beauty-profile.d.ts +11 -0
  124. package/domain/users/models/enums/accessory-importances.enum.d.ts +5 -0
  125. package/domain/users/models/enums/area.enum.d.ts +11 -0
  126. package/domain/users/models/enums/beard-problems.enum.d.ts +9 -0
  127. package/domain/users/models/enums/beard-sizes.enum.d.ts +7 -0
  128. package/domain/users/models/enums/beauty-product-importances.enum.d.ts +6 -0
  129. package/domain/users/models/enums/body-problems.enum.d.ts +11 -0
  130. package/domain/users/models/enums/body-shapes.enum.d.ts +7 -0
  131. package/domain/users/models/enums/body-tattoos.enum.d.ts +5 -0
  132. package/domain/users/models/enums/face-skin-oilinesses.enum.d.ts +7 -0
  133. package/domain/users/models/enums/face-skin-problems.enum.d.ts +10 -0
  134. package/domain/users/models/enums/face-skin-tones.enum.d.ts +8 -0
  135. package/domain/users/models/enums/family-incomes.enum.d.ts +8 -0
  136. package/domain/users/models/enums/fragrance-importances.enum.d.ts +5 -0
  137. package/domain/users/models/enums/hair-colors.enum.d.ts +10 -0
  138. package/domain/users/models/enums/hair-problems.enum.d.ts +10 -0
  139. package/domain/users/models/enums/hair-strands.enum.d.ts +8 -0
  140. package/domain/users/models/enums/hair-types.enum.d.ts +7 -0
  141. package/domain/users/models/enums/index.d.ts +20 -0
  142. package/domain/users/models/enums/office-position.enum.d.ts +6 -0
  143. package/domain/users/models/enums/product-spents.enum.d.ts +8 -0
  144. package/domain/users/models/enums/user-type.enum.d.ts +8 -0
  145. package/domain/users/models/index.d.ts +7 -0
  146. package/domain/users/models/lead.d.ts +7 -0
  147. package/domain/users/models/subscription/edition.d.ts +16 -0
  148. package/domain/users/models/subscription/enums/billing-status.enum.d.ts +3 -0
  149. package/domain/users/models/subscription/enums/edition-status.enum.d.ts +4 -0
  150. package/domain/users/models/subscription/enums/index.d.ts +4 -0
  151. package/domain/users/models/subscription/enums/payment-type.enum.d.ts +5 -0
  152. package/domain/users/models/subscription/enums/status.enum.d.ts +4 -0
  153. package/domain/users/models/subscription/index.d.ts +4 -0
  154. package/domain/users/models/subscription/payment.d.ts +13 -0
  155. package/domain/users/models/subscription/subscription.d.ts +28 -0
  156. package/domain/users/models/user-address.d.ts +7 -0
  157. package/domain/users/models/user-payment-method.d.ts +14 -0
  158. package/domain/users/models/user.d.ts +26 -0
  159. package/domain/users/repositories/beauty-profile.repository.d.ts +4 -0
  160. package/domain/users/repositories/edition.repository.d.ts +4 -0
  161. package/domain/users/repositories/index.d.ts +8 -0
  162. package/domain/users/repositories/lead.repository.d.ts +4 -0
  163. package/domain/users/repositories/subscription-payment.repository.d.ts +4 -0
  164. package/domain/users/repositories/subscription.repository.d.ts +4 -0
  165. package/domain/users/repositories/user-address.repository.d.ts +4 -0
  166. package/domain/users/repositories/user-payment-method.repository.d.ts +4 -0
  167. package/domain/users/repositories/user.repository.d.ts +6 -0
  168. package/domain/users/services/authentication.service.d.ts +12 -0
  169. package/domain/users/services/index.d.ts +3 -0
  170. package/domain/users/services/register.service.d.ts +7 -0
  171. package/domain/users/services/types/basic-user-data.type.d.ts +4 -0
  172. package/domain/users/services/types/index.d.ts +1 -0
  173. package/domain/users/use-cases/authentication.d.ts +21 -0
  174. package/domain/users/use-cases/index.d.ts +4 -0
  175. package/domain/users/use-cases/recovery-password.d.ts +6 -0
  176. package/domain/users/use-cases/register.d.ts +13 -0
  177. package/domain/users/use-cases/signout.d.ts +6 -0
  178. package/errors/duplicated-results.error.d.ts +5 -0
  179. package/errors/index.d.ts +4 -0
  180. package/errors/invalid-argument.error.d.ts +5 -0
  181. package/errors/not-found.error.d.ts +5 -0
  182. package/errors/required-argument.error.d.ts +6 -0
  183. package/esm2015/domain/catalog/index.js +3 -0
  184. package/esm2015/domain/catalog/models/category.js +10 -0
  185. package/esm2015/domain/catalog/models/enums/index.js +2 -0
  186. package/esm2015/domain/catalog/models/enums/shops.enum.js +7 -0
  187. package/esm2015/domain/catalog/models/index.js +7 -0
  188. package/esm2015/domain/catalog/models/kit-product.js +18 -0
  189. package/esm2015/domain/catalog/models/product.js +21 -0
  190. package/esm2015/domain/catalog/models/types/category-condition.type.js +2 -0
  191. package/esm2015/domain/catalog/models/types/category-filter.type.js +2 -0
  192. package/esm2015/domain/catalog/models/types/index.js +8 -0
  193. package/esm2015/domain/catalog/models/types/product-review.type.js +2 -0
  194. package/esm2015/domain/catalog/models/types/shops-description.type.js +2 -0
  195. package/esm2015/domain/catalog/models/types/shops-price.type.js +2 -0
  196. package/esm2015/domain/catalog/models/types/stock.type.js +2 -0
  197. package/esm2015/domain/catalog/models/types/variant-grade.type.js +2 -0
  198. package/esm2015/domain/catalog/models/variant.js +10 -0
  199. package/esm2015/domain/catalog/repositories/category.repository.js +2 -0
  200. package/esm2015/domain/catalog/repositories/index.js +5 -0
  201. package/esm2015/domain/catalog/repositories/product.repository.js +2 -0
  202. package/esm2015/domain/catalog/repositories/subscription-product.repository.js +2 -0
  203. package/esm2015/domain/catalog/repositories/variant.repository.js +2 -0
  204. package/esm2015/domain/generic/index.js +3 -0
  205. package/esm2015/domain/generic/model/base.model.js +23 -0
  206. package/esm2015/domain/generic/model/identifier-fields.js +2 -0
  207. package/esm2015/domain/generic/model/index.js +4 -0
  208. package/esm2015/domain/generic/model/types/base-model-builder.type.js +2 -0
  209. package/esm2015/domain/generic/model/types/identifier-model.type.js +2 -0
  210. package/esm2015/domain/generic/model/types/index.js +6 -0
  211. package/esm2015/domain/generic/model/types/model-base-structure.type.js +2 -0
  212. package/esm2015/domain/generic/model/types/non-function-properties.type.js +2 -0
  213. package/esm2015/domain/generic/model/types/non-function-property-name.type.js +2 -0
  214. package/esm2015/domain/generic/repository/create.repository.js +2 -0
  215. package/esm2015/domain/generic/repository/crud.repository.js +2 -0
  216. package/esm2015/domain/generic/repository/delete.repository.js +2 -0
  217. package/esm2015/domain/generic/repository/enums/index.js +3 -0
  218. package/esm2015/domain/generic/repository/enums/update-option-actions.enum.js +9 -0
  219. package/esm2015/domain/generic/repository/enums/where.enum.js +15 -0
  220. package/esm2015/domain/generic/repository/find.repository.js +2 -0
  221. package/esm2015/domain/generic/repository/get.repository.js +2 -0
  222. package/esm2015/domain/generic/repository/index.js +10 -0
  223. package/esm2015/domain/generic/repository/read.repository.js +2 -0
  224. package/esm2015/domain/generic/repository/types/index.js +7 -0
  225. package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +2 -0
  226. package/esm2015/domain/generic/repository/types/repository-find-result.type.js +2 -0
  227. package/esm2015/domain/generic/repository/types/repository-limit-options.type.js +2 -0
  228. package/esm2015/domain/generic/repository/types/repository-order-by-list.type.js +2 -0
  229. package/esm2015/domain/generic/repository/types/repository-update-params.type.js +2 -0
  230. package/esm2015/domain/generic/repository/types/where-options.type.js +2 -0
  231. package/esm2015/domain/generic/repository/update.repository.js +2 -0
  232. package/esm2015/domain/index.js +7 -0
  233. package/esm2015/domain/location/index.js +2 -0
  234. package/esm2015/domain/location/models/address.js +7 -0
  235. package/esm2015/domain/location/models/index.js +3 -0
  236. package/esm2015/domain/location/models/types/index.js +4 -0
  237. package/esm2015/domain/location/models/types/location-bound.type.js +2 -0
  238. package/esm2015/domain/location/models/types/location-geometry.type.js +2 -0
  239. package/esm2015/domain/location/models/types/location-lat-lng.type.js +2 -0
  240. package/esm2015/domain/shop-settings/enums/filter-type.enum.js +21 -0
  241. package/esm2015/domain/shop-settings/enums/index.js +3 -0
  242. package/esm2015/domain/shop-settings/enums/questions-filters.enum.js +21 -0
  243. package/esm2015/domain/shop-settings/helpers/beauty-questions.helper.js +46 -0
  244. package/esm2015/domain/shop-settings/helpers/index.js +2 -0
  245. package/esm2015/domain/shop-settings/index.js +5 -0
  246. package/esm2015/domain/shop-settings/models/home.js +7 -0
  247. package/esm2015/domain/shop-settings/models/index.js +4 -0
  248. package/esm2015/domain/shop-settings/models/shop-menu.js +7 -0
  249. package/esm2015/domain/shop-settings/models/types/banner.type.js +2 -0
  250. package/esm2015/domain/shop-settings/models/types/benefit.type.js +2 -0
  251. package/esm2015/domain/shop-settings/models/types/home-data.type.js +2 -0
  252. package/esm2015/domain/shop-settings/models/types/index.js +6 -0
  253. package/esm2015/domain/shop-settings/models/types/menu-nav.type.js +2 -0
  254. package/esm2015/domain/shop-settings/models/types/sub-menu.type.js +2 -0
  255. package/esm2015/domain/shop-settings/repositories/home.repository.js +2 -0
  256. package/esm2015/domain/shop-settings/repositories/index.js +3 -0
  257. package/esm2015/domain/shop-settings/repositories/shop-menu.repository.js +2 -0
  258. package/esm2015/domain/shopping/index.js +3 -0
  259. package/esm2015/domain/shopping/models/buy-2-win.js +14 -0
  260. package/esm2015/domain/shopping/models/checkout.js +38 -0
  261. package/esm2015/domain/shopping/models/coupons/coupon.js +23 -0
  262. package/esm2015/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js +6 -0
  263. package/esm2015/domain/shopping/models/coupons/enums/coupon-types.enum.js +8 -0
  264. package/esm2015/domain/shopping/models/coupons/enums/exclusivities.enum.js +7 -0
  265. package/esm2015/domain/shopping/models/coupons/enums/index.js +4 -0
  266. package/esm2015/domain/shopping/models/coupons/financial-coupon.js +28 -0
  267. package/esm2015/domain/shopping/models/coupons/index.js +4 -0
  268. package/esm2015/domain/shopping/models/enums/checkout-types.enum.js +6 -0
  269. package/esm2015/domain/shopping/models/enums/index.js +3 -0
  270. package/esm2015/domain/shopping/models/enums/order-status.enum.js +12 -0
  271. package/esm2015/domain/shopping/models/index.js +12 -0
  272. package/esm2015/domain/shopping/models/line-item.js +4 -0
  273. package/esm2015/domain/shopping/models/order.js +11 -0
  274. package/esm2015/domain/shopping/models/payment.js +169 -0
  275. package/esm2015/domain/shopping/models/shipping-method.js +7 -0
  276. package/esm2015/domain/shopping/models/subscription/checkout.js +28 -0
  277. package/esm2015/domain/shopping/models/subscription/index.js +3 -0
  278. package/esm2015/domain/shopping/models/subscription/plan.js +7 -0
  279. package/esm2015/domain/shopping/models/types/index.js +8 -0
  280. package/esm2015/domain/shopping/models/types/payment-address.type.js +2 -0
  281. package/esm2015/domain/shopping/models/types/payment-billing.type.js +2 -0
  282. package/esm2015/domain/shopping/models/types/payment-card.type.js +2 -0
  283. package/esm2015/domain/shopping/models/types/payment-customer.type.js +2 -0
  284. package/esm2015/domain/shopping/models/types/payment-document.type.js +2 -0
  285. package/esm2015/domain/shopping/models/types/payment-item.type.js +2 -0
  286. package/esm2015/domain/shopping/models/types/payment-shipping.type.js +2 -0
  287. package/esm2015/domain/shopping/repositories/buy-2-win.repository.js +2 -0
  288. package/esm2015/domain/shopping/repositories/checkout.repository.js +2 -0
  289. package/esm2015/domain/shopping/repositories/coupon.repository.js +2 -0
  290. package/esm2015/domain/shopping/repositories/index.js +8 -0
  291. package/esm2015/domain/shopping/repositories/legacy-order.repository.js +2 -0
  292. package/esm2015/domain/shopping/repositories/order.repository.js +2 -0
  293. package/esm2015/domain/shopping/repositories/payment.repository.js +2 -0
  294. package/esm2015/domain/shopping/repositories/subscription/checkout.repository.js +2 -0
  295. package/esm2015/domain/shopping/repositories/subscription/index.js +3 -0
  296. package/esm2015/domain/shopping/repositories/subscription/plan.repository.js +2 -0
  297. package/esm2015/domain/users/errors/index.js +4 -0
  298. package/esm2015/domain/users/errors/unauthorized.error.js +8 -0
  299. package/esm2015/domain/users/errors/user-already-registered.error.js +8 -0
  300. package/esm2015/domain/users/errors/weak-password.error.js +8 -0
  301. package/esm2015/domain/users/index.js +6 -0
  302. package/esm2015/domain/users/models/beauty-profile.js +12 -0
  303. package/esm2015/domain/users/models/enums/accessory-importances.enum.js +7 -0
  304. package/esm2015/domain/users/models/enums/area.enum.js +13 -0
  305. package/esm2015/domain/users/models/enums/beard-problems.enum.js +11 -0
  306. package/esm2015/domain/users/models/enums/beard-sizes.enum.js +9 -0
  307. package/esm2015/domain/users/models/enums/beauty-product-importances.enum.js +8 -0
  308. package/esm2015/domain/users/models/enums/body-problems.enum.js +13 -0
  309. package/esm2015/domain/users/models/enums/body-shapes.enum.js +9 -0
  310. package/esm2015/domain/users/models/enums/body-tattoos.enum.js +7 -0
  311. package/esm2015/domain/users/models/enums/face-skin-oilinesses.enum.js +9 -0
  312. package/esm2015/domain/users/models/enums/face-skin-problems.enum.js +12 -0
  313. package/esm2015/domain/users/models/enums/face-skin-tones.enum.js +10 -0
  314. package/esm2015/domain/users/models/enums/family-incomes.enum.js +10 -0
  315. package/esm2015/domain/users/models/enums/fragrance-importances.enum.js +7 -0
  316. package/esm2015/domain/users/models/enums/hair-colors.enum.js +12 -0
  317. package/esm2015/domain/users/models/enums/hair-problems.enum.js +12 -0
  318. package/esm2015/domain/users/models/enums/hair-strands.enum.js +10 -0
  319. package/esm2015/domain/users/models/enums/hair-types.enum.js +9 -0
  320. package/esm2015/domain/users/models/enums/index.js +21 -0
  321. package/esm2015/domain/users/models/enums/office-position.enum.js +8 -0
  322. package/esm2015/domain/users/models/enums/product-spents.enum.js +10 -0
  323. package/esm2015/domain/users/models/enums/user-type.enum.js +10 -0
  324. package/esm2015/domain/users/models/index.js +8 -0
  325. package/esm2015/domain/users/models/lead.js +7 -0
  326. package/esm2015/domain/users/models/subscription/edition.js +7 -0
  327. package/esm2015/domain/users/models/subscription/enums/billing-status.enum.js +5 -0
  328. package/esm2015/domain/users/models/subscription/enums/edition-status.enum.js +6 -0
  329. package/esm2015/domain/users/models/subscription/enums/index.js +5 -0
  330. package/esm2015/domain/users/models/subscription/enums/payment-type.enum.js +7 -0
  331. package/esm2015/domain/users/models/subscription/enums/status.enum.js +6 -0
  332. package/esm2015/domain/users/models/subscription/index.js +5 -0
  333. package/esm2015/domain/users/models/subscription/payment.js +14 -0
  334. package/esm2015/domain/users/models/subscription/subscription.js +43 -0
  335. package/esm2015/domain/users/models/user-address.js +7 -0
  336. package/esm2015/domain/users/models/user-payment-method.js +7 -0
  337. package/esm2015/domain/users/models/user.js +26 -0
  338. package/esm2015/domain/users/repositories/beauty-profile.repository.js +2 -0
  339. package/esm2015/domain/users/repositories/edition.repository.js +2 -0
  340. package/esm2015/domain/users/repositories/index.js +9 -0
  341. package/esm2015/domain/users/repositories/lead.repository.js +2 -0
  342. package/esm2015/domain/users/repositories/subscription-payment.repository.js +2 -0
  343. package/esm2015/domain/users/repositories/subscription.repository.js +2 -0
  344. package/esm2015/domain/users/repositories/user-address.repository.js +2 -0
  345. package/esm2015/domain/users/repositories/user-payment-method.repository.js +2 -0
  346. package/esm2015/domain/users/repositories/user.repository.js +2 -0
  347. package/esm2015/domain/users/services/authentication.service.js +2 -0
  348. package/esm2015/domain/users/services/index.js +4 -0
  349. package/esm2015/domain/users/services/register.service.js +2 -0
  350. package/esm2015/domain/users/services/types/basic-user-data.type.js +2 -0
  351. package/esm2015/domain/users/services/types/index.js +2 -0
  352. package/esm2015/domain/users/use-cases/authentication.js +40 -0
  353. package/esm2015/domain/users/use-cases/index.js +5 -0
  354. package/esm2015/domain/users/use-cases/recovery-password.js +12 -0
  355. package/esm2015/domain/users/use-cases/register.js +34 -0
  356. package/esm2015/domain/users/use-cases/signout.js +12 -0
  357. package/esm2015/errors/duplicated-results.error.js +8 -0
  358. package/esm2015/errors/index.js +5 -0
  359. package/esm2015/errors/invalid-argument.error.js +8 -0
  360. package/esm2015/errors/not-found.error.js +8 -0
  361. package/esm2015/errors/required-argument.error.js +9 -0
  362. package/esm2015/index.js +6 -0
  363. package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +22 -0
  364. package/esm2015/infra/elasticsearch/adapters/elastic-search.adapter.js +2 -0
  365. package/esm2015/infra/elasticsearch/adapters/index.js +3 -0
  366. package/esm2015/infra/elasticsearch/index.js +4 -0
  367. package/esm2015/infra/elasticsearch/indexes/index.js +2 -0
  368. package/esm2015/infra/elasticsearch/indexes/products-index.js +59 -0
  369. package/esm2015/infra/elasticsearch/types/elastic-search-result.js +2 -0
  370. package/esm2015/infra/elasticsearch/types/index.js +2 -0
  371. package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +52 -0
  372. package/esm2015/infra/firebase/auth/index.js +3 -0
  373. package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +26 -0
  374. package/esm2015/infra/firebase/auth/types/firebase-user-with-id.type.js +2 -0
  375. package/esm2015/infra/firebase/firestore/index.js +4 -0
  376. package/esm2015/infra/firebase/firestore/mixins/index.js +10 -0
  377. package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +31 -0
  378. package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +10 -0
  379. package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +18 -0
  380. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +86 -0
  381. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +22 -0
  382. package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +24 -0
  383. package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +17 -0
  384. package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +11 -0
  385. package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +45 -0
  386. package/esm2015/infra/firebase/firestore/models/user-search.js +7 -0
  387. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +72 -0
  388. package/esm2015/infra/firebase/firestore/repositories/catalog/index.js +5 -0
  389. package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +53 -0
  390. package/esm2015/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +14 -0
  391. package/esm2015/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +12 -0
  392. package/esm2015/infra/firebase/firestore/repositories/index.js +5 -0
  393. package/esm2015/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +56 -0
  394. package/esm2015/infra/firebase/firestore/repositories/shop-settings/index.js +3 -0
  395. package/esm2015/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +12 -0
  396. package/esm2015/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +12 -0
  397. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +12 -0
  398. package/esm2015/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +12 -0
  399. package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +29 -0
  400. package/esm2015/infra/firebase/firestore/repositories/shopping/index.js +9 -0
  401. package/esm2015/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +9 -0
  402. package/esm2015/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +12 -0
  403. package/esm2015/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +12 -0
  404. package/esm2015/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +12 -0
  405. package/esm2015/infra/firebase/firestore/repositories/users/index.js +10 -0
  406. package/esm2015/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +12 -0
  407. package/esm2015/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +14 -0
  408. package/esm2015/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +12 -0
  409. package/esm2015/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +14 -0
  410. package/esm2015/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +14 -0
  411. package/esm2015/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +14 -0
  412. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +70 -0
  413. package/esm2015/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +14 -0
  414. package/esm2015/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +12 -0
  415. package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +2 -0
  416. package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +2 -0
  417. package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +2 -0
  418. package/esm2015/infra/firebase/firestore/types/index.js +4 -0
  419. package/esm2015/infra/firebase/index.js +3 -0
  420. package/esm2015/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.js +13 -0
  421. package/esm2015/infra/hasura-graphql/enums/hasura-graphql-where.enum.js +15 -0
  422. package/esm2015/infra/hasura-graphql/enums/index.js +3 -0
  423. package/esm2015/infra/hasura-graphql/index.js +5 -0
  424. package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +31 -0
  425. package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +18 -0
  426. package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +70 -0
  427. package/esm2015/infra/hasura-graphql/mixins/helpers/index.js +4 -0
  428. package/esm2015/infra/hasura-graphql/mixins/index.js +8 -0
  429. package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +45 -0
  430. package/esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js +10 -0
  431. package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +29 -0
  432. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +93 -0
  433. package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +35 -0
  434. package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +94 -0
  435. package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +56 -0
  436. package/esm2015/infra/hasura-graphql/models/category-hasura-graphql.js +4 -0
  437. package/esm2015/infra/hasura-graphql/models/index.js +5 -0
  438. package/esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js +15 -0
  439. package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +11 -0
  440. package/esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js +9 -0
  441. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +135 -0
  442. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +4 -0
  443. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +370 -0
  444. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +100 -0
  445. package/esm2015/infra/hasura-graphql/repositories/index.js +2 -0
  446. package/esm2015/infra/hasura-graphql/types/fields.type.js +2 -0
  447. package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +2 -0
  448. package/esm2015/infra/hasura-graphql/types/hasura-graphql-auth-options.type.js +2 -0
  449. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +2 -0
  450. package/esm2015/infra/hasura-graphql/types/hasura-graphql-headers.type.js +2 -0
  451. package/esm2015/infra/hasura-graphql/types/index.js +9 -0
  452. package/esm2015/infra/hasura-graphql/types/nested-field.type.js +2 -0
  453. package/esm2015/infra/hasura-graphql/types/query-builder-options.type.js +2 -0
  454. package/esm2015/infra/hasura-graphql/types/variable-options.type.js +2 -0
  455. package/esm2015/infra/index.js +4 -0
  456. package/esm2015/infrab4a-connect.js +5 -5
  457. package/esm2015/utils/index.js +8 -0
  458. package/esm2015/utils/is-uuid.js +3 -0
  459. package/esm2015/utils/mixins/base.mixin.js +6 -0
  460. package/esm2015/utils/mixins/index.js +4 -0
  461. package/esm2015/utils/mixins/merge-constructor-params.type.js +2 -0
  462. package/esm2015/utils/mixins/mixin-ctor.type.js +2 -0
  463. package/esm2015/utils/parse-datetime.js +14 -0
  464. package/esm2015/utils/types/array-element.type.js +2 -0
  465. package/esm2015/utils/types/index.js +3 -0
  466. package/esm2015/utils/types/prop.type.js +2 -0
  467. package/fesm2015/infrab4a-connect.js +2840 -1545
  468. package/fesm2015/infrab4a-connect.js.map +1 -1
  469. package/index.d.ts +5 -0
  470. package/infra/elasticsearch/adapters/axios.adapter.d.ts +11 -0
  471. package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +4 -0
  472. package/infra/elasticsearch/adapters/index.d.ts +2 -0
  473. package/infra/elasticsearch/index.d.ts +3 -0
  474. package/infra/elasticsearch/indexes/index.d.ts +1 -0
  475. package/infra/elasticsearch/indexes/products-index.d.ts +11 -0
  476. package/infra/elasticsearch/types/elastic-search-result.d.ts +7 -0
  477. package/infra/elasticsearch/types/index.d.ts +1 -0
  478. package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +12 -0
  479. package/infra/firebase/auth/index.d.ts +2 -0
  480. package/infra/firebase/auth/register-firebase-auth.service.d.ts +8 -0
  481. package/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +3 -0
  482. package/infra/firebase/firestore/index.d.ts +3 -0
  483. package/infra/firebase/firestore/mixins/index.d.ts +9 -0
  484. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +4 -0
  485. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +4 -0
  486. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +4 -0
  487. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +4 -0
  488. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +4 -0
  489. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +4 -0
  490. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +11 -0
  491. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +7 -0
  492. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +7 -0
  493. package/infra/firebase/firestore/models/user-search.d.ts +9 -0
  494. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +17 -0
  495. package/infra/firebase/firestore/repositories/catalog/index.d.ts +4 -0
  496. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +11 -0
  497. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +13 -0
  498. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +8 -0
  499. package/infra/firebase/firestore/repositories/index.d.ts +4 -0
  500. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +16 -0
  501. package/infra/firebase/firestore/repositories/shop-settings/index.d.ts +2 -0
  502. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +8 -0
  503. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +8 -0
  504. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +8 -0
  505. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +8 -0
  506. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +12 -0
  507. package/infra/firebase/firestore/repositories/shopping/index.d.ts +8 -0
  508. package/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +7 -0
  509. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +8 -0
  510. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +8 -0
  511. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +8 -0
  512. package/infra/firebase/firestore/repositories/users/index.d.ts +9 -0
  513. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +8 -0
  514. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +13 -0
  515. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +8 -0
  516. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +13 -0
  517. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +13 -0
  518. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +13 -0
  519. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +19 -0
  520. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +13 -0
  521. package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +9 -0
  522. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +6 -0
  523. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +8 -0
  524. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +12 -0
  525. package/infra/firebase/firestore/types/index.d.ts +3 -0
  526. package/infra/firebase/index.d.ts +2 -0
  527. package/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.d.ts +11 -0
  528. package/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +13 -0
  529. package/infra/hasura-graphql/enums/index.d.ts +2 -0
  530. package/infra/hasura-graphql/index.d.ts +4 -0
  531. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +13 -0
  532. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +6 -0
  533. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +8 -0
  534. package/infra/hasura-graphql/mixins/helpers/index.d.ts +3 -0
  535. package/infra/hasura-graphql/mixins/index.d.ts +7 -0
  536. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +8 -0
  537. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +11 -0
  538. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +7 -0
  539. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +31 -0
  540. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +24 -0
  541. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +11 -0
  542. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +14 -0
  543. package/infra/hasura-graphql/models/category-hasura-graphql.d.ts +6 -0
  544. package/infra/hasura-graphql/models/index.d.ts +4 -0
  545. package/infra/hasura-graphql/models/kit-product-hasura-graphql.d.ts +6 -0
  546. package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +9 -0
  547. package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +9 -0
  548. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +22 -0
  549. package/infra/hasura-graphql/repositories/catalog/index.d.ts +3 -0
  550. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +26 -0
  551. package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +13 -0
  552. package/infra/hasura-graphql/repositories/index.d.ts +1 -0
  553. package/infra/hasura-graphql/types/fields.type.d.ts +2 -0
  554. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +21 -0
  555. package/infra/hasura-graphql/types/hasura-graphql-auth-options.type.d.ts +8 -0
  556. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +36 -0
  557. package/infra/hasura-graphql/types/hasura-graphql-headers.type.d.ts +7 -0
  558. package/infra/hasura-graphql/types/index.d.ts +8 -0
  559. package/infra/hasura-graphql/types/nested-field.type.d.ts +7 -0
  560. package/infra/hasura-graphql/types/query-builder-options.type.d.ts +7 -0
  561. package/infra/hasura-graphql/types/variable-options.type.d.ts +9 -0
  562. package/infra/index.d.ts +3 -0
  563. package/infrab4a-connect.d.ts +5 -5
  564. package/package.json +7 -3
  565. package/utils/index.d.ts +7 -0
  566. package/utils/is-uuid.d.ts +1 -0
  567. package/utils/mixins/base.mixin.d.ts +3 -0
  568. package/utils/mixins/index.d.ts +3 -0
  569. package/utils/mixins/merge-constructor-params.type.d.ts +3 -0
  570. package/utils/mixins/mixin-ctor.type.d.ts +1 -0
  571. package/utils/parse-datetime.d.ts +1 -0
  572. package/utils/types/array-element.type.d.ts +1 -0
  573. package/utils/types/index.d.ts +2 -0
  574. package/utils/types/prop.type.d.ts +1 -0
  575. package/esm2015/lib/domain/catalog/index.js +0 -3
  576. package/esm2015/lib/domain/catalog/models/category.js +0 -7
  577. package/esm2015/lib/domain/catalog/models/enums/index.js +0 -2
  578. package/esm2015/lib/domain/catalog/models/enums/shops.enum.js +0 -6
  579. package/esm2015/lib/domain/catalog/models/index.js +0 -6
  580. package/esm2015/lib/domain/catalog/models/product.js +0 -11
  581. package/esm2015/lib/domain/catalog/models/types/category-condition.type.js +0 -2
  582. package/esm2015/lib/domain/catalog/models/types/category-filter.type.js +0 -2
  583. package/esm2015/lib/domain/catalog/models/types/index.js +0 -8
  584. package/esm2015/lib/domain/catalog/models/types/product-review.type.js +0 -2
  585. package/esm2015/lib/domain/catalog/models/types/shops-description.type.js +0 -2
  586. package/esm2015/lib/domain/catalog/models/types/shops-price.type.js +0 -2
  587. package/esm2015/lib/domain/catalog/models/types/stock.type.js +0 -2
  588. package/esm2015/lib/domain/catalog/models/types/variant-grade.type.js +0 -2
  589. package/esm2015/lib/domain/catalog/models/variant.js +0 -7
  590. package/esm2015/lib/domain/catalog/repositories/category.repository.js +0 -2
  591. package/esm2015/lib/domain/catalog/repositories/index.js +0 -5
  592. package/esm2015/lib/domain/catalog/repositories/product.repository.js +0 -2
  593. package/esm2015/lib/domain/catalog/repositories/subscription-product.repository.js +0 -2
  594. package/esm2015/lib/domain/catalog/repositories/variant.repository.js +0 -2
  595. package/esm2015/lib/domain/general/index.js +0 -3
  596. package/esm2015/lib/domain/general/model/base-model-with-identifier-fields.js +0 -2
  597. package/esm2015/lib/domain/general/model/base.model.js +0 -13
  598. package/esm2015/lib/domain/general/model/identifier-fields.js +0 -2
  599. package/esm2015/lib/domain/general/model/index.js +0 -5
  600. package/esm2015/lib/domain/general/model/types/base-model-builder.type.js +0 -2
  601. package/esm2015/lib/domain/general/model/types/index.js +0 -4
  602. package/esm2015/lib/domain/general/model/types/non-function-properties.type.js +0 -2
  603. package/esm2015/lib/domain/general/model/types/non-function-property-name.type.js +0 -2
  604. package/esm2015/lib/domain/general/repository/create.repository.js +0 -2
  605. package/esm2015/lib/domain/general/repository/crud.repository.js +0 -2
  606. package/esm2015/lib/domain/general/repository/delete.repository.js +0 -2
  607. package/esm2015/lib/domain/general/repository/enums/index.js +0 -3
  608. package/esm2015/lib/domain/general/repository/enums/update-option-actions.enum.js +0 -9
  609. package/esm2015/lib/domain/general/repository/enums/where.enum.js +0 -12
  610. package/esm2015/lib/domain/general/repository/find.repository.js +0 -2
  611. package/esm2015/lib/domain/general/repository/get.repository.js +0 -2
  612. package/esm2015/lib/domain/general/repository/index.js +0 -10
  613. package/esm2015/lib/domain/general/repository/read.repository.js +0 -2
  614. package/esm2015/lib/domain/general/repository/types/index.js +0 -6
  615. package/esm2015/lib/domain/general/repository/types/repository-find-filters.type.js +0 -2
  616. package/esm2015/lib/domain/general/repository/types/repository-find-result.type.js +0 -2
  617. package/esm2015/lib/domain/general/repository/types/repository-limit-options.type.js +0 -2
  618. package/esm2015/lib/domain/general/repository/types/repository-order-by-list.type.js +0 -2
  619. package/esm2015/lib/domain/general/repository/types/repository-update-params.type.js +0 -2
  620. package/esm2015/lib/domain/general/repository/update.repository.js +0 -2
  621. package/esm2015/lib/domain/index.js +0 -7
  622. package/esm2015/lib/domain/location/index.js +0 -2
  623. package/esm2015/lib/domain/location/models/address.js +0 -4
  624. package/esm2015/lib/domain/location/models/index.js +0 -3
  625. package/esm2015/lib/domain/location/models/types/index.js +0 -4
  626. package/esm2015/lib/domain/location/models/types/location-bound.type.js +0 -2
  627. package/esm2015/lib/domain/location/models/types/location-geometry.type.js +0 -2
  628. package/esm2015/lib/domain/location/models/types/location-lat-lng.type.js +0 -2
  629. package/esm2015/lib/domain/shop-settings/enums/filter-type.enum.js +0 -21
  630. package/esm2015/lib/domain/shop-settings/enums/index.js +0 -3
  631. package/esm2015/lib/domain/shop-settings/enums/questions-filters.enum.js +0 -21
  632. package/esm2015/lib/domain/shop-settings/helpers/beauty-questions.helper.js +0 -46
  633. package/esm2015/lib/domain/shop-settings/helpers/index.js +0 -2
  634. package/esm2015/lib/domain/shop-settings/index.js +0 -5
  635. package/esm2015/lib/domain/shop-settings/models/home.js +0 -7
  636. package/esm2015/lib/domain/shop-settings/models/index.js +0 -4
  637. package/esm2015/lib/domain/shop-settings/models/shop-menu.js +0 -7
  638. package/esm2015/lib/domain/shop-settings/models/types/banner.type.js +0 -2
  639. package/esm2015/lib/domain/shop-settings/models/types/benefit.type.js +0 -2
  640. package/esm2015/lib/domain/shop-settings/models/types/index.js +0 -5
  641. package/esm2015/lib/domain/shop-settings/models/types/menu-nav.type.js +0 -2
  642. package/esm2015/lib/domain/shop-settings/models/types/sub-menu.type.js +0 -2
  643. package/esm2015/lib/domain/shop-settings/repositories/home.repository.js +0 -2
  644. package/esm2015/lib/domain/shop-settings/repositories/index.js +0 -3
  645. package/esm2015/lib/domain/shop-settings/repositories/shop-menu.repository.js +0 -2
  646. package/esm2015/lib/domain/shopping/index.js +0 -3
  647. package/esm2015/lib/domain/shopping/models/buy-2-win.js +0 -14
  648. package/esm2015/lib/domain/shopping/models/checkout.js +0 -46
  649. package/esm2015/lib/domain/shopping/models/coupons/club-coupon.js +0 -18
  650. package/esm2015/lib/domain/shopping/models/coupons/coupon.js +0 -31
  651. package/esm2015/lib/domain/shopping/models/coupons/enums/discount-type.enum.js +0 -7
  652. package/esm2015/lib/domain/shopping/models/coupons/enums/exclusivities.enum.js +0 -7
  653. package/esm2015/lib/domain/shopping/models/coupons/enums/index.js +0 -3
  654. package/esm2015/lib/domain/shopping/models/coupons/index.js +0 -5
  655. package/esm2015/lib/domain/shopping/models/coupons/store-coupon.js +0 -23
  656. package/esm2015/lib/domain/shopping/models/enums/checkout-types.enum.js +0 -6
  657. package/esm2015/lib/domain/shopping/models/enums/index.js +0 -3
  658. package/esm2015/lib/domain/shopping/models/enums/order-status.enum.js +0 -12
  659. package/esm2015/lib/domain/shopping/models/index.js +0 -12
  660. package/esm2015/lib/domain/shopping/models/line-item.js +0 -4
  661. package/esm2015/lib/domain/shopping/models/order.js +0 -11
  662. package/esm2015/lib/domain/shopping/models/payment.js +0 -169
  663. package/esm2015/lib/domain/shopping/models/shipping-method.js +0 -7
  664. package/esm2015/lib/domain/shopping/models/subscription/checkout.js +0 -28
  665. package/esm2015/lib/domain/shopping/models/subscription/index.js +0 -3
  666. package/esm2015/lib/domain/shopping/models/subscription/plan.js +0 -7
  667. package/esm2015/lib/domain/shopping/models/types/index.js +0 -8
  668. package/esm2015/lib/domain/shopping/models/types/payment-address.type.js +0 -2
  669. package/esm2015/lib/domain/shopping/models/types/payment-billing.type.js +0 -2
  670. package/esm2015/lib/domain/shopping/models/types/payment-card.type.js +0 -2
  671. package/esm2015/lib/domain/shopping/models/types/payment-customer.type.js +0 -2
  672. package/esm2015/lib/domain/shopping/models/types/payment-document.type.js +0 -2
  673. package/esm2015/lib/domain/shopping/models/types/payment-item.type.js +0 -2
  674. package/esm2015/lib/domain/shopping/models/types/payment-shipping.type.js +0 -2
  675. package/esm2015/lib/domain/shopping/repositories/buy-2-win.repository.js +0 -2
  676. package/esm2015/lib/domain/shopping/repositories/checkout.repository.js +0 -2
  677. package/esm2015/lib/domain/shopping/repositories/coupon.repository.js +0 -2
  678. package/esm2015/lib/domain/shopping/repositories/index.js +0 -8
  679. package/esm2015/lib/domain/shopping/repositories/legacy-order.repository.js +0 -2
  680. package/esm2015/lib/domain/shopping/repositories/order.repository.js +0 -2
  681. package/esm2015/lib/domain/shopping/repositories/payment.repository.js +0 -2
  682. package/esm2015/lib/domain/shopping/repositories/subscription/checkout.repository.js +0 -2
  683. package/esm2015/lib/domain/shopping/repositories/subscription/index.js +0 -3
  684. package/esm2015/lib/domain/shopping/repositories/subscription/plan.repository.js +0 -2
  685. package/esm2015/lib/domain/users/errors/index.js +0 -4
  686. package/esm2015/lib/domain/users/errors/unauthorized.error.js +0 -7
  687. package/esm2015/lib/domain/users/errors/user-already-registered.error.js +0 -7
  688. package/esm2015/lib/domain/users/errors/weak-password.error.js +0 -7
  689. package/esm2015/lib/domain/users/index.js +0 -6
  690. package/esm2015/lib/domain/users/models/beauty-profile.js +0 -12
  691. package/esm2015/lib/domain/users/models/enums/accessory-importances.enum.js +0 -7
  692. package/esm2015/lib/domain/users/models/enums/area.enum.js +0 -13
  693. package/esm2015/lib/domain/users/models/enums/beard-problems.enum.js +0 -11
  694. package/esm2015/lib/domain/users/models/enums/beard-sizes.enum.js +0 -9
  695. package/esm2015/lib/domain/users/models/enums/beauty-product-importances.enum.js +0 -8
  696. package/esm2015/lib/domain/users/models/enums/body-problems.enum.js +0 -13
  697. package/esm2015/lib/domain/users/models/enums/body-shapes.enum.js +0 -9
  698. package/esm2015/lib/domain/users/models/enums/body-tattoos.enum.js +0 -7
  699. package/esm2015/lib/domain/users/models/enums/face-skin-oilinesses.enum.js +0 -9
  700. package/esm2015/lib/domain/users/models/enums/face-skin-problems.enum.js +0 -12
  701. package/esm2015/lib/domain/users/models/enums/face-skin-tones.enum.js +0 -10
  702. package/esm2015/lib/domain/users/models/enums/family-incomes.enum.js +0 -10
  703. package/esm2015/lib/domain/users/models/enums/fragrance-importances.enum.js +0 -7
  704. package/esm2015/lib/domain/users/models/enums/hair-colors.enum.js +0 -12
  705. package/esm2015/lib/domain/users/models/enums/hair-problems.enum.js +0 -12
  706. package/esm2015/lib/domain/users/models/enums/hair-strands.enum.js +0 -10
  707. package/esm2015/lib/domain/users/models/enums/hair-types.enum.js +0 -9
  708. package/esm2015/lib/domain/users/models/enums/index.js +0 -21
  709. package/esm2015/lib/domain/users/models/enums/office-position.enum.js +0 -8
  710. package/esm2015/lib/domain/users/models/enums/product-spents.enum.js +0 -10
  711. package/esm2015/lib/domain/users/models/enums/user-type.enum.js +0 -10
  712. package/esm2015/lib/domain/users/models/index.js +0 -8
  713. package/esm2015/lib/domain/users/models/lead.js +0 -7
  714. package/esm2015/lib/domain/users/models/subscription/edition.js +0 -7
  715. package/esm2015/lib/domain/users/models/subscription/enums/billing-status.enum.js +0 -5
  716. package/esm2015/lib/domain/users/models/subscription/enums/edition-status.enum.js +0 -6
  717. package/esm2015/lib/domain/users/models/subscription/enums/index.js +0 -5
  718. package/esm2015/lib/domain/users/models/subscription/enums/payment-type.enum.js +0 -7
  719. package/esm2015/lib/domain/users/models/subscription/enums/status.enum.js +0 -6
  720. package/esm2015/lib/domain/users/models/subscription/index.js +0 -5
  721. package/esm2015/lib/domain/users/models/subscription/payment.js +0 -14
  722. package/esm2015/lib/domain/users/models/subscription/subscription.js +0 -43
  723. package/esm2015/lib/domain/users/models/user-address.js +0 -7
  724. package/esm2015/lib/domain/users/models/user-payment-method.js +0 -7
  725. package/esm2015/lib/domain/users/models/user.js +0 -26
  726. package/esm2015/lib/domain/users/repositories/beauty-profile.repository.js +0 -2
  727. package/esm2015/lib/domain/users/repositories/edition.repository.js +0 -2
  728. package/esm2015/lib/domain/users/repositories/index.js +0 -9
  729. package/esm2015/lib/domain/users/repositories/lead.repository.js +0 -2
  730. package/esm2015/lib/domain/users/repositories/subscription-payment.repository.js +0 -2
  731. package/esm2015/lib/domain/users/repositories/subscription.repository.js +0 -2
  732. package/esm2015/lib/domain/users/repositories/user-address.repository.js +0 -2
  733. package/esm2015/lib/domain/users/repositories/user-payment-method.repository.js +0 -2
  734. package/esm2015/lib/domain/users/repositories/user.repository.js +0 -2
  735. package/esm2015/lib/domain/users/services/authentication.service.js +0 -2
  736. package/esm2015/lib/domain/users/services/index.js +0 -4
  737. package/esm2015/lib/domain/users/services/register.service.js +0 -2
  738. package/esm2015/lib/domain/users/services/types/basic-user-data.type.js +0 -2
  739. package/esm2015/lib/domain/users/services/types/index.js +0 -2
  740. package/esm2015/lib/domain/users/use-cases/authentication.js +0 -40
  741. package/esm2015/lib/domain/users/use-cases/index.js +0 -4
  742. package/esm2015/lib/domain/users/use-cases/register.js +0 -34
  743. package/esm2015/lib/domain/users/use-cases/signout.js +0 -12
  744. package/esm2015/lib/errors/duplicated-results.error.js +0 -7
  745. package/esm2015/lib/errors/index.js +0 -5
  746. package/esm2015/lib/errors/invalid-argument.error.js +0 -7
  747. package/esm2015/lib/errors/not-found.error.js +0 -7
  748. package/esm2015/lib/errors/required-argument.error.js +0 -8
  749. package/esm2015/lib/index.js +0 -5
  750. package/esm2015/lib/infra/firebase/auth/authentication-firebase-auth.service.js +0 -47
  751. package/esm2015/lib/infra/firebase/auth/index.js +0 -3
  752. package/esm2015/lib/infra/firebase/auth/register-firebase-auth.service.js +0 -26
  753. package/esm2015/lib/infra/firebase/auth/types/firebase-user-with-id.type.js +0 -2
  754. package/esm2015/lib/infra/firebase/firestore/index.js +0 -4
  755. package/esm2015/lib/infra/firebase/firestore/mixins/index.js +0 -10
  756. package/esm2015/lib/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +0 -31
  757. package/esm2015/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +0 -10
  758. package/esm2015/lib/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +0 -18
  759. package/esm2015/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +0 -76
  760. package/esm2015/lib/infra/firebase/firestore/mixins/with-firestore.mixin.js +0 -26
  761. package/esm2015/lib/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +0 -24
  762. package/esm2015/lib/infra/firebase/firestore/mixins/with-helpers.mixin.js +0 -17
  763. package/esm2015/lib/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +0 -11
  764. package/esm2015/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +0 -45
  765. package/esm2015/lib/infra/firebase/firestore/models/user-search.js +0 -7
  766. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +0 -78
  767. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/index.js +0 -5
  768. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +0 -23
  769. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +0 -14
  770. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.js +0 -12
  771. package/esm2015/lib/infra/firebase/firestore/repositories/index.js +0 -5
  772. package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +0 -12
  773. package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/index.js +0 -3
  774. package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +0 -12
  775. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +0 -12
  776. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +0 -12
  777. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +0 -12
  778. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +0 -39
  779. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/index.js +0 -9
  780. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.js +0 -9
  781. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +0 -12
  782. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +0 -12
  783. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +0 -12
  784. package/esm2015/lib/infra/firebase/firestore/repositories/users/index.js +0 -10
  785. package/esm2015/lib/infra/firebase/firestore/repositories/users/lead-firestore.repository.js +0 -12
  786. package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +0 -14
  787. package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +0 -12
  788. package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +0 -14
  789. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +0 -14
  790. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +0 -14
  791. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.js +0 -70
  792. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.js +0 -14
  793. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-search-firestore.repository.js +0 -12
  794. package/esm2015/lib/infra/firebase/firestore/types/firestore-sub.repository.type.js +0 -2
  795. package/esm2015/lib/infra/firebase/firestore/types/firestore.helpers.type.js +0 -2
  796. package/esm2015/lib/infra/firebase/firestore/types/firestore.repository.type.js +0 -2
  797. package/esm2015/lib/infra/firebase/firestore/types/index.js +0 -4
  798. package/esm2015/lib/infra/firebase/index.js +0 -3
  799. package/esm2015/lib/infra/index.js +0 -2
  800. package/esm2015/lib/utils/index.js +0 -5
  801. package/esm2015/lib/utils/mixins/base.mixin.js +0 -6
  802. package/esm2015/lib/utils/mixins/index.js +0 -3
  803. package/esm2015/lib/utils/mixins/mixin-ctor.type.js +0 -2
  804. package/esm2015/lib/utils/types/index.js +0 -2
  805. package/esm2015/lib/utils/types/prop.type.js +0 -2
  806. package/esm2015/public-api.js +0 -3
  807. package/lib/domain/catalog/index.d.ts +0 -2
  808. package/lib/domain/catalog/models/category.d.ts +0 -22
  809. package/lib/domain/catalog/models/enums/index.d.ts +0 -1
  810. package/lib/domain/catalog/models/enums/shops.enum.d.ts +0 -4
  811. package/lib/domain/catalog/models/index.d.ts +0 -5
  812. package/lib/domain/catalog/models/product.d.ts +0 -33
  813. package/lib/domain/catalog/models/types/category-condition.type.d.ts +0 -4
  814. package/lib/domain/catalog/models/types/category-filter.type.d.ts +0 -4
  815. package/lib/domain/catalog/models/types/index.d.ts +0 -7
  816. package/lib/domain/catalog/models/types/product-review.type.d.ts +0 -14
  817. package/lib/domain/catalog/models/types/shops-description.type.d.ts +0 -7
  818. package/lib/domain/catalog/models/types/shops-price.type.d.ts +0 -10
  819. package/lib/domain/catalog/models/types/stock.type.d.ts +0 -3
  820. package/lib/domain/catalog/models/types/variant-grade.type.d.ts +0 -4
  821. package/lib/domain/catalog/models/variant.d.ts +0 -14
  822. package/lib/domain/catalog/repositories/category.repository.d.ts +0 -12
  823. package/lib/domain/catalog/repositories/index.d.ts +0 -4
  824. package/lib/domain/catalog/repositories/product.repository.d.ts +0 -5
  825. package/lib/domain/catalog/repositories/subscription-product.repository.d.ts +0 -4
  826. package/lib/domain/catalog/repositories/variant.repository.d.ts +0 -4
  827. package/lib/domain/general/index.d.ts +0 -2
  828. package/lib/domain/general/model/base-model-with-identifier-fields.d.ts +0 -3
  829. package/lib/domain/general/model/base.model.d.ts +0 -6
  830. package/lib/domain/general/model/identifier-fields.d.ts +0 -4
  831. package/lib/domain/general/model/index.d.ts +0 -4
  832. package/lib/domain/general/model/types/base-model-builder.type.d.ts +0 -5
  833. package/lib/domain/general/model/types/index.d.ts +0 -3
  834. package/lib/domain/general/model/types/non-function-properties.type.d.ts +0 -2
  835. package/lib/domain/general/model/types/non-function-property-name.type.d.ts +0 -3
  836. package/lib/domain/general/repository/create.repository.d.ts +0 -5
  837. package/lib/domain/general/repository/crud.repository.d.ts +0 -7
  838. package/lib/domain/general/repository/delete.repository.d.ts +0 -5
  839. package/lib/domain/general/repository/enums/index.d.ts +0 -2
  840. package/lib/domain/general/repository/enums/update-option-actions.enum.d.ts +0 -7
  841. package/lib/domain/general/repository/enums/where.enum.d.ts +0 -10
  842. package/lib/domain/general/repository/find.repository.d.ts +0 -5
  843. package/lib/domain/general/repository/get.repository.d.ts +0 -5
  844. package/lib/domain/general/repository/index.d.ts +0 -9
  845. package/lib/domain/general/repository/read.repository.d.ts +0 -5
  846. package/lib/domain/general/repository/types/index.d.ts +0 -5
  847. package/lib/domain/general/repository/types/repository-find-filters.type.d.ts +0 -14
  848. package/lib/domain/general/repository/types/repository-find-result.type.d.ts +0 -4
  849. package/lib/domain/general/repository/types/repository-limit-options.type.d.ts +0 -4
  850. package/lib/domain/general/repository/types/repository-order-by-list.type.d.ts +0 -5
  851. package/lib/domain/general/repository/types/repository-update-params.type.d.ts +0 -11
  852. package/lib/domain/general/repository/update.repository.d.ts +0 -5
  853. package/lib/domain/index.d.ts +0 -6
  854. package/lib/domain/location/index.d.ts +0 -1
  855. package/lib/domain/location/models/address.d.ts +0 -21
  856. package/lib/domain/location/models/index.d.ts +0 -2
  857. package/lib/domain/location/models/types/index.d.ts +0 -3
  858. package/lib/domain/location/models/types/location-bound.type.d.ts +0 -6
  859. package/lib/domain/location/models/types/location-geometry.type.d.ts +0 -7
  860. package/lib/domain/location/models/types/location-lat-lng.type.d.ts +0 -4
  861. package/lib/domain/shop-settings/enums/filter-type.enum.d.ts +0 -19
  862. package/lib/domain/shop-settings/enums/index.d.ts +0 -2
  863. package/lib/domain/shop-settings/enums/questions-filters.enum.d.ts +0 -19
  864. package/lib/domain/shop-settings/helpers/beauty-questions.helper.d.ts +0 -9
  865. package/lib/domain/shop-settings/helpers/index.d.ts +0 -1
  866. package/lib/domain/shop-settings/index.d.ts +0 -4
  867. package/lib/domain/shop-settings/models/home.d.ts +0 -17
  868. package/lib/domain/shop-settings/models/index.d.ts +0 -3
  869. package/lib/domain/shop-settings/models/shop-menu.d.ts +0 -7
  870. package/lib/domain/shop-settings/models/types/banner.type.d.ts +0 -6
  871. package/lib/domain/shop-settings/models/types/benefit.type.d.ts +0 -5
  872. package/lib/domain/shop-settings/models/types/index.d.ts +0 -4
  873. package/lib/domain/shop-settings/models/types/menu-nav.type.d.ts +0 -8
  874. package/lib/domain/shop-settings/models/types/sub-menu.type.d.ts +0 -8
  875. package/lib/domain/shop-settings/repositories/home.repository.d.ts +0 -4
  876. package/lib/domain/shop-settings/repositories/index.d.ts +0 -2
  877. package/lib/domain/shop-settings/repositories/shop-menu.repository.d.ts +0 -4
  878. package/lib/domain/shopping/index.d.ts +0 -2
  879. package/lib/domain/shopping/models/buy-2-win.d.ts +0 -18
  880. package/lib/domain/shopping/models/checkout.d.ts +0 -28
  881. package/lib/domain/shopping/models/coupons/club-coupon.d.ts +0 -7
  882. package/lib/domain/shopping/models/coupons/coupon.d.ts +0 -28
  883. package/lib/domain/shopping/models/coupons/enums/discount-type.enum.d.ts +0 -5
  884. package/lib/domain/shopping/models/coupons/enums/exclusivities.enum.d.ts +0 -5
  885. package/lib/domain/shopping/models/coupons/enums/index.d.ts +0 -2
  886. package/lib/domain/shopping/models/coupons/index.d.ts +0 -4
  887. package/lib/domain/shopping/models/coupons/store-coupon.d.ts +0 -8
  888. package/lib/domain/shopping/models/enums/checkout-types.enum.d.ts +0 -4
  889. package/lib/domain/shopping/models/enums/index.d.ts +0 -2
  890. package/lib/domain/shopping/models/enums/order-status.enum.d.ts +0 -10
  891. package/lib/domain/shopping/models/index.d.ts +0 -11
  892. package/lib/domain/shopping/models/line-item.d.ts +0 -8
  893. package/lib/domain/shopping/models/order.d.ts +0 -9
  894. package/lib/domain/shopping/models/payment.d.ts +0 -69
  895. package/lib/domain/shopping/models/shipping-method.d.ts +0 -18
  896. package/lib/domain/shopping/models/subscription/checkout.d.ts +0 -23
  897. package/lib/domain/shopping/models/subscription/index.d.ts +0 -2
  898. package/lib/domain/shopping/models/subscription/plan.d.ts +0 -12
  899. package/lib/domain/shopping/models/types/index.d.ts +0 -7
  900. package/lib/domain/shopping/models/types/payment-address.type.d.ts +0 -12
  901. package/lib/domain/shopping/models/types/payment-billing.type.d.ts +0 -7
  902. package/lib/domain/shopping/models/types/payment-card.type.d.ts +0 -14
  903. package/lib/domain/shopping/models/types/payment-customer.type.d.ts +0 -18
  904. package/lib/domain/shopping/models/types/payment-document.type.d.ts +0 -6
  905. package/lib/domain/shopping/models/types/payment-item.type.d.ts +0 -11
  906. package/lib/domain/shopping/models/types/payment-shipping.type.d.ts +0 -10
  907. package/lib/domain/shopping/repositories/buy-2-win.repository.d.ts +0 -4
  908. package/lib/domain/shopping/repositories/checkout.repository.d.ts +0 -4
  909. package/lib/domain/shopping/repositories/coupon.repository.d.ts +0 -4
  910. package/lib/domain/shopping/repositories/index.d.ts +0 -7
  911. package/lib/domain/shopping/repositories/legacy-order.repository.d.ts +0 -3
  912. package/lib/domain/shopping/repositories/order.repository.d.ts +0 -4
  913. package/lib/domain/shopping/repositories/payment.repository.d.ts +0 -4
  914. package/lib/domain/shopping/repositories/subscription/checkout.repository.d.ts +0 -4
  915. package/lib/domain/shopping/repositories/subscription/index.d.ts +0 -2
  916. package/lib/domain/shopping/repositories/subscription/plan.repository.d.ts +0 -4
  917. package/lib/domain/users/errors/index.d.ts +0 -3
  918. package/lib/domain/users/errors/unauthorized.error.d.ts +0 -4
  919. package/lib/domain/users/errors/user-already-registered.error.d.ts +0 -4
  920. package/lib/domain/users/errors/weak-password.error.d.ts +0 -4
  921. package/lib/domain/users/index.d.ts +0 -5
  922. package/lib/domain/users/models/beauty-profile.d.ts +0 -12
  923. package/lib/domain/users/models/enums/accessory-importances.enum.d.ts +0 -5
  924. package/lib/domain/users/models/enums/area.enum.d.ts +0 -11
  925. package/lib/domain/users/models/enums/beard-problems.enum.d.ts +0 -9
  926. package/lib/domain/users/models/enums/beard-sizes.enum.d.ts +0 -7
  927. package/lib/domain/users/models/enums/beauty-product-importances.enum.d.ts +0 -6
  928. package/lib/domain/users/models/enums/body-problems.enum.d.ts +0 -11
  929. package/lib/domain/users/models/enums/body-shapes.enum.d.ts +0 -7
  930. package/lib/domain/users/models/enums/body-tattoos.enum.d.ts +0 -5
  931. package/lib/domain/users/models/enums/face-skin-oilinesses.enum.d.ts +0 -7
  932. package/lib/domain/users/models/enums/face-skin-problems.enum.d.ts +0 -10
  933. package/lib/domain/users/models/enums/face-skin-tones.enum.d.ts +0 -8
  934. package/lib/domain/users/models/enums/family-incomes.enum.d.ts +0 -8
  935. package/lib/domain/users/models/enums/fragrance-importances.enum.d.ts +0 -5
  936. package/lib/domain/users/models/enums/hair-colors.enum.d.ts +0 -10
  937. package/lib/domain/users/models/enums/hair-problems.enum.d.ts +0 -10
  938. package/lib/domain/users/models/enums/hair-strands.enum.d.ts +0 -8
  939. package/lib/domain/users/models/enums/hair-types.enum.d.ts +0 -7
  940. package/lib/domain/users/models/enums/index.d.ts +0 -20
  941. package/lib/domain/users/models/enums/office-position.enum.d.ts +0 -6
  942. package/lib/domain/users/models/enums/product-spents.enum.d.ts +0 -8
  943. package/lib/domain/users/models/enums/user-type.enum.d.ts +0 -8
  944. package/lib/domain/users/models/index.d.ts +0 -7
  945. package/lib/domain/users/models/lead.d.ts +0 -9
  946. package/lib/domain/users/models/subscription/edition.d.ts +0 -15
  947. package/lib/domain/users/models/subscription/enums/billing-status.enum.d.ts +0 -3
  948. package/lib/domain/users/models/subscription/enums/edition-status.enum.d.ts +0 -4
  949. package/lib/domain/users/models/subscription/enums/index.d.ts +0 -4
  950. package/lib/domain/users/models/subscription/enums/payment-type.enum.d.ts +0 -5
  951. package/lib/domain/users/models/subscription/enums/status.enum.d.ts +0 -4
  952. package/lib/domain/users/models/subscription/index.d.ts +0 -4
  953. package/lib/domain/users/models/subscription/payment.d.ts +0 -14
  954. package/lib/domain/users/models/subscription/subscription.d.ts +0 -30
  955. package/lib/domain/users/models/user-address.d.ts +0 -7
  956. package/lib/domain/users/models/user-payment-method.d.ts +0 -13
  957. package/lib/domain/users/models/user.d.ts +0 -24
  958. package/lib/domain/users/repositories/beauty-profile.repository.d.ts +0 -4
  959. package/lib/domain/users/repositories/edition.repository.d.ts +0 -4
  960. package/lib/domain/users/repositories/index.d.ts +0 -8
  961. package/lib/domain/users/repositories/lead.repository.d.ts +0 -4
  962. package/lib/domain/users/repositories/subscription-payment.repository.d.ts +0 -4
  963. package/lib/domain/users/repositories/subscription.repository.d.ts +0 -4
  964. package/lib/domain/users/repositories/user-address.repository.d.ts +0 -4
  965. package/lib/domain/users/repositories/user-payment-method.repository.d.ts +0 -4
  966. package/lib/domain/users/repositories/user.repository.d.ts +0 -6
  967. package/lib/domain/users/services/authentication.service.d.ts +0 -11
  968. package/lib/domain/users/services/index.d.ts +0 -3
  969. package/lib/domain/users/services/register.service.d.ts +0 -7
  970. package/lib/domain/users/services/types/basic-user-data.type.d.ts +0 -4
  971. package/lib/domain/users/services/types/index.d.ts +0 -1
  972. package/lib/domain/users/use-cases/authentication.d.ts +0 -21
  973. package/lib/domain/users/use-cases/index.d.ts +0 -3
  974. package/lib/domain/users/use-cases/register.d.ts +0 -13
  975. package/lib/domain/users/use-cases/signout.d.ts +0 -6
  976. package/lib/errors/duplicated-results.error.d.ts +0 -4
  977. package/lib/errors/index.d.ts +0 -4
  978. package/lib/errors/invalid-argument.error.d.ts +0 -4
  979. package/lib/errors/not-found.error.d.ts +0 -4
  980. package/lib/errors/required-argument.error.d.ts +0 -5
  981. package/lib/index.d.ts +0 -4
  982. package/lib/infra/firebase/auth/authentication-firebase-auth.service.d.ts +0 -11
  983. package/lib/infra/firebase/auth/index.d.ts +0 -2
  984. package/lib/infra/firebase/auth/register-firebase-auth.service.d.ts +0 -8
  985. package/lib/infra/firebase/auth/types/firebase-user-with-id.type.d.ts +0 -3
  986. package/lib/infra/firebase/firestore/index.d.ts +0 -3
  987. package/lib/infra/firebase/firestore/mixins/index.d.ts +0 -9
  988. package/lib/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +0 -17
  989. package/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +0 -29
  990. package/lib/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +0 -15
  991. package/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +0 -20
  992. package/lib/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +0 -15
  993. package/lib/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +0 -15
  994. package/lib/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +0 -10
  995. package/lib/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +0 -14
  996. package/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +0 -16
  997. package/lib/infra/firebase/firestore/models/user-search.d.ts +0 -9
  998. package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +0 -55
  999. package/lib/infra/firebase/firestore/repositories/catalog/index.d.ts +0 -4
  1000. package/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +0 -50
  1001. package/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +0 -60
  1002. package/lib/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +0 -49
  1003. package/lib/infra/firebase/firestore/repositories/index.d.ts +0 -4
  1004. package/lib/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +0 -49
  1005. package/lib/infra/firebase/firestore/repositories/shop-settings/index.d.ts +0 -2
  1006. package/lib/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +0 -49
  1007. package/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +0 -49
  1008. package/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +0 -49
  1009. package/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +0 -49
  1010. package/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +0 -53
  1011. package/lib/infra/firebase/firestore/repositories/shopping/index.d.ts +0 -8
  1012. package/lib/infra/firebase/firestore/repositories/shopping/legacy-order-firestore.repository.d.ts +0 -7
  1013. package/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +0 -49
  1014. package/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +0 -49
  1015. package/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +0 -49
  1016. package/lib/infra/firebase/firestore/repositories/users/index.d.ts +0 -9
  1017. package/lib/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +0 -49
  1018. package/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +0 -60
  1019. package/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +0 -49
  1020. package/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +0 -60
  1021. package/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +0 -60
  1022. package/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +0 -60
  1023. package/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +0 -60
  1024. package/lib/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +0 -60
  1025. package/lib/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +0 -50
  1026. package/lib/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +0 -6
  1027. package/lib/infra/firebase/firestore/types/firestore.helpers.type.d.ts +0 -8
  1028. package/lib/infra/firebase/firestore/types/firestore.repository.type.d.ts +0 -8
  1029. package/lib/infra/firebase/firestore/types/index.d.ts +0 -3
  1030. package/lib/infra/firebase/index.d.ts +0 -2
  1031. package/lib/infra/index.d.ts +0 -1
  1032. package/lib/utils/index.d.ts +0 -4
  1033. package/lib/utils/mixins/base.mixin.d.ts +0 -3
  1034. package/lib/utils/mixins/index.d.ts +0 -2
  1035. package/lib/utils/mixins/mixin-ctor.type.d.ts +0 -1
  1036. package/lib/utils/types/index.d.ts +0 -1
  1037. package/lib/utils/types/prop.type.d.ts +0 -1
  1038. package/public-api.d.ts +0 -2
@@ -1,1664 +1,2959 @@
1
1
  import 'reflect-metadata';
2
- import { plainToClass, classToPlain, Expose, Type } from 'class-transformer';
3
- import { __decorate, __metadata, __awaiter } from 'tslib';
4
- import { isNil, isObject, isNumber, isString, isEmpty } from 'lodash';
5
- export { chunk, isEmpty, isNil, isNumber, isObject, isString, pick } from 'lodash';
2
+ import { plainToInstance, instanceToPlain, Expose, Type } from 'class-transformer';
3
+ import { __decorate, __metadata, __awaiter, __rest } 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 { isString, isNil, isNumber, isDate, set, isObject, isEmpty, chunk, isBoolean, isInteger, isNaN as isNaN$1, omit } from 'lodash';
7
+ export { chunk, isBoolean, isDate, isEmpty, isInteger, isNaN, isNil, isNumber, isObject, isString, now, omit, pick, set } from 'lodash';
8
+ import { CustomError } from 'ts-custom-error';
9
+ import { Md5 } from 'ts-md5';
10
+ import axios from 'axios';
6
11
  import firebase from 'firebase';
7
- import firebase$1 from 'firebase/app';
8
-
9
- class BaseModel {
10
- constructor(args) {
11
- Object.assign(this, args);
12
- }
13
- static toInstance(data) {
14
- return plainToClass(this, data);
15
- }
16
- toPlain() {
17
- return classToPlain(this, { exposeUnsetFields: false });
18
- }
19
- }
20
-
21
- var Where;
22
- (function (Where) {
23
- Where["EQUALS"] = "==";
24
- Where["NOTEQUALS"] = "!=";
25
- Where["GT"] = ">";
26
- Where["GTE"] = ">=";
27
- Where["IN"] = "in";
28
- Where["LT"] = "<";
29
- Where["LTE"] = "<=";
30
- Where["LIKE"] = "like";
12
+ import { mutation, query } from 'gql-query-builder';
13
+ import fetch from 'node-fetch';
14
+
15
+ class BaseModel {
16
+ get identifier() {
17
+ const fields = this.constructor.identifiersFields.filter((field) => field !== 'identifier');
18
+ return fields.reduce((object, field) => (Object.assign(Object.assign({}, object), { [field]: this[field] })), {});
19
+ }
20
+ get identifiersFields() {
21
+ return this.constructor.identifiersFields;
22
+ }
23
+ constructor(args) {
24
+ Object.assign(this, args);
25
+ }
26
+ static toInstance(data) {
27
+ return plainToInstance(this, data || {});
28
+ }
29
+ static isModel(value) {
30
+ return value instanceof this;
31
+ }
32
+ toPlain() {
33
+ return instanceToPlain(this);
34
+ }
35
+ }
36
+
37
+ var Where;
38
+ (function (Where) {
39
+ Where["EQUALS"] = "==";
40
+ Where["GT"] = ">";
41
+ Where["GTE"] = ">=";
42
+ Where["IN"] = "in";
43
+ Where["NOTIN"] = "not in";
44
+ Where["LT"] = "<";
45
+ Where["LTE"] = "<=";
46
+ Where["LIKE"] = "like";
47
+ Where["NOTLIKE"] = "not like";
48
+ Where["ISNULL"] = "is null";
49
+ Where["ISNOTNULL"] = "is not null";
31
50
  })(Where || (Where = {}));
32
51
 
33
- var UpdateOptionActions;
34
- (function (UpdateOptionActions) {
35
- UpdateOptionActions["UPDATE"] = "update";
36
- UpdateOptionActions["MERGE"] = "merge";
37
- UpdateOptionActions["REMOVE"] = "remove";
38
- UpdateOptionActions["REMOVE_FIELD"] = "removeField";
39
- UpdateOptionActions["NULL"] = "null";
52
+ var UpdateOptionActions;
53
+ (function (UpdateOptionActions) {
54
+ UpdateOptionActions["UPDATE"] = "update";
55
+ UpdateOptionActions["MERGE"] = "merge";
56
+ UpdateOptionActions["REMOVE"] = "remove";
57
+ UpdateOptionActions["REMOVE_FIELD"] = "removeField";
58
+ UpdateOptionActions["NULL"] = "null";
40
59
  })(UpdateOptionActions || (UpdateOptionActions = {}));
41
60
 
42
- var AccessoryImportances;
43
- (function (AccessoryImportances) {
44
- AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
45
- AccessoryImportances["LIKE_RARELY_USE"] = "Gosto, mas uso poucos";
46
- AccessoryImportances["LIKE_ALWAYS_FOLLOW_FASHION"] = "Gosto muito de acess\u00F3rios e sempre procuro acompanhar a moda";
61
+ var AccessoryImportances;
62
+ (function (AccessoryImportances) {
63
+ AccessoryImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
64
+ AccessoryImportances["LIKE_RARELY_USE"] = "Gosto, mas uso poucos";
65
+ AccessoryImportances["LIKE_ALWAYS_FOLLOW_FASHION"] = "Gosto muito de acess\u00F3rios e sempre procuro acompanhar a moda";
47
66
  })(AccessoryImportances || (AccessoryImportances = {}));
48
67
 
49
- var Area;
50
- (function (Area) {
51
- Area["GP"] = "Geral";
52
- Area["CRM"] = "CRM";
53
- Area["MediaProd"] = "Media Production";
54
- Area["Tech"] = "Tecnologia";
55
- Area["Transactional"] = "Transacional";
56
- Area["Operations"] = "Opera\u00E7\u00F5es";
57
- Area["Sales"] = "Comercial";
58
- Area["Finantial"] = "Financeiro";
59
- Area["HR"] = "RH";
68
+ var Area;
69
+ (function (Area) {
70
+ Area["GP"] = "Geral";
71
+ Area["CRM"] = "CRM";
72
+ Area["MediaProd"] = "Media Production";
73
+ Area["Tech"] = "Tecnologia";
74
+ Area["Transactional"] = "Transacional";
75
+ Area["Operations"] = "Opera\u00E7\u00F5es";
76
+ Area["Sales"] = "Comercial";
77
+ Area["Finantial"] = "Financeiro";
78
+ Area["HR"] = "RH";
60
79
  })(Area || (Area = {}));
61
80
 
62
- var BeardProblems;
63
- (function (BeardProblems) {
64
- BeardProblems["NO_PROBLEMS"] = "Sem problemas";
65
- BeardProblems["DRY"] = "Barba Seca";
66
- BeardProblems["OILY"] = "Barba Oleaosa";
67
- BeardProblems["DANCRUFF"] = "Barba com Caspa";
68
- BeardProblems["INGROWN_HAIRS"] = "P\u00EAlos Encravados";
69
- BeardProblems["DOESNT_GROW"] = "N\u00E3o Cresce";
70
- BeardProblems["SPARSE_BEARD"] = "Barba Rala";
81
+ var BeardProblems;
82
+ (function (BeardProblems) {
83
+ BeardProblems["NO_PROBLEMS"] = "Sem problemas";
84
+ BeardProblems["DRY"] = "Barba Seca";
85
+ BeardProblems["OILY"] = "Barba Oleaosa";
86
+ BeardProblems["DANCRUFF"] = "Barba com Caspa";
87
+ BeardProblems["INGROWN_HAIRS"] = "P\u00EAlos Encravados";
88
+ BeardProblems["DOESNT_GROW"] = "N\u00E3o Cresce";
89
+ BeardProblems["SPARSE_BEARD"] = "Barba Rala";
71
90
  })(BeardProblems || (BeardProblems = {}));
72
91
 
73
- var BeardSizes;
74
- (function (BeardSizes) {
75
- BeardSizes["BIG"] = "Grande";
76
- BeardSizes["MEDIUM"] = "M\u00E9dia";
77
- BeardSizes["SHORT"] = "Curta";
78
- BeardSizes["MUSTACHE"] = "Bigode";
79
- BeardSizes["NOTHING"] = "Sem Barba";
92
+ var BeardSizes;
93
+ (function (BeardSizes) {
94
+ BeardSizes["BIG"] = "Grande";
95
+ BeardSizes["MEDIUM"] = "M\u00E9dia";
96
+ BeardSizes["SHORT"] = "Curta";
97
+ BeardSizes["MUSTACHE"] = "Bigode";
98
+ BeardSizes["NOTHING"] = "Sem Barba";
80
99
  })(BeardSizes || (BeardSizes = {}));
81
100
 
82
- var BeautyProductImportances;
83
- (function (BeautyProductImportances) {
84
- BeautyProductImportances["KNOW_LITTLE_ABOUT"] = "Conhe\u00E7o bem pouco de produtos de beleza e rotinas de cuidados";
85
- BeautyProductImportances["ALREADY_BOUGHT_NOTHING_SPECIALIZED"] = "J\u00E1 comprei alguns produtos b\u00E1sicos para cuidar de mim, mas nada muito especializado";
86
- 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";
87
- BeautyProductImportances["PERSONAL_CARE_EXPERT"] = "Sou um expert em cuidados pessoais";
101
+ var BeautyProductImportances;
102
+ (function (BeautyProductImportances) {
103
+ BeautyProductImportances["KNOW_LITTLE_ABOUT"] = "Conhe\u00E7o bem pouco de produtos de beleza e rotinas de cuidados";
104
+ BeautyProductImportances["ALREADY_BOUGHT_NOTHING_SPECIALIZED"] = "J\u00E1 comprei alguns produtos b\u00E1sicos para cuidar de mim, mas nada muito especializado";
105
+ 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";
106
+ BeautyProductImportances["PERSONAL_CARE_EXPERT"] = "Sou um expert em cuidados pessoais";
88
107
  })(BeautyProductImportances || (BeautyProductImportances = {}));
89
108
 
90
- var BodyProblems;
91
- (function (BodyProblems) {
92
- BodyProblems["NO_WORRIES"] = "Sem preocupa\u00E7\u00F5es";
93
- BodyProblems["FLACCIDITY"] = "Flacidez";
94
- BodyProblems["LOCALIZED_FAT"] = "Gordura Localizada";
95
- BodyProblems["STRETCH_MARKS"] = "Estrias";
96
- BodyProblems["SENSITIVE_SKIN"] = "Pele Sens\u00EDvel";
97
- BodyProblems["DRY_SKIN"] = "Pele Seca";
98
- BodyProblems["OILY_ACNE"] = "Oleosa/Acne";
99
- BodyProblems["SKIN_FRECKLES"] = "Pele com Sardas";
100
- BodyProblems["PHOTOSENSITIVE_SKIN"] = "Pele Fotossens\u00EDvel";
109
+ var BodyProblems;
110
+ (function (BodyProblems) {
111
+ BodyProblems["NO_WORRIES"] = "Sem preocupa\u00E7\u00F5es";
112
+ BodyProblems["FLACCIDITY"] = "Flacidez";
113
+ BodyProblems["LOCALIZED_FAT"] = "Gordura Localizada";
114
+ BodyProblems["STRETCH_MARKS"] = "Estrias";
115
+ BodyProblems["SENSITIVE_SKIN"] = "Pele Sens\u00EDvel";
116
+ BodyProblems["DRY_SKIN"] = "Pele Seca";
117
+ BodyProblems["OILY_ACNE"] = "Oleosa/Acne";
118
+ BodyProblems["SKIN_FRECKLES"] = "Pele com Sardas";
119
+ BodyProblems["PHOTOSENSITIVE_SKIN"] = "Pele Fotossens\u00EDvel";
101
120
  })(BodyProblems || (BodyProblems = {}));
102
121
 
103
- var BodyShapes;
104
- (function (BodyShapes) {
105
- BodyShapes["LEAN"] = "Magro";
106
- BodyShapes["REGULAR"] = "Regular";
107
- BodyShapes["OVERWEIGHT"] = "Acima do Peso";
108
- BodyShapes["ATHLETIC"] = "Atl\u00E9tico";
109
- BodyShapes["MUSCULAR"] = "Musculoso";
122
+ var BodyShapes;
123
+ (function (BodyShapes) {
124
+ BodyShapes["LEAN"] = "Magro";
125
+ BodyShapes["REGULAR"] = "Regular";
126
+ BodyShapes["OVERWEIGHT"] = "Acima do Peso";
127
+ BodyShapes["ATHLETIC"] = "Atl\u00E9tico";
128
+ BodyShapes["MUSCULAR"] = "Musculoso";
110
129
  })(BodyShapes || (BodyShapes = {}));
111
130
 
112
- var BodyTattoos;
113
- (function (BodyTattoos) {
114
- BodyTattoos["NONE"] = "Nenhuma";
115
- BodyTattoos["HAS_DOESNT_CARE"] = "Tenho mas n\u00E3o cuido";
116
- BodyTattoos["HAS_CARE_LOT"] = "Tenho e cuido bastante";
131
+ var BodyTattoos;
132
+ (function (BodyTattoos) {
133
+ BodyTattoos["NONE"] = "Nenhuma";
134
+ BodyTattoos["HAS_DOESNT_CARE"] = "Tenho mas n\u00E3o cuido";
135
+ BodyTattoos["HAS_CARE_LOT"] = "Tenho e cuido bastante";
117
136
  })(BodyTattoos || (BodyTattoos = {}));
118
137
 
119
- var FaceSkinOilinesses;
120
- (function (FaceSkinOilinesses) {
121
- FaceSkinOilinesses["DRY"] = "Seca";
122
- FaceSkinOilinesses["OILY"] = "Oleaosa";
123
- FaceSkinOilinesses["MIXED"] = "Mista";
124
- FaceSkinOilinesses["NORMAL"] = "Normal";
125
- FaceSkinOilinesses["DONT_KNOW"] = "Eu n\u00E3o sei como dizer";
138
+ var FaceSkinOilinesses;
139
+ (function (FaceSkinOilinesses) {
140
+ FaceSkinOilinesses["DRY"] = "Seca";
141
+ FaceSkinOilinesses["OILY"] = "Oleaosa";
142
+ FaceSkinOilinesses["MIXED"] = "Mista";
143
+ FaceSkinOilinesses["NORMAL"] = "Normal";
144
+ FaceSkinOilinesses["DONT_KNOW"] = "Eu n\u00E3o sei como dizer";
126
145
  })(FaceSkinOilinesses || (FaceSkinOilinesses = {}));
127
146
 
128
- var FaceSkinProblems;
129
- (function (FaceSkinProblems) {
130
- FaceSkinProblems["NO_PROBLEMS"] = "Sem problemas";
131
- FaceSkinProblems["DARK_CIRCLES"] = "Olheiras";
132
- FaceSkinProblems["WRINKLES"] = "Rugas";
133
- FaceSkinProblems["BLACKHEADS_PIMPLES"] = "Cravos e Espinhas";
134
- FaceSkinProblems["STAINS"] = "Manchas";
135
- FaceSkinProblems["FRECKLES"] = "Sardas";
136
- FaceSkinProblems["SENSITIVE"] = "Sens\u00EDvel";
137
- FaceSkinProblems["PHOTOSENSITIVE"] = "Fotossens\u00EDvel";
147
+ var FaceSkinProblems;
148
+ (function (FaceSkinProblems) {
149
+ FaceSkinProblems["NO_PROBLEMS"] = "Sem problemas";
150
+ FaceSkinProblems["DARK_CIRCLES"] = "Olheiras";
151
+ FaceSkinProblems["WRINKLES"] = "Rugas";
152
+ FaceSkinProblems["BLACKHEADS_PIMPLES"] = "Cravos e Espinhas";
153
+ FaceSkinProblems["STAINS"] = "Manchas";
154
+ FaceSkinProblems["FRECKLES"] = "Sardas";
155
+ FaceSkinProblems["SENSITIVE"] = "Sens\u00EDvel";
156
+ FaceSkinProblems["PHOTOSENSITIVE"] = "Fotossens\u00EDvel";
138
157
  })(FaceSkinProblems || (FaceSkinProblems = {}));
139
158
 
140
- var FaceSkinTones;
141
- (function (FaceSkinTones) {
142
- FaceSkinTones["VERY_CLEAR"] = "Muito Clara";
143
- FaceSkinTones["CLEAR"] = "Clara";
144
- FaceSkinTones["MEDIUM_LIGHT"] = "Clara M\u00E9dia";
145
- FaceSkinTones["MEDIUM_DARK"] = "Escura M\u00E9dia";
146
- FaceSkinTones["DARK"] = "Escura";
147
- FaceSkinTones["VERY_DARK"] = "Muito Escura";
159
+ var FaceSkinTones;
160
+ (function (FaceSkinTones) {
161
+ FaceSkinTones["VERY_CLEAR"] = "Muito Clara";
162
+ FaceSkinTones["CLEAR"] = "Clara";
163
+ FaceSkinTones["MEDIUM_LIGHT"] = "Clara M\u00E9dia";
164
+ FaceSkinTones["MEDIUM_DARK"] = "Escura M\u00E9dia";
165
+ FaceSkinTones["DARK"] = "Escura";
166
+ FaceSkinTones["VERY_DARK"] = "Muito Escura";
148
167
  })(FaceSkinTones || (FaceSkinTones = {}));
149
168
 
150
- var FamilyIncomes;
151
- (function (FamilyIncomes) {
152
- FamilyIncomes["UNTIL_3000"] = "At\u00E9 R$3.000";
153
- FamilyIncomes["SINCE_3001_TO_7000"] = "De R$3.001 a R$7.000";
154
- FamilyIncomes["SINCE_7001_TO_10000"] = "De R$7.001 a R$10.000";
155
- FamilyIncomes["SINCE_10001_TO_15000"] = "De R$10.001 a R$15.000";
156
- FamilyIncomes["GRAN_THAN_15000"] = "Mais de R$15.000";
157
- FamilyIncomes["NOW_ANSWER"] = "Prefiro nao responder";
169
+ var FamilyIncomes;
170
+ (function (FamilyIncomes) {
171
+ FamilyIncomes["UNTIL_3000"] = "At\u00E9 R$3.000";
172
+ FamilyIncomes["SINCE_3001_TO_7000"] = "De R$3.001 a R$7.000";
173
+ FamilyIncomes["SINCE_7001_TO_10000"] = "De R$7.001 a R$10.000";
174
+ FamilyIncomes["SINCE_10001_TO_15000"] = "De R$10.001 a R$15.000";
175
+ FamilyIncomes["GRAN_THAN_15000"] = "Mais de R$15.000";
176
+ FamilyIncomes["NOW_ANSWER"] = "Prefiro nao responder";
158
177
  })(FamilyIncomes || (FamilyIncomes = {}));
159
178
 
160
- var FragranceImportances;
161
- (function (FragranceImportances) {
162
- FragranceImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
163
- FragranceImportances["LIKE_ALWAYS_USE_SAME"] = "Gosto de perfumes, mas uso sempre os mesmos";
164
- FragranceImportances["LIKE_INNOVATE"] = "Gosto de inovar e conhecer novas fragr\u00E2ncias";
179
+ var FragranceImportances;
180
+ (function (FragranceImportances) {
181
+ FragranceImportances["NOT_INTERESTED"] = "N\u00E3o tenho interesse";
182
+ FragranceImportances["LIKE_ALWAYS_USE_SAME"] = "Gosto de perfumes, mas uso sempre os mesmos";
183
+ FragranceImportances["LIKE_INNOVATE"] = "Gosto de inovar e conhecer novas fragr\u00E2ncias";
165
184
  })(FragranceImportances || (FragranceImportances = {}));
166
185
 
167
- var HairColors;
168
- (function (HairColors) {
169
- HairColors["BLACK"] = "Preto";
170
- HairColors["DARK_BROWN"] = "Castanho Escuro";
171
- HairColors["LIGHT_BROWN"] = "Castanho Claro";
172
- HairColors["DARK_BLONDE"] = "Loiro Escuro";
173
- HairColors["LIGHT_BLONDE"] = "Loiro Claro";
174
- HairColors["WHITE_GRAY"] = "Branco/Grisalho";
175
- HairColors["REDHEAD"] = "Ruivo";
176
- HairColors["OTHER"] = "RuiOutroo";
186
+ var HairColors;
187
+ (function (HairColors) {
188
+ HairColors["BLACK"] = "Preto";
189
+ HairColors["DARK_BROWN"] = "Castanho Escuro";
190
+ HairColors["LIGHT_BROWN"] = "Castanho Claro";
191
+ HairColors["DARK_BLONDE"] = "Loiro Escuro";
192
+ HairColors["LIGHT_BLONDE"] = "Loiro Claro";
193
+ HairColors["WHITE_GRAY"] = "Branco/Grisalho";
194
+ HairColors["REDHEAD"] = "Ruivo";
195
+ HairColors["OTHER"] = "RuiOutroo";
177
196
  })(HairColors || (HairColors = {}));
178
197
 
179
- var HairProblems;
180
- (function (HairProblems) {
181
- HairProblems["NO_PROBLEMS"] = "Sem problemas";
182
- HairProblems["DANCRUFF"] = "Caspa";
183
- HairProblems["LOSS"] = "Queda";
184
- HairProblems["OILY"] = "Oleosidade";
185
- HairProblems["DRYNESS"] = "Ressecamento";
186
- HairProblems["CHEMICAL"] = "Quimica";
187
- HairProblems["WHITE_HAIR"] = "Cabelos Brancos";
188
- HairProblems["REBEL_WIRES"] = "Fios Rebeldes";
198
+ var HairProblems;
199
+ (function (HairProblems) {
200
+ HairProblems["NO_PROBLEMS"] = "Sem problemas";
201
+ HairProblems["DANCRUFF"] = "Caspa";
202
+ HairProblems["LOSS"] = "Queda";
203
+ HairProblems["OILY"] = "Oleosidade";
204
+ HairProblems["DRYNESS"] = "Ressecamento";
205
+ HairProblems["CHEMICAL"] = "Quimica";
206
+ HairProblems["WHITE_HAIR"] = "Cabelos Brancos";
207
+ HairProblems["REBEL_WIRES"] = "Fios Rebeldes";
189
208
  })(HairProblems || (HairProblems = {}));
190
209
 
191
- var HairStrands;
192
- (function (HairStrands) {
193
- HairStrands["NORMAL"] = "Fio Normal";
194
- HairStrands["DRY"] = "Fio Seco";
195
- HairStrands["OILY"] = "Fio Oleoso";
196
- HairStrands["MIXED"] = "Fio Misto";
197
- HairStrands["FINE"] = "Fio Fino";
198
- HairStrands["THICK"] = "Fio Grosso";
210
+ var HairStrands;
211
+ (function (HairStrands) {
212
+ HairStrands["NORMAL"] = "Fio Normal";
213
+ HairStrands["DRY"] = "Fio Seco";
214
+ HairStrands["OILY"] = "Fio Oleoso";
215
+ HairStrands["MIXED"] = "Fio Misto";
216
+ HairStrands["FINE"] = "Fio Fino";
217
+ HairStrands["THICK"] = "Fio Grosso";
199
218
  })(HairStrands || (HairStrands = {}));
200
219
 
201
- var HairTypes;
202
- (function (HairTypes) {
203
- HairTypes["Smooth"] = "Liso";
204
- HairTypes["WAVY"] = "Ondulado";
205
- HairTypes["CURLY"] = "Cacheado";
206
- HairTypes["FRIZZY"] = "Crespo";
207
- HairTypes["BALD"] = "Sou careca";
220
+ var HairTypes;
221
+ (function (HairTypes) {
222
+ HairTypes["Smooth"] = "Liso";
223
+ HairTypes["WAVY"] = "Ondulado";
224
+ HairTypes["CURLY"] = "Cacheado";
225
+ HairTypes["FRIZZY"] = "Crespo";
226
+ HairTypes["BALD"] = "Sou careca";
208
227
  })(HairTypes || (HairTypes = {}));
209
228
 
210
- var OfficePosition;
211
- (function (OfficePosition) {
212
- OfficePosition["Intern"] = "Estagi\u00E1rio";
213
- OfficePosition["Analyst"] = "Analista";
214
- OfficePosition["Manager"] = "Gerente";
215
- OfficePosition["Director"] = "Diretor";
229
+ var OfficePosition;
230
+ (function (OfficePosition) {
231
+ OfficePosition["Intern"] = "Estagi\u00E1rio";
232
+ OfficePosition["Analyst"] = "Analista";
233
+ OfficePosition["Manager"] = "Gerente";
234
+ OfficePosition["Director"] = "Diretor";
216
235
  })(OfficePosition || (OfficePosition = {}));
217
236
 
218
- var ProductSpents;
219
- (function (ProductSpents) {
220
- ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
221
- ProductSpents["SINCE_51_TO_100"] = "De R$51 a R$100";
222
- ProductSpents["SINCE_101_TO_200"] = "De R$101 a R$200";
223
- ProductSpents["SINCE_201_TO_300"] = "De R$201 a R$300";
224
- ProductSpents["GRAN_THAN_300"] = "Mais de R$300";
225
- ProductSpents["NOW_ANSWER"] = "Prefiro nao responder";
237
+ var ProductSpents;
238
+ (function (ProductSpents) {
239
+ ProductSpents["UNTIL_50"] = "At\u00E9 R$50";
240
+ ProductSpents["SINCE_51_TO_100"] = "De R$51 a R$100";
241
+ ProductSpents["SINCE_101_TO_200"] = "De R$101 a R$200";
242
+ ProductSpents["SINCE_201_TO_300"] = "De R$201 a R$300";
243
+ ProductSpents["GRAN_THAN_300"] = "Mais de R$300";
244
+ ProductSpents["NOW_ANSWER"] = "Prefiro nao responder";
226
245
  })(ProductSpents || (ProductSpents = {}));
227
246
 
228
- var UserType;
229
- (function (UserType) {
230
- UserType["B2C"] = "Cliente Transacional";
231
- UserType["GlamGirl"] = "Glamgirl";
232
- UserType["MensBoy"] = "Mensboy";
233
- UserType["B2B"] = "Company";
234
- UserType["Collaborator"] = "Funcion\u00E1rio";
235
- UserType["Influencer"] = "Influencer";
247
+ var UserType;
248
+ (function (UserType) {
249
+ UserType["B2C"] = "Cliente Transacional";
250
+ UserType["GlamGirl"] = "Glamgirl";
251
+ UserType["MensBoy"] = "Mensboy";
252
+ UserType["B2B"] = "Company";
253
+ UserType["Collaborator"] = "Funcion\u00E1rio";
254
+ UserType["Influencer"] = "Influencer";
236
255
  })(UserType || (UserType = {}));
237
256
 
238
- var BillingStatus;
239
- (function (BillingStatus) {
240
- BillingStatus["PAYED"] = "PAGO";
257
+ var BillingStatus;
258
+ (function (BillingStatus) {
259
+ BillingStatus["PAYED"] = "PAGO";
241
260
  })(BillingStatus || (BillingStatus = {}));
242
261
 
243
- var EditionStatus;
244
- (function (EditionStatus) {
245
- EditionStatus["ALLOCATION_WAITING"] = "Aguardando aloca\u00E7\u00E3o";
246
- EditionStatus["SHIPPED"] = "Enviado";
262
+ var EditionStatus;
263
+ (function (EditionStatus) {
264
+ EditionStatus["ALLOCATION_WAITING"] = "Aguardando aloca\u00E7\u00E3o";
265
+ EditionStatus["SHIPPED"] = "Enviado";
247
266
  })(EditionStatus || (EditionStatus = {}));
248
267
 
249
- var PaymentType;
250
- (function (PaymentType) {
251
- PaymentType["AQUISITION"] = "Aquisi\u00E7\u00E3o";
252
- PaymentType["RENEWAL"] = "Renova\u00E7\u00E3o";
253
- PaymentType["FREIGHT"] = "mudan\u00E7a de endere\u00E7o, Frete";
268
+ var PaymentType;
269
+ (function (PaymentType) {
270
+ PaymentType["AQUISITION"] = "Aquisi\u00E7\u00E3o";
271
+ PaymentType["RENEWAL"] = "Renova\u00E7\u00E3o";
272
+ PaymentType["FREIGHT"] = "mudan\u00E7a de endere\u00E7o, Frete";
254
273
  })(PaymentType || (PaymentType = {}));
255
274
 
256
- var Status;
257
- (function (Status) {
258
- Status["ACTIVE"] = "active";
259
- Status["CANCELLED"] = "Cancelado";
275
+ var Status;
276
+ (function (Status) {
277
+ Status["ACTIVE"] = "active";
278
+ Status["CANCELLED"] = "Cancelado";
260
279
  })(Status || (Status = {}));
261
280
 
262
- class Edition extends BaseModel {
263
- identifierFields() {
264
- return ['id'];
265
- }
266
- }
267
-
268
- class Payment extends BaseModel {
269
- identifierFields() {
270
- return ['id'];
271
- }
272
- }
273
- __decorate([
274
- Expose({ name: 'refuse_reason' }),
275
- __metadata("design:type", String)
276
- ], Payment.prototype, "refuseReason", void 0);
277
- __decorate([
278
- Expose({ name: 'status_reason' }),
279
- __metadata("design:type", String)
280
- ], Payment.prototype, "statusReason", void 0);
281
- __decorate([
282
- Expose({ name: 'acquirer_response_code' }),
283
- __metadata("design:type", String)
284
- ], Payment.prototype, "acquirerResponseCode", void 0);
285
- __decorate([
286
- Expose({ name: 'acquirer_name' }),
287
- __metadata("design:type", String)
288
- ], Payment.prototype, "acquirerName", void 0);
289
- __decorate([
290
- Expose({ name: 'acquirer_id' }),
291
- __metadata("design:type", String)
292
- ], Payment.prototype, "acquirerId", void 0);
293
- __decorate([
294
- Expose({ name: 'authorization_code' }),
295
- __metadata("design:type", String)
296
- ], Payment.prototype, "authorizationCode", void 0);
297
- __decorate([
298
- Expose({ name: 'soft_descriptor' }),
299
- __metadata("design:type", String)
300
- ], Payment.prototype, "softDescriptor", void 0);
301
- __decorate([
302
- Expose({ name: 'date_created' }),
303
- __metadata("design:type", String)
304
- ], Payment.prototype, "dateCreated", void 0);
305
- __decorate([
306
- Expose({ name: 'date_updated' }),
307
- __metadata("design:type", String)
308
- ], Payment.prototype, "dateUpdated", void 0);
309
- __decorate([
310
- Expose({ name: 'authorized_amount' }),
311
- __metadata("design:type", Number)
312
- ], Payment.prototype, "authorizedAmount", void 0);
313
- __decorate([
314
- Expose({ name: 'paid_amount' }),
315
- __metadata("design:type", Number)
316
- ], Payment.prototype, "paidAmount", void 0);
317
- __decorate([
318
- Expose({ name: 'refunded_amount' }),
319
- __metadata("design:type", Number)
320
- ], Payment.prototype, "refundedAmount", void 0);
321
- __decorate([
322
- Expose({ name: 'card_holder_name' }),
323
- __metadata("design:type", String)
324
- ], Payment.prototype, "cardHolderName", void 0);
325
- __decorate([
326
- Expose({ name: 'card_last_digits' }),
327
- __metadata("design:type", String)
328
- ], Payment.prototype, "cardLastDigits", void 0);
329
- __decorate([
330
- Expose({ name: 'card_first_digits' }),
331
- __metadata("design:type", String)
332
- ], Payment.prototype, "cardFirstDigits", void 0);
333
- __decorate([
334
- Expose({ name: 'card_brand' }),
335
- __metadata("design:type", String)
336
- ], Payment.prototype, "cardBrand", void 0);
337
- __decorate([
338
- Expose({ name: 'card_pin_mode' }),
339
- __metadata("design:type", String)
340
- ], Payment.prototype, "cardPinMode", void 0);
341
- __decorate([
342
- Expose({ name: 'card_magstripe_fallback' }),
343
- __metadata("design:type", Boolean)
344
- ], Payment.prototype, "cardMagstripeFallback", void 0);
345
- __decorate([
346
- Expose({ name: 'cvm_pin' }),
347
- __metadata("design:type", Boolean)
348
- ], Payment.prototype, "cvmPin", void 0);
349
- __decorate([
350
- Expose({ name: 'postback_url' }),
351
- __metadata("design:type", String)
352
- ], Payment.prototype, "postbackUrl", void 0);
353
- __decorate([
354
- Expose({ name: 'payment_method' }),
355
- __metadata("design:type", String)
356
- ], Payment.prototype, "paymentMethod", void 0);
357
- __decorate([
358
- Expose({ name: 'capture_method' }),
359
- __metadata("design:type", String)
360
- ], Payment.prototype, "captureMethod", void 0);
361
- __decorate([
362
- Expose({ name: 'antifraud_score' }),
363
- __metadata("design:type", String)
364
- ], Payment.prototype, "antifraudScore", void 0);
365
- __decorate([
366
- Expose({ name: 'boleto_url' }),
367
- __metadata("design:type", String)
368
- ], Payment.prototype, "boletoUrl", void 0);
369
- __decorate([
370
- Expose({ name: 'boleto_barcode' }),
371
- __metadata("design:type", String)
372
- ], Payment.prototype, "boletoBarcode", void 0);
373
- __decorate([
374
- Expose({ name: 'boleto_expiration_date' }),
375
- __metadata("design:type", String)
376
- ], Payment.prototype, "boletoExpirationDate", void 0);
377
- __decorate([
378
- Expose({ name: 'subscription_id' }),
379
- __metadata("design:type", String)
380
- ], Payment.prototype, "subscriptionId", void 0);
381
- __decorate([
382
- Expose({ name: 'split_rules' }),
383
- __metadata("design:type", String)
384
- ], Payment.prototype, "splitRules", void 0);
385
- __decorate([
386
- Expose({ name: 'antifraud_metadata' }),
387
- __metadata("design:type", Object)
388
- ], Payment.prototype, "antifraudMetadata", void 0);
389
- __decorate([
390
- Expose({ name: 'reference_key' }),
391
- __metadata("design:type", String)
392
- ], Payment.prototype, "referenceKey", void 0);
393
- __decorate([
394
- Expose({ name: 'local_transaction_id' }),
395
- __metadata("design:type", String)
396
- ], Payment.prototype, "localTransactionId", void 0);
397
- __decorate([
398
- Expose({ name: 'local_time' }),
399
- __metadata("design:type", String)
400
- ], Payment.prototype, "localTime", void 0);
401
- __decorate([
402
- Expose({ name: 'fraud_covered' }),
403
- __metadata("design:type", Boolean)
404
- ], Payment.prototype, "fraudCovered", void 0);
405
- __decorate([
406
- Expose({ name: 'fraud_reimbursed' }),
407
- __metadata("design:type", String)
408
- ], Payment.prototype, "fraudReimbursed", void 0);
409
- __decorate([
410
- Expose({ name: 'order_id' }),
411
- __metadata("design:type", String)
412
- ], Payment.prototype, "orderId", void 0);
413
- __decorate([
414
- Expose({ name: 'risk_level' }),
415
- __metadata("design:type", String)
416
- ], Payment.prototype, "riskLevel", void 0);
417
- __decorate([
418
- Expose({ name: 'receipt_url' }),
419
- __metadata("design:type", String)
420
- ], Payment.prototype, "receiptUrl", void 0);
421
- __decorate([
422
- Expose({ name: 'private_label' }),
423
- __metadata("design:type", String)
424
- ], Payment.prototype, "privateLabel", void 0);
425
- __decorate([
426
- Expose({ name: 'pix_qr_code' }),
427
- __metadata("design:type", String)
428
- ], Payment.prototype, "pixQrCode", void 0);
429
- __decorate([
430
- Expose({ name: 'pix_expiration_date' }),
431
- __metadata("design:type", String)
281
+ class Edition extends BaseModel {
282
+ static get identifiersFields() {
283
+ return ['id', 'subscriptionId'];
284
+ }
285
+ }
286
+
287
+ class Payment extends BaseModel {
288
+ static get identifiersFields() {
289
+ return ['id'];
290
+ }
291
+ }
292
+ __decorate([
293
+ Expose({ name: 'refuse_reason' }),
294
+ __metadata("design:type", String)
295
+ ], Payment.prototype, "refuseReason", void 0);
296
+ __decorate([
297
+ Expose({ name: 'status_reason' }),
298
+ __metadata("design:type", String)
299
+ ], Payment.prototype, "statusReason", void 0);
300
+ __decorate([
301
+ Expose({ name: 'acquirer_response_code' }),
302
+ __metadata("design:type", String)
303
+ ], Payment.prototype, "acquirerResponseCode", void 0);
304
+ __decorate([
305
+ Expose({ name: 'acquirer_name' }),
306
+ __metadata("design:type", String)
307
+ ], Payment.prototype, "acquirerName", void 0);
308
+ __decorate([
309
+ Expose({ name: 'acquirer_id' }),
310
+ __metadata("design:type", String)
311
+ ], Payment.prototype, "acquirerId", void 0);
312
+ __decorate([
313
+ Expose({ name: 'authorization_code' }),
314
+ __metadata("design:type", String)
315
+ ], Payment.prototype, "authorizationCode", void 0);
316
+ __decorate([
317
+ Expose({ name: 'soft_descriptor' }),
318
+ __metadata("design:type", String)
319
+ ], Payment.prototype, "softDescriptor", void 0);
320
+ __decorate([
321
+ Expose({ name: 'date_created' }),
322
+ __metadata("design:type", String)
323
+ ], Payment.prototype, "dateCreated", void 0);
324
+ __decorate([
325
+ Expose({ name: 'date_updated' }),
326
+ __metadata("design:type", String)
327
+ ], Payment.prototype, "dateUpdated", void 0);
328
+ __decorate([
329
+ Expose({ name: 'authorized_amount' }),
330
+ __metadata("design:type", Number)
331
+ ], Payment.prototype, "authorizedAmount", void 0);
332
+ __decorate([
333
+ Expose({ name: 'paid_amount' }),
334
+ __metadata("design:type", Number)
335
+ ], Payment.prototype, "paidAmount", void 0);
336
+ __decorate([
337
+ Expose({ name: 'refunded_amount' }),
338
+ __metadata("design:type", Number)
339
+ ], Payment.prototype, "refundedAmount", void 0);
340
+ __decorate([
341
+ Expose({ name: 'card_holder_name' }),
342
+ __metadata("design:type", String)
343
+ ], Payment.prototype, "cardHolderName", void 0);
344
+ __decorate([
345
+ Expose({ name: 'card_last_digits' }),
346
+ __metadata("design:type", String)
347
+ ], Payment.prototype, "cardLastDigits", void 0);
348
+ __decorate([
349
+ Expose({ name: 'card_first_digits' }),
350
+ __metadata("design:type", String)
351
+ ], Payment.prototype, "cardFirstDigits", void 0);
352
+ __decorate([
353
+ Expose({ name: 'card_brand' }),
354
+ __metadata("design:type", String)
355
+ ], Payment.prototype, "cardBrand", void 0);
356
+ __decorate([
357
+ Expose({ name: 'card_pin_mode' }),
358
+ __metadata("design:type", String)
359
+ ], Payment.prototype, "cardPinMode", void 0);
360
+ __decorate([
361
+ Expose({ name: 'card_magstripe_fallback' }),
362
+ __metadata("design:type", Boolean)
363
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
364
+ __decorate([
365
+ Expose({ name: 'cvm_pin' }),
366
+ __metadata("design:type", Boolean)
367
+ ], Payment.prototype, "cvmPin", void 0);
368
+ __decorate([
369
+ Expose({ name: 'postback_url' }),
370
+ __metadata("design:type", String)
371
+ ], Payment.prototype, "postbackUrl", void 0);
372
+ __decorate([
373
+ Expose({ name: 'payment_method' }),
374
+ __metadata("design:type", String)
375
+ ], Payment.prototype, "paymentMethod", void 0);
376
+ __decorate([
377
+ Expose({ name: 'capture_method' }),
378
+ __metadata("design:type", String)
379
+ ], Payment.prototype, "captureMethod", void 0);
380
+ __decorate([
381
+ Expose({ name: 'antifraud_score' }),
382
+ __metadata("design:type", String)
383
+ ], Payment.prototype, "antifraudScore", void 0);
384
+ __decorate([
385
+ Expose({ name: 'boleto_url' }),
386
+ __metadata("design:type", String)
387
+ ], Payment.prototype, "boletoUrl", void 0);
388
+ __decorate([
389
+ Expose({ name: 'boleto_barcode' }),
390
+ __metadata("design:type", String)
391
+ ], Payment.prototype, "boletoBarcode", void 0);
392
+ __decorate([
393
+ Expose({ name: 'boleto_expiration_date' }),
394
+ __metadata("design:type", String)
395
+ ], Payment.prototype, "boletoExpirationDate", void 0);
396
+ __decorate([
397
+ Expose({ name: 'subscription_id' }),
398
+ __metadata("design:type", String)
399
+ ], Payment.prototype, "subscriptionId", void 0);
400
+ __decorate([
401
+ Expose({ name: 'split_rules' }),
402
+ __metadata("design:type", String)
403
+ ], Payment.prototype, "splitRules", void 0);
404
+ __decorate([
405
+ Expose({ name: 'antifraud_metadata' }),
406
+ __metadata("design:type", Object)
407
+ ], Payment.prototype, "antifraudMetadata", void 0);
408
+ __decorate([
409
+ Expose({ name: 'reference_key' }),
410
+ __metadata("design:type", String)
411
+ ], Payment.prototype, "referenceKey", void 0);
412
+ __decorate([
413
+ Expose({ name: 'local_transaction_id' }),
414
+ __metadata("design:type", String)
415
+ ], Payment.prototype, "localTransactionId", void 0);
416
+ __decorate([
417
+ Expose({ name: 'local_time' }),
418
+ __metadata("design:type", String)
419
+ ], Payment.prototype, "localTime", void 0);
420
+ __decorate([
421
+ Expose({ name: 'fraud_covered' }),
422
+ __metadata("design:type", Boolean)
423
+ ], Payment.prototype, "fraudCovered", void 0);
424
+ __decorate([
425
+ Expose({ name: 'fraud_reimbursed' }),
426
+ __metadata("design:type", String)
427
+ ], Payment.prototype, "fraudReimbursed", void 0);
428
+ __decorate([
429
+ Expose({ name: 'order_id' }),
430
+ __metadata("design:type", String)
431
+ ], Payment.prototype, "orderId", void 0);
432
+ __decorate([
433
+ Expose({ name: 'risk_level' }),
434
+ __metadata("design:type", String)
435
+ ], Payment.prototype, "riskLevel", void 0);
436
+ __decorate([
437
+ Expose({ name: 'receipt_url' }),
438
+ __metadata("design:type", String)
439
+ ], Payment.prototype, "receiptUrl", void 0);
440
+ __decorate([
441
+ Expose({ name: 'private_label' }),
442
+ __metadata("design:type", String)
443
+ ], Payment.prototype, "privateLabel", void 0);
444
+ __decorate([
445
+ Expose({ name: 'pix_qr_code' }),
446
+ __metadata("design:type", String)
447
+ ], Payment.prototype, "pixQrCode", void 0);
448
+ __decorate([
449
+ Expose({ name: 'pix_expiration_date' }),
450
+ __metadata("design:type", String)
432
451
  ], Payment.prototype, "pixExpirationDate", void 0);
433
452
 
434
- class SubscriptionPayment extends BaseModel {
435
- identifierFields() {
436
- return ['id'];
437
- }
438
- }
439
- __decorate([
440
- Type(() => Payment),
441
- __metadata("design:type", Payment)
453
+ class SubscriptionPayment extends BaseModel {
454
+ static get identifiersFields() {
455
+ return ['id', 'subscriptionId'];
456
+ }
457
+ }
458
+ __decorate([
459
+ Type(() => Payment),
460
+ __metadata("design:type", Payment)
442
461
  ], SubscriptionPayment.prototype, "payment", void 0);
443
462
 
444
- class Address extends BaseModel {
463
+ class Address extends BaseModel {
464
+ static get identifiersFields() {
465
+ return ['id'];
466
+ }
445
467
  }
446
468
 
447
- var CheckoutTypes;
448
- (function (CheckoutTypes) {
449
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
450
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
469
+ var CheckoutTypes;
470
+ (function (CheckoutTypes) {
471
+ CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
472
+ CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
451
473
  })(CheckoutTypes || (CheckoutTypes = {}));
452
474
 
453
- class Base {
454
- constructor(...args) {
455
- Object.assign(this, ...args);
456
- }
475
+ class Base {
476
+ constructor(...args) {
477
+ Object.assign(this, ...args);
478
+ }
457
479
  }
458
480
 
459
- var DiscountType;
460
- (function (DiscountType) {
461
- DiscountType[DiscountType["ABSOLUTE"] = 1] = "ABSOLUTE";
462
- DiscountType[DiscountType["PERCENTAGE"] = 2] = "PERCENTAGE";
463
- DiscountType[DiscountType["FREE_SHIPPING"] = 3] = "FREE_SHIPPING";
464
- })(DiscountType || (DiscountType = {}));
465
-
466
- var Exclusivities;
467
- (function (Exclusivities) {
468
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
469
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
470
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
471
- })(Exclusivities || (Exclusivities = {}));
481
+ 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);
472
482
 
473
- class Coupon extends BaseModel {
474
- get isInfluencer() {
475
- return !isNil(this.influencerEmail);
476
- }
477
- identifierFields() {
478
- return ['id'];
479
- }
480
- calculeDiscount(amount) {
481
- switch (this.discountType) {
482
- case DiscountType.ABSOLUTE:
483
- return this.discount < amount ? this.discount : amount;
484
- case DiscountType.PERCENTAGE:
485
- return this.discount * 0.01 * amount;
486
- }
487
- }
488
- }
489
- __decorate([
490
- Expose({ name: 'checkout_type' }),
491
- __metadata("design:type", Number)
492
- ], Coupon.prototype, "checkoutType", void 0);
493
- __decorate([
494
- Expose({ name: 'exclusivity_type' }),
495
- __metadata("design:type", Number)
496
- ], Coupon.prototype, "exclusivityType", void 0);
483
+ const parseDateTime = (value) => {
484
+ if (!isString(value))
485
+ return value;
486
+ if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
487
+ !/^\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))
488
+ return value;
489
+ const date = parseISO(value);
490
+ if (isNaN(date.getTime()))
491
+ return value;
492
+ return date;
493
+ };
497
494
 
498
- class SubscriptionPlan extends BaseModel {
499
- identifierFields() {
500
- return ['id'];
501
- }
502
- }
495
+ var CouponTypes;
496
+ (function (CouponTypes) {
497
+ CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
498
+ CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
499
+ CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
500
+ CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
501
+ })(CouponTypes || (CouponTypes = {}));
502
+
503
+ var CouponSubtypes;
504
+ (function (CouponSubtypes) {
505
+ CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
506
+ CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
507
+ })(CouponSubtypes || (CouponSubtypes = {}));
508
+
509
+ var Exclusivities;
510
+ (function (Exclusivities) {
511
+ Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
512
+ Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
513
+ Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
514
+ })(Exclusivities || (Exclusivities = {}));
503
515
 
504
- class BeautyProfile extends BaseModel {
505
- toPlain() {
506
- const plain = super.toPlain();
507
- delete plain.id;
508
- return plain;
509
- }
510
- identifierFields() {
511
- return ['id'];
512
- }
513
- }
516
+ class Coupon extends BaseModel {
517
+ get isInfluencer() {
518
+ return !isNil(this.influencerEmail);
519
+ }
520
+ static get identifiersFields() {
521
+ return ['id'];
522
+ }
523
+ }
524
+ __decorate([
525
+ Expose({ name: 'checkout_type' }),
526
+ __metadata("design:type", Number)
527
+ ], Coupon.prototype, "checkoutType", void 0);
528
+ __decorate([
529
+ Expose({ name: 'exclusivity_type' }),
530
+ __metadata("design:type", Number)
531
+ ], Coupon.prototype, "exclusivityType", void 0);
514
532
 
515
- class User extends BaseModel {
516
- static toInstance(data) {
517
- const instance = super.toInstance(data);
518
- if (!isNil(data.firstName))
519
- instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
520
- return instance;
521
- }
522
- identifierFields() {
523
- return ['id'];
524
- }
525
- toPlain() {
526
- const plain = super.toPlain();
527
- delete plain.beautyProfile;
528
- return plain;
529
- }
530
- }
531
- __decorate([
532
- Type(() => BeautyProfile),
533
- __metadata("design:type", BeautyProfile)
533
+ class SubscriptionPlan extends BaseModel {
534
+ static get identifiersFields() {
535
+ return ['id'];
536
+ }
537
+ }
538
+
539
+ class BeautyProfile extends BaseModel {
540
+ toPlain() {
541
+ const plain = super.toPlain();
542
+ delete plain.id;
543
+ return plain;
544
+ }
545
+ static get identifiersFields() {
546
+ return ['id', 'userId'];
547
+ }
548
+ }
549
+
550
+ class User extends BaseModel {
551
+ static toInstance(data) {
552
+ const instance = super.toInstance(data);
553
+ if (!isNil(data.firstName))
554
+ instance.displayName = `${data.firstName}${!isNil(data.lastName) ? ` ${data.lastName}` : ''}`;
555
+ return instance;
556
+ }
557
+ toPlain() {
558
+ const plain = super.toPlain();
559
+ delete plain.beautyProfile;
560
+ return plain;
561
+ }
562
+ static get identifiersFields() {
563
+ return ['id'];
564
+ }
565
+ }
566
+ __decorate([
567
+ Type(() => BeautyProfile),
568
+ __metadata("design:type", BeautyProfile)
534
569
  ], User.prototype, "beautyProfile", void 0);
535
570
 
536
- class Subscription extends BaseModel {
537
- identifierFields() {
538
- return ['id'];
539
- }
540
- }
541
- __decorate([
542
- Type(() => User),
543
- __metadata("design:type", User)
544
- ], Subscription.prototype, "user", void 0);
545
- __decorate([
546
- Type(() => SubscriptionPlan),
547
- __metadata("design:type", SubscriptionPlan)
548
- ], Subscription.prototype, "subscriptionPlan", void 0);
549
- __decorate([
550
- Type(() => Address),
551
- __metadata("design:type", Address)
552
- ], Subscription.prototype, "shippingAddress", void 0);
553
- __decorate([
554
- Type(() => Address),
555
- __metadata("design:type", Address)
556
- ], Subscription.prototype, "billingAddress", void 0);
557
- __decorate([
558
- Type(() => Coupon),
559
- __metadata("design:type", Coupon)
560
- ], Subscription.prototype, "coupon", void 0);
561
- __decorate([
562
- Type(() => Edition),
563
- __metadata("design:type", Array)
564
- ], Subscription.prototype, "editions", void 0);
565
- __decorate([
566
- Type(() => SubscriptionPayment),
567
- __metadata("design:type", Array)
571
+ class Subscription extends BaseModel {
572
+ static get identifiersFields() {
573
+ return ['id'];
574
+ }
575
+ }
576
+ __decorate([
577
+ Type(() => User),
578
+ __metadata("design:type", User)
579
+ ], Subscription.prototype, "user", void 0);
580
+ __decorate([
581
+ Type(() => SubscriptionPlan),
582
+ __metadata("design:type", SubscriptionPlan)
583
+ ], Subscription.prototype, "subscriptionPlan", void 0);
584
+ __decorate([
585
+ Type(() => Address),
586
+ __metadata("design:type", Address)
587
+ ], Subscription.prototype, "shippingAddress", void 0);
588
+ __decorate([
589
+ Type(() => Address),
590
+ __metadata("design:type", Address)
591
+ ], Subscription.prototype, "billingAddress", void 0);
592
+ __decorate([
593
+ Type(() => Coupon),
594
+ __metadata("design:type", Coupon)
595
+ ], Subscription.prototype, "coupon", void 0);
596
+ __decorate([
597
+ Type(() => Edition),
598
+ __metadata("design:type", Array)
599
+ ], Subscription.prototype, "editions", void 0);
600
+ __decorate([
601
+ Type(() => SubscriptionPayment),
602
+ __metadata("design:type", Array)
568
603
  ], Subscription.prototype, "payment", void 0);
569
604
 
570
- class UserAddress extends Address {
571
- identifierFields() {
572
- return ['id'];
573
- }
574
- }
575
-
576
- class UserPaymentMethod extends BaseModel {
577
- identifierFields() {
578
- return ['id'];
579
- }
580
- }
581
-
582
- class Lead extends BaseModel {
583
- identifierFields() {
584
- return ['id'];
585
- }
586
- }
587
-
588
- class UnauthorizedError extends Error {
589
- constructor(message) {
590
- super(message);
591
- this.message = message;
592
- }
593
- }
594
-
595
- var SignInMethods;
596
- (function (SignInMethods) {
597
- SignInMethods["EMAIL_PASSWORD"] = "email_password";
598
- SignInMethods["GOOGLE"] = "google";
599
- })(SignInMethods || (SignInMethods = {}));
600
- class Authentication {
601
- constructor(authService, userRepository) {
602
- this.authService = authService;
603
- this.userRepository = userRepository;
604
- }
605
- signIn({ email, password }, signInMethod) {
606
- return __awaiter(this, void 0, void 0, function* () {
607
- const method = this.getServiceByMethod(signInMethod);
608
- const userAuth = yield this.authService[method]({ email, password });
609
- const user = this.userRepository.get(userAuth);
610
- if (!isNil(user))
611
- return user;
612
- if (/^.+@b4a.com.br$/.test(userAuth.email))
613
- return this.createsUserByCredential(userAuth);
614
- throw new UnauthorizedError('Invalid credentials');
615
- });
616
- }
617
- getServiceByMethod(signInMethod) {
618
- return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
619
- }
620
- createsUserByCredential(user) {
621
- var _a;
622
- return __awaiter(this, void 0, void 0, function* () {
623
- const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
624
- const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
625
- lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
626
- return this.userRepository.create(person);
627
- });
628
- }
629
- }
630
-
631
- class UserAlreadyRegisteredError extends Error {
632
- constructor(message) {
633
- super(message);
634
- this.message = message;
635
- }
636
- }
637
-
638
- class WeakPasswordError extends Error {
639
- constructor(message = 'Weak password') {
640
- super(message);
641
- this.message = message;
642
- }
643
- }
644
-
645
- class Register {
646
- constructor(registerService, userRepository) {
647
- this.registerService = registerService;
648
- this.userRepository = userRepository;
649
- }
650
- register(params) {
651
- return __awaiter(this, void 0, void 0, function* () {
652
- const email = params.email.toLocaleLowerCase();
653
- const displayName = `${params.firstName} ${params.lastName}`;
654
- if (yield this.userRepository.checkIfExistsByField('cpf', params.cpf))
655
- throw new UserAlreadyRegisteredError(`User with CPF ${params.cpf} already registered`);
656
- if (yield this.userRepository.checkIfExistsByField('email', params.email))
657
- throw new UserAlreadyRegisteredError(`User with E-mail ${params.email} already registered`);
658
- const auth = yield this.registerService.register({
659
- birthday: params.birthday,
660
- email,
661
- firstName: params.firstName,
662
- lastName: params.lastName,
663
- cpf: params.cpf,
664
- displayName,
665
- phone: params.phone,
666
- password: params.password,
667
- });
668
- delete params.password;
669
- const user = yield this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
670
- displayName, type: UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
671
- return user;
672
- });
673
- }
674
- }
675
-
676
- class SignOut {
677
- constructor(authService) {
678
- this.authService = authService;
679
- }
680
- signOut() {
681
- return __awaiter(this, void 0, void 0, function* () {
682
- yield this.authService.signOut();
683
- });
684
- }
685
- }
686
-
687
- var Shops;
688
- (function (Shops) {
689
- Shops["MENSMARKET"] = "mensmarket";
690
- Shops["GLAMSHOP"] = "Glamshop";
605
+ class UserAddress extends Address {
606
+ static get identifiersFields() {
607
+ return ['id', 'userId'];
608
+ }
609
+ }
610
+
611
+ class UserPaymentMethod extends BaseModel {
612
+ static get identifiersFields() {
613
+ return ['id', 'userId'];
614
+ }
615
+ }
616
+
617
+ class Lead extends BaseModel {
618
+ static get identifiersFields() {
619
+ return ['id'];
620
+ }
621
+ }
622
+
623
+ class UnauthorizedError extends CustomError {
624
+ constructor(message) {
625
+ super(message);
626
+ this.message = message;
627
+ }
628
+ }
629
+
630
+ var SignInMethods;
631
+ (function (SignInMethods) {
632
+ SignInMethods["EMAIL_PASSWORD"] = "email_password";
633
+ SignInMethods["GOOGLE"] = "google";
634
+ })(SignInMethods || (SignInMethods = {}));
635
+ class Authentication {
636
+ constructor(authService, userRepository) {
637
+ this.authService = authService;
638
+ this.userRepository = userRepository;
639
+ }
640
+ signIn({ email, password }, signInMethod) {
641
+ return __awaiter(this, void 0, void 0, function* () {
642
+ const method = this.getServiceByMethod(signInMethod);
643
+ const userAuth = yield this.authService[method]({ email, password });
644
+ const user = this.userRepository.get(userAuth);
645
+ if (!isNil(user))
646
+ return user;
647
+ if (/^.+@b4a.com.br$/.test(userAuth.email))
648
+ return this.createsUserByCredential(userAuth);
649
+ throw new UnauthorizedError('Invalid credentials');
650
+ });
651
+ }
652
+ getServiceByMethod(signInMethod) {
653
+ return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
654
+ }
655
+ createsUserByCredential(user) {
656
+ var _a;
657
+ return __awaiter(this, void 0, void 0, function* () {
658
+ const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
659
+ const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
660
+ lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
661
+ return this.userRepository.create(person);
662
+ });
663
+ }
664
+ }
665
+
666
+ class UserAlreadyRegisteredError extends CustomError {
667
+ constructor(message) {
668
+ super(message);
669
+ this.message = message;
670
+ }
671
+ }
672
+
673
+ class WeakPasswordError extends CustomError {
674
+ constructor(message = 'Weak password') {
675
+ super(message);
676
+ this.message = message;
677
+ }
678
+ }
679
+
680
+ class Register {
681
+ constructor(registerService, userRepository) {
682
+ this.registerService = registerService;
683
+ this.userRepository = userRepository;
684
+ }
685
+ register(params) {
686
+ return __awaiter(this, void 0, void 0, function* () {
687
+ const email = params.email.toLocaleLowerCase();
688
+ const displayName = `${params.firstName} ${params.lastName}`;
689
+ if (yield this.userRepository.checkIfExistsByField('cpf', params.cpf))
690
+ throw new UserAlreadyRegisteredError(`Usuário com CPF ${params.cpf} registrado.`);
691
+ if (yield this.userRepository.checkIfExistsByField('email', params.email))
692
+ throw new UserAlreadyRegisteredError(`Usuário com e-mail ${params.email} registrado.`);
693
+ const auth = yield this.registerService.register({
694
+ birthday: params.birthday,
695
+ email,
696
+ firstName: params.firstName,
697
+ lastName: params.lastName,
698
+ cpf: params.cpf,
699
+ displayName,
700
+ phone: params.phone,
701
+ password: params.password,
702
+ });
703
+ delete params.password;
704
+ const user = yield this.userRepository.create(Object.assign(Object.assign({}, params), { id: auth.id, email,
705
+ displayName, type: UserType.B2C, dateCreated: new Date(), dateModified: new Date() }));
706
+ return user;
707
+ });
708
+ }
709
+ }
710
+
711
+ class SignOut {
712
+ constructor(authService) {
713
+ this.authService = authService;
714
+ }
715
+ signOut() {
716
+ return __awaiter(this, void 0, void 0, function* () {
717
+ yield this.authService.signOut();
718
+ });
719
+ }
720
+ }
721
+
722
+ class RecoveryPassword {
723
+ constructor(authService) {
724
+ this.authService = authService;
725
+ }
726
+ sendEmail(email) {
727
+ return __awaiter(this, void 0, void 0, function* () {
728
+ yield this.authService.sendPasswordResetEmail(email);
729
+ });
730
+ }
731
+ }
732
+
733
+ class Category extends BaseModel {
734
+ identifierFields() {
735
+ return ['id'];
736
+ }
737
+ static get identifiersFields() {
738
+ return ['id'];
739
+ }
740
+ }
741
+
742
+ var Shops;
743
+ (function (Shops) {
744
+ Shops["MENSMARKET"] = "mensmarket";
745
+ Shops["GLAMSHOP"] = "Glamshop";
746
+ Shops["GLAMPOINTS"] = "Glampoints";
691
747
  })(Shops || (Shops = {}));
692
748
 
693
- class Category extends BaseModel {
694
- identifierFields() {
695
- return ['id'];
696
- }
697
- }
698
-
699
- class Product extends BaseModel {
700
- identifierFields() {
701
- return ['id'];
702
- }
703
- getInfoByShop(shop) {
704
- var _a, _b, _c, _d, _e, _f;
705
- return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
706
- }
707
- }
708
-
709
- class Variant extends BaseModel {
710
- identifierFields() {
711
- return ['id'];
712
- }
713
- }
714
-
715
- class ClubCoupon extends Coupon {
716
- constructor() {
717
- super(...arguments);
718
- this.checkoutType = CheckoutTypes.SUBSCRIPTION;
719
- }
720
- static isClubCoupon(coupon) {
721
- return coupon instanceof ClubCoupon;
722
- }
723
- }
724
- __decorate([
725
- Expose({ name: 'checkout_type' }),
726
- __metadata("design:type", Object)
727
- ], ClubCoupon.prototype, "checkoutType", void 0);
728
-
729
- class StoreCoupon extends Coupon {
730
- constructor() {
731
- super(...arguments);
732
- this.checkoutType = CheckoutTypes.ECOMMERCE;
733
- }
734
- static isStoreCoupon(coupon) {
735
- return coupon instanceof StoreCoupon;
736
- }
737
- }
738
- __decorate([
739
- Expose({ name: 'checkout_type' }),
740
- __metadata("design:type", Object)
741
- ], StoreCoupon.prototype, "checkoutType", void 0);
742
- __decorate([
743
- Type(() => Category),
744
- __metadata("design:type", Array)
745
- ], StoreCoupon.prototype, "categories", void 0);
746
-
747
- var OrderStatus;
748
- (function (OrderStatus) {
749
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
750
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
751
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
752
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
753
- OrderStatus["ENVIADO"] = "Pedido Enviado";
754
- OrderStatus["ENTREGUE"] = "Pedido entregue";
755
- OrderStatus["CANCELADO"] = "Cancelado";
756
- OrderStatus["CREDIT_CARD"] = "credit_card";
749
+ class Product extends BaseModel {
750
+ identifierFields() {
751
+ return ['id'];
752
+ }
753
+ getInfoByShop(shop) {
754
+ var _a, _b, _c, _d, _e, _f;
755
+ return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
756
+ }
757
+ static get identifiersFields() {
758
+ return ['id'];
759
+ }
760
+ }
761
+ __decorate([
762
+ Type(() => KitProduct),
763
+ __metadata("design:type", Array)
764
+ ], Product.prototype, "kitProducts", void 0);
765
+
766
+ class KitProduct extends BaseModel {
767
+ static get identifiersFields() {
768
+ return ['productId', 'kitProducId'];
769
+ }
770
+ }
771
+ __decorate([
772
+ Type(() => Product),
773
+ __metadata("design:type", Product)
774
+ ], KitProduct.prototype, "kit", void 0);
775
+ __decorate([
776
+ Type(() => Product),
777
+ __metadata("design:type", Product)
778
+ ], KitProduct.prototype, "product", void 0);
779
+
780
+ class Variant extends BaseModel {
781
+ identifierFields() {
782
+ return ['id'];
783
+ }
784
+ static get identifiersFields() {
785
+ return ['id', 'productId'];
786
+ }
787
+ }
788
+
789
+ const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
790
+ class FinancialCoupon extends Coupon {
791
+ constructor() {
792
+ super(...arguments);
793
+ this.type = CouponTypes.FINANCIAL;
794
+ }
795
+ static isFinancialCoupon(coupon) {
796
+ return coupon.type === CouponTypes.FINANCIAL && !!coupon.subtype;
797
+ }
798
+ static createCoupon(userId) {
799
+ return this.toInstance({
800
+ name: Md5.hashStr(`${userId}_${Date.now}`).toString(),
801
+ nickname: `${Date.now()}`,
802
+ type: CouponTypes.FINANCIAL,
803
+ subtype: CouponSubtypes.PERCENTAGE,
804
+ checkoutType: CheckoutTypes.ECOMMERCE,
805
+ discount: 30,
806
+ user: userId,
807
+ createdAt: new Date(Date.now()),
808
+ expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
809
+ });
810
+ }
811
+ }
812
+
813
+ var OrderStatus;
814
+ (function (OrderStatus) {
815
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
816
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
817
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
818
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
819
+ OrderStatus["ENVIADO"] = "Pedido Enviado";
820
+ OrderStatus["ENTREGUE"] = "Pedido entregue";
821
+ OrderStatus["CANCELADO"] = "Cancelado";
822
+ OrderStatus["CREDIT_CARD"] = "credit_card";
757
823
  })(OrderStatus || (OrderStatus = {}));
758
824
 
759
- class LineItem extends Product {
760
- }
761
-
762
- class ShippingMethod extends BaseModel {
763
- identifierFields() {
764
- return ['id'];
765
- }
766
- }
767
-
768
- class Checkout extends BaseModel {
769
- get subTotalPrice() {
770
- return this.lineItems.reduce((total, item) => {
771
- return total + item.pricePaid;
772
- }, 0);
773
- }
774
- get totalPrice() {
775
- return this.totalPrice - this.discount;
776
- }
777
- identifierFields() {
778
- return ['id'];
779
- }
780
- }
781
- __decorate([
782
- Type(() => LineItem),
783
- __metadata("design:type", Array)
784
- ], Checkout.prototype, "lineItems", void 0);
785
- __decorate([
786
- Type(() => User),
787
- __metadata("design:type", User)
788
- ], Checkout.prototype, "user", void 0);
789
- __decorate([
790
- Type(() => Address),
791
- __metadata("design:type", Address)
792
- ], Checkout.prototype, "shippingAddress", void 0);
793
- __decorate([
794
- Type(() => Address),
795
- __metadata("design:type", Address)
796
- ], Checkout.prototype, "billingAddress", void 0);
797
- __decorate([
798
- Type(() => ShippingMethod),
799
- __metadata("design:type", ShippingMethod)
800
- ], Checkout.prototype, "shipping", void 0);
801
- __decorate([
802
- Type(() => StoreCoupon),
803
- __metadata("design:type", StoreCoupon)
825
+ class LineItem extends Product {
826
+ }
827
+
828
+ class ShippingMethod extends BaseModel {
829
+ static get identifiersFields() {
830
+ return ['id'];
831
+ }
832
+ }
833
+
834
+ class Checkout extends BaseModel {
835
+ static get identifiersFields() {
836
+ return ['id'];
837
+ }
838
+ }
839
+ __decorate([
840
+ Type(() => LineItem),
841
+ __metadata("design:type", Array)
842
+ ], Checkout.prototype, "lineItems", void 0);
843
+ __decorate([
844
+ Type(() => User),
845
+ __metadata("design:type", User)
846
+ ], Checkout.prototype, "user", void 0);
847
+ __decorate([
848
+ Type(() => Address),
849
+ __metadata("design:type", Address)
850
+ ], Checkout.prototype, "shippingAddress", void 0);
851
+ __decorate([
852
+ Type(() => Address),
853
+ __metadata("design:type", Address)
854
+ ], Checkout.prototype, "billingAddress", void 0);
855
+ __decorate([
856
+ Type(() => ShippingMethod),
857
+ __metadata("design:type", ShippingMethod)
858
+ ], Checkout.prototype, "shipping", void 0);
859
+ __decorate([
860
+ Type(() => Coupon),
861
+ __metadata("design:type", Coupon)
804
862
  ], Checkout.prototype, "coupon", void 0);
805
863
 
806
- class Order extends Checkout {
807
- }
808
- __decorate([
809
- Type(() => Payment),
810
- __metadata("design:type", Payment)
864
+ class Order extends Checkout {
865
+ }
866
+ __decorate([
867
+ Type(() => Payment),
868
+ __metadata("design:type", Payment)
811
869
  ], Order.prototype, "payment", void 0);
812
870
 
813
- class CheckoutSubscription extends BaseModel {
814
- identifierFields() {
815
- return ['id'];
816
- }
817
- }
818
- __decorate([
819
- Type(() => Address),
820
- __metadata("design:type", Address)
821
- ], CheckoutSubscription.prototype, "shippingAddress", void 0);
822
- __decorate([
823
- Type(() => Address),
824
- __metadata("design:type", Address)
825
- ], CheckoutSubscription.prototype, "billingAddress", void 0);
826
- __decorate([
827
- Type(() => SubscriptionPlan),
828
- __metadata("design:type", SubscriptionPlan)
829
- ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
830
- __decorate([
831
- Type(() => Coupon),
832
- __metadata("design:type", Coupon)
871
+ class CheckoutSubscription extends BaseModel {
872
+ static get identifiersFields() {
873
+ return ['id'];
874
+ }
875
+ }
876
+ __decorate([
877
+ Type(() => Address),
878
+ __metadata("design:type", Address)
879
+ ], CheckoutSubscription.prototype, "shippingAddress", void 0);
880
+ __decorate([
881
+ Type(() => Address),
882
+ __metadata("design:type", Address)
883
+ ], CheckoutSubscription.prototype, "billingAddress", void 0);
884
+ __decorate([
885
+ Type(() => SubscriptionPlan),
886
+ __metadata("design:type", SubscriptionPlan)
887
+ ], CheckoutSubscription.prototype, "subscriptionPlan", void 0);
888
+ __decorate([
889
+ Type(() => Coupon),
890
+ __metadata("design:type", Coupon)
833
891
  ], CheckoutSubscription.prototype, "coupon", void 0);
834
892
 
835
- class Buy2Win extends BaseModel {
836
- identifierFields() {
837
- return ['id'];
838
- }
839
- }
840
- __decorate([
841
- Type(() => Category),
842
- __metadata("design:type", Array)
893
+ class Buy2Win extends BaseModel {
894
+ static get identifiersFields() {
895
+ return ['id'];
896
+ }
897
+ }
898
+ __decorate([
899
+ Type(() => Category),
900
+ __metadata("design:type", Array)
843
901
  ], Buy2Win.prototype, "categories", void 0);
844
902
 
845
- var FilterType;
846
- (function (FilterType) {
847
- FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
848
- FilterType["BEARD_PROBLEMS"] = "beardProblems";
849
- FilterType["BEARD_SIZE"] = "beardSize";
850
- FilterType["BEAUTY_PRODUCT_IMPORTANCE"] = "beautyProductImportance";
851
- FilterType["BODY_PROBLEMS"] = "bodyProblems";
852
- FilterType["BODY_SHAPE"] = "bodyShape";
853
- FilterType["BODY_TATTOOS"] = "bodyTattoos";
854
- FilterType["FACE_SKIN_OILINESS"] = "faceSkinOiliness";
855
- FilterType["FACE_SKIN_PROBLEMS"] = "faceSkinProblems";
856
- FilterType["FACE_SKIN_TONE"] = "faceSkinTone";
857
- FilterType["FAMILY_INCOME"] = "familyIncome";
858
- FilterType["FRAGRANCE_IMPORTANCE"] = "fragranceImportance";
859
- FilterType["HAIR_COLOR"] = "hairColor";
860
- FilterType["HAIR_PROBLEMS"] = "hairProblems";
861
- FilterType["HAIR_STRANDS"] = "hairStrands";
862
- FilterType["HAIR_TYPE"] = "hairType";
863
- FilterType["PRODUCT_SPENT"] = "productSpent";
903
+ var FilterType;
904
+ (function (FilterType) {
905
+ FilterType["ACCESSORY_IMPORTANCE"] = "accessoryImportance";
906
+ FilterType["BEARD_PROBLEMS"] = "beardProblems";
907
+ FilterType["BEARD_SIZE"] = "beardSize";
908
+ FilterType["BEAUTY_PRODUCT_IMPORTANCE"] = "beautyProductImportance";
909
+ FilterType["BODY_PROBLEMS"] = "bodyProblems";
910
+ FilterType["BODY_SHAPE"] = "bodyShape";
911
+ FilterType["BODY_TATTOOS"] = "bodyTattoos";
912
+ FilterType["FACE_SKIN_OILINESS"] = "faceSkinOiliness";
913
+ FilterType["FACE_SKIN_PROBLEMS"] = "faceSkinProblems";
914
+ FilterType["FACE_SKIN_TONE"] = "faceSkinTone";
915
+ FilterType["FAMILY_INCOME"] = "familyIncome";
916
+ FilterType["FRAGRANCE_IMPORTANCE"] = "fragranceImportance";
917
+ FilterType["HAIR_COLOR"] = "hairColor";
918
+ FilterType["HAIR_PROBLEMS"] = "hairProblems";
919
+ FilterType["HAIR_STRANDS"] = "hairStrands";
920
+ FilterType["HAIR_TYPE"] = "hairType";
921
+ FilterType["PRODUCT_SPENT"] = "productSpent";
864
922
  })(FilterType || (FilterType = {}));
865
923
 
866
- var QuestionsFilters;
867
- (function (QuestionsFilters) {
868
- QuestionsFilters["ACCESSORY_IMPORTANCE"] = "Voc\u00EA gosta de usar acess\u00F3rios masculinos?";
869
- QuestionsFilters["BEARD_PROBLEMS"] = "Quais problemas de barba voc\u00EA tem?";
870
- QuestionsFilters["BEARD_SIZE"] = "Quais caracteristicas se aplicam \u00E0 sua BARBA/BIGODE?";
871
- QuestionsFilters["BEAUTY_PRODUCT_IMPORTANCE"] = "O que descreve melhor a sua rela\u00E7\u00E3o com produtos de beleza e cuidados pessoais?";
872
- QuestionsFilters["BODY_PROBLEMS"] = "Qual ou quais preocupa\u00E7\u00F5es voc\u00EA tem com a pele do seu corpo?";
873
- QuestionsFilters["BODY_SHAPE"] = "Qual e seu tipo de CORPO?";
874
- QuestionsFilters["BODY_TATTOOS"] = "Voc\u00EA tem alguma tatuagem?";
875
- QuestionsFilters["FACE_SKIN_OILINESS"] = "Quais caracteristicas se aplicam \u00E0 pele do seu ROSTO?";
876
- QuestionsFilters["FACE_SKIN_PROBLEMS"] = "Quais problemas a pele do seu rosto tem?";
877
- QuestionsFilters["FACE_SKIN_TONE"] = "Qual seu tom de pele?";
878
- QuestionsFilters["FAMILY_INCOME"] = "Qual a sua renda familiar mensal (considerando a renda de todas as pessoas que moram com voc\u00EA)?";
879
- QuestionsFilters["FRAGRANCE_IMPORTANCE"] = "O quanto voc\u00EA gosta de experimentar perfumes?";
880
- QuestionsFilters["HAIR_COLOR"] = "Seu cabelo \u00E9 naturalmente de qual COR?";
881
- QuestionsFilters["HAIR_PROBLEMS"] = "Qual ou quais problemas/caracter\u00EDstica de cabelo te preocupam?";
882
- QuestionsFilters["HAIR_STRANDS"] = "Como s\u00E3o seus fios?";
883
- QuestionsFilters["HAIR_TYPE"] = "Como \u00E9 o seu cabelo?";
884
- QuestionsFilters["PRODUCT_SPENT"] = "Qual \u00E9 o seu nivel de gasto mensal em produtos de beleza e cuidados pessoais?";
924
+ var QuestionsFilters;
925
+ (function (QuestionsFilters) {
926
+ QuestionsFilters["ACCESSORY_IMPORTANCE"] = "Voc\u00EA gosta de usar acess\u00F3rios masculinos?";
927
+ QuestionsFilters["BEARD_PROBLEMS"] = "Quais problemas de barba voc\u00EA tem?";
928
+ QuestionsFilters["BEARD_SIZE"] = "Quais caracteristicas se aplicam \u00E0 sua BARBA/BIGODE?";
929
+ QuestionsFilters["BEAUTY_PRODUCT_IMPORTANCE"] = "O que descreve melhor a sua rela\u00E7\u00E3o com produtos de beleza e cuidados pessoais?";
930
+ QuestionsFilters["BODY_PROBLEMS"] = "Qual ou quais preocupa\u00E7\u00F5es voc\u00EA tem com a pele do seu corpo?";
931
+ QuestionsFilters["BODY_SHAPE"] = "Qual e seu tipo de CORPO?";
932
+ QuestionsFilters["BODY_TATTOOS"] = "Voc\u00EA tem alguma tatuagem?";
933
+ QuestionsFilters["FACE_SKIN_OILINESS"] = "Quais caracteristicas se aplicam \u00E0 pele do seu ROSTO?";
934
+ QuestionsFilters["FACE_SKIN_PROBLEMS"] = "Quais problemas a pele do seu rosto tem?";
935
+ QuestionsFilters["FACE_SKIN_TONE"] = "Qual seu tom de pele?";
936
+ QuestionsFilters["FAMILY_INCOME"] = "Qual a sua renda familiar mensal (considerando a renda de todas as pessoas que moram com voc\u00EA)?";
937
+ QuestionsFilters["FRAGRANCE_IMPORTANCE"] = "O quanto voc\u00EA gosta de experimentar perfumes?";
938
+ QuestionsFilters["HAIR_COLOR"] = "Seu cabelo \u00E9 naturalmente de qual COR?";
939
+ QuestionsFilters["HAIR_PROBLEMS"] = "Qual ou quais problemas/caracter\u00EDstica de cabelo te preocupam?";
940
+ QuestionsFilters["HAIR_STRANDS"] = "Como s\u00E3o seus fios?";
941
+ QuestionsFilters["HAIR_TYPE"] = "Como \u00E9 o seu cabelo?";
942
+ QuestionsFilters["PRODUCT_SPENT"] = "Qual \u00E9 o seu nivel de gasto mensal em produtos de beleza e cuidados pessoais?";
885
943
  })(QuestionsFilters || (QuestionsFilters = {}));
886
944
 
887
- class BeautyQuestionsHelper {
888
- static getAnswers(filter) {
889
- switch (filter) {
890
- case FilterType.ACCESSORY_IMPORTANCE:
891
- return AccessoryImportances;
892
- case FilterType.BEARD_PROBLEMS:
893
- return BeardProblems;
894
- case FilterType.BEARD_SIZE:
895
- return BeardSizes;
896
- case FilterType.BEAUTY_PRODUCT_IMPORTANCE:
897
- return BeautyProductImportances;
898
- case FilterType.BODY_PROBLEMS:
899
- return BodyProblems;
900
- case FilterType.BODY_SHAPE:
901
- return BodyShapes;
902
- case FilterType.BODY_TATTOOS:
903
- return BodyTattoos;
904
- case FilterType.FACE_SKIN_OILINESS:
905
- return FaceSkinOilinesses;
906
- case FilterType.FACE_SKIN_PROBLEMS:
907
- return FaceSkinProblems;
908
- case FilterType.FACE_SKIN_TONE:
909
- return FaceSkinTones;
910
- case FilterType.FAMILY_INCOME:
911
- return FamilyIncomes;
912
- case FilterType.FRAGRANCE_IMPORTANCE:
913
- return FragranceImportances;
914
- case FilterType.HAIR_COLOR:
915
- return HairColors;
916
- case FilterType.HAIR_PROBLEMS:
917
- return HairProblems;
918
- case FilterType.HAIR_STRANDS:
919
- return HairStrands;
920
- case FilterType.HAIR_TYPE:
921
- return HairTypes;
922
- case FilterType.PRODUCT_SPENT:
923
- return ProductSpents;
924
- }
925
- }
926
- static getQuestions(filter) {
927
- return QuestionsFilters[filter];
928
- }
929
- }
930
-
931
- class Home extends BaseModel {
932
- identifierFields() {
933
- return ['id'];
934
- }
935
- }
936
-
937
- class ShopMenu extends BaseModel {
938
- identifierFields() {
939
- return ['id'];
940
- }
941
- }
942
-
943
- class InvalidArgumentError extends Error {
944
- constructor(message) {
945
- super(message);
946
- this.message = message;
947
- }
948
- }
949
-
950
- class RequiredArgumentError extends Error {
951
- constructor(args) {
952
- super(`Required arguments: ${args.join(', ')}`);
953
- this.args = args;
954
- this.arguments = args;
955
- }
956
- }
957
-
958
- class NotFoundError extends Error {
959
- constructor(message) {
960
- super(message);
961
- this.message = message;
962
- }
963
- }
964
-
965
- class DuplicatedResultsError extends Error {
966
- constructor(message) {
967
- super(message);
968
- this.message = message;
969
- }
970
- }
971
-
972
- const withFirestore = (MixinBase) => {
973
- return class extends MixinBase {
974
- constructor(...args) {
975
- super(args);
976
- }
977
- collection(path) {
978
- return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
979
- }
980
- buildModelInstance() {
981
- return {
982
- toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
983
- fromFirestore: (snap) => {
984
- const data = snap.data();
985
- Object.keys(data).forEach((key) => {
986
- if (data[key] instanceof firebase.firestore.Timestamp) {
987
- data[key] = data[key].toDate();
988
- }
989
- });
990
- return this.model.toInstance(Object.assign({ id: snap.id }, data));
991
- },
992
- };
993
- }
994
- };
945
+ class BeautyQuestionsHelper {
946
+ static getAnswers(filter) {
947
+ switch (filter) {
948
+ case FilterType.ACCESSORY_IMPORTANCE:
949
+ return AccessoryImportances;
950
+ case FilterType.BEARD_PROBLEMS:
951
+ return BeardProblems;
952
+ case FilterType.BEARD_SIZE:
953
+ return BeardSizes;
954
+ case FilterType.BEAUTY_PRODUCT_IMPORTANCE:
955
+ return BeautyProductImportances;
956
+ case FilterType.BODY_PROBLEMS:
957
+ return BodyProblems;
958
+ case FilterType.BODY_SHAPE:
959
+ return BodyShapes;
960
+ case FilterType.BODY_TATTOOS:
961
+ return BodyTattoos;
962
+ case FilterType.FACE_SKIN_OILINESS:
963
+ return FaceSkinOilinesses;
964
+ case FilterType.FACE_SKIN_PROBLEMS:
965
+ return FaceSkinProblems;
966
+ case FilterType.FACE_SKIN_TONE:
967
+ return FaceSkinTones;
968
+ case FilterType.FAMILY_INCOME:
969
+ return FamilyIncomes;
970
+ case FilterType.FRAGRANCE_IMPORTANCE:
971
+ return FragranceImportances;
972
+ case FilterType.HAIR_COLOR:
973
+ return HairColors;
974
+ case FilterType.HAIR_PROBLEMS:
975
+ return HairProblems;
976
+ case FilterType.HAIR_STRANDS:
977
+ return HairStrands;
978
+ case FilterType.HAIR_TYPE:
979
+ return HairTypes;
980
+ case FilterType.PRODUCT_SPENT:
981
+ return ProductSpents;
982
+ }
983
+ }
984
+ static getQuestions(filter) {
985
+ return QuestionsFilters[filter];
986
+ }
987
+ }
988
+
989
+ class Home extends BaseModel {
990
+ static get identifiersFields() {
991
+ return ['id'];
992
+ }
993
+ }
994
+
995
+ class ShopMenu extends BaseModel {
996
+ static get identifiersFields() {
997
+ return ['id'];
998
+ }
999
+ }
1000
+
1001
+ class InvalidArgumentError extends CustomError {
1002
+ constructor(message) {
1003
+ super(message);
1004
+ this.message = message;
1005
+ }
1006
+ }
1007
+
1008
+ class RequiredArgumentError extends CustomError {
1009
+ constructor(args) {
1010
+ super(`Required arguments: ${args.join(', ')}`);
1011
+ this.args = args;
1012
+ this.arguments = args;
1013
+ }
1014
+ }
1015
+
1016
+ class NotFoundError extends CustomError {
1017
+ constructor(message) {
1018
+ super(message);
1019
+ this.message = message;
1020
+ }
1021
+ }
1022
+
1023
+ class DuplicatedResultsError extends CustomError {
1024
+ constructor(message) {
1025
+ super(message);
1026
+ this.message = message;
1027
+ }
1028
+ }
1029
+
1030
+ class AxiosAdapter {
1031
+ constructor(config) {
1032
+ this.config = config;
1033
+ }
1034
+ query(index, query) {
1035
+ return __awaiter(this, void 0, void 0, function* () {
1036
+ const { data } = yield axios({
1037
+ url: `${this.config.url}/${index}`,
1038
+ method: 'POST',
1039
+ headers: { Authorization: `Basic ${this.config.credential}` },
1040
+ data: query,
1041
+ });
1042
+ return {
1043
+ total: data.hits.total.value,
1044
+ hits: data.hits.hits,
1045
+ };
1046
+ });
1047
+ }
1048
+ }
1049
+
1050
+ class ProductsIndex {
1051
+ constructor(adapter) {
1052
+ this.adapter = adapter;
1053
+ }
1054
+ findById(ids, options) {
1055
+ return __awaiter(this, void 0, void 0, function* () {
1056
+ const publishedField = options.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
1057
+ const fields = [
1058
+ 'brand',
1059
+ 'id',
1060
+ 'images',
1061
+ 'miniatures',
1062
+ 'name',
1063
+ 'price',
1064
+ 'sku',
1065
+ 'stock',
1066
+ 'slug',
1067
+ 'reviews',
1068
+ 'pricePaid',
1069
+ 'isGift',
1070
+ 'stock',
1071
+ 'weight',
1072
+ 'tags',
1073
+ 'hasVariants',
1074
+ ];
1075
+ const { hits } = yield this.adapter.query('products/_search', Object.assign({ _source: fields, query: {
1076
+ bool: {
1077
+ filter: [
1078
+ {
1079
+ terms: {
1080
+ _id: ids,
1081
+ },
1082
+ },
1083
+ {
1084
+ term: {
1085
+ [publishedField]: true,
1086
+ },
1087
+ },
1088
+ ...(options.hasStock
1089
+ ? [
1090
+ {
1091
+ range: {
1092
+ 'stock.quantity': {
1093
+ gt: 0,
1094
+ },
1095
+ },
1096
+ },
1097
+ ]
1098
+ : []),
1099
+ ],
1100
+ },
1101
+ } }, (options.size ? { size: options.size } : {})));
1102
+ return hits.map((hit) => Product.toInstance(hit._source));
1103
+ });
1104
+ }
1105
+ }
1106
+
1107
+ const withFirestore = (MixinBase) => {
1108
+ return class extends MixinBase {
1109
+ collection(path) {
1110
+ return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
1111
+ }
1112
+ buildModelInstance() {
1113
+ return {
1114
+ toFirestore: (data) => ((data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data),
1115
+ fromFirestore: (snap) => {
1116
+ const data = snap.data();
1117
+ Object.keys(data).forEach((key) => {
1118
+ if (data[key] && typeof data[key] === 'object' && '_seconds' in data[key]) {
1119
+ data[key] = data[key].toDate();
1120
+ }
1121
+ });
1122
+ return this.model.toInstance(Object.assign(Object.assign({}, data), { id: snap.id }));
1123
+ },
1124
+ };
1125
+ }
1126
+ };
995
1127
  };
996
1128
 
997
- const withHelpers = (MixinBase) => {
998
- return class extends MixinBase {
999
- toArray(snapShot) {
1000
- if (Array.isArray(snapShot)) {
1001
- return snapShot.map((doc) => doc.data());
1002
- }
1003
- else {
1004
- return snapShot.docs.map((doc) => doc.data());
1005
- }
1006
- }
1007
- isSubCollection(repository) {
1008
- return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
1009
- }
1010
- };
1129
+ const withHelpers = (MixinBase) => {
1130
+ return class extends MixinBase {
1131
+ toArray(snapShot) {
1132
+ if (Array.isArray(snapShot)) {
1133
+ return snapShot.map((doc) => doc.data());
1134
+ }
1135
+ else {
1136
+ return snapShot.docs.map((doc) => doc.data());
1137
+ }
1138
+ }
1139
+ isSubCollection(repository) {
1140
+ return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
1141
+ }
1142
+ };
1011
1143
  };
1012
1144
 
1013
- const withGetFirestore = (MixinBase) => {
1014
- return class GetFirestore extends MixinBase {
1015
- get(identifiers) {
1016
- return __awaiter(this, void 0, void 0, function* () {
1017
- const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
1018
- .doc(Object.values(identifiers).shift().toString())
1019
- .get();
1020
- const data = doc.data();
1021
- if (isNil(data))
1022
- throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1023
- return data;
1024
- });
1025
- }
1026
- buildCollectionPathForGet(identifiers) {
1027
- return this.isSubCollection(this)
1028
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
1029
- : this.collectionName;
1030
- }
1031
- };
1145
+ const withGetFirestore = (MixinBase) => {
1146
+ return class GetFirestore extends MixinBase {
1147
+ get(identifiers) {
1148
+ return __awaiter(this, void 0, void 0, function* () {
1149
+ const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
1150
+ .doc(Object.values(identifiers).shift().toString())
1151
+ .get();
1152
+ const data = doc.data();
1153
+ if (isNil(data))
1154
+ throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
1155
+ return data;
1156
+ });
1157
+ }
1158
+ buildCollectionPathForGet(identifiers) {
1159
+ return this.isSubCollection(this)
1160
+ ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
1161
+ : this.collectionName;
1162
+ }
1163
+ };
1032
1164
  };
1033
1165
 
1034
- const withFindFirestore = (MixinBase) => {
1035
- const checkIfIsFilterOption = (filter) => !isNil(filter === null || filter === void 0 ? void 0 : filter.operator);
1036
- const getValueFromFilter = (filter) => {
1037
- return checkIfIsFilterOption(filter) ? filter.value : filter;
1038
- };
1039
- return class FindFirestore extends MixinBase {
1040
- constructor() {
1041
- super(...arguments);
1042
- this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
1043
- this.buildWhereSentence = (queryReference, fieldName, options) => {
1044
- if (this.isSubCollection(this) && fieldName === this.parentIdField)
1045
- return queryReference;
1046
- if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
1047
- if (Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1048
- return queryReference.where(fieldName.toString(), 'array-contains-any', options.value);
1049
- queryReference = queryReference.where(fieldName.toString(), '>=', options.value);
1050
- queryReference = queryReference.where(fieldName.toString(), '<=', `${options.value}~`);
1051
- return queryReference;
1052
- }
1053
- if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1054
- return queryReference.where(fieldName.toString(), 'array-contains', options.value);
1055
- if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value))
1056
- return Object.keys(options).reduce((queryReferenceWithWhere, key) => this.buildWhereSentence(queryReferenceWithWhere, `${fieldName}.${key}`, options[key]), queryReference);
1057
- return queryReference.where(fieldName.toString(), (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1058
- };
1059
- }
1060
- find(filters, limits, orderBy) {
1061
- return __awaiter(this, void 0, void 0, function* () {
1062
- let query = this.collection(this.buildCollectionPathForFind(filters));
1063
- filters === null || filters === void 0 ? void 0 : filters.forEach((filterer) => (query = this.makeFirestoreWhere(query, filterer)));
1064
- orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach((orderer) => Object.keys(orderer).forEach((fieldName) => (query = query.orderBy(fieldName, orderer[fieldName]))));
1065
- query = yield this.defineLimits(query, filters, limits);
1066
- const docs = yield query.get();
1067
- const data = docs.docs.map((doc) => doc.data());
1068
- return {
1069
- data,
1070
- count: this.calculateCount(data, limits),
1071
- };
1072
- });
1073
- }
1074
- buildCollectionPathForFind(filters) {
1075
- var _a;
1076
- if (!this.isSubCollection(this))
1077
- return this.collectionName;
1078
- const parentIdField = this.parentIdField;
1079
- const parentId = getValueFromFilter((_a = filters.find((groupFilter) => Boolean(getValueFromFilter(groupFilter[parentIdField])))) === null || _a === void 0 ? void 0 : _a[parentIdField]);
1080
- return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
1081
- }
1082
- defineLimits(query, filters, limits) {
1083
- return __awaiter(this, void 0, void 0, function* () {
1084
- if (limits === null || limits === void 0 ? void 0 : limits.offset) {
1085
- if (limits.offset instanceof this.model)
1086
- query = query.startAfter(yield this.collection(this.buildCollectionPathForFind(filters))
1087
- .doc(limits.offset[limits.offset.identifierFields().shift()])
1088
- .get());
1089
- else if (isNumber(limits.offset) || isString(limits.offset))
1090
- query = query.startAt(limits.offset);
1091
- }
1092
- if (limits === null || limits === void 0 ? void 0 : limits.limit)
1093
- query = query.limit(limits.limit);
1094
- return query;
1095
- });
1096
- }
1097
- calculateCount(data, limits) {
1098
- if (data.length <= 0)
1099
- return 0;
1100
- if (data.length < (limits === null || limits === void 0 ? void 0 : limits.limit))
1101
- return data.length;
1102
- return Infinity;
1103
- }
1104
- };
1166
+ const withFindFirestore = (MixinBase) => {
1167
+ const checkIfIsFilterOption = (filter) => !isNil(filter === null || filter === void 0 ? void 0 : filter.operator);
1168
+ const getValueFromFilter = (filter) => {
1169
+ return checkIfIsFilterOption(filter) ? filter.value : filter;
1170
+ };
1171
+ const getFinalValueFrom = (value) => isNumber(value) || isString(value) || isDate(value) || Array.isArray(value)
1172
+ ? value
1173
+ : Object.values(getFinalValueFrom);
1174
+ return class FindFirestore extends MixinBase {
1175
+ constructor() {
1176
+ super(...arguments);
1177
+ this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
1178
+ this.buildWhereSentence = (queryReference, fieldName, options) => {
1179
+ if (this.isSubCollection(this) && fieldName === this.parentIdField)
1180
+ return queryReference;
1181
+ const value = (options === null || options === void 0 ? void 0 : options.value) || options;
1182
+ const object = {};
1183
+ set(object, fieldName, value);
1184
+ const plainInstance = new this.model(object).toPlain();
1185
+ const firestoreFieldName = fieldName.toString().indexOf('.') > -1
1186
+ ? fieldName.toString()
1187
+ : Object.keys(plainInstance).find((key) => plainInstance[key]);
1188
+ if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
1189
+ if (Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1190
+ return queryReference.where(firestoreFieldName, 'array-contains-any', options.value);
1191
+ queryReference = queryReference.where(firestoreFieldName, '>=', options.value);
1192
+ queryReference = queryReference.where(firestoreFieldName, '<=', `${options.value}~`);
1193
+ return queryReference;
1194
+ }
1195
+ if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1196
+ return queryReference.where(firestoreFieldName, 'array-contains', options.value);
1197
+ if (isObject(options) && isNil(options === null || options === void 0 ? void 0 : options.operator) && isNil(options === null || options === void 0 ? void 0 : options.value)) {
1198
+ return Object.keys(options).reduce((queryReferenceWithWhere, key) => this.buildWhereSentence(queryReferenceWithWhere, `${fieldName.toString()}.${key}`, options[key]), queryReference);
1199
+ }
1200
+ return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1201
+ };
1202
+ }
1203
+ find({ filters, limits, orderBy, } = {}) {
1204
+ return __awaiter(this, void 0, void 0, function* () {
1205
+ let query = this.collection(this.buildCollectionPathForFind(filters || {}));
1206
+ query = this.makeFirestoreWhere(query, filters || {});
1207
+ Object.keys(orderBy || {}).forEach((fieldName) => (query = query.orderBy(fieldName, orderBy[fieldName])));
1208
+ query = yield this.defineLimits(query, filters, limits);
1209
+ const docs = yield query.get();
1210
+ const data = docs.docs.map((doc) => doc.data());
1211
+ return {
1212
+ data,
1213
+ count: this.calculateCount(data, limits),
1214
+ };
1215
+ });
1216
+ }
1217
+ buildCollectionPathForFind(filters) {
1218
+ if (!this.isSubCollection(this))
1219
+ return this.collectionName;
1220
+ const parentIdField = this.parentIdField;
1221
+ const parentId = getValueFromFilter(filters === null || filters === void 0 ? void 0 : filters[parentIdField]);
1222
+ return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
1223
+ }
1224
+ defineLimits(query, filters, limits) {
1225
+ return __awaiter(this, void 0, void 0, function* () {
1226
+ if (limits === null || limits === void 0 ? void 0 : limits.offset) {
1227
+ if (this.model.isModel(limits.offset))
1228
+ query = query.startAfter(yield this.collection(this.buildCollectionPathForFind(filters))
1229
+ .doc(limits.offset[limits.offset.identifiersFields.shift()])
1230
+ .get());
1231
+ else if (isNumber(limits.offset) || isString(limits.offset))
1232
+ query = query.startAt(limits.offset);
1233
+ }
1234
+ if (limits === null || limits === void 0 ? void 0 : limits.limit)
1235
+ query = query.limit(limits.limit);
1236
+ return query;
1237
+ });
1238
+ }
1239
+ calculateCount(data, limits) {
1240
+ if (data.length <= 0)
1241
+ return 0;
1242
+ if (data.length < (limits === null || limits === void 0 ? void 0 : limits.limit))
1243
+ return data.length;
1244
+ return Infinity;
1245
+ }
1246
+ };
1105
1247
  };
1106
1248
 
1107
- const withCreateFirestore = (MixinBase) => {
1108
- return class CreateFirestore extends MixinBase {
1109
- create(data) {
1110
- return __awaiter(this, void 0, void 0, function* () {
1111
- const docRef = yield this.save(this.model.toInstance(data));
1112
- const doc = yield docRef.get();
1113
- return doc.data();
1114
- });
1115
- }
1116
- save(data) {
1117
- var _a;
1118
- return __awaiter(this, void 0, void 0, function* () {
1119
- const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
1120
- const collectionPath = this.buildCollectionPathForAdd(data);
1121
- if (isEmpty(id))
1122
- return this.collection(collectionPath).add(data);
1123
- const docRef = this.collection(collectionPath).doc(id);
1124
- yield docRef.set(data);
1125
- return docRef;
1126
- });
1127
- }
1128
- buildCollectionPathForAdd(identifiers) {
1129
- return this.isSubCollection(this)
1130
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
1131
- : this.collectionName;
1132
- }
1133
- };
1249
+ const withCreateFirestore = (MixinBase) => {
1250
+ return class CreateFirestore extends MixinBase {
1251
+ create(data) {
1252
+ return __awaiter(this, void 0, void 0, function* () {
1253
+ const docRef = yield this.save(this.model.toInstance(data));
1254
+ const doc = yield docRef.get();
1255
+ return doc.data();
1256
+ });
1257
+ }
1258
+ save(data) {
1259
+ var _a;
1260
+ return __awaiter(this, void 0, void 0, function* () {
1261
+ const id = (_a = data[data.identifiersFields.shift()]) === null || _a === void 0 ? void 0 : _a.toString();
1262
+ const collectionPath = this.buildCollectionPathForAdd(data);
1263
+ if (isEmpty(id))
1264
+ return this.collection(collectionPath).add(data);
1265
+ const docRef = this.collection(collectionPath).doc(id);
1266
+ yield docRef.set(data);
1267
+ return docRef;
1268
+ });
1269
+ }
1270
+ buildCollectionPathForAdd(identifiers) {
1271
+ return this.isSubCollection(this)
1272
+ ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
1273
+ : this.collectionName;
1274
+ }
1275
+ };
1134
1276
  };
1135
1277
 
1136
- const withUpdateFirestore = (MixinBase) => {
1137
- const getValueFromParams = (params, field) => { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
1138
- const getValueByAction = (options) => {
1139
- const fieldValues = firebase.firestore.FieldValue;
1140
- if (isNil(options.action))
1141
- return options;
1142
- if (options.action === UpdateOptionActions.REMOVE_FIELD)
1143
- return fieldValues.delete();
1144
- if (Array.isArray(options.value)) {
1145
- if (options.action === UpdateOptionActions.MERGE)
1146
- return fieldValues.arrayUnion(...options.value);
1147
- if (options.action === UpdateOptionActions.REMOVE)
1148
- return fieldValues.arrayRemove(...options.value);
1149
- }
1150
- return options.value;
1151
- };
1152
- return class UpdateFirestore extends MixinBase {
1153
- update(data) {
1154
- return __awaiter(this, void 0, void 0, function* () {
1155
- const model = new this.model();
1156
- const keyField = model.identifierFields().shift();
1157
- const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
1158
- yield docRef.set(this.paramsToPlain(data), { merge: true });
1159
- const doc = yield docRef.get();
1160
- return doc.data();
1161
- });
1162
- }
1163
- buildCollectionPathForUpdate(identifiers) {
1164
- return this.isSubCollection(this)
1165
- ? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
1166
- : this.collectionName;
1167
- }
1168
- paramsToPlain(params) {
1169
- const model = this.model;
1170
- if (params instanceof model)
1171
- return params;
1172
- return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
1173
- }
1174
- };
1278
+ const withUpdateFirestore = (MixinBase) => {
1279
+ const getValueFromParams = (params, field) => { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
1280
+ const getValueByAction = (options) => {
1281
+ const fieldValues = firebase.firestore.FieldValue;
1282
+ if (isNil(options.action))
1283
+ return options;
1284
+ if (options.action === UpdateOptionActions.REMOVE_FIELD)
1285
+ return fieldValues.delete();
1286
+ if (Array.isArray(options.value)) {
1287
+ if (options.action === UpdateOptionActions.MERGE)
1288
+ return fieldValues.arrayUnion(...options.value);
1289
+ if (options.action === UpdateOptionActions.REMOVE)
1290
+ return fieldValues.arrayRemove(...options.value);
1291
+ }
1292
+ return options.value;
1293
+ };
1294
+ return class UpdateFirestore extends MixinBase {
1295
+ update(data) {
1296
+ return __awaiter(this, void 0, void 0, function* () {
1297
+ const model = new this.model();
1298
+ const keyField = model.identifiersFields.shift();
1299
+ const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
1300
+ yield docRef.set(this.paramsToPlain(data), { merge: true });
1301
+ const doc = yield docRef.get();
1302
+ return doc.data();
1303
+ });
1304
+ }
1305
+ buildCollectionPathForUpdate(identifiers) {
1306
+ return this.isSubCollection(this)
1307
+ ? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
1308
+ : this.collectionName;
1309
+ }
1310
+ paramsToPlain(params) {
1311
+ const model = this.model;
1312
+ if (model.isModel(params))
1313
+ return params.toPlain();
1314
+ return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
1315
+ }
1316
+ };
1175
1317
  };
1176
1318
 
1177
- const withDeleteFirestore = (MixinBase) => {
1178
- return class DeleteFirestore extends MixinBase {
1179
- delete(identifiers) {
1180
- return __awaiter(this, void 0, void 0, function* () {
1181
- yield this.collection(this.buildCollectionPathForRemove(identifiers))
1182
- .doc(Object.values(identifiers).shift().toString())
1183
- .delete();
1184
- });
1185
- }
1186
- buildCollectionPathForRemove(identifiers) {
1187
- return this.isSubCollection(this)
1188
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
1189
- : this.collectionName;
1190
- }
1191
- };
1319
+ const withDeleteFirestore = (MixinBase) => {
1320
+ return class DeleteFirestore extends MixinBase {
1321
+ delete(identifiers) {
1322
+ return __awaiter(this, void 0, void 0, function* () {
1323
+ yield this.collection(this.buildCollectionPathForRemove(identifiers))
1324
+ .doc(Object.values(identifiers).shift().toString())
1325
+ .delete();
1326
+ });
1327
+ }
1328
+ buildCollectionPathForRemove(identifiers) {
1329
+ return this.isSubCollection(this)
1330
+ ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
1331
+ : this.collectionName;
1332
+ }
1333
+ };
1192
1334
  };
1193
1335
 
1194
- const withSubCollection = (MixinBase, ParentModel) => {
1195
- return class SubCollectionMix extends MixinBase {
1196
- constructor(...args) {
1197
- super(args);
1198
- }
1199
- collection(path) {
1200
- return super.collection(path);
1201
- }
1202
- };
1336
+ const withSubCollection = (MixinBase, ParentModel) => {
1337
+ return class SubCollectionMix extends MixinBase {
1338
+ constructor(...args) {
1339
+ super(args);
1340
+ }
1341
+ collection(path) {
1342
+ return super.collection(path);
1343
+ }
1344
+ };
1203
1345
  };
1204
1346
 
1205
- const withCrudFirestore = (MixinBase) => {
1206
- return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
1207
- };
1347
+ const withCrudFirestore = (MixinBase) => {
1348
+ return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
1349
+ };
1208
1350
  };
1209
1351
 
1210
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1211
- constructor(firestore) {
1212
- super();
1213
- this.firestore = firestore;
1214
- this.collectionName = 'subscription';
1215
- this.model = Subscription;
1216
- }
1217
- }
1218
-
1219
- class UserSearch extends BaseModel {
1220
- identifierFields() {
1221
- return ['id'];
1222
- }
1223
- }
1224
-
1225
- class UserSearchFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1226
- constructor(firestore) {
1227
- super();
1228
- this.firestore = firestore;
1229
- this.collectionName = 'userSearch';
1230
- this.model = UserSearch;
1231
- }
1232
- }
1233
-
1234
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1235
- constructor(firestore, userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore)) {
1236
- super();
1237
- this.firestore = firestore;
1238
- this.userSearchFirestoreRepository = userSearchFirestoreRepository;
1239
- this.collectionName = 'users';
1240
- this.model = User;
1241
- }
1242
- get(identifiers) {
1243
- const _super = Object.create(null, {
1244
- get: { get: () => super.get }
1245
- });
1246
- return __awaiter(this, void 0, void 0, function* () {
1247
- const user = yield _super.get.call(this, { id: identifiers.id });
1248
- user.beautyProfile = yield this.getBeautyProfile(user.id);
1249
- user.isSubscriber = yield this.checkIfIsSubscriber(user.id);
1250
- return user;
1251
- });
1252
- }
1253
- checkIfExistsByField(field, value) {
1254
- return __awaiter(this, void 0, void 0, function* () {
1255
- const result = yield this.userSearchFirestoreRepository.find([{ [field]: { operator: Where.EQUALS, value } }]);
1256
- return result.count > 0;
1257
- });
1258
- }
1259
- buildModelInstance() {
1260
- const { fromFirestore, toFirestore } = super.buildModelInstance();
1261
- return {
1262
- toFirestore: (data) => {
1263
- const plain = toFirestore(data);
1264
- delete plain.isSubscriber;
1265
- return plain;
1266
- },
1267
- fromFirestore,
1268
- };
1269
- }
1270
- getBeautyProfile(userId) {
1271
- return __awaiter(this, void 0, void 0, function* () {
1272
- const beautyProfile = yield this.collection()
1273
- .doc(userId)
1274
- .collection('CX')
1275
- .withConverter(this.buildBeautyProfileModelInstance())
1276
- .doc('beautyProfile')
1277
- .get();
1278
- return beautyProfile.data();
1279
- });
1280
- }
1281
- checkIfIsSubscriber(userId) {
1282
- return __awaiter(this, void 0, void 0, function* () {
1283
- const docs = yield this.firestore
1284
- .collection('subscription')
1285
- .where('user.id', '==', userId)
1286
- .where('status', '==', 'active')
1287
- .get();
1288
- return !!docs && !!docs.size;
1289
- });
1290
- }
1291
- buildBeautyProfileModelInstance() {
1292
- return {
1293
- toFirestore: (data) => data.toPlain(),
1294
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
1295
- };
1296
- }
1297
- }
1298
-
1299
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1300
- constructor(firestore, parentRepository) {
1301
- super();
1302
- this.firestore = firestore;
1303
- this.parentRepository = parentRepository;
1304
- this.collectionName = 'editions';
1305
- this.parentIdField = 'subscriptionId';
1306
- this.model = Edition;
1307
- }
1308
- }
1309
-
1310
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1311
- constructor(firestore, parentRepository) {
1312
- super();
1313
- this.firestore = firestore;
1314
- this.parentRepository = parentRepository;
1315
- this.collectionName = 'CX';
1316
- this.parentIdField = 'userId';
1317
- this.model = BeautyProfile;
1318
- }
1319
- }
1320
-
1321
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1322
- constructor(firestore, parentRepository) {
1323
- super();
1324
- this.firestore = firestore;
1325
- this.parentRepository = parentRepository;
1326
- this.collectionName = 'address';
1327
- this.parentIdField = 'userId';
1328
- this.model = UserAddress;
1329
- }
1330
- }
1331
-
1332
- class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1333
- constructor(firestore, parentRepository) {
1334
- super();
1335
- this.firestore = firestore;
1336
- this.parentRepository = parentRepository;
1337
- this.collectionName = 'payment_method';
1338
- this.parentIdField = 'userId';
1339
- this.model = UserPaymentMethod;
1340
- }
1341
- }
1342
-
1343
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1344
- constructor(firestore, parentRepository) {
1345
- super();
1346
- this.firestore = firestore;
1347
- this.parentRepository = parentRepository;
1348
- this.collectionName = 'payments';
1349
- this.parentIdField = 'subscriptionId';
1350
- this.model = SubscriptionPayment;
1351
- }
1352
- }
1353
-
1354
- class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1355
- constructor(firestore) {
1356
- super();
1357
- this.firestore = firestore;
1358
- this.collectionName = 'leads';
1359
- this.model = Lead;
1360
- }
1361
- }
1362
-
1363
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1364
- constructor(firestore) {
1365
- super();
1366
- this.firestore = firestore;
1367
- this.collectionName = 'categories';
1368
- this.model = Category;
1369
- }
1370
- getCategoryBySlug(slug, shop) {
1371
- return this.collection(this.collectionName)
1372
- .where('slug', '==', slug)
1373
- .where('shop', '==', shop)
1374
- .where('published', '==', true)
1375
- .get()
1376
- .then((snap) => {
1377
- if (snap.size > 1)
1378
- throw new DuplicatedResultsError('Query returned duplicated values');
1379
- if (snap.empty)
1380
- throw new NotFoundError(`Document with slug ${slug} not found`);
1381
- return snap.docs[0].data();
1382
- })
1383
- .catch((error) => error);
1384
- }
1385
- getCategoriesForHome(categoryIds, limit = 4) {
1386
- return __awaiter(this, void 0, void 0, function* () {
1387
- const categorySnap = yield this.collection(this.collectionName)
1388
- .where('id', 'in', categoryIds)
1389
- .where('published', '==', true)
1390
- .get();
1391
- if (categorySnap.empty)
1392
- throw new NotFoundError('Categories not found');
1393
- const categories = categorySnap.docs.map((doc) => doc.data());
1394
- const homeSections = [];
1395
- for (const category of categories) {
1396
- const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
1397
- const productSnap = yield this.collection('products')
1398
- .where('categories', 'array-contains', category.id)
1399
- .where(publishedField, '==', true)
1400
- .where('stock.quantity', '>', 1)
1401
- .limit(limit)
1402
- .get();
1403
- const products = productSnap.docs.map((doc) => doc.data());
1404
- homeSections.push({ category, products });
1405
- }
1406
- return homeSections;
1407
- });
1408
- }
1409
- mountCategory(category) {
1410
- return __awaiter(this, void 0, void 0, function* () {
1411
- if (!category.products)
1412
- throw new RequiredArgumentError(['Category products is empty']);
1413
- const chunks = category.products.reduce((resultArray, item, index) => {
1414
- const chunkIndex = Math.floor(index / 10);
1415
- if (!resultArray[chunkIndex])
1416
- resultArray[chunkIndex] = [];
1417
- resultArray[chunkIndex].push(item);
1418
- return resultArray;
1419
- }, []);
1420
- const products = [];
1421
- const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
1422
- yield Promise.all(chunks.map((productIds) => __awaiter(this, void 0, void 0, function* () {
1423
- const productSnap = yield this.collection('products')
1424
- .where(publishedField, '==', true)
1425
- .where('id', 'in', productIds)
1426
- .get();
1427
- if (productSnap.empty)
1428
- return;
1429
- products.push(...productSnap.docs.map((doc) => doc.data()));
1430
- })));
1431
- return products;
1432
- });
1433
- }
1434
- }
1435
-
1436
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1437
- constructor(firestore) {
1438
- super();
1439
- this.firestore = firestore;
1440
- this.collectionName = 'products';
1441
- this.model = Product;
1442
- }
1443
- getBySlug(slug, shop) {
1444
- var _a;
1445
- return __awaiter(this, void 0, void 0, function* () {
1446
- const result = yield this.find([
1447
- { slug: { operator: Where.EQUALS, value: slug } },
1448
- { shopAvailability: { operator: Where.IN, value: [shop] } },
1449
- ]);
1450
- return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
1451
- });
1452
- }
1453
- }
1454
-
1455
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
1456
- constructor(firestore, parentRepository) {
1457
- super();
1458
- this.firestore = firestore;
1459
- this.parentRepository = parentRepository;
1460
- this.collectionName = 'variants';
1461
- this.parentIdField = 'productId';
1462
- this.model = Variant;
1463
- }
1464
- }
1465
-
1466
- class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1467
- constructor(firestore) {
1468
- super();
1469
- this.firestore = firestore;
1470
- this.collectionName = 'subscriptionProducts';
1471
- this.model = Product;
1472
- }
1473
- }
1474
-
1475
- class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1476
- constructor(firestore) {
1477
- super();
1478
- this.firestore = firestore;
1479
- this.collectionName = 'checkouts';
1480
- this.model = Checkout;
1481
- }
1482
- }
1483
-
1484
- class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1485
- constructor(firestore) {
1486
- super();
1487
- this.firestore = firestore;
1488
- this.collectionName = 'coupons';
1489
- this.model = Coupon;
1490
- }
1491
- buildModelInstance() {
1492
- return {
1493
- toFirestore: (data) => {
1494
- var _a;
1495
- const plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
1496
- if (!!plain.categories)
1497
- plain.categories = (_a = plain === null || plain === void 0 ? void 0 : plain.categories) === null || _a === void 0 ? void 0 : _a.map((category) => category.id);
1498
- return plain;
1499
- },
1500
- fromFirestore: (snap) => {
1501
- var _a;
1502
- const data = snap.data();
1503
- Object.keys(data).forEach((key) => {
1504
- if (data[key] instanceof firebase.firestore.Timestamp) {
1505
- data[key] = data[key].toDate();
1506
- }
1507
- });
1508
- data.categories = (_a = data === null || data === void 0 ? void 0 : data.categories) === null || _a === void 0 ? void 0 : _a.map((category) => ({ id: category }));
1509
- if (data.checkout_type === CheckoutTypes.SUBSCRIPTION)
1510
- return ClubCoupon.toInstance(Object.assign({ id: snap.id }, data));
1511
- if (data.checkout_type === CheckoutTypes.ECOMMERCE)
1512
- return StoreCoupon.toInstance(Object.assign({ id: snap.id }, data));
1513
- return this.model.toInstance(Object.assign({ id: snap.id }, data));
1514
- },
1515
- };
1516
- }
1517
- }
1518
-
1519
- class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1520
- constructor(firestore) {
1521
- super();
1522
- this.firestore = firestore;
1523
- this.collectionName = 'orders';
1524
- this.model = Order;
1525
- }
1526
- }
1352
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1353
+ constructor(firestore) {
1354
+ super();
1355
+ this.firestore = firestore;
1356
+ this.collectionName = 'subscription';
1357
+ this.model = Subscription;
1358
+ }
1359
+ }
1360
+
1361
+ class UserSearch extends BaseModel {
1362
+ static get identifiersFields() {
1363
+ return ['id'];
1364
+ }
1365
+ }
1366
+
1367
+ class UserSearchFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1368
+ constructor(firestore) {
1369
+ super();
1370
+ this.firestore = firestore;
1371
+ this.collectionName = 'userSearch';
1372
+ this.model = UserSearch;
1373
+ }
1374
+ }
1375
+
1376
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1377
+ constructor(firestore, userSearchFirestoreRepository = new UserSearchFirestoreRepository(firestore)) {
1378
+ super();
1379
+ this.firestore = firestore;
1380
+ this.userSearchFirestoreRepository = userSearchFirestoreRepository;
1381
+ this.collectionName = 'users';
1382
+ this.model = User;
1383
+ }
1384
+ get(identifiers) {
1385
+ const _super = Object.create(null, {
1386
+ get: { get: () => super.get }
1387
+ });
1388
+ return __awaiter(this, void 0, void 0, function* () {
1389
+ const user = yield _super.get.call(this, { id: identifiers.id });
1390
+ user.beautyProfile = yield this.getBeautyProfile(user.id);
1391
+ user.isSubscriber = yield this.checkIfIsSubscriber(user.id);
1392
+ return user;
1393
+ });
1394
+ }
1395
+ checkIfExistsByField(field, value) {
1396
+ return __awaiter(this, void 0, void 0, function* () {
1397
+ const result = yield this.userSearchFirestoreRepository.find({ [field]: { operator: Where.EQUALS, value } });
1398
+ return result.count > 0;
1399
+ });
1400
+ }
1401
+ buildModelInstance() {
1402
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
1403
+ return {
1404
+ toFirestore: (data) => {
1405
+ const plain = toFirestore(data);
1406
+ delete plain.isSubscriber;
1407
+ return plain;
1408
+ },
1409
+ fromFirestore,
1410
+ };
1411
+ }
1412
+ getBeautyProfile(userId) {
1413
+ return __awaiter(this, void 0, void 0, function* () {
1414
+ const beautyProfile = yield this.collection()
1415
+ .doc(userId)
1416
+ .collection('CX')
1417
+ .withConverter(this.buildBeautyProfileModelInstance())
1418
+ .doc('beautyProfile')
1419
+ .get();
1420
+ return beautyProfile.data();
1421
+ });
1422
+ }
1423
+ checkIfIsSubscriber(userId) {
1424
+ return __awaiter(this, void 0, void 0, function* () {
1425
+ const docs = yield this.firestore
1426
+ .collection('subscription')
1427
+ .where('user.id', '==', userId)
1428
+ .where('status', '==', 'active')
1429
+ .get();
1430
+ return !!docs && !!docs.size;
1431
+ });
1432
+ }
1433
+ buildBeautyProfileModelInstance() {
1434
+ return {
1435
+ toFirestore: (data) => data.toPlain(),
1436
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
1437
+ };
1438
+ }
1439
+ }
1440
+
1441
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1442
+ constructor(firestore, parentRepository) {
1443
+ super();
1444
+ this.firestore = firestore;
1445
+ this.parentRepository = parentRepository;
1446
+ this.collectionName = 'editions';
1447
+ this.parentIdField = 'subscriptionId';
1448
+ this.model = Edition;
1449
+ }
1450
+ }
1451
+
1452
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1453
+ constructor(firestore, parentRepository) {
1454
+ super();
1455
+ this.firestore = firestore;
1456
+ this.parentRepository = parentRepository;
1457
+ this.collectionName = 'CX';
1458
+ this.parentIdField = 'userId';
1459
+ this.model = BeautyProfile;
1460
+ }
1461
+ }
1462
+
1463
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1464
+ constructor(firestore, parentRepository) {
1465
+ super();
1466
+ this.firestore = firestore;
1467
+ this.parentRepository = parentRepository;
1468
+ this.collectionName = 'address';
1469
+ this.parentIdField = 'userId';
1470
+ this.model = UserAddress;
1471
+ }
1472
+ }
1473
+
1474
+ class UserPaymentMethodFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
1475
+ constructor(firestore, parentRepository) {
1476
+ super();
1477
+ this.firestore = firestore;
1478
+ this.parentRepository = parentRepository;
1479
+ this.collectionName = 'payment_method';
1480
+ this.parentIdField = 'userId';
1481
+ this.model = UserPaymentMethod;
1482
+ }
1483
+ }
1484
+
1485
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
1486
+ constructor(firestore, parentRepository) {
1487
+ super();
1488
+ this.firestore = firestore;
1489
+ this.parentRepository = parentRepository;
1490
+ this.collectionName = 'payments';
1491
+ this.parentIdField = 'subscriptionId';
1492
+ this.model = SubscriptionPayment;
1493
+ }
1494
+ }
1495
+
1496
+ class LeadFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1497
+ constructor(firestore) {
1498
+ super();
1499
+ this.firestore = firestore;
1500
+ this.collectionName = 'leads';
1501
+ this.model = Lead;
1502
+ }
1503
+ }
1504
+
1505
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1506
+ constructor(firestore) {
1507
+ super();
1508
+ this.firestore = firestore;
1509
+ this.collectionName = 'categories';
1510
+ this.model = Category;
1511
+ }
1512
+ getCategoryBySlug(slug, shop) {
1513
+ return this.collection(this.collectionName)
1514
+ .where('slug', '==', slug)
1515
+ .where('shop', '==', shop)
1516
+ .where('published', '==', true)
1517
+ .get()
1518
+ .then((snap) => {
1519
+ if (snap.size > 1)
1520
+ throw new DuplicatedResultsError('Query returned duplicated values');
1521
+ if (snap.empty)
1522
+ throw new NotFoundError(`Document with slug ${slug} not found`);
1523
+ return snap.docs[0].data();
1524
+ })
1525
+ .catch((error) => error);
1526
+ }
1527
+ getCategoriesForHome(categoryIds, limit = 4) {
1528
+ return __awaiter(this, void 0, void 0, function* () {
1529
+ const categorySnap = yield this.collection(this.collectionName)
1530
+ .where('id', 'in', categoryIds.filter(Boolean))
1531
+ .where('published', '==', true)
1532
+ .get();
1533
+ if (categorySnap.empty)
1534
+ throw new NotFoundError('Categories not found');
1535
+ const categories = categorySnap.docs.map((doc) => doc.data());
1536
+ const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
1537
+ return ({
1538
+ category,
1539
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
1540
+ });
1541
+ })));
1542
+ return homeSections;
1543
+ });
1544
+ }
1545
+ mountCategory(category, options) {
1546
+ return __awaiter(this, void 0, void 0, function* () {
1547
+ if (!category.products)
1548
+ throw new RequiredArgumentError(['Category products is empty']);
1549
+ const chunks = chunk(category.products, 10);
1550
+ const products = [];
1551
+ const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
1552
+ for (const productIds of chunks) {
1553
+ if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
1554
+ break;
1555
+ let query = yield this.collection('productsErpVitrine')
1556
+ .where(publishedField, '==', true)
1557
+ .where('id', 'in', productIds);
1558
+ if (options === null || options === void 0 ? void 0 : options.hasStock)
1559
+ query = query.where('stock.quantity', '>', 0);
1560
+ if (options === null || options === void 0 ? void 0 : options.limit)
1561
+ query = query.limit(options === null || options === void 0 ? void 0 : options.limit);
1562
+ const productSnap = yield query.get();
1563
+ if (productSnap.empty)
1564
+ continue;
1565
+ products.push(...productSnap.docs.map((doc) => doc.data()));
1566
+ }
1567
+ return products;
1568
+ });
1569
+ }
1570
+ }
1571
+
1572
+ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1573
+ constructor(firestore) {
1574
+ super();
1575
+ this.firestore = firestore;
1576
+ this.reviews = {};
1577
+ this.collectionName = 'productsErpVitrine';
1578
+ this.model = Product;
1579
+ }
1580
+ getBySlug(slug, shop) {
1581
+ var _a;
1582
+ return __awaiter(this, void 0, void 0, function* () {
1583
+ const result = yield this.find({
1584
+ filters: {
1585
+ slug: { operator: Where.EQUALS, value: slug },
1586
+ shopAvailability: { operator: Where.IN, value: [shop] },
1587
+ },
1588
+ });
1589
+ return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
1590
+ });
1591
+ }
1592
+ fetchReviews(status) {
1593
+ return __awaiter(this, void 0, void 0, function* () {
1594
+ const { data: products } = yield this.find();
1595
+ products.forEach((product) => {
1596
+ var _a;
1597
+ if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
1598
+ return;
1599
+ const productInfo = {
1600
+ productId: product.id,
1601
+ productName: product.name,
1602
+ productSku: product.sku,
1603
+ };
1604
+ this.reviews.pending = [];
1605
+ this.reviews.approved = [];
1606
+ this.reviews.rejected = [];
1607
+ product.reviews.forEach((review) => {
1608
+ if ([null, undefined].includes(review.status))
1609
+ return this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
1610
+ if (review.status === false)
1611
+ return this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
1612
+ if (!!review.status)
1613
+ return this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
1614
+ });
1615
+ });
1616
+ return this.reviews[status];
1617
+ });
1618
+ }
1619
+ }
1620
+
1621
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
1622
+ constructor(firestore, parentRepository) {
1623
+ super();
1624
+ this.firestore = firestore;
1625
+ this.parentRepository = parentRepository;
1626
+ this.collectionName = 'variants';
1627
+ this.parentIdField = 'productId';
1628
+ this.model = Variant;
1629
+ }
1630
+ }
1631
+
1632
+ class SubscriptionProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1633
+ constructor(firestore) {
1634
+ super();
1635
+ this.firestore = firestore;
1636
+ this.collectionName = 'subscriptionProducts';
1637
+ this.model = Product;
1638
+ }
1639
+ }
1640
+
1641
+ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1642
+ constructor(firestore) {
1643
+ super();
1644
+ this.firestore = firestore;
1645
+ this.collectionName = 'checkouts';
1646
+ this.model = Checkout;
1647
+ }
1648
+ }
1649
+
1650
+ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1651
+ constructor(firestore) {
1652
+ super();
1653
+ this.firestore = firestore;
1654
+ this.collectionName = 'coupons';
1655
+ this.model = Coupon;
1656
+ }
1657
+ buildModelInstance() {
1658
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
1659
+ return {
1660
+ toFirestore: (data) => {
1661
+ const plain = toFirestore(data);
1662
+ if (!!data.expiresIn)
1663
+ plain.expiresIn = data.expiresIn.getTime();
1664
+ return plain;
1665
+ },
1666
+ fromFirestore: (snap) => {
1667
+ const instance = fromFirestore(snap);
1668
+ if (!isNil(instance.expiresIn))
1669
+ instance.expiresIn = new Date(snap.data().expiresIn);
1670
+ return instance;
1671
+ },
1672
+ };
1673
+ }
1674
+ }
1675
+
1676
+ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1677
+ constructor(firestore) {
1678
+ super();
1679
+ this.firestore = firestore;
1680
+ this.collectionName = 'orders';
1681
+ this.model = Order;
1682
+ }
1683
+ }
1684
+
1685
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1686
+ constructor(firestore) {
1687
+ super();
1688
+ this.firestore = firestore;
1689
+ this.collectionName = 'payments';
1690
+ this.model = Payment;
1691
+ }
1692
+ }
1693
+
1694
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1695
+ constructor(firestore) {
1696
+ super();
1697
+ this.firestore = firestore;
1698
+ this.collectionName = 'checkoutsSubscription';
1699
+ this.model = CheckoutSubscription;
1700
+ }
1701
+ }
1702
+
1703
+ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1704
+ constructor(firestore) {
1705
+ super();
1706
+ this.firestore = firestore;
1707
+ this.collectionName = 'subscriptionPlans';
1708
+ this.model = SubscriptionPlan;
1709
+ }
1710
+ }
1711
+
1712
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1713
+ constructor(firestore) {
1714
+ super();
1715
+ this.firestore = firestore;
1716
+ this.collectionName = 'buy2win';
1717
+ this.model = Buy2Win;
1718
+ }
1719
+ }
1720
+
1721
+ class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1722
+ constructor(firestore) {
1723
+ super(firestore);
1724
+ this.firestore = firestore;
1725
+ this.collectionName = 'legacyOrders';
1726
+ }
1727
+ }
1728
+
1729
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1730
+ constructor(firestore) {
1731
+ super();
1732
+ this.firestore = firestore;
1733
+ this.homeToFirestore = (home) => {
1734
+ var _a;
1735
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
1736
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.homeCategoryGroupToPlain);
1737
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.homeCategoryGroupToPlain);
1738
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.homeCategoryGroupToPlain);
1739
+ }
1740
+ return home;
1741
+ };
1742
+ this.homeCategoryGroupToPlain = (homeCategoryGroup) => ({
1743
+ category: homeCategoryGroup.category.toPlain(),
1744
+ products: homeCategoryGroup.products.map((product) => product.toPlain()),
1745
+ });
1746
+ this.homeFromFirestore = (home) => {
1747
+ var _a;
1748
+ if ((_a = home.data) === null || _a === void 0 ? void 0 : _a.data) {
1749
+ home.data.data.discoverProducts = home.data.data.discoverProducts.map(this.plainToHomeCategoryGroup);
1750
+ home.data.data.featuredProducts = home.data.data.featuredProducts.map(this.plainToHomeCategoryGroup);
1751
+ home.data.data.verticalProducts = home.data.data.verticalProducts.map(this.plainToHomeCategoryGroup);
1752
+ home.data.createdAt =
1753
+ home.data.createdAt instanceof firebase.firestore.Timestamp ? home.data.createdAt.toDate() : home.data.createdAt;
1754
+ home.data.expiresAt =
1755
+ home.data.expiresAt instanceof firebase.firestore.Timestamp ? home.data.expiresAt.toDate() : home.data.expiresAt;
1756
+ }
1757
+ return home;
1758
+ };
1759
+ this.plainToHomeCategoryGroup = (homeCategoryGroup) => ({
1760
+ category: Category.toInstance(homeCategoryGroup.category),
1761
+ products: homeCategoryGroup.products.map((product) => Product.toInstance(product)),
1762
+ });
1763
+ this.collectionName = 'dms';
1764
+ this.model = Home;
1765
+ }
1766
+ buildModelInstance() {
1767
+ const { fromFirestore, toFirestore } = super.buildModelInstance();
1768
+ return {
1769
+ toFirestore: (data) => {
1770
+ const modifiedData = this.homeToFirestore(data);
1771
+ return toFirestore(modifiedData);
1772
+ },
1773
+ fromFirestore: (snap) => {
1774
+ const instance = fromFirestore(snap);
1775
+ return this.homeFromFirestore(instance);
1776
+ },
1777
+ };
1778
+ }
1779
+ }
1780
+
1781
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1782
+ constructor(firestore) {
1783
+ super();
1784
+ this.firestore = firestore;
1785
+ this.collectionName = 'shopMenus';
1786
+ this.model = ShopMenu;
1787
+ }
1788
+ }
1789
+
1790
+ class AuthenticationFirebaseAuthService {
1791
+ constructor(firebaseAuth) {
1792
+ this.firebaseAuth = firebaseAuth;
1793
+ }
1794
+ signInWithEmailAndPassword(data) {
1795
+ return __awaiter(this, void 0, void 0, function* () {
1796
+ const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
1797
+ const user = credentials.user;
1798
+ return {
1799
+ id: user.uid,
1800
+ displayName: user.displayName,
1801
+ email: user.email,
1802
+ phone: user.phoneNumber,
1803
+ isAnonymous: false,
1804
+ };
1805
+ });
1806
+ }
1807
+ signInWithGoogle() {
1808
+ return __awaiter(this, void 0, void 0, function* () {
1809
+ const credentials = yield this.firebaseAuth.signInWithPopup(new firebase.auth.GoogleAuthProvider());
1810
+ const user = credentials.user;
1811
+ return {
1812
+ id: user.uid,
1813
+ displayName: user.displayName,
1814
+ email: user.email,
1815
+ phone: user.phoneNumber,
1816
+ isAnonymous: false,
1817
+ };
1818
+ });
1819
+ }
1820
+ signOut() {
1821
+ return __awaiter(this, void 0, void 0, function* () {
1822
+ this.firebaseAuth.signOut();
1823
+ });
1824
+ }
1825
+ signInAnonymously() {
1826
+ return __awaiter(this, void 0, void 0, function* () {
1827
+ const auth = yield this.firebaseAuth.signInAnonymously();
1828
+ const user = auth.user;
1829
+ user.id = auth.user.uid;
1830
+ return user;
1831
+ });
1832
+ }
1833
+ sendPasswordResetEmail(email) {
1834
+ return __awaiter(this, void 0, void 0, function* () {
1835
+ return this.firebaseAuth.sendPasswordResetEmail(email);
1836
+ });
1837
+ }
1838
+ }
1839
+
1840
+ class RegisterFirebaseAuthService {
1841
+ constructor(firebaseAuth) {
1842
+ this.firebaseAuth = firebaseAuth;
1843
+ }
1844
+ register(params) {
1845
+ return __awaiter(this, void 0, void 0, function* () {
1846
+ try {
1847
+ const auth = yield this.firebaseAuth.createUserWithEmailAndPassword(params.email, params.password);
1848
+ const user = auth.user;
1849
+ user.sendEmailVerification();
1850
+ user.id = auth.user.uid;
1851
+ return user;
1852
+ }
1853
+ catch (error) {
1854
+ if (error.code === 'auth/email-already-in-use')
1855
+ throw new UserAlreadyRegisteredError('Email already registered');
1856
+ if (error.code === 'auth/weak-password')
1857
+ throw new WeakPasswordError();
1858
+ throw error;
1859
+ }
1860
+ });
1861
+ }
1862
+ }
1863
+
1864
+ class AttributeOptionHelper {
1865
+ }
1866
+ AttributeOptionHelper.FindByAttribute = (attributeName, fields) => {
1867
+ if (fields.includes(attributeName))
1868
+ return { columnName: attributeName.toString(), attributeName };
1869
+ const field = fields.find((columnOption) => isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()));
1870
+ const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
1871
+ if (isNil(fieldOption))
1872
+ return { columnName: attributeName.toString(), attributeName };
1873
+ if (Array.isArray(fieldOption))
1874
+ return { columnName: attributeName.toString(), attributeName, fields: fieldOption };
1875
+ return Object.assign({ attributeName, columnName: attributeName.toString() }, fieldOption);
1876
+ };
1877
+ AttributeOptionHelper.CheckIsColumnOption = (fieldValue) => !!fieldValue.columnName;
1878
+ AttributeOptionHelper.FindColumnOptionFromList = (columnName, fields) => {
1879
+ if (fields.includes(columnName))
1880
+ return { columnName, attributeName: columnName };
1881
+ const field = fields.find((columnOption) => {
1882
+ var _a;
1883
+ return isObject(columnOption) &&
1884
+ ((_a = Object.values(columnOption).find((option) => AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName)) === null || _a === void 0 ? void 0 : _a.columnName) === columnName;
1885
+ }) || {};
1886
+ const attributeName = Object.keys(field).find((fieldOptionFromList) => AttributeOptionHelper.CheckIsColumnOption(field[fieldOptionFromList]) ||
1887
+ Array.isArray(field[fieldOptionFromList]));
1888
+ const fieldOption = field === null || field === void 0 ? void 0 : field[attributeName];
1889
+ if (Array.isArray(fieldOption))
1890
+ return { attributeName: attributeName, fields: fieldOption };
1891
+ return Object.assign({ attributeName: attributeName || columnName, columnName }, fieldOption);
1892
+ };
1527
1893
 
1528
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1529
- constructor(firestore) {
1530
- super();
1531
- this.firestore = firestore;
1532
- this.collectionName = 'payments';
1533
- this.model = Payment;
1534
- }
1535
- }
1894
+ class GraphQLFieldHelper {
1895
+ }
1896
+ GraphQLFieldHelper.CheckIsGraphQLParams = (params) => !isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation;
1897
+ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = (fields) => {
1898
+ return fields === null || fields === void 0 ? void 0 : fields.map((field) => {
1899
+ if (isString(field))
1900
+ return field.toString();
1901
+ const fieldName = Object.keys(field).shift();
1902
+ const fieldValue = field[fieldName];
1903
+ if (Array.isArray(fieldValue))
1904
+ return { [fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue) };
1905
+ if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
1906
+ return;
1907
+ if (fieldValue.fields)
1908
+ return {
1909
+ [fieldValue.columnName || fieldName]: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
1910
+ };
1911
+ return fieldValue.columnName;
1912
+ }).filter((field) => !!field);
1913
+ };
1914
+ GraphQLFieldHelper.ConvertFieldValueFrom = (data, fields) => Object.keys(data).reduce((result, columnName) => {
1915
+ const { attributeName, fields: attributeFields, from, } = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields);
1916
+ if (!!attributeFields && Array.isArray(attributeFields)) {
1917
+ if (Array.isArray(data[columnName]))
1918
+ return Object.assign(Object.assign({}, result), { [attributeName]: from
1919
+ ? from(data[columnName], data)
1920
+ : data[columnName].map((value) => GraphQLFieldHelper.ConvertFieldValueFrom(value, attributeFields)) });
1921
+ if (isObject(data[columnName]))
1922
+ return Object.assign(Object.assign({}, result), { [attributeName]: GraphQLFieldHelper.ConvertFieldValueFrom(data[columnName], attributeFields) });
1923
+ }
1924
+ if (!!from)
1925
+ return Object.assign(Object.assign({}, result), { [attributeName]: from(data[columnName], data) });
1926
+ return Object.assign(Object.assign({}, result), { [attributeName]: parseDateTime(data[columnName]) });
1927
+ }, {});
1928
+ GraphQLFieldHelper.ConvertFieldValueTo = (instance, fields, update = false) => {
1929
+ var _a;
1930
+ const data = ((_a = instance.toPlain) === null || _a === void 0 ? void 0 : _a.call(instance)) || instance;
1931
+ return Object.keys(data).reduce((result, attributeName) => {
1932
+ const { columnName, fields: attributeFields, foreignKeyColumn, to, bindPersistData, } = AttributeOptionHelper.FindByAttribute(attributeName, fields);
1933
+ if (bindPersistData)
1934
+ return Object.assign(Object.assign({}, result), bindPersistData(data[attributeName], instance));
1935
+ if (isNil(columnName))
1936
+ return result;
1937
+ if (!!foreignKeyColumn &&
1938
+ !isEmpty(foreignKeyColumn) &&
1939
+ !Object.keys(foreignKeyColumn).filter((key) => { var _a; return !((_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[key]); }).length)
1940
+ return Object.keys(foreignKeyColumn).reduce((object, current) => { var _a; return (Object.assign(Object.assign({}, object), { [foreignKeyColumn[current]]: (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current] })); }, Object.assign({}, result));
1941
+ if (update && isObject(data[attributeName]) && !isNil(attributeFields) && !isDate(data[attributeName]))
1942
+ return result;
1943
+ if (!!columnName && Array.isArray(attributeFields) && isObject(data[attributeName])) {
1944
+ const converted = !isNil(columnName) && to ? to(instance[attributeName], instance) : data[attributeName];
1945
+ return Object.assign(Object.assign({}, result), (converted !== undefined
1946
+ ? {
1947
+ [columnName]: {
1948
+ data: instance[attributeName] instanceof BaseModel
1949
+ ? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
1950
+ : converted,
1951
+ },
1952
+ }
1953
+ : {}));
1954
+ }
1955
+ if (!!to)
1956
+ return Object.assign(Object.assign({}, result), { [columnName]: to(instance[attributeName], instance) });
1957
+ return Object.assign(Object.assign({}, result), { [columnName]: data[attributeName] });
1958
+ }, {});
1959
+ };
1536
1960
 
1537
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1538
- constructor(firestore) {
1539
- super();
1540
- this.firestore = firestore;
1541
- this.collectionName = 'checkoutsSubscription';
1542
- this.model = CheckoutSubscription;
1543
- }
1544
- }
1961
+ class FilterOptionHelper {
1962
+ }
1963
+ FilterOptionHelper.CheckIfIsFilterOption = (filter) => !isNil(filter === null || filter === void 0 ? void 0 : filter.operator);
1964
+ FilterOptionHelper.GetValueFromFilter = (filter, fieldOption) => {
1965
+ if (!FilterOptionHelper.CheckIfIsFilterOption(filter))
1966
+ return filter;
1967
+ if (filter.operator === Where.ISNULL)
1968
+ return true;
1969
+ if (filter.operator === Where.ISNOTNULL)
1970
+ return false;
1971
+ const converter = fieldOption.to ? fieldOption.to : (value) => value;
1972
+ return Array.isArray(filter.value) && !fieldOption.fields && [Where.IN, Where.NOTIN].includes(filter.operator)
1973
+ ? filter.value.map((fieldValue) => converter(fieldValue))
1974
+ : converter(filter.value);
1975
+ };
1545
1976
 
1546
- class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1547
- constructor(firestore) {
1548
- super();
1549
- this.firestore = firestore;
1550
- this.collectionName = 'subscriptionPlans';
1551
- this.model = SubscriptionPlan;
1552
- }
1553
- }
1977
+ const withCreateHasuraGraphQL = (MixinBase) => {
1978
+ return class CreateHasuraGraphQLMixin extends MixinBase {
1979
+ constructor(...params) {
1980
+ const options = params === null || params === void 0 ? void 0 : params[0];
1981
+ super(...params);
1982
+ this.insertGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertGraphQLOperation) || `insert_${this.tableName}_one`;
1983
+ this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || `${this.tableName}_insert_input`;
1984
+ }
1985
+ create(data) {
1986
+ return __awaiter(this, void 0, void 0, function* () {
1987
+ const newData = yield this.save(this.model.toInstance(data));
1988
+ return this.model.toInstance(newData);
1989
+ });
1990
+ }
1991
+ save(data) {
1992
+ return __awaiter(this, void 0, void 0, function* () {
1993
+ const primaryKeyColumns = this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName);
1994
+ const foreignKeyColumns = this.fields
1995
+ .map((field) => {
1996
+ const columnOptions = Object.values(field).shift();
1997
+ return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
1998
+ columnOptions.foreignKeyColumn && [
1999
+ ...Object.values(columnOptions.foreignKeyColumn),
2000
+ {
2001
+ [columnOptions.columnName]: Object.keys(columnOptions.foreignKeyColumn).map((foreignKeyField) => {
2002
+ var _a;
2003
+ return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
2004
+ foreignKeyField;
2005
+ }),
2006
+ },
2007
+ ]);
2008
+ })
2009
+ .filter(Boolean)
2010
+ .reduce((keys, current) => [...keys, ...current], []);
2011
+ const result = yield this.mutation(this.insertGraphQLOperation, [...primaryKeyColumns, ...foreignKeyColumns], {
2012
+ object: { type: this.insertGraphQLObjectType, required: true, value: this.convertDataToHasura(data) },
2013
+ });
2014
+ return Object.assign(Object.assign({}, data.toPlain()), this.convertDataFromHasura(result[this.insertGraphQLOperation]).toPlain());
2015
+ });
2016
+ }
2017
+ };
2018
+ };
1554
2019
 
1555
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1556
- constructor(firestore) {
1557
- super();
1558
- this.firestore = firestore;
1559
- this.collectionName = 'buy2win';
1560
- this.model = Buy2Win;
1561
- }
1562
- }
2020
+ const withDeleteHasuraGraphQL = (MixinBase) => {
2021
+ return class DeleteHasuraGraphQLMixin extends MixinBase {
2022
+ constructor(...params) {
2023
+ const options = params === null || params === void 0 ? void 0 : params[0];
2024
+ super(...params);
2025
+ this.deleteGraphQLOperation = (options === null || options === void 0 ? void 0 : options.deleteGraphQLOperation) || `delete_${this.tableName}_by_pk`;
2026
+ }
2027
+ delete(identifiers) {
2028
+ return __awaiter(this, void 0, void 0, function* () {
2029
+ const instance = this.model.toInstance(identifiers);
2030
+ yield this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), this.model.identifiersFields.reduce((ids, identifier) => {
2031
+ if (isNil(instance[identifier]))
2032
+ return ids;
2033
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2034
+ const value = columnOption.to(identifiers[identifier.toString()], instance);
2035
+ return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
2036
+ type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
2037
+ value,
2038
+ required: true,
2039
+ } });
2040
+ }, {}));
2041
+ });
2042
+ }
2043
+ };
2044
+ };
1563
2045
 
1564
- class LegacyOrderFirestoreRepository extends OrderFirestoreRepository {
1565
- constructor(firestore) {
1566
- super(firestore);
1567
- this.firestore = firestore;
1568
- this.collectionName = 'legacyOrders';
1569
- }
1570
- }
2046
+ const withHasuraGraphQL = (MixinBase) => {
2047
+ return class HasuraGraphQLMixin extends MixinBase {
2048
+ constructor(...params) {
2049
+ const options = params[0];
2050
+ super(...params);
2051
+ this.tableName = options.tableName;
2052
+ this.endpoint = options.endpoint;
2053
+ this.authOptions = options.authOptions;
2054
+ this.model = options.model;
2055
+ this.fields = options.fields || this.model.identifiersFields;
2056
+ }
2057
+ get headers() {
2058
+ return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (isNil(this.authOptions.authRole)
2059
+ ? {}
2060
+ : { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }));
2061
+ }
2062
+ mutation(operation, fields, variables) {
2063
+ return __awaiter(this, void 0, void 0, function* () {
2064
+ const resultQuery = mutation({
2065
+ operation,
2066
+ variables,
2067
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2068
+ });
2069
+ return this.fetch(resultQuery);
2070
+ });
2071
+ }
2072
+ query(operation, fields, variables) {
2073
+ return __awaiter(this, void 0, void 0, function* () {
2074
+ const resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
2075
+ ? query(operation.map((option) => ({
2076
+ operation: option.operation,
2077
+ variables: option.variables,
2078
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
2079
+ })))
2080
+ : query({
2081
+ operation,
2082
+ variables,
2083
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
2084
+ });
2085
+ return this.fetch(resultQuery);
2086
+ });
2087
+ }
2088
+ fetch(params) {
2089
+ return __awaiter(this, void 0, void 0, function* () {
2090
+ const headers = this.headers;
2091
+ const response = yield fetch(`${this.endpoint}`, {
2092
+ method: 'POST',
2093
+ body: JSON.stringify(params),
2094
+ headers,
2095
+ });
2096
+ const result = yield response.json();
2097
+ if (!isNil(result.errors))
2098
+ throw new Error(JSON.stringify(result.errors));
2099
+ return result.data;
2100
+ });
2101
+ }
2102
+ getAttributeGraphQLTypeOf(value) {
2103
+ if (isUUID(value))
2104
+ return 'uuid';
2105
+ if (isString(value))
2106
+ return 'String';
2107
+ if (isBoolean(value))
2108
+ return 'Boolean';
2109
+ if (value instanceof Date)
2110
+ return 'timestamptz';
2111
+ if (isInteger(value))
2112
+ return 'Int';
2113
+ if (isNumber(value))
2114
+ return 'numeric';
2115
+ throw new Error('Type not implemented yet');
2116
+ }
2117
+ checkIfIsDateTimeAndParse(value) {
2118
+ if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value))
2119
+ return value;
2120
+ const date = parseISO(value);
2121
+ if (isNaN$1(date.getTime()))
2122
+ return value;
2123
+ return date;
2124
+ }
2125
+ convertDataFromHasura(data) {
2126
+ const plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
2127
+ return this.model.toInstance(plain);
2128
+ }
2129
+ convertDataToHasura(instance, update = false) {
2130
+ return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
2131
+ }
2132
+ };
2133
+ };
1571
2134
 
1572
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1573
- constructor(firestore) {
1574
- super();
1575
- this.firestore = firestore;
1576
- this.collectionName = 'dms';
1577
- this.model = Home;
1578
- }
1579
- }
2135
+ const withUpdateHasuraGraphQL = (MixinBase) => {
2136
+ const getValueByAction = (options) => {
2137
+ if (options instanceof BaseModel)
2138
+ return options.toPlain();
2139
+ if (isNil(options === null || options === void 0 ? void 0 : options.action))
2140
+ return options;
2141
+ if ([UpdateOptionActions.REMOVE_FIELD.toString(), UpdateOptionActions.NULL.toString()].includes(options.action))
2142
+ return null;
2143
+ return options.value;
2144
+ };
2145
+ return class UpdateHasuraGraphQLMixin extends MixinBase {
2146
+ constructor(...params) {
2147
+ const options = params === null || params === void 0 ? void 0 : params[0];
2148
+ super(...params);
2149
+ this.updateGraphQLOperation = (options === null || options === void 0 ? void 0 : options.updateGraphQLOperation) || `update_${this.tableName}_by_pk`;
2150
+ this.updateGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.updateGraphQLObjectType) || `${this.tableName}_set_input`;
2151
+ this.updateGraphQLPKType = (options === null || options === void 0 ? void 0 : options.updateGraphQLPKType) || `${this.tableName}_pk_columns_input`;
2152
+ }
2153
+ update(data) {
2154
+ return __awaiter(this, void 0, void 0, function* () {
2155
+ const plainData = this.paramsToPlain(data);
2156
+ yield this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map((field) => AttributeOptionHelper.FindByAttribute(field, this.fields).columnName), {
2157
+ _set: {
2158
+ type: this.updateGraphQLObjectType,
2159
+ value: this.convertDataToHasura(this.model.toInstance(plainData), true),
2160
+ required: true,
2161
+ },
2162
+ pk_columns: { type: this.updateGraphQLPKType, value: this.getUpdateModelKeys(plainData), required: true },
2163
+ });
2164
+ return this.model.toInstance(plainData);
2165
+ });
2166
+ }
2167
+ paramsToPlain(params) {
2168
+ const model = this.model;
2169
+ if (model.isModel(params))
2170
+ return params.toPlain();
2171
+ return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && { [currentKey]: getValueByAction(params[currentKey]) }))), {});
2172
+ }
2173
+ getUpdateModelKeys(data) {
2174
+ const instance = this.model.toInstance(data);
2175
+ return this.model.identifiersFields.reduce((ids, identifier) => {
2176
+ var _a;
2177
+ if (isNil(instance[identifier]))
2178
+ return ids;
2179
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2180
+ const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier.toString()], instance)) || data[columnOption.attributeName];
2181
+ return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: value });
2182
+ }, {});
2183
+ }
2184
+ };
2185
+ };
1580
2186
 
1581
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1582
- constructor(firestore) {
1583
- super();
1584
- this.firestore = firestore;
1585
- this.collectionName = 'shopMenus';
1586
- this.model = ShopMenu;
1587
- }
1588
- }
2187
+ const withGetHasuraGraphQL = (MixinBase) => {
2188
+ return class GetHasuraGraphQLMixin extends MixinBase {
2189
+ constructor(...params) {
2190
+ const options = params === null || params === void 0 ? void 0 : params[0];
2191
+ super(...params);
2192
+ this.getGraphQLOperation = (options === null || options === void 0 ? void 0 : options.getGraphQLOperation) || `${this.tableName}_by_pk`;
2193
+ }
2194
+ get(identifiers) {
2195
+ return __awaiter(this, void 0, void 0, function* () {
2196
+ const instance = this.model.toInstance(identifiers);
2197
+ const result = yield this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce((ids, identifier) => {
2198
+ var _a;
2199
+ if (isNil(instance[identifier]))
2200
+ return ids;
2201
+ const columnOption = AttributeOptionHelper.FindByAttribute(identifier, this.fields);
2202
+ const value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier.toString()], instance)) || identifiers[identifier.toString()];
2203
+ return Object.assign(Object.assign({}, ids), { [columnOption.columnName]: {
2204
+ type: this.getAttributeGraphQLTypeOf(columnOption.type || value),
2205
+ value,
2206
+ required: true,
2207
+ } });
2208
+ }, {}));
2209
+ const data = result[this.getGraphQLOperation];
2210
+ if (isNil(data))
2211
+ throw new NotFoundError(`${instance.constructor.name} not found`);
2212
+ return this.convertDataFromHasura(result[this.getGraphQLOperation]);
2213
+ });
2214
+ }
2215
+ };
2216
+ };
1589
2217
 
1590
- class AuthenticationFirebaseAuthService {
1591
- constructor(firebaseAuth) {
1592
- this.firebaseAuth = firebaseAuth;
1593
- }
1594
- signInWithEmailAndPassword(data) {
1595
- return __awaiter(this, void 0, void 0, function* () {
1596
- const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
1597
- const user = credentials.user;
1598
- return {
1599
- id: user.uid,
1600
- displayName: user.displayName,
1601
- email: user.email,
1602
- phone: user.phoneNumber,
1603
- isAnonymous: false,
1604
- };
1605
- });
1606
- }
1607
- signInWithGoogle() {
1608
- return __awaiter(this, void 0, void 0, function* () {
1609
- const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
1610
- const user = credentials.user;
1611
- return {
1612
- id: user.uid,
1613
- displayName: user.displayName,
1614
- email: user.email,
1615
- phone: user.phoneNumber,
1616
- isAnonymous: false,
1617
- };
1618
- });
1619
- }
1620
- signOut() {
1621
- return __awaiter(this, void 0, void 0, function* () {
1622
- this.firebaseAuth.signOut();
1623
- });
1624
- }
1625
- signInAnonymously() {
1626
- return __awaiter(this, void 0, void 0, function* () {
1627
- const auth = yield this.firebaseAuth.signInAnonymously();
1628
- const user = auth.user;
1629
- user.id = auth.user.uid;
1630
- return user;
1631
- });
1632
- }
1633
- }
2218
+ var HasuraGraphQLWhere;
2219
+ (function (HasuraGraphQLWhere) {
2220
+ HasuraGraphQLWhere["EQUALS"] = "_eq";
2221
+ HasuraGraphQLWhere["GT"] = "_gt";
2222
+ HasuraGraphQLWhere["GTE"] = "_gte";
2223
+ HasuraGraphQLWhere["IN"] = "_in";
2224
+ HasuraGraphQLWhere["NOTIN"] = "_nin";
2225
+ HasuraGraphQLWhere["LT"] = "_lt";
2226
+ HasuraGraphQLWhere["LTE"] = "_lte";
2227
+ HasuraGraphQLWhere["LIKE"] = "_like";
2228
+ HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
2229
+ HasuraGraphQLWhere["ISNULL"] = "_is_null";
2230
+ HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
2231
+ })(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
2232
+
2233
+ var HasuraGraphQLColumnType;
2234
+ (function (HasuraGraphQLColumnType) {
2235
+ HasuraGraphQLColumnType["Int"] = "Int";
2236
+ HasuraGraphQLColumnType["Float"] = "Float";
2237
+ HasuraGraphQLColumnType["Boolean"] = "Boolean";
2238
+ HasuraGraphQLColumnType["String"] = "String";
2239
+ HasuraGraphQLColumnType["DateTime"] = "timestampz";
2240
+ HasuraGraphQLColumnType["Json"] = "json";
2241
+ HasuraGraphQLColumnType["Jsonb"] = "jsonb";
2242
+ HasuraGraphQLColumnType["Enum"] = "enum";
2243
+ HasuraGraphQLColumnType["Uuid"] = "uuid";
2244
+ })(HasuraGraphQLColumnType || (HasuraGraphQLColumnType = {}));
2245
+
2246
+ const withFindHasuraGraphQL = (MixinBase) => {
2247
+ return class FindHasuraGraphQLMixin extends MixinBase {
2248
+ constructor() {
2249
+ super(...arguments);
2250
+ this.makeGraphQLWhere = (filter, fields) => Object.keys(filter).reduce((variables, fieldName) => {
2251
+ const columnOption = AttributeOptionHelper.FindByAttribute(fieldName, fields);
2252
+ if (!columnOption.bindFindFilter)
2253
+ return Object.assign(Object.assign({}, variables), { [columnOption.columnName]: this.buildWhereSentence(fieldName, filter[fieldName], fields) });
2254
+ const builtFilter = columnOption.bindFindFilter(filter[fieldName]);
2255
+ return Object.assign(Object.assign({}, variables), Object.keys(builtFilter).reduce((variablesList, columnName) => (Object.assign(Object.assign({}, variablesList), { [columnName]: this.buildWhereSentence(fieldName, builtFilter[columnName], fields) })), {}));
2256
+ }, {});
2257
+ this.buildWhereSentence = (field, options, fields) => {
2258
+ const fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
2259
+ if (!Array.isArray(options) &&
2260
+ isObject(options) &&
2261
+ isNil(options === null || options === void 0 ? void 0 : options.operator) &&
2262
+ isNil(options === null || options === void 0 ? void 0 : options.value) &&
2263
+ isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
2264
+ return Object.keys(options).reduce((variables, key) => {
2265
+ const fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
2266
+ const columnName = fieldOptions.columnName;
2267
+ const columnFields = fieldOptions.fields;
2268
+ return Object.assign(Object.assign({}, variables), { [columnName]: this.buildWhereSentence(key, options[key], columnFields || []) });
2269
+ }, {});
2270
+ if (!Array.isArray(options) && !isNil(fieldSentenceOptions.fields))
2271
+ return {
2272
+ [fieldSentenceOptions.fields[0]]: this.buildOperatorSentence(options, fieldSentenceOptions),
2273
+ };
2274
+ if (isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
2275
+ options = Object.values(options)[0];
2276
+ return Array.isArray(options)
2277
+ ? options.reduce((whereSentence, option) => (Object.assign(Object.assign({}, whereSentence), this.buildOperatorSentence(option, fieldSentenceOptions))), {})
2278
+ : this.buildOperatorSentence(options, fieldSentenceOptions);
2279
+ };
2280
+ this.buildOperatorSentence = (options, fieldOption) => ({
2281
+ [this.getHasuraOperator(options, fieldOption)]: FilterOptionHelper.GetValueFromFilter(options, fieldOption),
2282
+ });
2283
+ this.getHasuraOperator = (options, fieldOption) => FilterOptionHelper.CheckIfIsFilterOption(options)
2284
+ ? fieldOption.type === HasuraGraphQLColumnType.Jsonb
2285
+ ? this.getHasuraJsonbOperator(options)
2286
+ : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))]
2287
+ : HasuraGraphQLWhere.EQUALS;
2288
+ this.getHasuraJsonbOperator = (options) => options.operator === Where.IN
2289
+ ? '_contains'
2290
+ : options.operator === Where.LIKE
2291
+ ? '_has_keys_any'
2292
+ : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find((graphQLOperator) => graphQLOperator === Object.keys(Where).find((operator) => Where[operator] === (options === null || options === void 0 ? void 0 : options.operator)))];
2293
+ }
2294
+ find(options) {
2295
+ return __awaiter(this, void 0, void 0, function* () {
2296
+ const { filters, limits, orderBy } = options || {};
2297
+ const variablesCount = Object.assign(Object.assign({}, (isNil(orderBy) ? {} : { order_by: { type: `${this.tableName}_order_by!`, list: true, value: orderBy } })), (isNil(filters)
2298
+ ? {}
2299
+ : {
2300
+ where: {
2301
+ value: this.makeGraphQLWhere(filters, this.fields),
2302
+ type: `${this.tableName}_bool_exp`,
2303
+ required: true,
2304
+ },
2305
+ }));
2306
+ const variables = Object.assign(Object.assign({}, (isNil(limits) ? {} : limits)), variablesCount);
2307
+ const result = yield this.query([
2308
+ {
2309
+ operation: this.tableName,
2310
+ fields: options.fields
2311
+ ? options.fields
2312
+ .map((fieldName) => {
2313
+ var _a;
2314
+ return (_a = this.fields.find((fieldOption) => fieldOption === fieldName)) !== null && _a !== void 0 ? _a : this.fields.find((fieldOption) => Object.keys(fieldOption).shift() === fieldName);
2315
+ })
2316
+ .filter(Boolean)
2317
+ : this.fields,
2318
+ variables,
2319
+ },
2320
+ {
2321
+ operation: `${this.tableName}_aggregate`,
2322
+ fields: [{ aggregate: ['count'] }],
2323
+ variables: variablesCount,
2324
+ },
2325
+ ]);
2326
+ const data = result[this.tableName].map((row) => this.convertDataFromHasura(row));
2327
+ const count = result[`${this.tableName}_aggregate`].aggregate.count;
2328
+ return { count, data };
2329
+ });
2330
+ }
2331
+ };
2332
+ };
1634
2333
 
1635
- class RegisterFirebaseAuthService {
1636
- constructor(firebaseAuth) {
1637
- this.firebaseAuth = firebaseAuth;
1638
- }
1639
- register(params) {
1640
- return __awaiter(this, void 0, void 0, function* () {
1641
- try {
1642
- const auth = yield this.firebaseAuth.createUserWithEmailAndPassword(params.email, params.password);
1643
- const user = auth.user;
1644
- user.sendEmailVerification();
1645
- user.id = auth.user.uid;
1646
- return user;
1647
- }
1648
- catch (error) {
1649
- if (error.code === 'auth/email-already-in-use')
1650
- throw new UserAlreadyRegisteredError('Email already registered');
1651
- if (error.code === 'auth/weak-password')
1652
- throw new WeakPasswordError();
1653
- throw error;
1654
- }
1655
- });
1656
- }
1657
- }
2334
+ const withCrudHasuraGraphQL = (MixinBase) => {
2335
+ return class CrudHasuraGraphQLMixin extends withUpdateHasuraGraphQL(withGetHasuraGraphQL(withFindHasuraGraphQL(withDeleteHasuraGraphQL(withCreateHasuraGraphQL(MixinBase))))) {
2336
+ };
2337
+ };
1658
2338
 
1659
- /**
1660
- * Generated bundle index. Do not edit.
2339
+ class CategoryHasuraGraphQL extends Category {
2340
+ }
2341
+
2342
+ class ProductHasuraGraphQL extends Product {
2343
+ }
2344
+ __decorate([
2345
+ Type(() => KitProductHasuraGraphQL),
2346
+ __metadata("design:type", Array)
2347
+ ], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
2348
+
2349
+ class KitProductHasuraGraphQL extends KitProduct {
2350
+ }
2351
+ __decorate([
2352
+ Type(() => ProductHasuraGraphQL),
2353
+ __metadata("design:type", ProductHasuraGraphQL)
2354
+ ], KitProductHasuraGraphQL.prototype, "kit", void 0);
2355
+ __decorate([
2356
+ Type(() => ProductHasuraGraphQL),
2357
+ __metadata("design:type", ProductHasuraGraphQL)
2358
+ ], KitProductHasuraGraphQL.prototype, "product", void 0);
2359
+
2360
+ class VariantHasuraGraphQL extends Variant {
2361
+ constructor() {
2362
+ super(...arguments);
2363
+ this.name = '';
2364
+ this.hasVariants = false;
2365
+ }
2366
+ }
2367
+
2368
+ class CategoryHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2369
+ constructor(endpoint, authOptions, productRepository) {
2370
+ super({
2371
+ tableName: 'category',
2372
+ model: Category,
2373
+ endpoint,
2374
+ authOptions,
2375
+ fields: [
2376
+ { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
2377
+ { firestoreId: { columnName: 'firestore_id' } },
2378
+ 'name',
2379
+ 'description',
2380
+ 'image',
2381
+ 'published',
2382
+ 'shop',
2383
+ 'slug',
2384
+ { brandCategory: { columnName: 'brand_category' } },
2385
+ { brandCategoryBanner: { columnName: 'brand_banner' } },
2386
+ { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
2387
+ { brandLogo: { columnName: 'brand_logo' } },
2388
+ { brandCondition: { columnName: 'brand_condition' } },
2389
+ {
2390
+ conditions: {
2391
+ columnName: 'tag_condition',
2392
+ type: HasuraGraphQLColumnType.Jsonb,
2393
+ from: (tags, row) => ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }),
2394
+ bindPersistData: (value) => {
2395
+ var _a, _b;
2396
+ return {
2397
+ brand_condition: value.brand,
2398
+ tag_condition: `{"${((_b = (_a = value === null || value === void 0 ? void 0 : value.tags) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '","')) || ''}"}`,
2399
+ };
2400
+ },
2401
+ bindFindFilter: (sentence) => {
2402
+ return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
2403
+ },
2404
+ },
2405
+ },
2406
+ 'filters',
2407
+ { createdAt: { columnName: 'created_at' } },
2408
+ { updatedAt: { columnName: 'updated_at' } },
2409
+ {
2410
+ products: {
2411
+ columnName: 'products',
2412
+ fields: ['product_id'],
2413
+ from: (value) => value.map((product) => product.product_id.toString()),
2414
+ to: (productIds) => productIds.map((productId) => ({
2415
+ product_id: +productId,
2416
+ })),
2417
+ },
2418
+ },
2419
+ ],
2420
+ });
2421
+ this.productRepository = productRepository;
2422
+ }
2423
+ get(identifiers) {
2424
+ const _super = Object.create(null, {
2425
+ get: { get: () => super.get }
2426
+ });
2427
+ var _a;
2428
+ return __awaiter(this, void 0, void 0, function* () {
2429
+ return Number.isNaN(+identifiers.id)
2430
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2431
+ : _super.get.call(this, identifiers);
2432
+ });
2433
+ }
2434
+ getCategoryBySlug(slug, shop) {
2435
+ return __awaiter(this, void 0, void 0, function* () {
2436
+ if (!slug)
2437
+ return;
2438
+ const { data, count } = yield this.find({ filters: { slug, shop, published: true } });
2439
+ if (count > 1)
2440
+ throw new DuplicatedResultsError('Query returned duplicated values');
2441
+ if (!count)
2442
+ throw new NotFoundError(`Category with slug ${slug} not found`);
2443
+ return data.shift();
2444
+ });
2445
+ }
2446
+ getCategoriesForHome(categoryIds, limit = 4) {
2447
+ return __awaiter(this, void 0, void 0, function* () {
2448
+ const { data: categories, count } = yield this.find({
2449
+ filters: { firestoreId: { operator: Where.IN, value: categoryIds.filter(Boolean) }, published: true },
2450
+ });
2451
+ if (!count)
2452
+ throw new NotFoundError('Categories not found');
2453
+ const homeSections = yield Promise.all(categories.map((category) => __awaiter(this, void 0, void 0, function* () {
2454
+ return ({
2455
+ category,
2456
+ products: yield this.mountCategory(category, { limit, hasStock: true }),
2457
+ });
2458
+ })));
2459
+ return homeSections;
2460
+ });
2461
+ }
2462
+ mountCategory(category, options) {
2463
+ return __awaiter(this, void 0, void 0, function* () {
2464
+ if (!category.products)
2465
+ throw new RequiredArgumentError(['Category products is empty']);
2466
+ const products = [];
2467
+ const publishedField = category.shop === Shops.GLAMSHOP ? 'publishedGlam' : 'published';
2468
+ const { data: productsData } = yield this.productRepository.find(Object.assign({ filters: Object.assign({ id: { operator: Where.IN, value: category.products }, [publishedField]: true }, ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: Where.GT, value: 0 } } } : {})), fields: [
2469
+ 'id',
2470
+ 'name',
2471
+ 'slug',
2472
+ 'images',
2473
+ 'miniatures',
2474
+ 'price',
2475
+ 'fullPrice',
2476
+ 'subscriberDiscountPercentage',
2477
+ 'subscriberPrice',
2478
+ 'stock',
2479
+ 'published',
2480
+ 'publishedGlam',
2481
+ 'CEST',
2482
+ 'EAN',
2483
+ 'NCM',
2484
+ 'brand',
2485
+ 'costPrice',
2486
+ 'hasVariants',
2487
+ 'isKit',
2488
+ 'shopAvailability',
2489
+ 'sku',
2490
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})));
2491
+ products.push(...productsData);
2492
+ return products;
2493
+ });
2494
+ }
2495
+ }
2496
+
2497
+ class ProductHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2498
+ constructor(endpoint, authOptions) {
2499
+ super({
2500
+ tableName: 'product',
2501
+ model: ProductHasuraGraphQL,
2502
+ endpoint,
2503
+ authOptions,
2504
+ fields: [],
2505
+ });
2506
+ this.bindReviewToModel = (plain) => (Object.assign(Object.assign({}, omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id }));
2507
+ this.bindReviewToHasura = (review) => (Object.assign(Object.assign({}, omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])), { person_id: review.personId, order_id: review.orderId }));
2508
+ const commonFields = [
2509
+ { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
2510
+ { firestoreId: { columnName: 'firestore_id' } },
2511
+ { CEST: { columnName: 'cest' } },
2512
+ { EAN: { columnName: 'ean' } },
2513
+ { NCM: { columnName: 'ncm' } },
2514
+ 'brand',
2515
+ { costPrice: { columnName: 'cost_price' } },
2516
+ {
2517
+ description: {
2518
+ columnName: 'description',
2519
+ from: (description) => Object.values(Shops).reduce((shops, shop) => (Object.assign(Object.assign({}, shops), { [shop]: { description } })), {}),
2520
+ to: (value) => Object.values(value).shift().description,
2521
+ },
2522
+ },
2523
+ { hasVariants: { columnName: 'has_variants' } },
2524
+ { images: { columnName: 'images', to: (value) => { var _a; return `{"${((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, `","`)) || ''}"}`; } } },
2525
+ { miniatures: { columnName: 'miniatures', to: (value) => { var _a; return `{"${((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, `","`)) || ''}"}`; } } },
2526
+ 'name',
2527
+ {
2528
+ price: {
2529
+ columnName: 'price',
2530
+ from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
2531
+ price,
2532
+ fullPrice: data.full_price,
2533
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
2534
+ subscriberPrice: data.subscriber_price,
2535
+ } })), {}),
2536
+ bindFindFilter: (sentence) => {
2537
+ const filters = Object.values(sentence).shift();
2538
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
2539
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
2540
+ })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
2541
+ subscriber_price: filters.subscriberPrice,
2542
+ }));
2543
+ },
2544
+ bindPersistData: (value) => {
2545
+ const priceData = Object.values(value).shift();
2546
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
2547
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
2548
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
2549
+ },
2550
+ },
2551
+ },
2552
+ { fullPrice: { columnName: 'full_price' } },
2553
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
2554
+ { subscriberPrice: { columnName: 'subscriber_price' } },
2555
+ 'published',
2556
+ { publishedGlam: { columnName: 'published_glam' } },
2557
+ 'sku',
2558
+ {
2559
+ stock: {
2560
+ columnName: 'stock',
2561
+ from: (quantity) => ({ quantity }),
2562
+ to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
2563
+ },
2564
+ },
2565
+ 'slug',
2566
+ 'type',
2567
+ 'video',
2568
+ 'weight',
2569
+ {
2570
+ shopAvailability: {
2571
+ columnName: 'shop_availabilities',
2572
+ fields: ['shop'],
2573
+ from: (shop) => (Array.isArray(shop) ? shop.map((row) => row.shop) : []),
2574
+ to: (shops) => shops.map((shop) => ({ shop })),
2575
+ },
2576
+ },
2577
+ { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
2578
+ { isKit: { columnName: 'is_kit' } },
2579
+ { createdAt: { columnName: 'created_at' } },
2580
+ { updatedAt: { columnName: 'updated_at' } },
2581
+ ];
2582
+ this.fields = [
2583
+ ...commonFields,
2584
+ {
2585
+ categories: {
2586
+ columnName: 'categories',
2587
+ fields: ['category_id'],
2588
+ bindPersistData: (value) => ({
2589
+ categories: { data: value.map((category) => ({ category_id: +category })) },
2590
+ }),
2591
+ to: (categories) => categories.map((categoryId) => +categoryId),
2592
+ from: (categories) => (categories === null || categories === void 0 ? void 0 : categories.map((category) => { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || [],
2593
+ },
2594
+ },
2595
+ {
2596
+ kitProducts: {
2597
+ columnName: 'kit_products',
2598
+ foreignKeyColumn: { productId: 'id' },
2599
+ fields: [
2600
+ { productId: { columnName: 'product_id' } },
2601
+ { kitProductId: { columnName: 'kit_product_id' } },
2602
+ 'quantity',
2603
+ { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
2604
+ ],
2605
+ },
2606
+ },
2607
+ ];
2608
+ }
2609
+ get reviewsFields() {
2610
+ return [
2611
+ 'id',
2612
+ 'shop',
2613
+ 'rate',
2614
+ 'author',
2615
+ 'email',
2616
+ 'location',
2617
+ 'review',
2618
+ 'status',
2619
+ 'title',
2620
+ 'person_id',
2621
+ 'points',
2622
+ 'order_id',
2623
+ 'created_at',
2624
+ 'updated_at',
2625
+ ];
2626
+ }
2627
+ create(data) {
2628
+ const _super = Object.create(null, {
2629
+ create: { get: () => super.create }
2630
+ });
2631
+ return __awaiter(this, void 0, void 0, function* () {
2632
+ const product = yield _super.create.call(this, omit(data, ['reviews']));
2633
+ try {
2634
+ product.reviews = yield this.updateReviews(+product.id, data);
2635
+ }
2636
+ catch (error) {
2637
+ yield this.delete({ id: product.id });
2638
+ throw error;
2639
+ }
2640
+ return product;
2641
+ });
2642
+ }
2643
+ get(identifiers) {
2644
+ const _super = Object.create(null, {
2645
+ get: { get: () => super.get }
2646
+ });
2647
+ var _a;
2648
+ return __awaiter(this, void 0, void 0, function* () {
2649
+ const product = Number.isNaN(+identifiers.id)
2650
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2651
+ : yield _super.get.call(this, identifiers);
2652
+ product.reviews = yield this.findReviewsByProduct(+product.id);
2653
+ return product;
2654
+ });
2655
+ }
2656
+ getBySlug(slug, shop) {
2657
+ var _a;
2658
+ return __awaiter(this, void 0, void 0, function* () {
2659
+ console.log(slug, shop);
2660
+ const result = yield this.find({
2661
+ filters: {
2662
+ slug: { operator: Where.EQUALS, value: slug },
2663
+ shopAvailability: { operator: Where.IN, value: [shop] },
2664
+ },
2665
+ });
2666
+ const product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
2667
+ product.reviews = yield this.findReviewsByProduct(+product.id);
2668
+ return product;
2669
+ });
2670
+ }
2671
+ update(params) {
2672
+ const _super = Object.create(null, {
2673
+ update: { get: () => super.update }
2674
+ });
2675
+ return __awaiter(this, void 0, void 0, function* () {
2676
+ const { categories, kitProducts, reviews, id: checkId } = params, data = __rest(params, ["categories", "kitProducts", "reviews", "id"]);
2677
+ const plainData = this.paramsToPlain({ id: checkId });
2678
+ const id = yield this.getId(plainData.id);
2679
+ const product = yield _super.update.call(this, Object.assign({ id }, data));
2680
+ product.categories = categories && (yield this.updateCategories(+id, { categories }));
2681
+ product.kitProducts = kitProducts && (yield this.updateKitProducts(+id, { kitProducts }));
2682
+ product.reviews = reviews && (yield this.updateReviews(+id, { reviews }));
2683
+ return product;
2684
+ });
2685
+ }
2686
+ fetchReviews(status) {
2687
+ return __awaiter(this, void 0, void 0, function* () {
2688
+ const reviews = {
2689
+ status: status === 'pending'
2690
+ ? { [HasuraGraphQLWhere.ISNULL]: true }
2691
+ : { [HasuraGraphQLWhere.EQUALS]: status === 'approved' },
2692
+ };
2693
+ const { product: data } = yield this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
2694
+ where: { value: { reviews }, type: 'product_bool_exp', required: true },
2695
+ });
2696
+ return data.reduce((reviews, product) => [
2697
+ ...reviews,
2698
+ ...product.reviews
2699
+ .filter((review) => (status === 'pending' && [undefined, null].includes(review.status)) ||
2700
+ (status === 'approved' && review.status === true) ||
2701
+ (status === 'rejected' && review.status === false))
2702
+ .map((review) => (Object.assign(Object.assign({}, this.bindReviewToModel(review)), { productId: product.id, productName: product.name, productSku: product.sku }))),
2703
+ ], []);
2704
+ });
2705
+ }
2706
+ updateCategories(productId, { categories }) {
2707
+ return __awaiter(this, void 0, void 0, function* () {
2708
+ const plainData = this.paramsToPlain({ categories });
2709
+ yield this.mutation('delete_category_product', ['affected_rows'], {
2710
+ where: {
2711
+ type: 'category_product_bool_exp',
2712
+ required: true,
2713
+ value: { product_id: { _eq: productId } },
2714
+ },
2715
+ });
2716
+ yield this.mutation('insert_category_product', ['affected_rows'], {
2717
+ objects: {
2718
+ type: '[category_product_insert_input!]',
2719
+ required: true,
2720
+ value: plainData.categories.map((categoryId) => ({ category_id: categoryId, product_id: productId })),
2721
+ },
2722
+ });
2723
+ return plainData.categories;
2724
+ });
2725
+ }
2726
+ updateKitProducts(productId, { kitProducts }) {
2727
+ return __awaiter(this, void 0, void 0, function* () {
2728
+ const plainData = this.paramsToPlain({ kitProducts });
2729
+ yield this.mutation('delete_product_kit', ['affected_rows'], {
2730
+ where: {
2731
+ type: 'product_kit_bool_exp',
2732
+ required: true,
2733
+ value: { product_id: { _eq: productId } },
2734
+ },
2735
+ });
2736
+ yield this.mutation('insert_product_kit', ['affected_rows'], {
2737
+ objects: {
2738
+ type: '[product_kit_insert_input!]',
2739
+ required: true,
2740
+ value: plainData.kitProducts.map((kitProduct) => ({
2741
+ kit_product_id: kitProduct.productId || kitProduct.product.id,
2742
+ product_id: productId,
2743
+ quantity: kitProduct.quantity,
2744
+ })),
2745
+ },
2746
+ });
2747
+ return plainData.kitProducts;
2748
+ });
2749
+ }
2750
+ updateReviews(productId, { reviews }) {
2751
+ return __awaiter(this, void 0, void 0, function* () {
2752
+ if (!reviews)
2753
+ return [];
2754
+ if ('action' in reviews && reviews.action === 'remove') {
2755
+ const reviewIds = yield Promise.all(reviews.value.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
2756
+ const review = yield this.findReview(reviewData, productId);
2757
+ return review === null || review === void 0 ? void 0 : review.id;
2758
+ })));
2759
+ yield this.mutation('delete_product_review', ['affected_rows'], {
2760
+ where: { value: { id: { _in: reviewIds.filter(Boolean) } }, type: 'product_review_bool_exp', required: true },
2761
+ });
2762
+ return reviews.value.map((review, index) => !reviewIds[index] && review).filter(Boolean);
2763
+ }
2764
+ const plainData = this.paramsToPlain({ reviews });
2765
+ return Promise.all(plainData.reviews.map((reviewData) => __awaiter(this, void 0, void 0, function* () {
2766
+ const review = yield this.findReview(reviewData, productId);
2767
+ if (review)
2768
+ return this.bindReviewToModel((yield this.mutation('update_product_review_by_pk', this.reviewsFields, {
2769
+ pk_columns: {
2770
+ value: { id: review.id },
2771
+ type: 'product_review_pk_columns_input',
2772
+ required: true,
2773
+ },
2774
+ _set: {
2775
+ value: omit(this.bindReviewToHasura(reviewData), ['id', 'product_id']),
2776
+ type: 'product_review_set_input',
2777
+ required: true,
2778
+ },
2779
+ })).update_product_review_by_pk);
2780
+ return this.bindReviewToModel((yield this.mutation('insert_product_review_one', this.reviewsFields, {
2781
+ object: {
2782
+ value: omit(Object.assign(Object.assign({}, this.bindReviewToHasura(reviewData)), { product_id: productId }), ['id']),
2783
+ type: 'product_review_insert_input',
2784
+ required: true,
2785
+ },
2786
+ })).insert_product_review_one);
2787
+ })));
2788
+ });
2789
+ }
2790
+ getId(id) {
2791
+ var _a, _b;
2792
+ return __awaiter(this, void 0, void 0, function* () {
2793
+ if (!Number.isNaN(+id))
2794
+ return id;
2795
+ const { data } = yield this.find({ filters: { firestoreId: id } });
2796
+ if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
2797
+ return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
2798
+ throw new NotFoundError(`Product with id ${id} not found`);
2799
+ });
2800
+ }
2801
+ findReviewsByProduct(productId) {
2802
+ return __awaiter(this, void 0, void 0, function* () {
2803
+ const { product_review: data } = yield this.query('product_review', this.reviewsFields, {
2804
+ where: {
2805
+ value: {
2806
+ product_id: { _eq: productId },
2807
+ },
2808
+ type: 'product_review_bool_exp',
2809
+ required: true,
2810
+ },
2811
+ });
2812
+ return data && data.map((review) => this.bindReviewToModel(review));
2813
+ });
2814
+ }
2815
+ findReview(review, productId) {
2816
+ return __awaiter(this, void 0, void 0, function* () {
2817
+ if (review.id)
2818
+ return review;
2819
+ let loadedReview;
2820
+ if (review.personId)
2821
+ loadedReview = yield this.getReviewByPersonId(review.personId, productId);
2822
+ if (!loadedReview && review.author && review.email)
2823
+ loadedReview = yield this.getReviewByAuthorAndEmail(review.author, review.email, productId);
2824
+ return loadedReview || review;
2825
+ });
2826
+ }
2827
+ getReviewByPersonId(personId, productId) {
2828
+ return __awaiter(this, void 0, void 0, function* () {
2829
+ const { product_review: data } = yield this.query('product_review', this.reviewsFields, {
2830
+ where: {
2831
+ value: {
2832
+ product_id: { _eq: productId },
2833
+ person_id: { _eq: personId },
2834
+ },
2835
+ type: `product_review_bool_exp`,
2836
+ required: true,
2837
+ },
2838
+ });
2839
+ return data && data[0] && this.bindReviewToModel(data[0]);
2840
+ });
2841
+ }
2842
+ getReviewByAuthorAndEmail(author, email, productId) {
2843
+ return __awaiter(this, void 0, void 0, function* () {
2844
+ const { product_review: data } = yield this.query('product_review', this.reviewsFields, {
2845
+ where: {
2846
+ value: {
2847
+ product_id: { _eq: productId },
2848
+ author: { _eq: author },
2849
+ email: { _eq: email },
2850
+ },
2851
+ type: `product_review_bool_exp`,
2852
+ required: true,
2853
+ },
2854
+ });
2855
+ return data && data[0] && this.bindReviewToModel(data[0]);
2856
+ });
2857
+ }
2858
+ }
2859
+
2860
+ class VariantHasuraGraphQLRepository extends withCrudHasuraGraphQL(withHasuraGraphQL(Base)) {
2861
+ constructor(endpoint, authOptions) {
2862
+ super({
2863
+ tableName: 'product',
2864
+ model: VariantHasuraGraphQL,
2865
+ endpoint,
2866
+ authOptions,
2867
+ fields: [
2868
+ { id: { columnName: 'id', to: (value) => +value, from: (value) => value.toString() } },
2869
+ { firestoreId: { columnName: 'firestore_id' } },
2870
+ { productId: { columnName: 'main_product_id', to: (value) => +value, from: (value) => value === null || value === void 0 ? void 0 : value.toString() } },
2871
+ { EAN: { columnName: 'ean' } },
2872
+ { costPrice: { columnName: 'cost_price' } },
2873
+ {
2874
+ price: {
2875
+ columnName: 'price',
2876
+ from: (price, data) => Object.values(Shops).reduce((prices, shop) => (Object.assign(Object.assign({}, prices), { [shop]: {
2877
+ price,
2878
+ fullPrice: data.full_price,
2879
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
2880
+ subscriberPrice: data.subscriber_price,
2881
+ } })), {}),
2882
+ bindFindFilter: (sentence) => {
2883
+ const filters = Object.values(sentence).shift();
2884
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
2885
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
2886
+ })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
2887
+ subscriber_price: filters.subscriberPrice,
2888
+ }));
2889
+ },
2890
+ bindPersistData: (value) => {
2891
+ const priceData = Object.values(value).shift();
2892
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
2893
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
2894
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
2895
+ },
2896
+ },
2897
+ },
2898
+ { fullPrice: { columnName: 'full_price' } },
2899
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
2900
+ { subscriberPrice: { columnName: 'subscriber_price' } },
2901
+ 'sku',
2902
+ {
2903
+ stock: {
2904
+ columnName: 'stock',
2905
+ from: (quantity) => ({ quantity }),
2906
+ to: (value) => (isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity),
2907
+ },
2908
+ },
2909
+ 'weight',
2910
+ { name: { to: () => '', from: () => undefined } },
2911
+ { hasVariants: { columnName: 'has_variants', to: () => false, from: () => undefined } },
2912
+ { createdAt: { columnName: 'created_at' } },
2913
+ { updatedAt: { columnName: 'updated_at' } },
2914
+ ],
2915
+ });
2916
+ }
2917
+ get(identifiers) {
2918
+ const _super = Object.create(null, {
2919
+ get: { get: () => super.get }
2920
+ });
2921
+ var _a;
2922
+ return __awaiter(this, void 0, void 0, function* () {
2923
+ return Number.isNaN(+identifiers.id)
2924
+ ? (_a = (yield this.find({ filters: { firestoreId: identifiers.id } })).data) === null || _a === void 0 ? void 0 : _a[0]
2925
+ : _super.get.call(this, identifiers);
2926
+ });
2927
+ }
2928
+ update(params) {
2929
+ const _super = Object.create(null, {
2930
+ update: { get: () => super.update }
2931
+ });
2932
+ return __awaiter(this, void 0, void 0, function* () {
2933
+ const { productId, id: checkId } = params, data = __rest(params, ["productId", "id"]);
2934
+ const dataWithProductId = this.paramsToPlain({ id: checkId, productId });
2935
+ const id = yield this.getId(dataWithProductId.id);
2936
+ const product = yield _super.update.call(this, Object.assign({ id }, data));
2937
+ product.productId = dataWithProductId.productId;
2938
+ return product;
2939
+ });
2940
+ }
2941
+ getId(id) {
2942
+ var _a, _b;
2943
+ return __awaiter(this, void 0, void 0, function* () {
2944
+ if (!Number.isNaN(+id))
2945
+ return id;
2946
+ const { data } = yield this.find({ filters: { firestoreId: id } });
2947
+ if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
2948
+ return (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id;
2949
+ throw new NotFoundError(`Product with id ${id} not found`);
2950
+ });
2951
+ }
2952
+ }
2953
+
2954
+ /**
2955
+ * Generated bundle index. Do not edit.
1661
2956
  */
1662
2957
 
1663
- export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, ClubCoupon, Coupon, CouponFirestoreRepository, DiscountType, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FragranceImportances, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductSpents, ProductVariantFirestoreRepository, QuestionsFilters, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, StoreCoupon, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserSearchFirestoreRepository, UserType, Variant, WeakPasswordError, Where, withCreateFirestore, withCrudFirestore, withDeleteFirestore, withFindFirestore, withFirestore, withGetFirestore, withHelpers, withSubCollection, withUpdateFirestore };
2958
+ export { AccessoryImportances, Address, Area, Authentication, AuthenticationFirebaseAuthService, AxiosAdapter, Base, BaseModel, BeardProblems, BeardSizes, BeautyProductImportances, BeautyProfile, BeautyQuestionsHelper, BillingStatus, BodyProblems, BodyShapes, BodyTattoos, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, CategoryHasuraGraphQL, CategoryHasuraGraphQLRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FaceSkinOilinesses, FaceSkinProblems, FaceSkinTones, FamilyIncomes, FilterType, FinancialCoupon, FragranceImportances, HairColors, HairProblems, HairStrands, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, KitProduct, KitProductHasuraGraphQL, Lead, LeadFirestoreRepository, LegacyOrderFirestoreRepository, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductHasuraGraphQL, ProductHasuraGraphQLRepository, ProductSpents, ProductVariantFirestoreRepository, ProductsIndex, QuestionsFilters, RecoveryPassword, Register, RegisterFirebaseAuthService, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserAlreadyRegisteredError, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserPaymentMethod, UserPaymentMethodFirestoreRepository, UserSearchFirestoreRepository, UserType, Variant, VariantHasuraGraphQL, VariantHasuraGraphQLRepository, WeakPasswordError, Where, isUUID, parseDateTime, withCreateFirestore, withCreateHasuraGraphQL, withCrudFirestore, withCrudHasuraGraphQL, withDeleteFirestore, withDeleteHasuraGraphQL, withFindFirestore, withFindHasuraGraphQL, withFirestore, withGetFirestore, withGetHasuraGraphQL, withHasuraGraphQL, withHelpers, withSubCollection, withUpdateFirestore, withUpdateHasuraGraphQL };
1664
2959
  //# sourceMappingURL=infrab4a-connect.js.map