@infrab4a/connect 3.16.0-beta.1 → 4.0.0-beta.10

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