@infrab4a/connect 3.15.0 → 4.0.0-beta.0

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