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