@infrab4a/connect 0.4.7 → 0.4.9

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 (392) hide show
  1. package/README.md +24 -24
  2. package/bundles/infrab4a-connect.umd.js +1610 -1539
  3. package/bundles/infrab4a-connect.umd.js.map +1 -1
  4. package/esm2015/infrab4a-connect.js +4 -4
  5. package/esm2015/lib/domain/catalog/index.js +3 -3
  6. package/esm2015/lib/domain/catalog/models/category.js +7 -7
  7. package/esm2015/lib/domain/catalog/models/enums/index.js +2 -2
  8. package/esm2015/lib/domain/catalog/models/enums/shops.enum.js +6 -6
  9. package/esm2015/lib/domain/catalog/models/index.js +6 -6
  10. package/esm2015/lib/domain/catalog/models/product.js +7 -7
  11. package/esm2015/lib/domain/catalog/models/types/category-condition.type.js +2 -2
  12. package/esm2015/lib/domain/catalog/models/types/category-filter.type.js +2 -2
  13. package/esm2015/lib/domain/catalog/models/types/index.js +8 -8
  14. package/esm2015/lib/domain/catalog/models/types/product-review.type.js +2 -2
  15. package/esm2015/lib/domain/catalog/models/types/shops-description.type.js +2 -2
  16. package/esm2015/lib/domain/catalog/models/types/shops-price.type.js +2 -2
  17. package/esm2015/lib/domain/catalog/models/types/stock.type.js +2 -2
  18. package/esm2015/lib/domain/catalog/models/types/variant-grade.type.js +2 -2
  19. package/esm2015/lib/domain/catalog/models/variant.js +7 -7
  20. package/esm2015/lib/domain/catalog/repositories/category.repository.js +2 -2
  21. package/esm2015/lib/domain/catalog/repositories/index.js +4 -4
  22. package/esm2015/lib/domain/catalog/repositories/product.repository.js +2 -2
  23. package/esm2015/lib/domain/catalog/repositories/variant.repository.js +2 -2
  24. package/esm2015/lib/domain/general/index.js +3 -3
  25. package/esm2015/lib/domain/general/model/base-model-with-identifier-fields.js +2 -2
  26. package/esm2015/lib/domain/general/model/base.model.js +13 -13
  27. package/esm2015/lib/domain/general/model/identifier-fields.js +2 -2
  28. package/esm2015/lib/domain/general/model/index.js +5 -5
  29. package/esm2015/lib/domain/general/model/types/base-model-builder.type.js +2 -2
  30. package/esm2015/lib/domain/general/model/types/index.js +4 -4
  31. package/esm2015/lib/domain/general/model/types/non-function-properties.type.js +2 -2
  32. package/esm2015/lib/domain/general/model/types/non-function-property-name.type.js +2 -2
  33. package/esm2015/lib/domain/general/repository/create.repository.js +2 -2
  34. package/esm2015/lib/domain/general/repository/crud.repository.js +2 -2
  35. package/esm2015/lib/domain/general/repository/delete.repository.js +2 -2
  36. package/esm2015/lib/domain/general/repository/enums/index.js +3 -3
  37. package/esm2015/lib/domain/general/repository/enums/update-option-actions.enum.js +9 -9
  38. package/esm2015/lib/domain/general/repository/enums/where.enum.js +11 -11
  39. package/esm2015/lib/domain/general/repository/find.repository.js +2 -2
  40. package/esm2015/lib/domain/general/repository/get.repository.js +2 -2
  41. package/esm2015/lib/domain/general/repository/index.js +10 -10
  42. package/esm2015/lib/domain/general/repository/read.repository.js +2 -2
  43. package/esm2015/lib/domain/general/repository/types/index.js +6 -6
  44. package/esm2015/lib/domain/general/repository/types/repository-find-filters.type.js +2 -2
  45. package/esm2015/lib/domain/general/repository/types/repository-find-result.type.js +2 -2
  46. package/esm2015/lib/domain/general/repository/types/repository-limit-options.type.js +2 -2
  47. package/esm2015/lib/domain/general/repository/types/repository-order-by-list.type.js +2 -2
  48. package/esm2015/lib/domain/general/repository/types/repository-update-params.type.js +2 -2
  49. package/esm2015/lib/domain/general/repository/update.repository.js +2 -2
  50. package/esm2015/lib/domain/index.js +7 -7
  51. package/esm2015/lib/domain/location/index.js +2 -2
  52. package/esm2015/lib/domain/location/models/address.js +4 -4
  53. package/esm2015/lib/domain/location/models/index.js +3 -3
  54. package/esm2015/lib/domain/location/models/types/index.js +4 -4
  55. package/esm2015/lib/domain/location/models/types/location-bound.type.js +2 -2
  56. package/esm2015/lib/domain/location/models/types/location-geometry.type.js +2 -2
  57. package/esm2015/lib/domain/location/models/types/location-lat-lng.type.js +2 -2
  58. package/esm2015/lib/domain/shop-settings/index.js +3 -3
  59. package/esm2015/lib/domain/shop-settings/models/home.js +7 -7
  60. package/esm2015/lib/domain/shop-settings/models/index.js +4 -4
  61. package/esm2015/lib/domain/shop-settings/models/shop-menu.js +7 -7
  62. package/esm2015/lib/domain/shop-settings/models/types/banner.type.js +2 -2
  63. package/esm2015/lib/domain/shop-settings/models/types/benefit.type.js +2 -2
  64. package/esm2015/lib/domain/shop-settings/models/types/index.js +5 -5
  65. package/esm2015/lib/domain/shop-settings/models/types/menu-nav.type.js +2 -2
  66. package/esm2015/lib/domain/shop-settings/models/types/sub-menu.type.js +2 -2
  67. package/esm2015/lib/domain/shop-settings/repositories/home.repository.js +2 -2
  68. package/esm2015/lib/domain/shop-settings/repositories/index.js +3 -3
  69. package/esm2015/lib/domain/shop-settings/repositories/shop-menu.repository.js +2 -2
  70. package/esm2015/lib/domain/shopping/index.js +3 -3
  71. package/esm2015/lib/domain/shopping/models/buy-2-win.js +7 -7
  72. package/esm2015/lib/domain/shopping/models/checkout.js +7 -7
  73. package/esm2015/lib/domain/shopping/models/coupons/coupon.js +15 -15
  74. package/esm2015/lib/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js +6 -6
  75. package/esm2015/lib/domain/shopping/models/coupons/enums/coupon-types.enum.js +8 -8
  76. package/esm2015/lib/domain/shopping/models/coupons/enums/exclusivities.enum.js +7 -7
  77. package/esm2015/lib/domain/shopping/models/coupons/enums/index.js +4 -4
  78. package/esm2015/lib/domain/shopping/models/coupons/financial-coupon.js +28 -28
  79. package/esm2015/lib/domain/shopping/models/coupons/index.js +4 -4
  80. package/esm2015/lib/domain/shopping/models/enums/checkout-types.enum.js +6 -6
  81. package/esm2015/lib/domain/shopping/models/enums/index.js +3 -3
  82. package/esm2015/lib/domain/shopping/models/enums/order-status.enum.js +12 -12
  83. package/esm2015/lib/domain/shopping/models/index.js +12 -12
  84. package/esm2015/lib/domain/shopping/models/line-item.js +4 -4
  85. package/esm2015/lib/domain/shopping/models/order.js +4 -4
  86. package/esm2015/lib/domain/shopping/models/payment.js +129 -129
  87. package/esm2015/lib/domain/shopping/models/shipping-method.js +7 -7
  88. package/esm2015/lib/domain/shopping/models/subscription/checkout.js +7 -7
  89. package/esm2015/lib/domain/shopping/models/subscription/index.js +3 -3
  90. package/esm2015/lib/domain/shopping/models/subscription/plan.js +7 -7
  91. package/esm2015/lib/domain/shopping/models/types/index.js +8 -8
  92. package/esm2015/lib/domain/shopping/models/types/payment-address.type.js +2 -2
  93. package/esm2015/lib/domain/shopping/models/types/payment-billing.type.js +2 -2
  94. package/esm2015/lib/domain/shopping/models/types/payment-card.type.js +2 -2
  95. package/esm2015/lib/domain/shopping/models/types/payment-customer.type.js +2 -2
  96. package/esm2015/lib/domain/shopping/models/types/payment-document.type.js +2 -2
  97. package/esm2015/lib/domain/shopping/models/types/payment-item.type.js +2 -2
  98. package/esm2015/lib/domain/shopping/models/types/payment-shipping.type.js +2 -2
  99. package/esm2015/lib/domain/shopping/repositories/buy-2-win.repository.js +2 -2
  100. package/esm2015/lib/domain/shopping/repositories/checkout.repository.js +2 -2
  101. package/esm2015/lib/domain/shopping/repositories/coupon.repository.js +2 -2
  102. package/esm2015/lib/domain/shopping/repositories/index.js +7 -7
  103. package/esm2015/lib/domain/shopping/repositories/order.repository.js +2 -2
  104. package/esm2015/lib/domain/shopping/repositories/payment.repository.js +2 -2
  105. package/esm2015/lib/domain/shopping/repositories/subscription/checkout.repository.js +2 -2
  106. package/esm2015/lib/domain/shopping/repositories/subscription/index.js +3 -3
  107. package/esm2015/lib/domain/shopping/repositories/subscription/plan.repository.js +2 -2
  108. package/esm2015/lib/domain/users/errors/index.js +2 -2
  109. package/esm2015/lib/domain/users/errors/unauthorized.error.js +7 -7
  110. package/esm2015/lib/domain/users/index.js +6 -6
  111. package/esm2015/lib/domain/users/models/beauty-profile.js +12 -12
  112. package/esm2015/lib/domain/users/models/enums/area.enum.js +13 -13
  113. package/esm2015/lib/domain/users/models/enums/beard-sizes.enum.js +9 -9
  114. package/esm2015/lib/domain/users/models/enums/hair-types.enum.js +9 -9
  115. package/esm2015/lib/domain/users/models/enums/index.js +7 -7
  116. package/esm2015/lib/domain/users/models/enums/office-position.enum.js +8 -8
  117. package/esm2015/lib/domain/users/models/enums/user-type.enum.js +10 -10
  118. package/esm2015/lib/domain/users/models/index.js +6 -6
  119. package/esm2015/lib/domain/users/models/subscription/edition.js +7 -7
  120. package/esm2015/lib/domain/users/models/subscription/enums/billing-status.enum.js +5 -5
  121. package/esm2015/lib/domain/users/models/subscription/enums/edition-status.enum.js +5 -5
  122. package/esm2015/lib/domain/users/models/subscription/enums/index.js +5 -5
  123. package/esm2015/lib/domain/users/models/subscription/enums/payment-type.enum.js +7 -7
  124. package/esm2015/lib/domain/users/models/subscription/enums/status.enum.js +5 -5
  125. package/esm2015/lib/domain/users/models/subscription/index.js +5 -5
  126. package/esm2015/lib/domain/users/models/subscription/payment.js +7 -7
  127. package/esm2015/lib/domain/users/models/subscription/subscription.js +7 -7
  128. package/esm2015/lib/domain/users/models/user-address.js +7 -7
  129. package/esm2015/lib/domain/users/models/user.js +17 -17
  130. package/esm2015/lib/domain/users/repositories/beauty-profile.repository.js +2 -2
  131. package/esm2015/lib/domain/users/repositories/edition.repository.js +2 -2
  132. package/esm2015/lib/domain/users/repositories/index.js +7 -7
  133. package/esm2015/lib/domain/users/repositories/subscription-payment.repository.js +2 -2
  134. package/esm2015/lib/domain/users/repositories/subscription.repository.js +2 -2
  135. package/esm2015/lib/domain/users/repositories/user-address.repository.js +2 -2
  136. package/esm2015/lib/domain/users/repositories/user.repository.js +2 -2
  137. package/esm2015/lib/domain/users/services/authentication.service.js +2 -2
  138. package/esm2015/lib/domain/users/services/index.js +2 -2
  139. package/esm2015/lib/domain/users/use-cases/authentication.js +40 -40
  140. package/esm2015/lib/domain/users/use-cases/index.js +3 -3
  141. package/esm2015/lib/domain/users/use-cases/signout.js +12 -12
  142. package/esm2015/lib/errors/duplicated-results.error.js +7 -7
  143. package/esm2015/lib/errors/index.js +5 -5
  144. package/esm2015/lib/errors/invalid-argument.error.js +7 -7
  145. package/esm2015/lib/errors/not-found.error.js +7 -7
  146. package/esm2015/lib/errors/required-argument.error.js +8 -8
  147. package/esm2015/lib/index.js +5 -5
  148. package/esm2015/lib/infra/firebase/auth/authentication-firebase-auth.service.js +27 -27
  149. package/esm2015/lib/infra/firebase/auth/index.js +2 -2
  150. package/esm2015/lib/infra/firebase/firestore/index.js +4 -4
  151. package/esm2015/lib/infra/firebase/firestore/mixins/index.js +10 -10
  152. package/esm2015/lib/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +30 -30
  153. package/esm2015/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +10 -10
  154. package/esm2015/lib/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +18 -18
  155. package/esm2015/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +64 -64
  156. package/esm2015/lib/infra/firebase/firestore/mixins/with-firestore.mixin.js +26 -26
  157. package/esm2015/lib/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +24 -24
  158. package/esm2015/lib/infra/firebase/firestore/mixins/with-helpers.mixin.js +17 -17
  159. package/esm2015/lib/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +11 -11
  160. package/esm2015/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +45 -45
  161. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +74 -50
  162. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/index.js +4 -4
  163. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +23 -12
  164. package/esm2015/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.js +14 -14
  165. package/esm2015/lib/infra/firebase/firestore/repositories/index.js +5 -5
  166. package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.js +12 -12
  167. package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/index.js +3 -3
  168. package/esm2015/lib/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.js +12 -12
  169. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.js +12 -12
  170. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.js +12 -12
  171. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.js +12 -12
  172. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +12 -12
  173. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/index.js +8 -8
  174. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.js +12 -12
  175. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.js +12 -12
  176. package/esm2015/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.js +12 -12
  177. package/esm2015/lib/infra/firebase/firestore/repositories/users/index.js +7 -7
  178. package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.js +14 -14
  179. package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.js +12 -12
  180. package/esm2015/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.js +14 -14
  181. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.js +14 -14
  182. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.js +14 -14
  183. package/esm2015/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.js +40 -40
  184. package/esm2015/lib/infra/firebase/firestore/types/firestore-sub.repository.type.js +2 -2
  185. package/esm2015/lib/infra/firebase/firestore/types/firestore.helpers.type.js +2 -2
  186. package/esm2015/lib/infra/firebase/firestore/types/firestore.repository.type.js +2 -2
  187. package/esm2015/lib/infra/firebase/firestore/types/index.js +4 -4
  188. package/esm2015/lib/infra/firebase/index.js +3 -3
  189. package/esm2015/lib/infra/index.js +2 -2
  190. package/esm2015/lib/utils/index.js +5 -5
  191. package/esm2015/lib/utils/mixins/base.mixin.js +6 -6
  192. package/esm2015/lib/utils/mixins/index.js +3 -3
  193. package/esm2015/lib/utils/mixins/mixin-ctor.type.js +2 -2
  194. package/esm2015/lib/utils/types/index.js +2 -2
  195. package/esm2015/lib/utils/types/prop.type.js +2 -2
  196. package/esm2015/public-api.js +2 -2
  197. package/fesm2015/infrab4a-connect.js +978 -944
  198. package/fesm2015/infrab4a-connect.js.map +1 -1
  199. package/infrab4a-connect.d.ts +5 -5
  200. package/lib/domain/catalog/index.d.ts +2 -2
  201. package/lib/domain/catalog/models/category.d.ts +20 -20
  202. package/lib/domain/catalog/models/enums/index.d.ts +1 -1
  203. package/lib/domain/catalog/models/enums/shops.enum.d.ts +4 -4
  204. package/lib/domain/catalog/models/index.d.ts +5 -5
  205. package/lib/domain/catalog/models/product.d.ts +32 -31
  206. package/lib/domain/catalog/models/types/category-condition.type.d.ts +4 -4
  207. package/lib/domain/catalog/models/types/category-filter.type.d.ts +4 -4
  208. package/lib/domain/catalog/models/types/index.d.ts +7 -7
  209. package/lib/domain/catalog/models/types/product-review.type.d.ts +12 -12
  210. package/lib/domain/catalog/models/types/shops-description.type.d.ts +7 -7
  211. package/lib/domain/catalog/models/types/shops-price.type.d.ts +10 -10
  212. package/lib/domain/catalog/models/types/stock.type.d.ts +3 -3
  213. package/lib/domain/catalog/models/types/variant-grade.type.d.ts +4 -4
  214. package/lib/domain/catalog/models/variant.d.ts +12 -12
  215. package/lib/domain/catalog/repositories/category.repository.d.ts +12 -11
  216. package/lib/domain/catalog/repositories/index.d.ts +3 -3
  217. package/lib/domain/catalog/repositories/product.repository.d.ts +5 -4
  218. package/lib/domain/catalog/repositories/variant.repository.d.ts +4 -4
  219. package/lib/domain/general/index.d.ts +2 -2
  220. package/lib/domain/general/model/base-model-with-identifier-fields.d.ts +3 -3
  221. package/lib/domain/general/model/base.model.d.ts +6 -6
  222. package/lib/domain/general/model/identifier-fields.d.ts +4 -4
  223. package/lib/domain/general/model/index.d.ts +4 -4
  224. package/lib/domain/general/model/types/base-model-builder.type.d.ts +5 -5
  225. package/lib/domain/general/model/types/index.d.ts +3 -3
  226. package/lib/domain/general/model/types/non-function-properties.type.d.ts +2 -2
  227. package/lib/domain/general/model/types/non-function-property-name.type.d.ts +3 -3
  228. package/lib/domain/general/repository/create.repository.d.ts +5 -5
  229. package/lib/domain/general/repository/crud.repository.d.ts +7 -7
  230. package/lib/domain/general/repository/delete.repository.d.ts +5 -5
  231. package/lib/domain/general/repository/enums/index.d.ts +2 -2
  232. package/lib/domain/general/repository/enums/update-option-actions.enum.d.ts +7 -7
  233. package/lib/domain/general/repository/enums/where.enum.d.ts +9 -9
  234. package/lib/domain/general/repository/find.repository.d.ts +5 -5
  235. package/lib/domain/general/repository/get.repository.d.ts +5 -5
  236. package/lib/domain/general/repository/index.d.ts +9 -9
  237. package/lib/domain/general/repository/read.repository.d.ts +5 -5
  238. package/lib/domain/general/repository/types/index.d.ts +5 -5
  239. package/lib/domain/general/repository/types/repository-find-filters.type.d.ts +10 -10
  240. package/lib/domain/general/repository/types/repository-find-result.type.d.ts +4 -4
  241. package/lib/domain/general/repository/types/repository-limit-options.type.d.ts +4 -4
  242. package/lib/domain/general/repository/types/repository-order-by-list.type.d.ts +5 -5
  243. package/lib/domain/general/repository/types/repository-update-params.type.d.ts +11 -11
  244. package/lib/domain/general/repository/update.repository.d.ts +5 -5
  245. package/lib/domain/index.d.ts +6 -6
  246. package/lib/domain/location/index.d.ts +1 -1
  247. package/lib/domain/location/models/address.d.ts +21 -21
  248. package/lib/domain/location/models/index.d.ts +2 -2
  249. package/lib/domain/location/models/types/index.d.ts +3 -3
  250. package/lib/domain/location/models/types/location-bound.type.d.ts +6 -6
  251. package/lib/domain/location/models/types/location-geometry.type.d.ts +7 -7
  252. package/lib/domain/location/models/types/location-lat-lng.type.d.ts +4 -4
  253. package/lib/domain/shop-settings/index.d.ts +2 -2
  254. package/lib/domain/shop-settings/models/home.d.ts +17 -17
  255. package/lib/domain/shop-settings/models/index.d.ts +3 -3
  256. package/lib/domain/shop-settings/models/shop-menu.d.ts +7 -7
  257. package/lib/domain/shop-settings/models/types/banner.type.d.ts +6 -6
  258. package/lib/domain/shop-settings/models/types/benefit.type.d.ts +5 -5
  259. package/lib/domain/shop-settings/models/types/index.d.ts +4 -4
  260. package/lib/domain/shop-settings/models/types/menu-nav.type.d.ts +8 -8
  261. package/lib/domain/shop-settings/models/types/sub-menu.type.d.ts +8 -8
  262. package/lib/domain/shop-settings/repositories/home.repository.d.ts +4 -4
  263. package/lib/domain/shop-settings/repositories/index.d.ts +2 -2
  264. package/lib/domain/shop-settings/repositories/shop-menu.repository.d.ts +4 -4
  265. package/lib/domain/shopping/index.d.ts +2 -2
  266. package/lib/domain/shopping/models/buy-2-win.d.ts +18 -18
  267. package/lib/domain/shopping/models/checkout.d.ts +28 -28
  268. package/lib/domain/shopping/models/coupons/coupon.d.ts +25 -25
  269. package/lib/domain/shopping/models/coupons/enums/coupon-subtypes.enum.d.ts +4 -4
  270. package/lib/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +6 -6
  271. package/lib/domain/shopping/models/coupons/enums/exclusivities.enum.d.ts +5 -5
  272. package/lib/domain/shopping/models/coupons/enums/index.d.ts +3 -3
  273. package/lib/domain/shopping/models/coupons/financial-coupon.d.ts +8 -8
  274. package/lib/domain/shopping/models/coupons/index.d.ts +3 -3
  275. package/lib/domain/shopping/models/enums/checkout-types.enum.d.ts +4 -4
  276. package/lib/domain/shopping/models/enums/index.d.ts +2 -2
  277. package/lib/domain/shopping/models/enums/order-status.enum.d.ts +10 -10
  278. package/lib/domain/shopping/models/index.d.ts +11 -11
  279. package/lib/domain/shopping/models/line-item.d.ts +7 -7
  280. package/lib/domain/shopping/models/order.d.ts +7 -7
  281. package/lib/domain/shopping/models/payment.d.ts +69 -69
  282. package/lib/domain/shopping/models/shipping-method.d.ts +18 -18
  283. package/lib/domain/shopping/models/subscription/checkout.d.ts +23 -23
  284. package/lib/domain/shopping/models/subscription/index.d.ts +2 -2
  285. package/lib/domain/shopping/models/subscription/plan.d.ts +12 -12
  286. package/lib/domain/shopping/models/types/index.d.ts +7 -7
  287. package/lib/domain/shopping/models/types/payment-address.type.d.ts +12 -12
  288. package/lib/domain/shopping/models/types/payment-billing.type.d.ts +7 -7
  289. package/lib/domain/shopping/models/types/payment-card.type.d.ts +14 -14
  290. package/lib/domain/shopping/models/types/payment-customer.type.d.ts +18 -18
  291. package/lib/domain/shopping/models/types/payment-document.type.d.ts +6 -6
  292. package/lib/domain/shopping/models/types/payment-item.type.d.ts +11 -11
  293. package/lib/domain/shopping/models/types/payment-shipping.type.d.ts +10 -10
  294. package/lib/domain/shopping/repositories/buy-2-win.repository.d.ts +4 -4
  295. package/lib/domain/shopping/repositories/checkout.repository.d.ts +4 -4
  296. package/lib/domain/shopping/repositories/coupon.repository.d.ts +4 -4
  297. package/lib/domain/shopping/repositories/index.d.ts +6 -6
  298. package/lib/domain/shopping/repositories/order.repository.d.ts +4 -4
  299. package/lib/domain/shopping/repositories/payment.repository.d.ts +4 -4
  300. package/lib/domain/shopping/repositories/subscription/checkout.repository.d.ts +4 -4
  301. package/lib/domain/shopping/repositories/subscription/index.d.ts +2 -2
  302. package/lib/domain/shopping/repositories/subscription/plan.repository.d.ts +4 -4
  303. package/lib/domain/users/errors/index.d.ts +1 -1
  304. package/lib/domain/users/errors/unauthorized.error.d.ts +4 -4
  305. package/lib/domain/users/index.d.ts +5 -5
  306. package/lib/domain/users/models/beauty-profile.d.ts +12 -12
  307. package/lib/domain/users/models/enums/area.enum.d.ts +11 -11
  308. package/lib/domain/users/models/enums/beard-sizes.enum.d.ts +7 -7
  309. package/lib/domain/users/models/enums/hair-types.enum.d.ts +7 -7
  310. package/lib/domain/users/models/enums/index.d.ts +6 -6
  311. package/lib/domain/users/models/enums/office-position.enum.d.ts +6 -6
  312. package/lib/domain/users/models/enums/user-type.enum.d.ts +8 -8
  313. package/lib/domain/users/models/index.d.ts +5 -5
  314. package/lib/domain/users/models/subscription/edition.d.ts +15 -15
  315. package/lib/domain/users/models/subscription/enums/billing-status.enum.d.ts +3 -3
  316. package/lib/domain/users/models/subscription/enums/edition-status.enum.d.ts +3 -3
  317. package/lib/domain/users/models/subscription/enums/index.d.ts +4 -4
  318. package/lib/domain/users/models/subscription/enums/payment-type.enum.d.ts +5 -5
  319. package/lib/domain/users/models/subscription/enums/status.enum.d.ts +3 -3
  320. package/lib/domain/users/models/subscription/index.d.ts +4 -4
  321. package/lib/domain/users/models/subscription/payment.d.ts +14 -14
  322. package/lib/domain/users/models/subscription/subscription.d.ts +30 -30
  323. package/lib/domain/users/models/user-address.d.ts +7 -7
  324. package/lib/domain/users/models/user.d.ts +23 -23
  325. package/lib/domain/users/repositories/beauty-profile.repository.d.ts +4 -4
  326. package/lib/domain/users/repositories/edition.repository.d.ts +4 -4
  327. package/lib/domain/users/repositories/index.d.ts +6 -6
  328. package/lib/domain/users/repositories/subscription-payment.repository.d.ts +4 -4
  329. package/lib/domain/users/repositories/subscription.repository.d.ts +4 -4
  330. package/lib/domain/users/repositories/user-address.repository.d.ts +4 -4
  331. package/lib/domain/users/repositories/user.repository.d.ts +4 -4
  332. package/lib/domain/users/services/authentication.service.d.ts +10 -10
  333. package/lib/domain/users/services/index.d.ts +1 -1
  334. package/lib/domain/users/use-cases/authentication.d.ts +21 -21
  335. package/lib/domain/users/use-cases/index.d.ts +2 -2
  336. package/lib/domain/users/use-cases/signout.d.ts +6 -6
  337. package/lib/errors/duplicated-results.error.d.ts +4 -4
  338. package/lib/errors/index.d.ts +4 -4
  339. package/lib/errors/invalid-argument.error.d.ts +4 -4
  340. package/lib/errors/not-found.error.d.ts +4 -4
  341. package/lib/errors/required-argument.error.d.ts +5 -5
  342. package/lib/index.d.ts +4 -4
  343. package/lib/infra/firebase/auth/authentication-firebase-auth.service.d.ts +9 -9
  344. package/lib/infra/firebase/auth/index.d.ts +1 -1
  345. package/lib/infra/firebase/firestore/index.d.ts +3 -3
  346. package/lib/infra/firebase/firestore/mixins/index.d.ts +9 -9
  347. package/lib/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +17 -17
  348. package/lib/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +29 -29
  349. package/lib/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +15 -15
  350. package/lib/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +20 -20
  351. package/lib/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +15 -15
  352. package/lib/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +15 -15
  353. package/lib/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +10 -10
  354. package/lib/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +14 -14
  355. package/lib/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +16 -16
  356. package/lib/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +55 -54
  357. package/lib/infra/firebase/firestore/repositories/catalog/index.d.ts +3 -3
  358. package/lib/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +50 -49
  359. package/lib/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +60 -60
  360. package/lib/infra/firebase/firestore/repositories/index.d.ts +4 -4
  361. package/lib/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +49 -49
  362. package/lib/infra/firebase/firestore/repositories/shop-settings/index.d.ts +2 -2
  363. package/lib/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +49 -49
  364. package/lib/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +49 -49
  365. package/lib/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +49 -49
  366. package/lib/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +49 -49
  367. package/lib/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +49 -49
  368. package/lib/infra/firebase/firestore/repositories/shopping/index.d.ts +7 -7
  369. package/lib/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +49 -49
  370. package/lib/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +49 -49
  371. package/lib/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +49 -49
  372. package/lib/infra/firebase/firestore/repositories/users/index.d.ts +6 -6
  373. package/lib/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +60 -60
  374. package/lib/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +49 -49
  375. package/lib/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +60 -60
  376. package/lib/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +60 -60
  377. package/lib/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +60 -60
  378. package/lib/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +52 -52
  379. package/lib/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +6 -6
  380. package/lib/infra/firebase/firestore/types/firestore.helpers.type.d.ts +8 -8
  381. package/lib/infra/firebase/firestore/types/firestore.repository.type.d.ts +8 -8
  382. package/lib/infra/firebase/firestore/types/index.d.ts +3 -3
  383. package/lib/infra/firebase/index.d.ts +2 -2
  384. package/lib/infra/index.d.ts +1 -1
  385. package/lib/utils/index.d.ts +4 -4
  386. package/lib/utils/mixins/base.mixin.d.ts +3 -3
  387. package/lib/utils/mixins/index.d.ts +2 -2
  388. package/lib/utils/mixins/mixin-ctor.type.d.ts +1 -1
  389. package/lib/utils/types/index.d.ts +1 -1
  390. package/lib/utils/types/prop.type.d.ts +1 -1
  391. package/package.json +2 -2
  392. package/public-api.d.ts +1 -1
@@ -6,1012 +6,1046 @@ import { Md5 } from 'ts-md5';
6
6
  import firebase from 'firebase';
7
7
  import firebase$1 from 'firebase/app';
8
8
 
9
- class BaseModel {
10
- constructor(args) {
11
- Object.assign(this, args);
12
- }
13
- static toInstance(data) {
14
- return plainToClass(this, data);
15
- }
16
- toPlain() {
17
- return classToPlain(this, { exposeUnsetFields: false });
18
- }
19
- }
20
-
21
- var Where;
22
- (function (Where) {
23
- Where["EQUALS"] = "==";
24
- Where["GT"] = ">";
25
- Where["GTE"] = ">=";
26
- Where["IN"] = "in";
27
- Where["LT"] = "<";
28
- Where["LTE"] = "<=";
29
- Where["LIKE"] = "like";
9
+ class BaseModel {
10
+ constructor(args) {
11
+ Object.assign(this, args);
12
+ }
13
+ static toInstance(data) {
14
+ return plainToClass(this, data);
15
+ }
16
+ toPlain() {
17
+ return classToPlain(this, { exposeUnsetFields: false });
18
+ }
19
+ }
20
+
21
+ var Where;
22
+ (function (Where) {
23
+ Where["EQUALS"] = "==";
24
+ Where["GT"] = ">";
25
+ Where["GTE"] = ">=";
26
+ Where["IN"] = "in";
27
+ Where["LT"] = "<";
28
+ Where["LTE"] = "<=";
29
+ Where["LIKE"] = "like";
30
30
  })(Where || (Where = {}));
31
31
 
32
- var UpdateOptionActions;
33
- (function (UpdateOptionActions) {
34
- UpdateOptionActions["UPDATE"] = "update";
35
- UpdateOptionActions["MERGE"] = "merge";
36
- UpdateOptionActions["REMOVE"] = "remove";
37
- UpdateOptionActions["REMOVE_FIELD"] = "removeField";
38
- UpdateOptionActions["NULL"] = "null";
32
+ var UpdateOptionActions;
33
+ (function (UpdateOptionActions) {
34
+ UpdateOptionActions["UPDATE"] = "update";
35
+ UpdateOptionActions["MERGE"] = "merge";
36
+ UpdateOptionActions["REMOVE"] = "remove";
37
+ UpdateOptionActions["REMOVE_FIELD"] = "removeField";
38
+ UpdateOptionActions["NULL"] = "null";
39
39
  })(UpdateOptionActions || (UpdateOptionActions = {}));
40
40
 
41
- var UserType;
42
- (function (UserType) {
43
- UserType["B2C"] = "Cliente Transacional";
44
- UserType["GlamGirl"] = "Glamgirl";
45
- UserType["MensBoy"] = "Mensboy";
46
- UserType["B2B"] = "Company";
47
- UserType["Collaborator"] = "Funcion\u00E1rio";
48
- UserType["Influencer"] = "Influencer";
41
+ var UserType;
42
+ (function (UserType) {
43
+ UserType["B2C"] = "Cliente Transacional";
44
+ UserType["GlamGirl"] = "Glamgirl";
45
+ UserType["MensBoy"] = "Mensboy";
46
+ UserType["B2B"] = "Company";
47
+ UserType["Collaborator"] = "Funcion\u00E1rio";
48
+ UserType["Influencer"] = "Influencer";
49
49
  })(UserType || (UserType = {}));
50
50
 
51
- var BeardSizes;
52
- (function (BeardSizes) {
53
- BeardSizes["BIG"] = "Grande";
54
- BeardSizes["MEDIUM"] = "M\u00E9dia";
55
- BeardSizes["SHORT"] = "Curta";
56
- BeardSizes["MUSTACHE"] = "Bigode";
57
- BeardSizes["NOTHING"] = "Sem Barba";
51
+ var BeardSizes;
52
+ (function (BeardSizes) {
53
+ BeardSizes["BIG"] = "Grande";
54
+ BeardSizes["MEDIUM"] = "M\u00E9dia";
55
+ BeardSizes["SHORT"] = "Curta";
56
+ BeardSizes["MUSTACHE"] = "Bigode";
57
+ BeardSizes["NOTHING"] = "Sem Barba";
58
58
  })(BeardSizes || (BeardSizes = {}));
59
59
 
60
- var HairTypes;
61
- (function (HairTypes) {
62
- HairTypes["Smooth"] = "Liso";
63
- HairTypes["WAVY"] = "Ondulado";
64
- HairTypes["CURLY"] = "Cacheado";
65
- HairTypes["FRIZZY"] = "Crespo";
66
- HairTypes["BALD"] = "Sou careca";
60
+ var HairTypes;
61
+ (function (HairTypes) {
62
+ HairTypes["Smooth"] = "Liso";
63
+ HairTypes["WAVY"] = "Ondulado";
64
+ HairTypes["CURLY"] = "Cacheado";
65
+ HairTypes["FRIZZY"] = "Crespo";
66
+ HairTypes["BALD"] = "Sou careca";
67
67
  })(HairTypes || (HairTypes = {}));
68
68
 
69
- var Area;
70
- (function (Area) {
71
- Area["GP"] = "Geral";
72
- Area["CRM"] = "CRM";
73
- Area["MediaProd"] = "Media Production";
74
- Area["Tech"] = "Tecnologia";
75
- Area["Transactional"] = "Transacional";
76
- Area["Operations"] = "Opera\u00E7\u00F5es";
77
- Area["Sales"] = "Comercial";
78
- Area["Finantial"] = "Financeiro";
79
- Area["HR"] = "RH";
69
+ var Area;
70
+ (function (Area) {
71
+ Area["GP"] = "Geral";
72
+ Area["CRM"] = "CRM";
73
+ Area["MediaProd"] = "Media Production";
74
+ Area["Tech"] = "Tecnologia";
75
+ Area["Transactional"] = "Transacional";
76
+ Area["Operations"] = "Opera\u00E7\u00F5es";
77
+ Area["Sales"] = "Comercial";
78
+ Area["Finantial"] = "Financeiro";
79
+ Area["HR"] = "RH";
80
80
  })(Area || (Area = {}));
81
81
 
82
- var OfficePosition;
83
- (function (OfficePosition) {
84
- OfficePosition["Intern"] = "Estagi\u00E1rio";
85
- OfficePosition["Analyst"] = "Analista";
86
- OfficePosition["Manager"] = "Gerente";
87
- OfficePosition["Director"] = "Diretor";
82
+ var OfficePosition;
83
+ (function (OfficePosition) {
84
+ OfficePosition["Intern"] = "Estagi\u00E1rio";
85
+ OfficePosition["Analyst"] = "Analista";
86
+ OfficePosition["Manager"] = "Gerente";
87
+ OfficePosition["Director"] = "Diretor";
88
88
  })(OfficePosition || (OfficePosition = {}));
89
89
 
90
- var BillingStatus;
91
- (function (BillingStatus) {
92
- BillingStatus["PAYED"] = "PAGO";
90
+ var BillingStatus;
91
+ (function (BillingStatus) {
92
+ BillingStatus["PAYED"] = "PAGO";
93
93
  })(BillingStatus || (BillingStatus = {}));
94
94
 
95
- var EditionStatus;
96
- (function (EditionStatus) {
97
- EditionStatus["ALLOCATION_WAITING"] = "Aguardando aloca\u00E7\u00E3o";
95
+ var EditionStatus;
96
+ (function (EditionStatus) {
97
+ EditionStatus["ALLOCATION_WAITING"] = "Aguardando aloca\u00E7\u00E3o";
98
98
  })(EditionStatus || (EditionStatus = {}));
99
99
 
100
- var PaymentType;
101
- (function (PaymentType) {
102
- PaymentType["AQUISITION"] = "Aquisi\u00E7\u00E3o";
103
- PaymentType["RENEWAL"] = "Renova\u00E7\u00E3o";
104
- PaymentType["FREIGHT"] = "mudan\u00E7a de endere\u00E7o, Frete";
100
+ var PaymentType;
101
+ (function (PaymentType) {
102
+ PaymentType["AQUISITION"] = "Aquisi\u00E7\u00E3o";
103
+ PaymentType["RENEWAL"] = "Renova\u00E7\u00E3o";
104
+ PaymentType["FREIGHT"] = "mudan\u00E7a de endere\u00E7o, Frete";
105
105
  })(PaymentType || (PaymentType = {}));
106
106
 
107
- var Status;
108
- (function (Status) {
109
- Status["ACTIVE"] = "active";
107
+ var Status;
108
+ (function (Status) {
109
+ Status["ACTIVE"] = "active";
110
110
  })(Status || (Status = {}));
111
111
 
112
- class Edition extends BaseModel {
113
- identifierFields() {
114
- return ['id'];
115
- }
116
- }
117
-
118
- class SubscriptionPayment extends BaseModel {
119
- identifierFields() {
120
- return ['id'];
121
- }
122
- }
123
-
124
- class Subscription extends BaseModel {
125
- identifierFields() {
126
- return ['id'];
127
- }
128
- }
129
-
130
- class User extends BaseModel {
131
- static toInstance(data) {
132
- const instance = super.toInstance(data);
133
- instance.displayName = `${data.firstName} ${data.lastName}`;
134
- return instance;
135
- }
136
- identifierFields() {
137
- return ['id'];
138
- }
139
- toPlain() {
140
- const plain = super.toPlain();
141
- delete plain.beautyProfile;
142
- return plain;
143
- }
144
- }
145
-
146
- class BeautyProfile extends BaseModel {
147
- toPlain() {
148
- const plain = super.toPlain();
149
- delete plain.id;
150
- return plain;
151
- }
152
- identifierFields() {
153
- return ['id'];
154
- }
155
- }
156
-
157
- class Address extends BaseModel {
158
- }
159
-
160
- class UserAddress extends Address {
161
- identifierFields() {
162
- return ['id'];
163
- }
164
- }
165
-
166
- class Base {
167
- constructor(...args) {
168
- Object.assign(this, ...args);
169
- }
170
- }
171
-
172
- class UnauthorizedError extends Error {
173
- constructor(message) {
174
- super(message);
175
- this.message = message;
176
- }
177
- }
178
-
179
- var SignInMethods;
180
- (function (SignInMethods) {
181
- SignInMethods["EMAIL_PASSWORD"] = "email_password";
182
- SignInMethods["GOOGLE"] = "google";
183
- })(SignInMethods || (SignInMethods = {}));
184
- class Authentication {
185
- constructor(authService, userRepository) {
186
- this.authService = authService;
187
- this.userRepository = userRepository;
188
- }
189
- signIn({ email, password }, signInMethod) {
190
- return __awaiter(this, void 0, void 0, function* () {
191
- const method = this.getServiceByMethod(signInMethod);
192
- const userAuth = yield this.authService[method]({ email, password });
193
- const user = this.userRepository.get(userAuth);
194
- if (!isNil(user))
195
- return user;
196
- if (/^.+@b4a.com.br$/.test(userAuth.email))
197
- return this.createsUserByCredential(userAuth);
198
- throw new UnauthorizedError('Invalid credentials');
199
- });
200
- }
201
- getServiceByMethod(signInMethod) {
202
- return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
203
- }
204
- createsUserByCredential(user) {
205
- var _a;
206
- return __awaiter(this, void 0, void 0, function* () {
207
- const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
208
- const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
209
- lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
210
- return this.userRepository.create(person);
211
- });
212
- }
213
- }
214
-
215
- class SignOut {
216
- constructor(authService) {
217
- this.authService = authService;
218
- }
219
- signOut() {
220
- return __awaiter(this, void 0, void 0, function* () {
221
- yield this.authService.signOut();
222
- });
223
- }
224
- }
225
-
226
- var Shops;
227
- (function (Shops) {
228
- Shops["MENSMARKET"] = "Men's Market";
229
- Shops["GLAMSHOP"] = "Glamshop";
112
+ class Edition extends BaseModel {
113
+ identifierFields() {
114
+ return ['id'];
115
+ }
116
+ }
117
+
118
+ class SubscriptionPayment extends BaseModel {
119
+ identifierFields() {
120
+ return ['id'];
121
+ }
122
+ }
123
+
124
+ class Subscription extends BaseModel {
125
+ identifierFields() {
126
+ return ['id'];
127
+ }
128
+ }
129
+
130
+ class User extends BaseModel {
131
+ static toInstance(data) {
132
+ const instance = super.toInstance(data);
133
+ instance.displayName = `${data.firstName} ${data.lastName}`;
134
+ return instance;
135
+ }
136
+ identifierFields() {
137
+ return ['id'];
138
+ }
139
+ toPlain() {
140
+ const plain = super.toPlain();
141
+ delete plain.beautyProfile;
142
+ return plain;
143
+ }
144
+ }
145
+
146
+ class BeautyProfile extends BaseModel {
147
+ toPlain() {
148
+ const plain = super.toPlain();
149
+ delete plain.id;
150
+ return plain;
151
+ }
152
+ identifierFields() {
153
+ return ['id'];
154
+ }
155
+ }
156
+
157
+ class Address extends BaseModel {
158
+ }
159
+
160
+ class UserAddress extends Address {
161
+ identifierFields() {
162
+ return ['id'];
163
+ }
164
+ }
165
+
166
+ class Base {
167
+ constructor(...args) {
168
+ Object.assign(this, ...args);
169
+ }
170
+ }
171
+
172
+ class UnauthorizedError extends Error {
173
+ constructor(message) {
174
+ super(message);
175
+ this.message = message;
176
+ }
177
+ }
178
+
179
+ var SignInMethods;
180
+ (function (SignInMethods) {
181
+ SignInMethods["EMAIL_PASSWORD"] = "email_password";
182
+ SignInMethods["GOOGLE"] = "google";
183
+ })(SignInMethods || (SignInMethods = {}));
184
+ class Authentication {
185
+ constructor(authService, userRepository) {
186
+ this.authService = authService;
187
+ this.userRepository = userRepository;
188
+ }
189
+ signIn({ email, password }, signInMethod) {
190
+ return __awaiter(this, void 0, void 0, function* () {
191
+ const method = this.getServiceByMethod(signInMethod);
192
+ const userAuth = yield this.authService[method]({ email, password });
193
+ const user = this.userRepository.get(userAuth);
194
+ if (!isNil(user))
195
+ return user;
196
+ if (/^.+@b4a.com.br$/.test(userAuth.email))
197
+ return this.createsUserByCredential(userAuth);
198
+ throw new UnauthorizedError('Invalid credentials');
199
+ });
200
+ }
201
+ getServiceByMethod(signInMethod) {
202
+ return signInMethod === SignInMethods.EMAIL_PASSWORD ? 'signInWithEmailAndPassword' : 'signInWithGoogle';
203
+ }
204
+ createsUserByCredential(user) {
205
+ var _a;
206
+ return __awaiter(this, void 0, void 0, function* () {
207
+ const [firstName, lastName] = (_a = user.displayName) === null || _a === void 0 ? void 0 : _a.split(/\s/);
208
+ const person = User.toInstance(Object.assign(Object.assign({}, user), { cpf: '', birthday: new Date(), firstName,
209
+ lastName, acceptsNewsletter: false, area: Area.Transactional, officePosition: OfficePosition.Intern, type: UserType.Collaborator }));
210
+ return this.userRepository.create(person);
211
+ });
212
+ }
213
+ }
214
+
215
+ class SignOut {
216
+ constructor(authService) {
217
+ this.authService = authService;
218
+ }
219
+ signOut() {
220
+ return __awaiter(this, void 0, void 0, function* () {
221
+ yield this.authService.signOut();
222
+ });
223
+ }
224
+ }
225
+
226
+ var Shops;
227
+ (function (Shops) {
228
+ Shops["MENSMARKET"] = "Men's Market";
229
+ Shops["GLAMSHOP"] = "Glamshop";
230
230
  })(Shops || (Shops = {}));
231
231
 
232
- class Category extends BaseModel {
233
- identifierFields() {
234
- return ['id'];
235
- }
232
+ class Category extends BaseModel {
233
+ identifierFields() {
234
+ return ['id'];
235
+ }
236
236
  }
237
237
 
238
- class Product extends BaseModel {
239
- identifierFields() {
240
- return ['id'];
241
- }
238
+ class Product extends BaseModel {
239
+ identifierFields() {
240
+ return ['id'];
241
+ }
242
242
  }
243
243
 
244
- class Variant extends BaseModel {
245
- identifierFields() {
246
- return ['id'];
247
- }
244
+ class Variant extends BaseModel {
245
+ identifierFields() {
246
+ return ['id'];
247
+ }
248
248
  }
249
249
 
250
- var CouponTypes;
251
- (function (CouponTypes) {
252
- CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
253
- CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
254
- CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
255
- CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
250
+ var CouponTypes;
251
+ (function (CouponTypes) {
252
+ CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
253
+ CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
254
+ CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
255
+ CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
256
256
  })(CouponTypes || (CouponTypes = {}));
257
257
 
258
- var CouponSubtypes;
259
- (function (CouponSubtypes) {
260
- CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
261
- CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
258
+ var CouponSubtypes;
259
+ (function (CouponSubtypes) {
260
+ CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
261
+ CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
262
262
  })(CouponSubtypes || (CouponSubtypes = {}));
263
263
 
264
- var Exclusivities;
265
- (function (Exclusivities) {
266
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
267
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
268
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
264
+ var Exclusivities;
265
+ (function (Exclusivities) {
266
+ Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
267
+ Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
268
+ Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
269
269
  })(Exclusivities || (Exclusivities = {}));
270
270
 
271
- class Coupon extends BaseModel {
272
- identifierFields() {
273
- return ['id'];
274
- }
275
- }
276
- __decorate([
277
- Expose({ name: 'checkout_type' })
278
- ], Coupon.prototype, "checkoutType", void 0);
279
- __decorate([
280
- Expose({ name: 'exclusivity_type' })
271
+ class Coupon extends BaseModel {
272
+ identifierFields() {
273
+ return ['id'];
274
+ }
275
+ }
276
+ __decorate([
277
+ Expose({ name: 'checkout_type' })
278
+ ], Coupon.prototype, "checkoutType", void 0);
279
+ __decorate([
280
+ Expose({ name: 'exclusivity_type' })
281
281
  ], Coupon.prototype, "exclusivityType", void 0);
282
282
 
283
- var CheckoutTypes;
284
- (function (CheckoutTypes) {
285
- CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
286
- CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
283
+ var CheckoutTypes;
284
+ (function (CheckoutTypes) {
285
+ CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
286
+ CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
287
287
  })(CheckoutTypes || (CheckoutTypes = {}));
288
288
 
289
- const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
290
- class FinancialCoupon extends Coupon {
291
- constructor() {
292
- super(...arguments);
293
- this.type = CouponTypes.FINANCIAL;
294
- }
295
- static isFinancialCoupon(coupon) {
296
- return coupon.type === CouponTypes.FINANCIAL && !!coupon.subtype;
297
- }
298
- static createCoupon(userId) {
299
- return this.toInstance({
300
- name: Md5.hashStr(`${userId}_${Date.now}`).toString(),
301
- nickname: `${Date.now()}`,
302
- type: CouponTypes.FINANCIAL,
303
- subtype: CouponSubtypes.PERCENTAGE,
304
- checkoutType: CheckoutTypes.ECOMMERCE,
305
- discount: 30,
306
- user: userId,
307
- createdAt: new Date(Date.now()),
308
- expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
309
- });
310
- }
311
- }
312
-
313
- var OrderStatus;
314
- (function (OrderStatus) {
315
- OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
316
- OrderStatus["EM_PREPARO"] = "Preparando pedido";
317
- OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
318
- OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
319
- OrderStatus["ENVIADO"] = "Pedido Enviado";
320
- OrderStatus["ENTREGUE"] = "Pedido entregue";
321
- OrderStatus["CANCELADO"] = "Cancelado";
322
- OrderStatus["CREDIT_CARD"] = "credit_card";
289
+ const COUPON_EXPIRATION = 60 * 60 * 24 * 30;
290
+ class FinancialCoupon extends Coupon {
291
+ constructor() {
292
+ super(...arguments);
293
+ this.type = CouponTypes.FINANCIAL;
294
+ }
295
+ static isFinancialCoupon(coupon) {
296
+ return coupon.type === CouponTypes.FINANCIAL && !!coupon.subtype;
297
+ }
298
+ static createCoupon(userId) {
299
+ return this.toInstance({
300
+ name: Md5.hashStr(`${userId}_${Date.now}`).toString(),
301
+ nickname: `${Date.now()}`,
302
+ type: CouponTypes.FINANCIAL,
303
+ subtype: CouponSubtypes.PERCENTAGE,
304
+ checkoutType: CheckoutTypes.ECOMMERCE,
305
+ discount: 30,
306
+ user: userId,
307
+ createdAt: new Date(Date.now()),
308
+ expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
309
+ });
310
+ }
311
+ }
312
+
313
+ var OrderStatus;
314
+ (function (OrderStatus) {
315
+ OrderStatus["AGUARDANDO_PAGAMENTO"] = "Aguardando pagamento";
316
+ OrderStatus["EM_PREPARO"] = "Preparando pedido";
317
+ OrderStatus["NF_EMITIDA"] = "Nota Fiscal Emitida";
318
+ OrderStatus["AGUARDANDO_ENVIO"] = "Aguardando Transaportadora";
319
+ OrderStatus["ENVIADO"] = "Pedido Enviado";
320
+ OrderStatus["ENTREGUE"] = "Pedido entregue";
321
+ OrderStatus["CANCELADO"] = "Cancelado";
322
+ OrderStatus["CREDIT_CARD"] = "credit_card";
323
323
  })(OrderStatus || (OrderStatus = {}));
324
324
 
325
- class Checkout extends BaseModel {
326
- identifierFields() {
327
- return ['id'];
328
- }
329
- }
330
-
331
- class LineItem extends Product {
332
- }
333
-
334
- class Order extends Checkout {
335
- }
336
-
337
- class Payment extends BaseModel {
338
- identifierFields() {
339
- return ['id'];
340
- }
341
- }
342
- __decorate([
343
- Expose({ name: 'refuse_reason' })
344
- ], Payment.prototype, "refuseReason", void 0);
345
- __decorate([
346
- Expose({ name: 'status_reason' })
347
- ], Payment.prototype, "statusReason", void 0);
348
- __decorate([
349
- Expose({ name: 'acquirer_response_code' })
350
- ], Payment.prototype, "acquirerResponseCode", void 0);
351
- __decorate([
352
- Expose({ name: 'acquirer_name' })
353
- ], Payment.prototype, "acquirerName", void 0);
354
- __decorate([
355
- Expose({ name: 'acquirer_id' })
356
- ], Payment.prototype, "acquirerId", void 0);
357
- __decorate([
358
- Expose({ name: 'authorization_code' })
359
- ], Payment.prototype, "authorizationCode", void 0);
360
- __decorate([
361
- Expose({ name: 'soft_descriptor' })
362
- ], Payment.prototype, "softDescriptor", void 0);
363
- __decorate([
364
- Expose({ name: 'date_created' })
365
- ], Payment.prototype, "dateCreated", void 0);
366
- __decorate([
367
- Expose({ name: 'date_updated' })
368
- ], Payment.prototype, "dateUpdated", void 0);
369
- __decorate([
370
- Expose({ name: 'authorized_amount' })
371
- ], Payment.prototype, "authorizedAmount", void 0);
372
- __decorate([
373
- Expose({ name: 'paid_amount' })
374
- ], Payment.prototype, "paidAmount", void 0);
375
- __decorate([
376
- Expose({ name: 'refunded_amount' })
377
- ], Payment.prototype, "refundedAmount", void 0);
378
- __decorate([
379
- Expose({ name: 'card_holder_name' })
380
- ], Payment.prototype, "cardHolderName", void 0);
381
- __decorate([
382
- Expose({ name: 'card_last_digits' })
383
- ], Payment.prototype, "cardLastDigits", void 0);
384
- __decorate([
385
- Expose({ name: 'card_first_digits' })
386
- ], Payment.prototype, "cardFirstDigits", void 0);
387
- __decorate([
388
- Expose({ name: 'card_brand' })
389
- ], Payment.prototype, "cardBrand", void 0);
390
- __decorate([
391
- Expose({ name: 'card_pin_mode' })
392
- ], Payment.prototype, "cardPinMode", void 0);
393
- __decorate([
394
- Expose({ name: 'card_magstripe_fallback' })
395
- ], Payment.prototype, "cardMagstripeFallback", void 0);
396
- __decorate([
397
- Expose({ name: 'cvm_pin' })
398
- ], Payment.prototype, "cvmPin", void 0);
399
- __decorate([
400
- Expose({ name: 'postback_url' })
401
- ], Payment.prototype, "postbackUrl", void 0);
402
- __decorate([
403
- Expose({ name: 'payment_method' })
404
- ], Payment.prototype, "paymentMethod", void 0);
405
- __decorate([
406
- Expose({ name: 'capture_method' })
407
- ], Payment.prototype, "captureMethod", void 0);
408
- __decorate([
409
- Expose({ name: 'antifraud_score' })
410
- ], Payment.prototype, "antifraudScore", void 0);
411
- __decorate([
412
- Expose({ name: 'boleto_url' })
413
- ], Payment.prototype, "boletoUrl", void 0);
414
- __decorate([
415
- Expose({ name: 'boleto_barcode' })
416
- ], Payment.prototype, "boletoBarcode", void 0);
417
- __decorate([
418
- Expose({ name: 'boleto_expiration_date' })
419
- ], Payment.prototype, "boletoExpirationDate", void 0);
420
- __decorate([
421
- Expose({ name: 'subscription_id' })
422
- ], Payment.prototype, "subscriptionId", void 0);
423
- __decorate([
424
- Expose({ name: 'split_rules' })
425
- ], Payment.prototype, "splitRules", void 0);
426
- __decorate([
427
- Expose({ name: 'antifraud_metadata' })
428
- ], Payment.prototype, "antifraudMetadata", void 0);
429
- __decorate([
430
- Expose({ name: 'reference_key' })
431
- ], Payment.prototype, "referenceKey", void 0);
432
- __decorate([
433
- Expose({ name: 'local_transaction_id' })
434
- ], Payment.prototype, "localTransactionId", void 0);
435
- __decorate([
436
- Expose({ name: 'local_time' })
437
- ], Payment.prototype, "localTime", void 0);
438
- __decorate([
439
- Expose({ name: 'fraud_covered' })
440
- ], Payment.prototype, "fraudCovered", void 0);
441
- __decorate([
442
- Expose({ name: 'fraud_reimbursed' })
443
- ], Payment.prototype, "fraudReimbursed", void 0);
444
- __decorate([
445
- Expose({ name: 'order_id' })
446
- ], Payment.prototype, "orderId", void 0);
447
- __decorate([
448
- Expose({ name: 'risk_level' })
449
- ], Payment.prototype, "riskLevel", void 0);
450
- __decorate([
451
- Expose({ name: 'receipt_url' })
452
- ], Payment.prototype, "receiptUrl", void 0);
453
- __decorate([
454
- Expose({ name: 'private_label' })
455
- ], Payment.prototype, "privateLabel", void 0);
456
- __decorate([
457
- Expose({ name: 'pix_qr_code' })
458
- ], Payment.prototype, "pixQrCode", void 0);
459
- __decorate([
460
- Expose({ name: 'pix_expiration_date' })
325
+ class Checkout extends BaseModel {
326
+ identifierFields() {
327
+ return ['id'];
328
+ }
329
+ }
330
+
331
+ class LineItem extends Product {
332
+ }
333
+
334
+ class Order extends Checkout {
335
+ }
336
+
337
+ class Payment extends BaseModel {
338
+ identifierFields() {
339
+ return ['id'];
340
+ }
341
+ }
342
+ __decorate([
343
+ Expose({ name: 'refuse_reason' })
344
+ ], Payment.prototype, "refuseReason", void 0);
345
+ __decorate([
346
+ Expose({ name: 'status_reason' })
347
+ ], Payment.prototype, "statusReason", void 0);
348
+ __decorate([
349
+ Expose({ name: 'acquirer_response_code' })
350
+ ], Payment.prototype, "acquirerResponseCode", void 0);
351
+ __decorate([
352
+ Expose({ name: 'acquirer_name' })
353
+ ], Payment.prototype, "acquirerName", void 0);
354
+ __decorate([
355
+ Expose({ name: 'acquirer_id' })
356
+ ], Payment.prototype, "acquirerId", void 0);
357
+ __decorate([
358
+ Expose({ name: 'authorization_code' })
359
+ ], Payment.prototype, "authorizationCode", void 0);
360
+ __decorate([
361
+ Expose({ name: 'soft_descriptor' })
362
+ ], Payment.prototype, "softDescriptor", void 0);
363
+ __decorate([
364
+ Expose({ name: 'date_created' })
365
+ ], Payment.prototype, "dateCreated", void 0);
366
+ __decorate([
367
+ Expose({ name: 'date_updated' })
368
+ ], Payment.prototype, "dateUpdated", void 0);
369
+ __decorate([
370
+ Expose({ name: 'authorized_amount' })
371
+ ], Payment.prototype, "authorizedAmount", void 0);
372
+ __decorate([
373
+ Expose({ name: 'paid_amount' })
374
+ ], Payment.prototype, "paidAmount", void 0);
375
+ __decorate([
376
+ Expose({ name: 'refunded_amount' })
377
+ ], Payment.prototype, "refundedAmount", void 0);
378
+ __decorate([
379
+ Expose({ name: 'card_holder_name' })
380
+ ], Payment.prototype, "cardHolderName", void 0);
381
+ __decorate([
382
+ Expose({ name: 'card_last_digits' })
383
+ ], Payment.prototype, "cardLastDigits", void 0);
384
+ __decorate([
385
+ Expose({ name: 'card_first_digits' })
386
+ ], Payment.prototype, "cardFirstDigits", void 0);
387
+ __decorate([
388
+ Expose({ name: 'card_brand' })
389
+ ], Payment.prototype, "cardBrand", void 0);
390
+ __decorate([
391
+ Expose({ name: 'card_pin_mode' })
392
+ ], Payment.prototype, "cardPinMode", void 0);
393
+ __decorate([
394
+ Expose({ name: 'card_magstripe_fallback' })
395
+ ], Payment.prototype, "cardMagstripeFallback", void 0);
396
+ __decorate([
397
+ Expose({ name: 'cvm_pin' })
398
+ ], Payment.prototype, "cvmPin", void 0);
399
+ __decorate([
400
+ Expose({ name: 'postback_url' })
401
+ ], Payment.prototype, "postbackUrl", void 0);
402
+ __decorate([
403
+ Expose({ name: 'payment_method' })
404
+ ], Payment.prototype, "paymentMethod", void 0);
405
+ __decorate([
406
+ Expose({ name: 'capture_method' })
407
+ ], Payment.prototype, "captureMethod", void 0);
408
+ __decorate([
409
+ Expose({ name: 'antifraud_score' })
410
+ ], Payment.prototype, "antifraudScore", void 0);
411
+ __decorate([
412
+ Expose({ name: 'boleto_url' })
413
+ ], Payment.prototype, "boletoUrl", void 0);
414
+ __decorate([
415
+ Expose({ name: 'boleto_barcode' })
416
+ ], Payment.prototype, "boletoBarcode", void 0);
417
+ __decorate([
418
+ Expose({ name: 'boleto_expiration_date' })
419
+ ], Payment.prototype, "boletoExpirationDate", void 0);
420
+ __decorate([
421
+ Expose({ name: 'subscription_id' })
422
+ ], Payment.prototype, "subscriptionId", void 0);
423
+ __decorate([
424
+ Expose({ name: 'split_rules' })
425
+ ], Payment.prototype, "splitRules", void 0);
426
+ __decorate([
427
+ Expose({ name: 'antifraud_metadata' })
428
+ ], Payment.prototype, "antifraudMetadata", void 0);
429
+ __decorate([
430
+ Expose({ name: 'reference_key' })
431
+ ], Payment.prototype, "referenceKey", void 0);
432
+ __decorate([
433
+ Expose({ name: 'local_transaction_id' })
434
+ ], Payment.prototype, "localTransactionId", void 0);
435
+ __decorate([
436
+ Expose({ name: 'local_time' })
437
+ ], Payment.prototype, "localTime", void 0);
438
+ __decorate([
439
+ Expose({ name: 'fraud_covered' })
440
+ ], Payment.prototype, "fraudCovered", void 0);
441
+ __decorate([
442
+ Expose({ name: 'fraud_reimbursed' })
443
+ ], Payment.prototype, "fraudReimbursed", void 0);
444
+ __decorate([
445
+ Expose({ name: 'order_id' })
446
+ ], Payment.prototype, "orderId", void 0);
447
+ __decorate([
448
+ Expose({ name: 'risk_level' })
449
+ ], Payment.prototype, "riskLevel", void 0);
450
+ __decorate([
451
+ Expose({ name: 'receipt_url' })
452
+ ], Payment.prototype, "receiptUrl", void 0);
453
+ __decorate([
454
+ Expose({ name: 'private_label' })
455
+ ], Payment.prototype, "privateLabel", void 0);
456
+ __decorate([
457
+ Expose({ name: 'pix_qr_code' })
458
+ ], Payment.prototype, "pixQrCode", void 0);
459
+ __decorate([
460
+ Expose({ name: 'pix_expiration_date' })
461
461
  ], Payment.prototype, "pixExpirationDate", void 0);
462
462
 
463
- class ShippingMethod extends BaseModel {
464
- identifierFields() {
465
- return ['id'];
466
- }
467
- }
468
-
469
- class CheckoutSubscription extends BaseModel {
470
- identifierFields() {
471
- return ['id'];
472
- }
473
- }
474
-
475
- class SubscriptionPlan extends BaseModel {
476
- identifierFields() {
477
- return ['id'];
478
- }
479
- }
480
-
481
- class Buy2Win extends BaseModel {
482
- identifierFields() {
483
- return ['id'];
484
- }
485
- }
486
-
487
- class Home extends BaseModel {
488
- identifierFields() {
489
- return ['id'];
490
- }
491
- }
492
-
493
- class ShopMenu extends BaseModel {
494
- identifierFields() {
495
- return ['id'];
496
- }
497
- }
498
-
499
- class InvalidArgumentError extends Error {
500
- constructor(message) {
501
- super(message);
502
- this.message = message;
503
- }
504
- }
505
-
506
- class RequiredArgumentError extends Error {
507
- constructor(args) {
508
- super(`Required arguments: ${args.join(', ')}`);
509
- this.args = args;
510
- this.arguments = args;
511
- }
512
- }
513
-
514
- class NotFoundError extends Error {
515
- constructor(message) {
516
- super(message);
517
- this.message = message;
518
- }
519
- }
520
-
521
- class DuplicatedResultsError extends Error {
522
- constructor(message) {
523
- super(message);
524
- this.message = message;
525
- }
526
- }
527
-
528
- const withFirestore = (MixinBase) => {
529
- return class extends MixinBase {
530
- constructor(...args) {
531
- super(args);
532
- }
533
- collection(path) {
534
- return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
535
- }
536
- buildModelInstance() {
537
- return {
538
- toFirestore: (data) => data.toPlain(),
539
- fromFirestore: (snap) => {
540
- const data = snap.data();
541
- Object.keys(data).forEach((key) => {
542
- if (data[key] instanceof firebase.firestore.Timestamp) {
543
- data[key] = data[key].toDate();
544
- }
545
- });
546
- return this.model.toInstance(Object.assign({ id: snap.id }, data));
547
- },
548
- };
549
- }
550
- };
463
+ class ShippingMethod extends BaseModel {
464
+ identifierFields() {
465
+ return ['id'];
466
+ }
467
+ }
468
+
469
+ class CheckoutSubscription extends BaseModel {
470
+ identifierFields() {
471
+ return ['id'];
472
+ }
473
+ }
474
+
475
+ class SubscriptionPlan extends BaseModel {
476
+ identifierFields() {
477
+ return ['id'];
478
+ }
479
+ }
480
+
481
+ class Buy2Win extends BaseModel {
482
+ identifierFields() {
483
+ return ['id'];
484
+ }
485
+ }
486
+
487
+ class Home extends BaseModel {
488
+ identifierFields() {
489
+ return ['id'];
490
+ }
491
+ }
492
+
493
+ class ShopMenu extends BaseModel {
494
+ identifierFields() {
495
+ return ['id'];
496
+ }
497
+ }
498
+
499
+ class InvalidArgumentError extends Error {
500
+ constructor(message) {
501
+ super(message);
502
+ this.message = message;
503
+ }
504
+ }
505
+
506
+ class RequiredArgumentError extends Error {
507
+ constructor(args) {
508
+ super(`Required arguments: ${args.join(', ')}`);
509
+ this.args = args;
510
+ this.arguments = args;
511
+ }
512
+ }
513
+
514
+ class NotFoundError extends Error {
515
+ constructor(message) {
516
+ super(message);
517
+ this.message = message;
518
+ }
519
+ }
520
+
521
+ class DuplicatedResultsError extends Error {
522
+ constructor(message) {
523
+ super(message);
524
+ this.message = message;
525
+ }
526
+ }
527
+
528
+ const withFirestore = (MixinBase) => {
529
+ return class extends MixinBase {
530
+ constructor(...args) {
531
+ super(args);
532
+ }
533
+ collection(path) {
534
+ return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
535
+ }
536
+ buildModelInstance() {
537
+ return {
538
+ toFirestore: (data) => data.toPlain(),
539
+ fromFirestore: (snap) => {
540
+ const data = snap.data();
541
+ Object.keys(data).forEach((key) => {
542
+ if (data[key] instanceof firebase.firestore.Timestamp) {
543
+ data[key] = data[key].toDate();
544
+ }
545
+ });
546
+ return this.model.toInstance(Object.assign({ id: snap.id }, data));
547
+ },
548
+ };
549
+ }
550
+ };
551
551
  };
552
552
 
553
- const withHelpers = (MixinBase) => {
554
- return class extends MixinBase {
555
- toArray(snapShot) {
556
- if (Array.isArray(snapShot)) {
557
- return snapShot.map((doc) => doc.data());
558
- }
559
- else {
560
- return snapShot.docs.map((doc) => doc.data());
561
- }
562
- }
563
- isSubCollection(repository) {
564
- return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
565
- }
566
- };
553
+ const withHelpers = (MixinBase) => {
554
+ return class extends MixinBase {
555
+ toArray(snapShot) {
556
+ if (Array.isArray(snapShot)) {
557
+ return snapShot.map((doc) => doc.data());
558
+ }
559
+ else {
560
+ return snapShot.docs.map((doc) => doc.data());
561
+ }
562
+ }
563
+ isSubCollection(repository) {
564
+ return !isNil(Object.keys(this).find((key) => key === 'parentRepository'));
565
+ }
566
+ };
567
567
  };
568
568
 
569
- const withGetFirestore = (MixinBase) => {
570
- return class GetFirestore extends MixinBase {
571
- get(identifiers) {
572
- return __awaiter(this, void 0, void 0, function* () {
573
- const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
574
- .doc(Object.values(identifiers).shift().toString())
575
- .get();
576
- const data = doc.data();
577
- if (isNil(data))
578
- throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
579
- return data;
580
- });
581
- }
582
- buildCollectionPathForGet(identifiers) {
583
- return this.isSubCollection(this)
584
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
585
- : this.collectionName;
586
- }
587
- };
569
+ const withGetFirestore = (MixinBase) => {
570
+ return class GetFirestore extends MixinBase {
571
+ get(identifiers) {
572
+ return __awaiter(this, void 0, void 0, function* () {
573
+ const doc = yield this.collection(this.buildCollectionPathForGet(identifiers))
574
+ .doc(Object.values(identifiers).shift().toString())
575
+ .get();
576
+ const data = doc.data();
577
+ if (isNil(data))
578
+ throw new NotFoundError(`Document ${JSON.stringify(identifiers)} not found`);
579
+ return data;
580
+ });
581
+ }
582
+ buildCollectionPathForGet(identifiers) {
583
+ return this.isSubCollection(this)
584
+ ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
585
+ : this.collectionName;
586
+ }
587
+ };
588
588
  };
589
589
 
590
- const withFindFirestore = (MixinBase) => {
591
- return class FindFirestore extends MixinBase {
592
- constructor() {
593
- super(...arguments);
594
- this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
595
- this.buildWhereSentence = (queryReference, fieldName, options) => {
596
- if (this.isSubCollection(this) && fieldName === this.parentIdField)
597
- return queryReference;
598
- if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
599
- queryReference = queryReference.where(fieldName.toString(), '>=', options.value);
600
- queryReference = queryReference.where(fieldName.toString(), '<=', `${options.value}~`);
601
- return queryReference;
602
- }
603
- if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
604
- return queryReference.where(fieldName.toString(), 'array-contains-any', options.value);
605
- return queryReference.where(fieldName.toString(), options.operator, options.value);
606
- };
607
- }
608
- find(filters, limits, orderBy) {
609
- return __awaiter(this, void 0, void 0, function* () {
610
- let query = this.collection(this.buildCollectionPathForFind(filters));
611
- filters === null || filters === void 0 ? void 0 : filters.forEach((filterer) => (query = this.makeFirestoreWhere(query, filterer)));
612
- orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach((orderer) => Object.keys(orderer).forEach((fieldName) => (query = query.orderBy(fieldName, orderer[fieldName]))));
613
- query = this.defineLimits(query, filters, limits);
614
- const docs = yield query.get();
615
- const data = docs.docs.map((doc) => doc.data());
616
- return {
617
- data,
618
- count: this.calculateCount(data, limits),
619
- };
620
- });
621
- }
622
- buildCollectionPathForFind(filters) {
623
- var _a;
624
- if (!this.isSubCollection(this))
625
- return this.collectionName;
626
- const parentIdField = this.parentIdField;
627
- const parentId = (_a = filters.find((groupFilter) => { var _a; return Boolean((_a = groupFilter[parentIdField]) === null || _a === void 0 ? void 0 : _a.value); })) === null || _a === void 0 ? void 0 : _a[parentIdField].value;
628
- return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
629
- }
630
- defineLimits(query, filters, limits) {
631
- if (limits === null || limits === void 0 ? void 0 : limits.offset) {
632
- if (limits.offset instanceof this.model)
633
- query = query.startAfter(this.collection(this.buildCollectionPathForFind(filters)).doc(limits.offset[limits.offset.identifierFields().shift()]));
634
- if (isNumber(limits.offset) || isString(limits.offset))
635
- query = query.startAt(limits.offset);
636
- }
637
- if (limits === null || limits === void 0 ? void 0 : limits.limit)
638
- query = query.limit(limits.limit);
639
- return query;
640
- }
641
- calculateCount(data, limits) {
642
- if (data.length <= 0)
643
- return 0;
644
- if (data.length < (limits === null || limits === void 0 ? void 0 : limits.limit))
645
- return data.length;
646
- return Infinity;
647
- }
648
- };
590
+ const withFindFirestore = (MixinBase) => {
591
+ return class FindFirestore extends MixinBase {
592
+ constructor() {
593
+ super(...arguments);
594
+ this.makeFirestoreWhere = (queryReference, filter) => Object.keys(filter).reduce((query, fieldName) => this.buildWhereSentence(query, fieldName, filter[fieldName]), queryReference);
595
+ this.buildWhereSentence = (queryReference, fieldName, options) => {
596
+ if (this.isSubCollection(this) && fieldName === this.parentIdField)
597
+ return queryReference;
598
+ if ((options === null || options === void 0 ? void 0 : options.operator) === Where.LIKE) {
599
+ queryReference = queryReference.where(fieldName.toString(), '>=', options.value);
600
+ queryReference = queryReference.where(fieldName.toString(), '<=', `${options.value}~`);
601
+ return queryReference;
602
+ }
603
+ if ((options === null || options === void 0 ? void 0 : options.operator) === Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
604
+ return queryReference.where(fieldName.toString(), 'array-contains-any', options.value);
605
+ return queryReference.where(fieldName.toString(), options.operator, options.value);
606
+ };
607
+ }
608
+ find(filters, limits, orderBy) {
609
+ return __awaiter(this, void 0, void 0, function* () {
610
+ let query = this.collection(this.buildCollectionPathForFind(filters));
611
+ filters === null || filters === void 0 ? void 0 : filters.forEach((filterer) => (query = this.makeFirestoreWhere(query, filterer)));
612
+ orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach((orderer) => Object.keys(orderer).forEach((fieldName) => (query = query.orderBy(fieldName, orderer[fieldName]))));
613
+ query = this.defineLimits(query, filters, limits);
614
+ const docs = yield query.get();
615
+ const data = docs.docs.map((doc) => doc.data());
616
+ return {
617
+ data,
618
+ count: this.calculateCount(data, limits),
619
+ };
620
+ });
621
+ }
622
+ buildCollectionPathForFind(filters) {
623
+ var _a;
624
+ if (!this.isSubCollection(this))
625
+ return this.collectionName;
626
+ const parentIdField = this.parentIdField;
627
+ const parentId = (_a = filters.find((groupFilter) => { var _a; return Boolean((_a = groupFilter[parentIdField]) === null || _a === void 0 ? void 0 : _a.value); })) === null || _a === void 0 ? void 0 : _a[parentIdField].value;
628
+ return `${this.parentRepository.collectionName}/${parentId}/${this.collectionName}`;
629
+ }
630
+ defineLimits(query, filters, limits) {
631
+ if (limits === null || limits === void 0 ? void 0 : limits.offset) {
632
+ if (limits.offset instanceof this.model)
633
+ query = query.startAfter(this.collection(this.buildCollectionPathForFind(filters)).doc(limits.offset[limits.offset.identifierFields().shift()]));
634
+ if (isNumber(limits.offset) || isString(limits.offset))
635
+ query = query.startAt(limits.offset);
636
+ }
637
+ if (limits === null || limits === void 0 ? void 0 : limits.limit)
638
+ query = query.limit(limits.limit);
639
+ return query;
640
+ }
641
+ calculateCount(data, limits) {
642
+ if (data.length <= 0)
643
+ return 0;
644
+ if (data.length < (limits === null || limits === void 0 ? void 0 : limits.limit))
645
+ return data.length;
646
+ return Infinity;
647
+ }
648
+ };
649
649
  };
650
650
 
651
- const withCreateFirestore = (MixinBase) => {
652
- return class CreateFirestore extends MixinBase {
653
- create(data) {
654
- return __awaiter(this, void 0, void 0, function* () {
655
- const docRef = yield this.save(this.model.toInstance(data));
656
- const doc = yield docRef.get();
657
- return doc.data();
658
- });
659
- }
660
- save(data) {
661
- var _a;
662
- return __awaiter(this, void 0, void 0, function* () {
663
- const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
664
- if (isEmpty(id))
665
- return this.collection(this.buildCollectionPathForAdd(data)).add(data);
666
- const docRef = this.collection().doc(id);
667
- yield docRef.set(data);
668
- return docRef;
669
- });
670
- }
671
- buildCollectionPathForAdd(identifiers) {
672
- return this.isSubCollection(this)
673
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
674
- : this.collectionName;
675
- }
676
- };
651
+ const withCreateFirestore = (MixinBase) => {
652
+ return class CreateFirestore extends MixinBase {
653
+ create(data) {
654
+ return __awaiter(this, void 0, void 0, function* () {
655
+ const docRef = yield this.save(this.model.toInstance(data));
656
+ const doc = yield docRef.get();
657
+ return doc.data();
658
+ });
659
+ }
660
+ save(data) {
661
+ var _a;
662
+ return __awaiter(this, void 0, void 0, function* () {
663
+ const id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
664
+ if (isEmpty(id))
665
+ return this.collection(this.buildCollectionPathForAdd(data)).add(data);
666
+ const docRef = this.collection().doc(id);
667
+ yield docRef.set(data);
668
+ return docRef;
669
+ });
670
+ }
671
+ buildCollectionPathForAdd(identifiers) {
672
+ return this.isSubCollection(this)
673
+ ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
674
+ : this.collectionName;
675
+ }
676
+ };
677
677
  };
678
678
 
679
- const withUpdateFirestore = (MixinBase) => {
680
- const getValueFromParams = (params, field) => { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
681
- const getValueByAction = (options) => {
682
- const fieldValues = firebase.firestore.FieldValue;
683
- if (isNil(options.action))
684
- return options;
685
- if (options.action === UpdateOptionActions.REMOVE_FIELD)
686
- return fieldValues.delete();
687
- if (Array.isArray(options.value)) {
688
- if (options.action === UpdateOptionActions.MERGE)
689
- return fieldValues.arrayUnion(...options.value);
690
- if (options.action === UpdateOptionActions.REMOVE)
691
- return fieldValues.arrayRemove(...options.value);
692
- }
693
- return options.value;
694
- };
695
- return class UpdateFirestore extends MixinBase {
696
- update(data) {
697
- return __awaiter(this, void 0, void 0, function* () {
698
- const model = new this.model();
699
- const keyField = model.identifierFields().shift();
700
- const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
701
- yield docRef.update(this.paramsToPlain(data));
702
- const doc = yield docRef.get();
703
- return doc.data();
704
- });
705
- }
706
- buildCollectionPathForUpdate(identifiers) {
707
- return this.isSubCollection(this)
708
- ? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
709
- : this.collectionName;
710
- }
711
- paramsToPlain(params) {
712
- const model = this.model;
713
- if (params instanceof model)
714
- return params.toPlain();
715
- return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
716
- }
717
- };
679
+ const withUpdateFirestore = (MixinBase) => {
680
+ const getValueFromParams = (params, field) => { var _a; return (isNil((_a = params[field]) === null || _a === void 0 ? void 0 : _a.value) ? params[field] : params[field].value) || null; };
681
+ const getValueByAction = (options) => {
682
+ const fieldValues = firebase.firestore.FieldValue;
683
+ if (isNil(options.action))
684
+ return options;
685
+ if (options.action === UpdateOptionActions.REMOVE_FIELD)
686
+ return fieldValues.delete();
687
+ if (Array.isArray(options.value)) {
688
+ if (options.action === UpdateOptionActions.MERGE)
689
+ return fieldValues.arrayUnion(...options.value);
690
+ if (options.action === UpdateOptionActions.REMOVE)
691
+ return fieldValues.arrayRemove(...options.value);
692
+ }
693
+ return options.value;
694
+ };
695
+ return class UpdateFirestore extends MixinBase {
696
+ update(data) {
697
+ return __awaiter(this, void 0, void 0, function* () {
698
+ const model = new this.model();
699
+ const keyField = model.identifierFields().shift();
700
+ const docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
701
+ yield docRef.update(this.paramsToPlain(data));
702
+ const doc = yield docRef.get();
703
+ return doc.data();
704
+ });
705
+ }
706
+ buildCollectionPathForUpdate(identifiers) {
707
+ return this.isSubCollection(this)
708
+ ? `${this.parentRepository.collectionName}/${getValueFromParams(identifiers, this.parentIdField)}/${this.collectionName}`
709
+ : this.collectionName;
710
+ }
711
+ paramsToPlain(params) {
712
+ const model = this.model;
713
+ if (params instanceof model)
714
+ return params.toPlain();
715
+ return Object.keys(params).reduce((data, currentKey) => (Object.assign(Object.assign({}, data), { [currentKey]: getValueByAction(params[currentKey]) })), {});
716
+ }
717
+ };
718
718
  };
719
719
 
720
- const withDeleteFirestore = (MixinBase) => {
721
- return class DeleteFirestore extends MixinBase {
722
- delete(identifiers) {
723
- return __awaiter(this, void 0, void 0, function* () {
724
- yield this.collection(this.buildCollectionPathForRemove(identifiers))
725
- .doc(Object.values(identifiers).shift().toString())
726
- .delete();
727
- });
728
- }
729
- buildCollectionPathForRemove(identifiers) {
730
- return this.isSubCollection(this)
731
- ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
732
- : this.collectionName;
733
- }
734
- };
720
+ const withDeleteFirestore = (MixinBase) => {
721
+ return class DeleteFirestore extends MixinBase {
722
+ delete(identifiers) {
723
+ return __awaiter(this, void 0, void 0, function* () {
724
+ yield this.collection(this.buildCollectionPathForRemove(identifiers))
725
+ .doc(Object.values(identifiers).shift().toString())
726
+ .delete();
727
+ });
728
+ }
729
+ buildCollectionPathForRemove(identifiers) {
730
+ return this.isSubCollection(this)
731
+ ? `${this.parentRepository.collectionName}/${identifiers[this.parentIdField]}/${this.collectionName}`
732
+ : this.collectionName;
733
+ }
734
+ };
735
735
  };
736
736
 
737
- const withSubCollection = (MixinBase, ParentModel) => {
738
- return class SubCollectionMix extends MixinBase {
739
- constructor(...args) {
740
- super(args);
741
- }
742
- collection(path) {
743
- return super.collection(path);
744
- }
745
- };
737
+ const withSubCollection = (MixinBase, ParentModel) => {
738
+ return class SubCollectionMix extends MixinBase {
739
+ constructor(...args) {
740
+ super(args);
741
+ }
742
+ collection(path) {
743
+ return super.collection(path);
744
+ }
745
+ };
746
746
  };
747
747
 
748
- const withCrudFirestore = (MixinBase) => {
749
- return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
750
- };
748
+ const withCrudFirestore = (MixinBase) => {
749
+ return class CrudFirestore extends withUpdateFirestore(withGetFirestore(withFindFirestore(withDeleteFirestore(withCreateFirestore(MixinBase))))) {
750
+ };
751
751
  };
752
752
 
753
- class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
754
- constructor(firestore) {
755
- super();
756
- this.firestore = firestore;
757
- this.collectionName = 'subscription';
758
- this.model = Subscription;
759
- }
760
- }
761
-
762
- class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
763
- constructor(firestore) {
764
- super();
765
- this.firestore = firestore;
766
- this.collectionName = 'users';
767
- this.model = User;
768
- }
769
- get(identifiers) {
770
- const _super = Object.create(null, {
771
- get: { get: () => super.get }
772
- });
773
- return __awaiter(this, void 0, void 0, function* () {
774
- const user = yield _super.get.call(this, { id: identifiers.id });
775
- user.beautyProfile = yield this.getBeautyProfile(user.id);
776
- return user;
777
- });
778
- }
779
- getBeautyProfile(userId) {
780
- return __awaiter(this, void 0, void 0, function* () {
781
- const beautyProfile = yield this.collection()
782
- .doc(userId)
783
- .collection('CX')
784
- .withConverter(this.buildBeautyProfileModelInstance())
785
- .doc('beautyProfile')
786
- .get();
787
- return beautyProfile.data();
788
- });
789
- }
790
- buildBeautyProfileModelInstance() {
791
- return {
792
- toFirestore: (data) => data.toPlain(),
793
- fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
794
- };
795
- }
796
- }
797
-
798
- class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
799
- constructor(firestore, parentRepository) {
800
- super();
801
- this.firestore = firestore;
802
- this.parentRepository = parentRepository;
803
- this.collectionName = 'editions';
804
- this.parentIdField = 'subscriptionId';
805
- this.model = Edition;
806
- }
807
- }
808
-
809
- class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
810
- constructor(firestore, parentRepository) {
811
- super();
812
- this.firestore = firestore;
813
- this.parentRepository = parentRepository;
814
- this.collectionName = 'CX';
815
- this.parentIdField = 'userId';
816
- this.model = BeautyProfile;
817
- }
818
- }
819
-
820
- class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
821
- constructor(firestore, parentRepository) {
822
- super();
823
- this.firestore = firestore;
824
- this.parentRepository = parentRepository;
825
- this.collectionName = 'address';
826
- this.parentIdField = 'userId';
827
- this.model = UserAddress;
828
- }
829
- }
830
-
831
- class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
832
- constructor(firestore, parentRepository) {
833
- super();
834
- this.firestore = firestore;
835
- this.parentRepository = parentRepository;
836
- this.collectionName = 'Payments';
837
- this.parentIdField = 'subscriptionId';
838
- this.model = SubscriptionPayment;
839
- }
840
- }
841
-
842
- class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
843
- constructor(firestore) {
844
- super();
845
- this.firestore = firestore;
846
- this.collectionName = 'categories';
847
- this.model = Category;
848
- }
849
- getCategoryBySlug(slug, shop) {
850
- return this.collection(this.collectionName)
851
- .where("slug", "==", slug)
852
- .where("shop", "==", shop)
853
- .where("published", "==", true)
854
- .get().then(snap => {
855
- if (snap.size > 1)
856
- throw new DuplicatedResultsError("Query returned duplicated values");
857
- if (snap.empty)
858
- throw new NotFoundError(`Document with slug ${slug} not found`);
859
- return snap.docs[0].data();
860
- }).catch(error => error);
861
- }
862
- getCategoriesForHome(categoryIds) {
863
- return __awaiter(this, void 0, void 0, function* () {
864
- const categorySnap = yield this.collection(this.collectionName)
865
- .where("id", "in", categoryIds)
866
- .where("published", "==", true)
867
- .get();
868
- if (categorySnap.empty)
869
- throw new NotFoundError("Categories not found");
870
- const categories = categorySnap.docs.map(doc => doc.data());
871
- const homeSections = [];
872
- for (const category of categories) {
873
- const productSnap = yield this.collection("products")
874
- .where("categories", "array-contains", category.id)
875
- .where("published", "==", true)
876
- .where("stock.quantity", ">", 1)
877
- .limit(4)
878
- .get();
879
- const products = productSnap.docs.map(doc => doc.data());
880
- homeSections.push({ title: category.name, products });
881
- }
882
- return homeSections;
883
- });
884
- }
885
- }
886
-
887
- class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
888
- constructor(firestore) {
889
- super();
890
- this.firestore = firestore;
891
- this.collectionName = 'products';
892
- this.model = Product;
893
- }
894
- }
895
-
896
- class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
897
- constructor(firestore, parentRepository) {
898
- super();
899
- this.firestore = firestore;
900
- this.parentRepository = parentRepository;
901
- this.collectionName = 'variants';
902
- this.parentIdField = 'productId';
903
- this.model = Variant;
904
- }
905
- }
906
-
907
- class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
908
- constructor(firestore) {
909
- super();
910
- this.firestore = firestore;
911
- this.collectionName = 'checkouts';
912
- this.model = Checkout;
913
- }
914
- }
915
-
916
- class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
917
- constructor(firestore) {
918
- super();
919
- this.firestore = firestore;
920
- this.collectionName = 'coupons';
921
- this.model = Coupon;
922
- }
923
- }
924
-
925
- class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
926
- constructor(firestore) {
927
- super();
928
- this.firestore = firestore;
929
- this.collectionName = 'orders';
930
- this.model = Order;
931
- }
932
- }
933
-
934
- class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
935
- constructor(firestore) {
936
- super();
937
- this.firestore = firestore;
938
- this.collectionName = 'payments';
939
- this.model = Payment;
940
- }
941
- }
942
-
943
- class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
944
- constructor(firestore) {
945
- super();
946
- this.firestore = firestore;
947
- this.collectionName = 'checkoutsSubscription';
948
- this.model = CheckoutSubscription;
949
- }
950
- }
951
-
952
- class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
953
- constructor(firestore) {
954
- super();
955
- this.firestore = firestore;
956
- this.collectionName = 'subscriptionPlans';
957
- this.model = SubscriptionPlan;
958
- }
959
- }
960
-
961
- class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
962
- constructor(firestore) {
963
- super();
964
- this.firestore = firestore;
965
- this.collectionName = 'buy2win';
966
- this.model = Buy2Win;
967
- }
968
- }
969
-
970
- class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
971
- constructor(firestore) {
972
- super();
973
- this.firestore = firestore;
974
- this.collectionName = 'dms';
975
- this.model = Home;
976
- }
977
- }
978
-
979
- class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
980
- constructor(firestore) {
981
- super();
982
- this.firestore = firestore;
983
- this.collectionName = 'shopMenus';
984
- this.model = ShopMenu;
985
- }
986
- }
987
-
988
- class AuthenticationFirebaseAuthService {
989
- constructor(firebaseAuth) {
990
- this.firebaseAuth = firebaseAuth;
991
- }
992
- signInWithEmailAndPassword(data) {
993
- return __awaiter(this, void 0, void 0, function* () {
994
- const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
995
- const user = credentials.user;
996
- return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
997
- });
998
- }
999
- signInWithGoogle() {
1000
- return __awaiter(this, void 0, void 0, function* () {
1001
- const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
1002
- const user = credentials.user;
1003
- return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
1004
- });
1005
- }
1006
- signOut() {
1007
- return __awaiter(this, void 0, void 0, function* () {
1008
- this.firebaseAuth.signOut();
1009
- });
1010
- }
1011
- }
1012
-
1013
- /**
1014
- * Generated bundle index. Do not edit.
753
+ class SubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
754
+ constructor(firestore) {
755
+ super();
756
+ this.firestore = firestore;
757
+ this.collectionName = 'subscription';
758
+ this.model = Subscription;
759
+ }
760
+ }
761
+
762
+ class UserFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
763
+ constructor(firestore) {
764
+ super();
765
+ this.firestore = firestore;
766
+ this.collectionName = 'users';
767
+ this.model = User;
768
+ }
769
+ get(identifiers) {
770
+ const _super = Object.create(null, {
771
+ get: { get: () => super.get }
772
+ });
773
+ return __awaiter(this, void 0, void 0, function* () {
774
+ const user = yield _super.get.call(this, { id: identifiers.id });
775
+ user.beautyProfile = yield this.getBeautyProfile(user.id);
776
+ return user;
777
+ });
778
+ }
779
+ getBeautyProfile(userId) {
780
+ return __awaiter(this, void 0, void 0, function* () {
781
+ const beautyProfile = yield this.collection()
782
+ .doc(userId)
783
+ .collection('CX')
784
+ .withConverter(this.buildBeautyProfileModelInstance())
785
+ .doc('beautyProfile')
786
+ .get();
787
+ return beautyProfile.data();
788
+ });
789
+ }
790
+ buildBeautyProfileModelInstance() {
791
+ return {
792
+ toFirestore: (data) => data.toPlain(),
793
+ fromFirestore: (snap) => BeautyProfile.toInstance(snap.data()),
794
+ };
795
+ }
796
+ }
797
+
798
+ class SubscriptionEditionFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
799
+ constructor(firestore, parentRepository) {
800
+ super();
801
+ this.firestore = firestore;
802
+ this.parentRepository = parentRepository;
803
+ this.collectionName = 'editions';
804
+ this.parentIdField = 'subscriptionId';
805
+ this.model = Edition;
806
+ }
807
+ }
808
+
809
+ class UserBeautyProfileFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
810
+ constructor(firestore, parentRepository) {
811
+ super();
812
+ this.firestore = firestore;
813
+ this.parentRepository = parentRepository;
814
+ this.collectionName = 'CX';
815
+ this.parentIdField = 'userId';
816
+ this.model = BeautyProfile;
817
+ }
818
+ }
819
+
820
+ class UserAddressFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), User) {
821
+ constructor(firestore, parentRepository) {
822
+ super();
823
+ this.firestore = firestore;
824
+ this.parentRepository = parentRepository;
825
+ this.collectionName = 'address';
826
+ this.parentIdField = 'userId';
827
+ this.model = UserAddress;
828
+ }
829
+ }
830
+
831
+ class SubscriptionPaymentFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Subscription) {
832
+ constructor(firestore, parentRepository) {
833
+ super();
834
+ this.firestore = firestore;
835
+ this.parentRepository = parentRepository;
836
+ this.collectionName = 'Payments';
837
+ this.parentIdField = 'subscriptionId';
838
+ this.model = SubscriptionPayment;
839
+ }
840
+ }
841
+
842
+ class CategoryFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
843
+ constructor(firestore) {
844
+ super();
845
+ this.firestore = firestore;
846
+ this.collectionName = 'categories';
847
+ this.model = Category;
848
+ }
849
+ getCategoryBySlug(slug, shop) {
850
+ return this.collection(this.collectionName)
851
+ .where("slug", "==", slug)
852
+ .where("shop", "==", shop)
853
+ .where("published", "==", true)
854
+ .get().then(snap => {
855
+ if (snap.size > 1)
856
+ throw new DuplicatedResultsError("Query returned duplicated values");
857
+ if (snap.empty)
858
+ throw new NotFoundError(`Document with slug ${slug} not found`);
859
+ return snap.docs[0].data();
860
+ }).catch(error => error);
861
+ }
862
+ getCategoriesForHome(categoryIds) {
863
+ return __awaiter(this, void 0, void 0, function* () {
864
+ const categorySnap = yield this.collection(this.collectionName)
865
+ .where("id", "in", categoryIds)
866
+ .where("published", "==", true)
867
+ .get();
868
+ if (categorySnap.empty)
869
+ throw new NotFoundError("Categories not found");
870
+ const categories = categorySnap.docs.map(doc => doc.data());
871
+ const homeSections = [];
872
+ for (const category of categories) {
873
+ const productSnap = yield this.collection("products")
874
+ .where("categories", "array-contains", category.id)
875
+ // .where("published", "==", true)
876
+ .where("stock.quantity", ">", 1)
877
+ .limit(4)
878
+ .get();
879
+ const products = productSnap.docs.map(doc => doc.data());
880
+ homeSections.push({ title: category.name, products });
881
+ }
882
+ return homeSections;
883
+ });
884
+ }
885
+ mountCategory(category) {
886
+ return __awaiter(this, void 0, void 0, function* () {
887
+ if (!category.products)
888
+ throw new RequiredArgumentError(["Category products is empty"]);
889
+ const chunks = category.products.reduce((resultArray, item, index) => {
890
+ const chunkIndex = Math.floor(index / 10);
891
+ if (!resultArray[chunkIndex])
892
+ resultArray[chunkIndex] = [];
893
+ resultArray[chunkIndex].push(item);
894
+ return resultArray;
895
+ }, []);
896
+ const products = [];
897
+ for (const productIds of chunks) {
898
+ const productSnap = yield this.collection("products")
899
+ .where("id", "in", productIds)
900
+ // .where("published", "==", true)
901
+ .get();
902
+ if (productSnap.empty)
903
+ continue;
904
+ products.push(...productSnap.docs.map(doc => doc.data()));
905
+ }
906
+ return products;
907
+ });
908
+ }
909
+ }
910
+
911
+ class ProductFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
912
+ constructor(firestore) {
913
+ super();
914
+ this.firestore = firestore;
915
+ this.collectionName = 'products';
916
+ this.model = Product;
917
+ }
918
+ getBySlug(slug, shop) {
919
+ var _a;
920
+ return __awaiter(this, void 0, void 0, function* () {
921
+ const result = yield this.find([
922
+ { slug: { operator: Where.EQUALS, value: slug } },
923
+ { shopAvailability: { operator: Where.IN, value: [shop] } },
924
+ ]);
925
+ return (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
926
+ });
927
+ }
928
+ }
929
+
930
+ class ProductVariantFirestoreRepository extends withSubCollection(withCrudFirestore(withHelpers(withFirestore(Base))), Product) {
931
+ constructor(firestore, parentRepository) {
932
+ super();
933
+ this.firestore = firestore;
934
+ this.parentRepository = parentRepository;
935
+ this.collectionName = 'variants';
936
+ this.parentIdField = 'productId';
937
+ this.model = Variant;
938
+ }
939
+ }
940
+
941
+ class CheckoutFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
942
+ constructor(firestore) {
943
+ super();
944
+ this.firestore = firestore;
945
+ this.collectionName = 'checkouts';
946
+ this.model = Checkout;
947
+ }
948
+ }
949
+
950
+ class CouponFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
951
+ constructor(firestore) {
952
+ super();
953
+ this.firestore = firestore;
954
+ this.collectionName = 'coupons';
955
+ this.model = Coupon;
956
+ }
957
+ }
958
+
959
+ class OrderFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
960
+ constructor(firestore) {
961
+ super();
962
+ this.firestore = firestore;
963
+ this.collectionName = 'orders';
964
+ this.model = Order;
965
+ }
966
+ }
967
+
968
+ class PaymentFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
969
+ constructor(firestore) {
970
+ super();
971
+ this.firestore = firestore;
972
+ this.collectionName = 'payments';
973
+ this.model = Payment;
974
+ }
975
+ }
976
+
977
+ class CheckoutSubscriptionFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
978
+ constructor(firestore) {
979
+ super();
980
+ this.firestore = firestore;
981
+ this.collectionName = 'checkoutsSubscription';
982
+ this.model = CheckoutSubscription;
983
+ }
984
+ }
985
+
986
+ class SubscriptionPlanFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
987
+ constructor(firestore) {
988
+ super();
989
+ this.firestore = firestore;
990
+ this.collectionName = 'subscriptionPlans';
991
+ this.model = SubscriptionPlan;
992
+ }
993
+ }
994
+
995
+ class Buy2WinFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
996
+ constructor(firestore) {
997
+ super();
998
+ this.firestore = firestore;
999
+ this.collectionName = 'buy2win';
1000
+ this.model = Buy2Win;
1001
+ }
1002
+ }
1003
+
1004
+ class HomeFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1005
+ constructor(firestore) {
1006
+ super();
1007
+ this.firestore = firestore;
1008
+ this.collectionName = 'dms';
1009
+ this.model = Home;
1010
+ }
1011
+ }
1012
+
1013
+ class ShopMenuFirestoreRepository extends withCrudFirestore(withHelpers(withFirestore(Base))) {
1014
+ constructor(firestore) {
1015
+ super();
1016
+ this.firestore = firestore;
1017
+ this.collectionName = 'shopMenus';
1018
+ this.model = ShopMenu;
1019
+ }
1020
+ }
1021
+
1022
+ class AuthenticationFirebaseAuthService {
1023
+ constructor(firebaseAuth) {
1024
+ this.firebaseAuth = firebaseAuth;
1025
+ }
1026
+ signInWithEmailAndPassword(data) {
1027
+ return __awaiter(this, void 0, void 0, function* () {
1028
+ const credentials = yield this.firebaseAuth.signInWithEmailAndPassword(data.email, data.password);
1029
+ const user = credentials.user;
1030
+ return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
1031
+ });
1032
+ }
1033
+ signInWithGoogle() {
1034
+ return __awaiter(this, void 0, void 0, function* () {
1035
+ const credentials = yield this.firebaseAuth.signInWithPopup(new firebase$1.auth.GoogleAuthProvider());
1036
+ const user = credentials.user;
1037
+ return { id: user.uid, displayName: user.displayName, email: user.email, phone: user.phoneNumber };
1038
+ });
1039
+ }
1040
+ signOut() {
1041
+ return __awaiter(this, void 0, void 0, function* () {
1042
+ this.firebaseAuth.signOut();
1043
+ });
1044
+ }
1045
+ }
1046
+
1047
+ /**
1048
+ * Generated bundle index. Do not edit.
1015
1049
  */
1016
1050
 
1017
1051
  export { Address, Area, Authentication, AuthenticationFirebaseAuthService, Base, BaseModel, BeardSizes, BeautyProfile, BillingStatus, Buy2Win, Buy2WinFirestoreRepository, Category, CategoryFirestoreRepository, Checkout, CheckoutFirestoreRepository, CheckoutSubscription, CheckoutSubscriptionFirestoreRepository, CheckoutTypes, Coupon, CouponFirestoreRepository, CouponSubtypes, CouponTypes, DuplicatedResultsError, Edition, EditionStatus, Exclusivities, FinancialCoupon, HairTypes, Home, HomeFirestoreRepository, InvalidArgumentError, LineItem, NotFoundError, OfficePosition, Order, OrderFirestoreRepository, OrderStatus, Payment, PaymentFirestoreRepository, PaymentType, Product, ProductFirestoreRepository, ProductVariantFirestoreRepository, RequiredArgumentError, ShippingMethod, ShopMenu, ShopMenuFirestoreRepository, Shops, SignInMethods, SignOut, Status, Subscription, SubscriptionEditionFirestoreRepository, SubscriptionFirestoreRepository, SubscriptionPayment, SubscriptionPaymentFirestoreRepository, SubscriptionPlan, SubscriptionPlanFirestoreRepository, UnauthorizedError, UpdateOptionActions, User, UserAddress, UserAddressFirestoreRepository, UserBeautyProfileFirestoreRepository, UserFirestoreRepository, UserType, Variant, Where, withCreateFirestore, withCrudFirestore, withDeleteFirestore, withFindFirestore, withFirestore, withGetFirestore, withHelpers, withSubCollection, withUpdateFirestore };