@infrab4a/connect 4.0.0-beta.9 → 4.0.1-beta-0

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