@infrab4a/connect 1.0.0-beta.8 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (364) hide show
  1. package/bundles/infrab4a-connect.umd.js +2173 -267
  2. package/bundles/infrab4a-connect.umd.js.map +1 -1
  3. package/domain/catalog/models/category.d.ts +5 -4
  4. package/domain/catalog/models/index.d.ts +3 -2
  5. package/domain/catalog/models/kit-product.d.ts +12 -0
  6. package/domain/catalog/models/product.d.ts +9 -4
  7. package/domain/catalog/models/types/product-review.type.d.ts +10 -8
  8. package/domain/catalog/models/variant.d.ts +7 -3
  9. package/domain/catalog/repositories/category.repository.d.ts +1 -1
  10. package/domain/catalog/repositories/product.repository.d.ts +10 -3
  11. package/domain/catalog/repositories/subscription-product.repository.d.ts +1 -1
  12. package/domain/catalog/repositories/variant.repository.d.ts +1 -1
  13. package/domain/generic/model/base.model.d.ts +10 -0
  14. package/domain/{general → generic}/model/index.d.ts +0 -1
  15. package/domain/generic/model/types/base-model-builder.type.d.ts +15 -0
  16. package/domain/generic/model/types/identifier-model.type.d.ts +7 -0
  17. package/domain/{general → generic}/model/types/index.d.ts +2 -0
  18. package/domain/generic/model/types/model-base-structure.type.d.ts +6 -0
  19. package/domain/generic/model/types/non-function-properties.type.d.ts +12 -0
  20. package/domain/generic/model/types/non-function-property-name.type.d.ts +4 -0
  21. package/domain/generic/repository/create.repository.d.ts +8 -0
  22. package/domain/generic/repository/crud.repository.d.ts +19 -0
  23. package/domain/generic/repository/delete.repository.d.ts +7 -0
  24. package/domain/{general → generic}/repository/enums/where.enum.d.ts +5 -2
  25. package/domain/generic/repository/find.repository.d.ts +11 -0
  26. package/domain/generic/repository/get.repository.d.ts +5 -0
  27. package/domain/generic/repository/read.repository.d.ts +14 -0
  28. package/domain/{general → generic}/repository/types/index.d.ts +1 -0
  29. package/domain/generic/repository/types/repository-find-filters.type.d.ts +13 -0
  30. package/domain/{general → generic}/repository/types/repository-update-params.type.d.ts +4 -4
  31. package/domain/generic/repository/types/where-options.type.d.ts +2 -0
  32. package/domain/generic/repository/update.repository.d.ts +6 -0
  33. package/domain/index.d.ts +1 -1
  34. package/domain/location/models/address.d.ts +3 -2
  35. package/domain/shop-settings/models/home.d.ts +3 -3
  36. package/domain/shop-settings/models/shop-menu.d.ts +3 -3
  37. package/domain/shop-settings/repositories/home.repository.d.ts +1 -1
  38. package/domain/shop-settings/repositories/shop-menu.repository.d.ts +1 -1
  39. package/domain/shopping/models/buy-2-win.d.ts +3 -5
  40. package/domain/shopping/models/checkout.d.ts +7 -9
  41. package/domain/shopping/models/coupons/coupon.d.ts +13 -15
  42. package/domain/shopping/models/coupons/enums/coupon-subtypes.enum.d.ts +4 -0
  43. package/domain/shopping/models/coupons/enums/coupon-types.enum.d.ts +6 -0
  44. package/domain/shopping/models/coupons/enums/index.d.ts +2 -1
  45. package/domain/shopping/models/coupons/financial-coupon.d.ts +9 -0
  46. package/domain/shopping/models/coupons/index.d.ts +1 -2
  47. package/domain/shopping/models/payment.d.ts +3 -5
  48. package/domain/shopping/models/shipping-method.d.ts +3 -5
  49. package/domain/shopping/models/subscription/checkout.d.ts +3 -5
  50. package/domain/shopping/models/subscription/plan.d.ts +3 -5
  51. package/domain/shopping/repositories/buy-2-win.repository.d.ts +1 -1
  52. package/domain/shopping/repositories/checkout.repository.d.ts +1 -1
  53. package/domain/shopping/repositories/coupon.repository.d.ts +1 -1
  54. package/domain/shopping/repositories/order.repository.d.ts +1 -1
  55. package/domain/shopping/repositories/payment.repository.d.ts +1 -1
  56. package/domain/shopping/repositories/subscription/checkout.repository.d.ts +1 -1
  57. package/domain/shopping/repositories/subscription/plan.repository.d.ts +1 -1
  58. package/domain/users/errors/unauthorized.error.d.ts +2 -1
  59. package/domain/users/errors/user-already-registered.error.d.ts +2 -1
  60. package/domain/users/errors/weak-password.error.d.ts +2 -1
  61. package/domain/users/models/beauty-profile.d.ts +4 -5
  62. package/domain/users/models/lead.d.ts +3 -5
  63. package/domain/users/models/subscription/edition.d.ts +4 -5
  64. package/domain/users/models/subscription/payment.d.ts +4 -5
  65. package/domain/users/models/subscription/subscription.d.ts +3 -5
  66. package/domain/users/models/user-address.d.ts +3 -3
  67. package/domain/users/models/user-payment-method.d.ts +4 -4
  68. package/domain/users/models/user.d.ts +13 -10
  69. package/domain/users/repositories/beauty-profile.repository.d.ts +1 -1
  70. package/domain/users/repositories/edition.repository.d.ts +1 -1
  71. package/domain/users/repositories/lead.repository.d.ts +1 -1
  72. package/domain/users/repositories/subscription-payment.repository.d.ts +1 -1
  73. package/domain/users/repositories/subscription.repository.d.ts +1 -1
  74. package/domain/users/repositories/user-address.repository.d.ts +1 -1
  75. package/domain/users/repositories/user-payment-method.repository.d.ts +1 -1
  76. package/domain/users/repositories/user.repository.d.ts +2 -2
  77. package/errors/duplicated-results.error.d.ts +2 -1
  78. package/errors/invalid-argument.error.d.ts +2 -1
  79. package/errors/not-found.error.d.ts +2 -1
  80. package/errors/required-argument.error.d.ts +2 -1
  81. package/esm2015/domain/catalog/models/category.js +5 -2
  82. package/esm2015/domain/catalog/models/index.js +4 -3
  83. package/esm2015/domain/catalog/models/kit-product.js +18 -0
  84. package/esm2015/domain/catalog/models/product.js +12 -2
  85. package/esm2015/domain/catalog/models/types/product-review.type.js +1 -1
  86. package/esm2015/domain/catalog/models/variant.js +5 -2
  87. package/esm2015/domain/catalog/repositories/category.repository.js +1 -1
  88. package/esm2015/domain/catalog/repositories/product.repository.js +1 -1
  89. package/esm2015/domain/catalog/repositories/subscription-product.repository.js +1 -1
  90. package/esm2015/domain/catalog/repositories/variant.repository.js +1 -1
  91. package/esm2015/domain/{general → generic}/index.js +1 -1
  92. package/esm2015/domain/generic/model/base.model.js +23 -0
  93. package/esm2015/domain/{general → generic}/model/identifier-fields.js +1 -1
  94. package/esm2015/domain/generic/model/index.js +4 -0
  95. package/esm2015/domain/generic/model/types/base-model-builder.type.js +2 -0
  96. package/esm2015/domain/generic/model/types/identifier-model.type.js +2 -0
  97. package/esm2015/domain/generic/model/types/index.js +6 -0
  98. package/esm2015/domain/generic/model/types/model-base-structure.type.js +2 -0
  99. package/esm2015/domain/generic/model/types/non-function-properties.type.js +2 -0
  100. package/esm2015/domain/generic/model/types/non-function-property-name.type.js +2 -0
  101. package/esm2015/domain/generic/repository/create.repository.js +2 -0
  102. package/esm2015/domain/generic/repository/crud.repository.js +2 -0
  103. package/esm2015/domain/generic/repository/delete.repository.js +2 -0
  104. package/esm2015/domain/{general → generic}/repository/enums/index.js +1 -1
  105. package/esm2015/domain/{general → generic}/repository/enums/update-option-actions.enum.js +1 -1
  106. package/esm2015/domain/generic/repository/enums/where.enum.js +15 -0
  107. package/esm2015/domain/generic/repository/find.repository.js +2 -0
  108. package/esm2015/domain/generic/repository/get.repository.js +2 -0
  109. package/esm2015/domain/{general → generic}/repository/index.js +1 -1
  110. package/esm2015/domain/generic/repository/read.repository.js +2 -0
  111. package/esm2015/domain/generic/repository/types/index.js +7 -0
  112. package/esm2015/domain/generic/repository/types/repository-find-filters.type.js +2 -0
  113. package/esm2015/domain/{general → generic}/repository/types/repository-find-result.type.js +1 -1
  114. package/esm2015/domain/{general → generic}/repository/types/repository-limit-options.type.js +1 -1
  115. package/esm2015/domain/{general → generic}/repository/types/repository-order-by-list.type.js +1 -1
  116. package/esm2015/domain/generic/repository/types/repository-update-params.type.js +2 -0
  117. package/esm2015/domain/generic/repository/types/where-options.type.js +2 -0
  118. package/esm2015/domain/generic/repository/update.repository.js +2 -0
  119. package/esm2015/domain/index.js +2 -2
  120. package/esm2015/domain/location/models/address.js +5 -2
  121. package/esm2015/domain/shop-settings/models/home.js +3 -3
  122. package/esm2015/domain/shop-settings/models/shop-menu.js +3 -3
  123. package/esm2015/domain/shop-settings/repositories/home.repository.js +1 -1
  124. package/esm2015/domain/shop-settings/repositories/shop-menu.repository.js +1 -1
  125. package/esm2015/domain/shopping/models/buy-2-win.js +3 -3
  126. package/esm2015/domain/shopping/models/checkout.js +6 -15
  127. package/esm2015/domain/shopping/models/coupons/coupon.js +4 -12
  128. package/esm2015/domain/shopping/models/coupons/enums/coupon-subtypes.enum.js +6 -0
  129. package/esm2015/domain/shopping/models/coupons/enums/coupon-types.enum.js +8 -0
  130. package/esm2015/domain/shopping/models/coupons/enums/index.js +3 -2
  131. package/esm2015/domain/shopping/models/coupons/financial-coupon.js +28 -0
  132. package/esm2015/domain/shopping/models/coupons/index.js +2 -3
  133. package/esm2015/domain/shopping/models/payment.js +3 -3
  134. package/esm2015/domain/shopping/models/shipping-method.js +3 -3
  135. package/esm2015/domain/shopping/models/subscription/checkout.js +3 -3
  136. package/esm2015/domain/shopping/models/subscription/plan.js +3 -3
  137. package/esm2015/domain/shopping/repositories/buy-2-win.repository.js +1 -1
  138. package/esm2015/domain/shopping/repositories/checkout.repository.js +1 -1
  139. package/esm2015/domain/shopping/repositories/coupon.repository.js +1 -1
  140. package/esm2015/domain/shopping/repositories/order.repository.js +1 -1
  141. package/esm2015/domain/shopping/repositories/payment.repository.js +1 -1
  142. package/esm2015/domain/shopping/repositories/subscription/checkout.repository.js +1 -1
  143. package/esm2015/domain/shopping/repositories/subscription/plan.repository.js +1 -1
  144. package/esm2015/domain/users/errors/unauthorized.error.js +3 -2
  145. package/esm2015/domain/users/errors/user-already-registered.error.js +3 -2
  146. package/esm2015/domain/users/errors/weak-password.error.js +3 -2
  147. package/esm2015/domain/users/models/beauty-profile.js +4 -4
  148. package/esm2015/domain/users/models/lead.js +3 -3
  149. package/esm2015/domain/users/models/subscription/edition.js +4 -4
  150. package/esm2015/domain/users/models/subscription/payment.js +4 -4
  151. package/esm2015/domain/users/models/subscription/subscription.js +3 -3
  152. package/esm2015/domain/users/models/user-address.js +3 -3
  153. package/esm2015/domain/users/models/user-payment-method.js +4 -4
  154. package/esm2015/domain/users/models/user.js +5 -5
  155. package/esm2015/domain/users/repositories/beauty-profile.repository.js +1 -1
  156. package/esm2015/domain/users/repositories/edition.repository.js +1 -1
  157. package/esm2015/domain/users/repositories/lead.repository.js +1 -1
  158. package/esm2015/domain/users/repositories/subscription-payment.repository.js +1 -1
  159. package/esm2015/domain/users/repositories/subscription.repository.js +1 -1
  160. package/esm2015/domain/users/repositories/user-address.repository.js +1 -1
  161. package/esm2015/domain/users/repositories/user-payment-method.repository.js +1 -1
  162. package/esm2015/domain/users/repositories/user.repository.js +1 -1
  163. package/esm2015/errors/duplicated-results.error.js +3 -2
  164. package/esm2015/errors/invalid-argument.error.js +3 -2
  165. package/esm2015/errors/not-found.error.js +3 -2
  166. package/esm2015/errors/required-argument.error.js +3 -2
  167. package/esm2015/infra/elasticsearch/adapters/axios.adapter.js +36 -1
  168. package/esm2015/infra/elasticsearch/adapters/elastic-search.adapter.js +1 -1
  169. package/esm2015/infra/elasticsearch/indexes/products-index.js +35 -1
  170. package/esm2015/infra/firebase/auth/authentication-firebase-auth.service.js +2 -2
  171. package/esm2015/infra/firebase/auth/register-firebase-auth.service.js +1 -1
  172. package/esm2015/infra/firebase/firestore/mixins/with-create-firestore.mixin.js +2 -2
  173. package/esm2015/infra/firebase/firestore/mixins/with-crud-firestore.mixin.js +1 -1
  174. package/esm2015/infra/firebase/firestore/mixins/with-delete-firestore.mixin.js +1 -1
  175. package/esm2015/infra/firebase/firestore/mixins/with-find-firestore.mixin.js +9 -10
  176. package/esm2015/infra/firebase/firestore/mixins/with-firestore.mixin.js +2 -6
  177. package/esm2015/infra/firebase/firestore/mixins/with-get-firestore.mixin.js +1 -1
  178. package/esm2015/infra/firebase/firestore/mixins/with-helpers.mixin.js +1 -1
  179. package/esm2015/infra/firebase/firestore/mixins/with-sub-collection.mixin.js +1 -1
  180. package/esm2015/infra/firebase/firestore/mixins/with-update-firestore.mixin.js +4 -4
  181. package/esm2015/infra/firebase/firestore/models/user-search.js +3 -3
  182. package/esm2015/infra/firebase/firestore/repositories/catalog/category-firestore.repository.js +4 -2
  183. package/esm2015/infra/firebase/firestore/repositories/catalog/product-firestore.repository.js +37 -8
  184. package/esm2015/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.js +11 -21
  185. package/esm2015/infra/firebase/firestore/repositories/users/user-firestore.repository.js +2 -2
  186. package/esm2015/infra/firebase/firestore/types/firestore-sub.repository.type.js +1 -1
  187. package/esm2015/infra/firebase/firestore/types/firestore.helpers.type.js +1 -1
  188. package/esm2015/infra/firebase/firestore/types/firestore.repository.type.js +1 -1
  189. package/esm2015/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.js +13 -0
  190. package/esm2015/infra/hasura-graphql/enums/hasura-graphql-where.enum.js +15 -0
  191. package/esm2015/infra/hasura-graphql/enums/index.js +3 -0
  192. package/esm2015/infra/hasura-graphql/index.js +5 -0
  193. package/esm2015/infra/hasura-graphql/mixins/helpers/attribute-option.helper.js +31 -0
  194. package/esm2015/infra/hasura-graphql/mixins/helpers/filter-option.helper.js +18 -0
  195. package/esm2015/infra/hasura-graphql/mixins/helpers/graphql-field.helper.js +72 -0
  196. package/esm2015/infra/hasura-graphql/mixins/helpers/index.js +4 -0
  197. package/esm2015/infra/hasura-graphql/mixins/index.js +8 -0
  198. package/esm2015/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.js +45 -0
  199. package/esm2015/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.js +10 -0
  200. package/esm2015/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.js +29 -0
  201. package/esm2015/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.js +93 -0
  202. package/esm2015/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.js +35 -0
  203. package/esm2015/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.js +94 -0
  204. package/esm2015/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.js +56 -0
  205. package/esm2015/infra/hasura-graphql/models/category-hasura-graphql.js +4 -0
  206. package/esm2015/infra/hasura-graphql/models/index.js +5 -0
  207. package/esm2015/infra/hasura-graphql/models/kit-product-hasura-graphql.js +15 -0
  208. package/esm2015/infra/hasura-graphql/models/product-hasura-graphql.js +11 -0
  209. package/esm2015/infra/hasura-graphql/models/variant-hasura-graphql.js +9 -0
  210. package/esm2015/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.js +136 -0
  211. package/esm2015/infra/hasura-graphql/repositories/catalog/index.js +4 -0
  212. package/esm2015/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.js +375 -0
  213. package/esm2015/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.js +107 -0
  214. package/esm2015/infra/hasura-graphql/repositories/index.js +2 -0
  215. package/esm2015/infra/hasura-graphql/types/fields.type.js +2 -0
  216. package/esm2015/infra/hasura-graphql/types/graphql.repository.type.js +2 -0
  217. package/esm2015/infra/hasura-graphql/types/hasura-graphql-auth-options.type.js +2 -0
  218. package/esm2015/infra/hasura-graphql/types/hasura-graphql-fields.type.js +2 -0
  219. package/esm2015/infra/hasura-graphql/types/hasura-graphql-headers.type.js +2 -0
  220. package/esm2015/infra/hasura-graphql/types/index.js +9 -0
  221. package/esm2015/infra/hasura-graphql/types/nested-field.type.js +2 -0
  222. package/esm2015/infra/hasura-graphql/types/query-builder-options.type.js +2 -0
  223. package/esm2015/infra/hasura-graphql/types/variable-options.type.js +2 -0
  224. package/esm2015/infra/index.js +2 -1
  225. package/esm2015/utils/index.js +6 -4
  226. package/esm2015/utils/is-uuid.js +3 -0
  227. package/esm2015/utils/mixins/index.js +2 -1
  228. package/esm2015/utils/mixins/merge-constructor-params.type.js +2 -0
  229. package/esm2015/utils/mixins/mixin-ctor.type.js +1 -1
  230. package/esm2015/utils/parse-datetime.js +14 -0
  231. package/esm2015/utils/types/array-element.type.js +2 -0
  232. package/esm2015/utils/types/index.js +2 -1
  233. package/fesm2015/infrab4a-connect.js +1375 -142
  234. package/fesm2015/infrab4a-connect.js.map +1 -1
  235. package/infra/elasticsearch/adapters/axios.adapter.d.ts +3 -0
  236. package/infra/elasticsearch/adapters/elastic-search.adapter.d.ts +3 -0
  237. package/infra/elasticsearch/indexes/products-index.d.ts +5 -1
  238. package/infra/firebase/auth/authentication-firebase-auth.service.d.ts +1 -1
  239. package/infra/firebase/auth/register-firebase-auth.service.d.ts +1 -1
  240. package/infra/firebase/firestore/mixins/with-create-firestore.mixin.d.ts +3 -16
  241. package/infra/firebase/firestore/mixins/with-crud-firestore.mixin.d.ts +3 -28
  242. package/infra/firebase/firestore/mixins/with-delete-firestore.mixin.d.ts +3 -14
  243. package/infra/firebase/firestore/mixins/with-find-firestore.mixin.d.ts +3 -19
  244. package/infra/firebase/firestore/mixins/with-firestore.mixin.d.ts +3 -14
  245. package/infra/firebase/firestore/mixins/with-get-firestore.mixin.d.ts +3 -14
  246. package/infra/firebase/firestore/mixins/with-helpers.mixin.d.ts +5 -4
  247. package/infra/firebase/firestore/mixins/with-sub-collection.mixin.d.ts +7 -14
  248. package/infra/firebase/firestore/mixins/with-update-firestore.mixin.d.ts +6 -15
  249. package/infra/firebase/firestore/models/user-search.d.ts +3 -3
  250. package/infra/firebase/firestore/repositories/catalog/category-firestore.repository.d.ts +1 -42
  251. package/infra/firebase/firestore/repositories/catalog/product-firestore.repository.d.ts +5 -44
  252. package/infra/firebase/firestore/repositories/catalog/product-variant-firestore.repository.d.ts +4 -51
  253. package/infra/firebase/firestore/repositories/catalog/subscription-product-firestore.repository.d.ts +1 -42
  254. package/infra/firebase/firestore/repositories/shop-settings/home-firestore.repository.d.ts +1 -42
  255. package/infra/firebase/firestore/repositories/shop-settings/shop-menu-firestore.repository.d.ts +1 -42
  256. package/infra/firebase/firestore/repositories/shopping/buy-2-win-firestore.repository.d.ts +1 -42
  257. package/infra/firebase/firestore/repositories/shopping/checkout-firestore.repository.d.ts +1 -42
  258. package/infra/firebase/firestore/repositories/shopping/checkout-subscription-firestore.repository.d.ts +1 -42
  259. package/infra/firebase/firestore/repositories/shopping/coupon-firestore.repository.d.ts +1 -42
  260. package/infra/firebase/firestore/repositories/shopping/order-firestore.repository.d.ts +1 -42
  261. package/infra/firebase/firestore/repositories/shopping/payment-firestore.repository.d.ts +1 -42
  262. package/infra/firebase/firestore/repositories/shopping/subscription-plan-firestore.repository.d.ts +1 -42
  263. package/infra/firebase/firestore/repositories/users/lead-firestore.repository.d.ts +1 -42
  264. package/infra/firebase/firestore/repositories/users/subscription-edition-firestore.repository.d.ts +4 -51
  265. package/infra/firebase/firestore/repositories/users/subscription-firestore.repository.d.ts +1 -42
  266. package/infra/firebase/firestore/repositories/users/subscription-payment-firestore.repository.d.ts +4 -51
  267. package/infra/firebase/firestore/repositories/users/user-address-firestore.repository.d.ts +4 -51
  268. package/infra/firebase/firestore/repositories/users/user-beauty-profile-firestore.repository.d.ts +4 -51
  269. package/infra/firebase/firestore/repositories/users/user-firestore.repository.d.ts +1 -42
  270. package/infra/firebase/firestore/repositories/users/user-payment-method-firestore.repository.d.ts +4 -51
  271. package/infra/firebase/firestore/repositories/users/user-search-firestore.repository.d.ts +1 -42
  272. package/infra/firebase/firestore/types/firestore-sub.repository.type.d.ts +3 -3
  273. package/infra/firebase/firestore/types/firestore.helpers.type.d.ts +3 -3
  274. package/infra/firebase/firestore/types/firestore.repository.type.d.ts +7 -3
  275. package/infra/hasura-graphql/enums/hasura-graphql-column-type.enum.d.ts +11 -0
  276. package/infra/hasura-graphql/enums/hasura-graphql-where.enum.d.ts +13 -0
  277. package/infra/hasura-graphql/enums/index.d.ts +2 -0
  278. package/infra/hasura-graphql/index.d.ts +4 -0
  279. package/infra/hasura-graphql/mixins/helpers/attribute-option.helper.d.ts +13 -0
  280. package/infra/hasura-graphql/mixins/helpers/filter-option.helper.d.ts +6 -0
  281. package/infra/hasura-graphql/mixins/helpers/graphql-field.helper.d.ts +8 -0
  282. package/infra/hasura-graphql/mixins/helpers/index.d.ts +3 -0
  283. package/infra/hasura-graphql/mixins/index.d.ts +7 -0
  284. package/infra/hasura-graphql/mixins/with-create-hasura-graphql.mixin.d.ts +8 -0
  285. package/infra/hasura-graphql/mixins/with-crud-hasura-graphql.mixin.d.ts +11 -0
  286. package/infra/hasura-graphql/mixins/with-delete-hasura-graphql.mixin.d.ts +7 -0
  287. package/infra/hasura-graphql/mixins/with-find-hasura-graphql.mixin.d.ts +31 -0
  288. package/infra/hasura-graphql/mixins/with-get-hasura-graphql.mixin.d.ts +24 -0
  289. package/infra/hasura-graphql/mixins/with-hasura-graphql.mixin.d.ts +11 -0
  290. package/infra/hasura-graphql/mixins/with-update-hasura-graphql.mixin.d.ts +14 -0
  291. package/infra/hasura-graphql/models/category-hasura-graphql.d.ts +6 -0
  292. package/infra/hasura-graphql/models/index.d.ts +4 -0
  293. package/infra/hasura-graphql/models/kit-product-hasura-graphql.d.ts +6 -0
  294. package/infra/hasura-graphql/models/product-hasura-graphql.d.ts +9 -0
  295. package/infra/hasura-graphql/models/variant-hasura-graphql.d.ts +9 -0
  296. package/infra/hasura-graphql/repositories/catalog/category-hasura-graphql.repository.d.ts +22 -0
  297. package/infra/hasura-graphql/repositories/catalog/index.d.ts +3 -0
  298. package/infra/hasura-graphql/repositories/catalog/product-hasura-graphql.repository.d.ts +26 -0
  299. package/infra/hasura-graphql/repositories/catalog/variant-hasura-graphql.repository.d.ts +13 -0
  300. package/infra/hasura-graphql/repositories/index.d.ts +1 -0
  301. package/infra/hasura-graphql/types/fields.type.d.ts +2 -0
  302. package/infra/hasura-graphql/types/graphql.repository.type.d.ts +21 -0
  303. package/infra/hasura-graphql/types/hasura-graphql-auth-options.type.d.ts +8 -0
  304. package/infra/hasura-graphql/types/hasura-graphql-fields.type.d.ts +36 -0
  305. package/infra/hasura-graphql/types/hasura-graphql-headers.type.d.ts +7 -0
  306. package/infra/hasura-graphql/types/index.d.ts +8 -0
  307. package/infra/hasura-graphql/types/nested-field.type.d.ts +7 -0
  308. package/infra/hasura-graphql/types/query-builder-options.type.d.ts +7 -0
  309. package/infra/hasura-graphql/types/variable-options.type.d.ts +9 -0
  310. package/infra/index.d.ts +1 -0
  311. package/package.json +5 -3
  312. package/utils/index.d.ts +5 -4
  313. package/utils/is-uuid.d.ts +1 -0
  314. package/utils/mixins/index.d.ts +1 -0
  315. package/utils/mixins/merge-constructor-params.type.d.ts +3 -0
  316. package/utils/mixins/mixin-ctor.type.d.ts +1 -1
  317. package/utils/parse-datetime.d.ts +1 -0
  318. package/utils/types/array-element.type.d.ts +1 -0
  319. package/utils/types/index.d.ts +1 -0
  320. package/domain/general/model/base-model-with-identifier-fields.d.ts +0 -3
  321. package/domain/general/model/base.model.d.ts +0 -6
  322. package/domain/general/model/types/base-model-builder.type.d.ts +0 -5
  323. package/domain/general/model/types/non-function-properties.type.d.ts +0 -2
  324. package/domain/general/model/types/non-function-property-name.type.d.ts +0 -3
  325. package/domain/general/repository/create.repository.d.ts +0 -5
  326. package/domain/general/repository/crud.repository.d.ts +0 -7
  327. package/domain/general/repository/delete.repository.d.ts +0 -5
  328. package/domain/general/repository/find.repository.d.ts +0 -5
  329. package/domain/general/repository/get.repository.d.ts +0 -5
  330. package/domain/general/repository/read.repository.d.ts +0 -5
  331. package/domain/general/repository/types/repository-find-filters.type.d.ts +0 -14
  332. package/domain/general/repository/update.repository.d.ts +0 -5
  333. package/domain/shopping/models/coupons/club-coupon.d.ts +0 -7
  334. package/domain/shopping/models/coupons/enums/discount-type.enum.d.ts +0 -5
  335. package/domain/shopping/models/coupons/store-coupon.d.ts +0 -8
  336. package/esm2015/domain/general/model/base-model-with-identifier-fields.js +0 -2
  337. package/esm2015/domain/general/model/base.model.js +0 -13
  338. package/esm2015/domain/general/model/index.js +0 -5
  339. package/esm2015/domain/general/model/types/base-model-builder.type.js +0 -2
  340. package/esm2015/domain/general/model/types/index.js +0 -4
  341. package/esm2015/domain/general/model/types/non-function-properties.type.js +0 -2
  342. package/esm2015/domain/general/model/types/non-function-property-name.type.js +0 -2
  343. package/esm2015/domain/general/repository/create.repository.js +0 -2
  344. package/esm2015/domain/general/repository/crud.repository.js +0 -2
  345. package/esm2015/domain/general/repository/delete.repository.js +0 -2
  346. package/esm2015/domain/general/repository/enums/where.enum.js +0 -12
  347. package/esm2015/domain/general/repository/find.repository.js +0 -2
  348. package/esm2015/domain/general/repository/get.repository.js +0 -2
  349. package/esm2015/domain/general/repository/read.repository.js +0 -2
  350. package/esm2015/domain/general/repository/types/index.js +0 -6
  351. package/esm2015/domain/general/repository/types/repository-find-filters.type.js +0 -2
  352. package/esm2015/domain/general/repository/types/repository-update-params.type.js +0 -2
  353. package/esm2015/domain/general/repository/update.repository.js +0 -2
  354. package/esm2015/domain/shopping/models/coupons/club-coupon.js +0 -18
  355. package/esm2015/domain/shopping/models/coupons/enums/discount-type.enum.js +0 -7
  356. package/esm2015/domain/shopping/models/coupons/store-coupon.js +0 -23
  357. /package/domain/{general → generic}/index.d.ts +0 -0
  358. /package/domain/{general → generic}/model/identifier-fields.d.ts +0 -0
  359. /package/domain/{general → generic}/repository/enums/index.d.ts +0 -0
  360. /package/domain/{general → generic}/repository/enums/update-option-actions.enum.d.ts +0 -0
  361. /package/domain/{general → generic}/repository/index.d.ts +0 -0
  362. /package/domain/{general → generic}/repository/types/repository-find-result.type.d.ts +0 -0
  363. /package/domain/{general → generic}/repository/types/repository-limit-options.type.d.ts +0 -0
  364. /package/domain/{general → generic}/repository/types/repository-order-by-list.type.d.ts +0 -0
@@ -1,24 +1,46 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('axios'), require('firebase'), require('firebase/app')) :
3
- typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'axios', 'firebase', 'firebase/app'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global.axios, global.firebase, global.firebase$1));
5
- })(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, axios, firebase, firebase$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('reflect-metadata'), require('class-transformer'), require('date-fns'), require('lodash'), require('ts-custom-error'), require('ts-md5'), require('axios'), require('firebase'), require('gql-query-builder'), require('node-fetch')) :
3
+ typeof define === 'function' && define.amd ? define('@infrab4a/connect', ['exports', 'reflect-metadata', 'class-transformer', 'date-fns', 'lodash', 'ts-custom-error', 'ts-md5', 'axios', 'firebase', 'gql-query-builder', 'node-fetch'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.infrab4a = global.infrab4a || {}, global.infrab4a.connect = {}), null, global["class-transformer"], global["date-fns"], global.lodash, global["ts-custom-error"], global["ts-md5"], global.axios, global.firebase, global["gql-query-builder"], global["node-fetch"]));
5
+ })(this, (function (exports, reflectMetadata, classTransformer, dateFns, lodash, tsCustomError, tsMd5, axios, firebase, gqlQueryBuilder, fetch) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
10
  var firebase__default = /*#__PURE__*/_interopDefaultLegacy(firebase);
11
- var firebase__default$1 = /*#__PURE__*/_interopDefaultLegacy(firebase$1);
11
+ var fetch__default = /*#__PURE__*/_interopDefaultLegacy(fetch);
12
12
 
13
13
  var BaseModel = /** @class */ (function () {
14
14
  function BaseModel(args) {
15
15
  Object.assign(this, args);
16
16
  }
17
+ Object.defineProperty(BaseModel.prototype, "identifier", {
18
+ get: function () {
19
+ var _this = this;
20
+ var fields = this.constructor.identifiersFields.filter(function (field) { return field !== 'identifier'; });
21
+ return fields.reduce(function (object, field) {
22
+ var _a;
23
+ return (Object.assign(Object.assign({}, object), (_a = {}, _a[field] = _this[field], _a)));
24
+ }, {});
25
+ },
26
+ enumerable: false,
27
+ configurable: true
28
+ });
29
+ Object.defineProperty(BaseModel.prototype, "identifiersFields", {
30
+ get: function () {
31
+ return this.constructor.identifiersFields;
32
+ },
33
+ enumerable: false,
34
+ configurable: true
35
+ });
17
36
  BaseModel.toInstance = function (data) {
18
- return classTransformer.plainToClass(this, data);
37
+ return classTransformer.plainToInstance(this, data || {});
38
+ };
39
+ BaseModel.isModel = function (value) {
40
+ return value instanceof this;
19
41
  };
20
42
  BaseModel.prototype.toPlain = function () {
21
- return classTransformer.classToPlain(this, { exposeUnsetFields: false });
43
+ return classTransformer.instanceToPlain(this);
22
44
  };
23
45
  return BaseModel;
24
46
  }());
@@ -26,13 +48,16 @@
26
48
  exports.Where = void 0;
27
49
  (function (Where) {
28
50
  Where["EQUALS"] = "==";
29
- Where["NOTEQUALS"] = "!=";
30
51
  Where["GT"] = ">";
31
52
  Where["GTE"] = ">=";
32
53
  Where["IN"] = "in";
54
+ Where["NOTIN"] = "not in";
33
55
  Where["LT"] = "<";
34
56
  Where["LTE"] = "<=";
35
57
  Where["LIKE"] = "like";
58
+ Where["NOTLIKE"] = "not like";
59
+ Where["ISNULL"] = "is null";
60
+ Where["ISNOTNULL"] = "is not null";
36
61
  })(exports.Where || (exports.Where = {}));
37
62
 
38
63
  exports.UpdateOptionActions = void 0;
@@ -587,9 +612,13 @@
587
612
  function Edition() {
588
613
  return _super !== null && _super.apply(this, arguments) || this;
589
614
  }
590
- Edition.prototype.identifierFields = function () {
591
- return ['id'];
592
- };
615
+ Object.defineProperty(Edition, "identifiersFields", {
616
+ get: function () {
617
+ return ['id', 'subscriptionId'];
618
+ },
619
+ enumerable: false,
620
+ configurable: true
621
+ });
593
622
  return Edition;
594
623
  }(BaseModel));
595
624
 
@@ -598,9 +627,13 @@
598
627
  function Payment() {
599
628
  return _super !== null && _super.apply(this, arguments) || this;
600
629
  }
601
- Payment.prototype.identifierFields = function () {
602
- return ['id'];
603
- };
630
+ Object.defineProperty(Payment, "identifiersFields", {
631
+ get: function () {
632
+ return ['id'];
633
+ },
634
+ enumerable: false,
635
+ configurable: true
636
+ });
604
637
  return Payment;
605
638
  }(BaseModel));
606
639
  __decorate([
@@ -769,9 +802,13 @@
769
802
  function SubscriptionPayment() {
770
803
  return _super !== null && _super.apply(this, arguments) || this;
771
804
  }
772
- SubscriptionPayment.prototype.identifierFields = function () {
773
- return ['id'];
774
- };
805
+ Object.defineProperty(SubscriptionPayment, "identifiersFields", {
806
+ get: function () {
807
+ return ['id', 'subscriptionId'];
808
+ },
809
+ enumerable: false,
810
+ configurable: true
811
+ });
775
812
  return SubscriptionPayment;
776
813
  }(BaseModel));
777
814
  __decorate([
@@ -784,6 +821,13 @@
784
821
  function Address() {
785
822
  return _super !== null && _super.apply(this, arguments) || this;
786
823
  }
824
+ Object.defineProperty(Address, "identifiersFields", {
825
+ get: function () {
826
+ return ['id'];
827
+ },
828
+ enumerable: false,
829
+ configurable: true
830
+ });
787
831
  return Address;
788
832
  }(BaseModel));
789
833
 
@@ -798,19 +842,19 @@
798
842
  return Base;
799
843
  }());
800
844
 
801
- exports.DiscountType = void 0;
802
- (function (DiscountType) {
803
- DiscountType[DiscountType["ABSOLUTE"] = 1] = "ABSOLUTE";
804
- DiscountType[DiscountType["PERCENTAGE"] = 2] = "PERCENTAGE";
805
- DiscountType[DiscountType["FREE_SHIPPING"] = 3] = "FREE_SHIPPING";
806
- })(exports.DiscountType || (exports.DiscountType = {}));
845
+ var isUUID = function (value) { return lodash.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); };
807
846
 
808
- exports.Exclusivities = void 0;
809
- (function (Exclusivities) {
810
- Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
811
- Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
812
- Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
813
- })(exports.Exclusivities || (exports.Exclusivities = {}));
847
+ var parseDateTime = function (value) {
848
+ if (!lodash.isString(value))
849
+ return value;
850
+ if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value) &&
851
+ !/^\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))
852
+ return value;
853
+ var date = dateFns.parseISO(value);
854
+ if (isNaN(date.getTime()))
855
+ return value;
856
+ return date;
857
+ };
814
858
 
815
859
  var Coupon = /** @class */ (function (_super) {
816
860
  __extends(Coupon, _super);
@@ -824,17 +868,13 @@
824
868
  enumerable: false,
825
869
  configurable: true
826
870
  });
827
- Coupon.prototype.identifierFields = function () {
828
- return ['id'];
829
- };
830
- Coupon.prototype.calculeDiscount = function (amount) {
831
- switch (this.discountType) {
832
- case exports.DiscountType.ABSOLUTE:
833
- return this.discount < amount ? this.discount : amount;
834
- case exports.DiscountType.PERCENTAGE:
835
- return this.discount * 0.01 * amount;
836
- }
837
- };
871
+ Object.defineProperty(Coupon, "identifiersFields", {
872
+ get: function () {
873
+ return ['id'];
874
+ },
875
+ enumerable: false,
876
+ configurable: true
877
+ });
838
878
  return Coupon;
839
879
  }(BaseModel));
840
880
  __decorate([
@@ -851,9 +891,13 @@
851
891
  function SubscriptionPlan() {
852
892
  return _super !== null && _super.apply(this, arguments) || this;
853
893
  }
854
- SubscriptionPlan.prototype.identifierFields = function () {
855
- return ['id'];
856
- };
894
+ Object.defineProperty(SubscriptionPlan, "identifiersFields", {
895
+ get: function () {
896
+ return ['id'];
897
+ },
898
+ enumerable: false,
899
+ configurable: true
900
+ });
857
901
  return SubscriptionPlan;
858
902
  }(BaseModel));
859
903
 
@@ -867,9 +911,13 @@
867
911
  delete plain.id;
868
912
  return plain;
869
913
  };
870
- BeautyProfile.prototype.identifierFields = function () {
871
- return ['id'];
872
- };
914
+ Object.defineProperty(BeautyProfile, "identifiersFields", {
915
+ get: function () {
916
+ return ['id', 'userId'];
917
+ },
918
+ enumerable: false,
919
+ configurable: true
920
+ });
873
921
  return BeautyProfile;
874
922
  }(BaseModel));
875
923
 
@@ -884,14 +932,18 @@
884
932
  instance.displayName = "" + data.firstName + (!lodash.isNil(data.lastName) ? " " + data.lastName : '');
885
933
  return instance;
886
934
  };
887
- User.prototype.identifierFields = function () {
888
- return ['id'];
889
- };
890
935
  User.prototype.toPlain = function () {
891
936
  var plain = _super.prototype.toPlain.call(this);
892
937
  delete plain.beautyProfile;
893
938
  return plain;
894
939
  };
940
+ Object.defineProperty(User, "identifiersFields", {
941
+ get: function () {
942
+ return ['id'];
943
+ },
944
+ enumerable: false,
945
+ configurable: true
946
+ });
895
947
  return User;
896
948
  }(BaseModel));
897
949
  __decorate([
@@ -904,9 +956,13 @@
904
956
  function Subscription() {
905
957
  return _super !== null && _super.apply(this, arguments) || this;
906
958
  }
907
- Subscription.prototype.identifierFields = function () {
908
- return ['id'];
909
- };
959
+ Object.defineProperty(Subscription, "identifiersFields", {
960
+ get: function () {
961
+ return ['id'];
962
+ },
963
+ enumerable: false,
964
+ configurable: true
965
+ });
910
966
  return Subscription;
911
967
  }(BaseModel));
912
968
  __decorate([
@@ -943,9 +999,13 @@
943
999
  function UserAddress() {
944
1000
  return _super !== null && _super.apply(this, arguments) || this;
945
1001
  }
946
- UserAddress.prototype.identifierFields = function () {
947
- return ['id'];
948
- };
1002
+ Object.defineProperty(UserAddress, "identifiersFields", {
1003
+ get: function () {
1004
+ return ['id', 'userId'];
1005
+ },
1006
+ enumerable: false,
1007
+ configurable: true
1008
+ });
949
1009
  return UserAddress;
950
1010
  }(Address));
951
1011
 
@@ -954,9 +1014,13 @@
954
1014
  function UserPaymentMethod() {
955
1015
  return _super !== null && _super.apply(this, arguments) || this;
956
1016
  }
957
- UserPaymentMethod.prototype.identifierFields = function () {
958
- return ['id'];
959
- };
1017
+ Object.defineProperty(UserPaymentMethod, "identifiersFields", {
1018
+ get: function () {
1019
+ return ['id', 'userId'];
1020
+ },
1021
+ enumerable: false,
1022
+ configurable: true
1023
+ });
960
1024
  return UserPaymentMethod;
961
1025
  }(BaseModel));
962
1026
 
@@ -965,9 +1029,13 @@
965
1029
  function Lead() {
966
1030
  return _super !== null && _super.apply(this, arguments) || this;
967
1031
  }
968
- Lead.prototype.identifierFields = function () {
969
- return ['id'];
970
- };
1032
+ Object.defineProperty(Lead, "identifiersFields", {
1033
+ get: function () {
1034
+ return ['id'];
1035
+ },
1036
+ enumerable: false,
1037
+ configurable: true
1038
+ });
971
1039
  return Lead;
972
1040
  }(BaseModel));
973
1041
 
@@ -979,7 +1047,7 @@
979
1047
  return _this;
980
1048
  }
981
1049
  return UnauthorizedError;
982
- }(Error));
1050
+ }(tsCustomError.CustomError));
983
1051
 
984
1052
  exports.SignInMethods = void 0;
985
1053
  (function (SignInMethods) {
@@ -1038,7 +1106,7 @@
1038
1106
  return _this;
1039
1107
  }
1040
1108
  return UserAlreadyRegisteredError;
1041
- }(Error));
1109
+ }(tsCustomError.CustomError));
1042
1110
 
1043
1111
  var WeakPasswordError = /** @class */ (function (_super) {
1044
1112
  __extends(WeakPasswordError, _super);
@@ -1049,7 +1117,7 @@
1049
1117
  return _this;
1050
1118
  }
1051
1119
  return WeakPasswordError;
1052
- }(Error));
1120
+ }(tsCustomError.CustomError));
1053
1121
 
1054
1122
  var Register = /** @class */ (function () {
1055
1123
  function Register(registerService, userRepository) {
@@ -1135,13 +1203,6 @@
1135
1203
  return RecoveryPassword;
1136
1204
  }());
1137
1205
 
1138
- exports.Shops = void 0;
1139
- (function (Shops) {
1140
- Shops["MENSMARKET"] = "mensmarket";
1141
- Shops["GLAMSHOP"] = "Glamshop";
1142
- Shops["GLAMPOINTS"] = "Glampoints";
1143
- })(exports.Shops || (exports.Shops = {}));
1144
-
1145
1206
  var Category = /** @class */ (function (_super) {
1146
1207
  __extends(Category, _super);
1147
1208
  function Category() {
@@ -1150,9 +1211,23 @@
1150
1211
  Category.prototype.identifierFields = function () {
1151
1212
  return ['id'];
1152
1213
  };
1214
+ Object.defineProperty(Category, "identifiersFields", {
1215
+ get: function () {
1216
+ return ['id'];
1217
+ },
1218
+ enumerable: false,
1219
+ configurable: true
1220
+ });
1153
1221
  return Category;
1154
1222
  }(BaseModel));
1155
1223
 
1224
+ exports.Shops = void 0;
1225
+ (function (Shops) {
1226
+ Shops["MENSMARKET"] = "mensmarket";
1227
+ Shops["GLAMSHOP"] = "Glamshop";
1228
+ Shops["GLAMPOINTS"] = "Glampoints";
1229
+ })(exports.Shops || (exports.Shops = {}));
1230
+
1156
1231
  var Product = /** @class */ (function (_super) {
1157
1232
  __extends(Product, _super);
1158
1233
  function Product() {
@@ -1165,8 +1240,42 @@
1165
1240
  var _a, _b, _c, _d, _e, _f;
1166
1241
  return Object.assign(Object.assign(Object.assign({}, (((_b = (_a = this.description) === null || _a === void 0 ? void 0 : _a[shop]) === null || _b === void 0 ? void 0 : _b.description) ? { description: (_d = (_c = this.description) === null || _c === void 0 ? void 0 : _c[shop]) === null || _d === void 0 ? void 0 : _d.description } : {})), (((_e = this.price) === null || _e === void 0 ? void 0 : _e[shop]) || {})), (((_f = this.stock) === null || _f === void 0 ? void 0 : _f[shop]) || {}));
1167
1242
  };
1243
+ Object.defineProperty(Product, "identifiersFields", {
1244
+ get: function () {
1245
+ return ['id'];
1246
+ },
1247
+ enumerable: false,
1248
+ configurable: true
1249
+ });
1168
1250
  return Product;
1169
1251
  }(BaseModel));
1252
+ __decorate([
1253
+ classTransformer.Type(function () { return KitProduct; }),
1254
+ __metadata("design:type", Array)
1255
+ ], Product.prototype, "kitProducts", void 0);
1256
+
1257
+ var KitProduct = /** @class */ (function (_super) {
1258
+ __extends(KitProduct, _super);
1259
+ function KitProduct() {
1260
+ return _super !== null && _super.apply(this, arguments) || this;
1261
+ }
1262
+ Object.defineProperty(KitProduct, "identifiersFields", {
1263
+ get: function () {
1264
+ return ['productId', 'kitProducId'];
1265
+ },
1266
+ enumerable: false,
1267
+ configurable: true
1268
+ });
1269
+ return KitProduct;
1270
+ }(BaseModel));
1271
+ __decorate([
1272
+ classTransformer.Type(function () { return Product; }),
1273
+ __metadata("design:type", Product)
1274
+ ], KitProduct.prototype, "kit", void 0);
1275
+ __decorate([
1276
+ classTransformer.Type(function () { return Product; }),
1277
+ __metadata("design:type", Product)
1278
+ ], KitProduct.prototype, "product", void 0);
1170
1279
 
1171
1280
  var Variant = /** @class */ (function (_super) {
1172
1281
  __extends(Variant, _super);
@@ -1176,52 +1285,69 @@
1176
1285
  Variant.prototype.identifierFields = function () {
1177
1286
  return ['id'];
1178
1287
  };
1288
+ Object.defineProperty(Variant, "identifiersFields", {
1289
+ get: function () {
1290
+ return ['id', 'productId'];
1291
+ },
1292
+ enumerable: false,
1293
+ configurable: true
1294
+ });
1179
1295
  return Variant;
1180
1296
  }(BaseModel));
1181
1297
 
1298
+ exports.CouponTypes = void 0;
1299
+ (function (CouponTypes) {
1300
+ CouponTypes[CouponTypes["FINANCIAL"] = 1] = "FINANCIAL";
1301
+ CouponTypes[CouponTypes["PRODUCT"] = 2] = "PRODUCT";
1302
+ CouponTypes[CouponTypes["GIFTCARD"] = 3] = "GIFTCARD";
1303
+ CouponTypes[CouponTypes["VOUCHER"] = 4] = "VOUCHER";
1304
+ })(exports.CouponTypes || (exports.CouponTypes = {}));
1305
+
1306
+ exports.CouponSubtypes = void 0;
1307
+ (function (CouponSubtypes) {
1308
+ CouponSubtypes[CouponSubtypes["ABSOLUTE"] = 1] = "ABSOLUTE";
1309
+ CouponSubtypes[CouponSubtypes["PERCENTAGE"] = 2] = "PERCENTAGE";
1310
+ })(exports.CouponSubtypes || (exports.CouponSubtypes = {}));
1311
+
1312
+ exports.Exclusivities = void 0;
1313
+ (function (Exclusivities) {
1314
+ Exclusivities[Exclusivities["ALL_USERS"] = 1] = "ALL_USERS";
1315
+ Exclusivities[Exclusivities["SPECIFIC_USER"] = 2] = "SPECIFIC_USER";
1316
+ Exclusivities[Exclusivities["COLLABORATORS"] = 3] = "COLLABORATORS";
1317
+ })(exports.Exclusivities || (exports.Exclusivities = {}));
1318
+
1182
1319
  exports.CheckoutTypes = void 0;
1183
1320
  (function (CheckoutTypes) {
1184
1321
  CheckoutTypes[CheckoutTypes["ECOMMERCE"] = 1] = "ECOMMERCE";
1185
1322
  CheckoutTypes[CheckoutTypes["SUBSCRIPTION"] = 2] = "SUBSCRIPTION";
1186
1323
  })(exports.CheckoutTypes || (exports.CheckoutTypes = {}));
1187
1324
 
1188
- var ClubCoupon = /** @class */ (function (_super) {
1189
- __extends(ClubCoupon, _super);
1190
- function ClubCoupon() {
1325
+ var COUPON_EXPIRATION = 60 * 60 * 24 * 30;
1326
+ var FinancialCoupon = /** @class */ (function (_super) {
1327
+ __extends(FinancialCoupon, _super);
1328
+ function FinancialCoupon() {
1191
1329
  var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1192
- _this.checkoutType = exports.CheckoutTypes.SUBSCRIPTION;
1330
+ _this.type = exports.CouponTypes.FINANCIAL;
1193
1331
  return _this;
1194
1332
  }
1195
- ClubCoupon.isClubCoupon = function (coupon) {
1196
- return coupon instanceof ClubCoupon;
1333
+ FinancialCoupon.isFinancialCoupon = function (coupon) {
1334
+ return coupon.type === exports.CouponTypes.FINANCIAL && !!coupon.subtype;
1197
1335
  };
1198
- return ClubCoupon;
1199
- }(Coupon));
1200
- __decorate([
1201
- classTransformer.Expose({ name: 'checkout_type' }),
1202
- __metadata("design:type", Object)
1203
- ], ClubCoupon.prototype, "checkoutType", void 0);
1204
-
1205
- var StoreCoupon = /** @class */ (function (_super) {
1206
- __extends(StoreCoupon, _super);
1207
- function StoreCoupon() {
1208
- var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
1209
- _this.checkoutType = exports.CheckoutTypes.ECOMMERCE;
1210
- return _this;
1211
- }
1212
- StoreCoupon.isStoreCoupon = function (coupon) {
1213
- return coupon instanceof StoreCoupon;
1336
+ FinancialCoupon.createCoupon = function (userId) {
1337
+ return this.toInstance({
1338
+ name: tsMd5.Md5.hashStr(userId + "_" + Date.now).toString(),
1339
+ nickname: "" + Date.now(),
1340
+ type: exports.CouponTypes.FINANCIAL,
1341
+ subtype: exports.CouponSubtypes.PERCENTAGE,
1342
+ checkoutType: exports.CheckoutTypes.ECOMMERCE,
1343
+ discount: 30,
1344
+ user: userId,
1345
+ createdAt: new Date(Date.now()),
1346
+ expiresIn: new Date(Date.now() + COUPON_EXPIRATION),
1347
+ });
1214
1348
  };
1215
- return StoreCoupon;
1349
+ return FinancialCoupon;
1216
1350
  }(Coupon));
1217
- __decorate([
1218
- classTransformer.Expose({ name: 'checkout_type' }),
1219
- __metadata("design:type", Object)
1220
- ], StoreCoupon.prototype, "checkoutType", void 0);
1221
- __decorate([
1222
- classTransformer.Type(function () { return Category; }),
1223
- __metadata("design:type", Array)
1224
- ], StoreCoupon.prototype, "categories", void 0);
1225
1351
 
1226
1352
  exports.OrderStatus = void 0;
1227
1353
  (function (OrderStatus) {
@@ -1248,9 +1374,13 @@
1248
1374
  function ShippingMethod() {
1249
1375
  return _super !== null && _super.apply(this, arguments) || this;
1250
1376
  }
1251
- ShippingMethod.prototype.identifierFields = function () {
1252
- return ['id'];
1253
- };
1377
+ Object.defineProperty(ShippingMethod, "identifiersFields", {
1378
+ get: function () {
1379
+ return ['id'];
1380
+ },
1381
+ enumerable: false,
1382
+ configurable: true
1383
+ });
1254
1384
  return ShippingMethod;
1255
1385
  }(BaseModel));
1256
1386
 
@@ -1259,26 +1389,13 @@
1259
1389
  function Checkout() {
1260
1390
  return _super !== null && _super.apply(this, arguments) || this;
1261
1391
  }
1262
- Object.defineProperty(Checkout.prototype, "subTotalPrice", {
1263
- get: function () {
1264
- return this.lineItems.reduce(function (total, item) {
1265
- return total + item.pricePaid;
1266
- }, 0);
1267
- },
1268
- enumerable: false,
1269
- configurable: true
1270
- });
1271
- Object.defineProperty(Checkout.prototype, "totalPrice", {
1392
+ Object.defineProperty(Checkout, "identifiersFields", {
1272
1393
  get: function () {
1273
- var _a;
1274
- return this.subTotalPrice + ((_a = this.shipping) === null || _a === void 0 ? void 0 : _a.ShippingPrice) - this.discount;
1394
+ return ['id'];
1275
1395
  },
1276
1396
  enumerable: false,
1277
1397
  configurable: true
1278
1398
  });
1279
- Checkout.prototype.identifierFields = function () {
1280
- return ['id'];
1281
- };
1282
1399
  return Checkout;
1283
1400
  }(BaseModel));
1284
1401
  __decorate([
@@ -1302,8 +1419,8 @@
1302
1419
  __metadata("design:type", ShippingMethod)
1303
1420
  ], Checkout.prototype, "shipping", void 0);
1304
1421
  __decorate([
1305
- classTransformer.Type(function () { return StoreCoupon; }),
1306
- __metadata("design:type", StoreCoupon)
1422
+ classTransformer.Type(function () { return Coupon; }),
1423
+ __metadata("design:type", Coupon)
1307
1424
  ], Checkout.prototype, "coupon", void 0);
1308
1425
 
1309
1426
  var Order = /** @class */ (function (_super) {
@@ -1323,9 +1440,13 @@
1323
1440
  function CheckoutSubscription() {
1324
1441
  return _super !== null && _super.apply(this, arguments) || this;
1325
1442
  }
1326
- CheckoutSubscription.prototype.identifierFields = function () {
1327
- return ['id'];
1328
- };
1443
+ Object.defineProperty(CheckoutSubscription, "identifiersFields", {
1444
+ get: function () {
1445
+ return ['id'];
1446
+ },
1447
+ enumerable: false,
1448
+ configurable: true
1449
+ });
1329
1450
  return CheckoutSubscription;
1330
1451
  }(BaseModel));
1331
1452
  __decorate([
@@ -1350,9 +1471,13 @@
1350
1471
  function Buy2Win() {
1351
1472
  return _super !== null && _super.apply(this, arguments) || this;
1352
1473
  }
1353
- Buy2Win.prototype.identifierFields = function () {
1354
- return ['id'];
1355
- };
1474
+ Object.defineProperty(Buy2Win, "identifiersFields", {
1475
+ get: function () {
1476
+ return ['id'];
1477
+ },
1478
+ enumerable: false,
1479
+ configurable: true
1480
+ });
1356
1481
  return Buy2Win;
1357
1482
  }(BaseModel));
1358
1483
  __decorate([
@@ -1454,9 +1579,13 @@
1454
1579
  function Home() {
1455
1580
  return _super !== null && _super.apply(this, arguments) || this;
1456
1581
  }
1457
- Home.prototype.identifierFields = function () {
1458
- return ['id'];
1459
- };
1582
+ Object.defineProperty(Home, "identifiersFields", {
1583
+ get: function () {
1584
+ return ['id'];
1585
+ },
1586
+ enumerable: false,
1587
+ configurable: true
1588
+ });
1460
1589
  return Home;
1461
1590
  }(BaseModel));
1462
1591
 
@@ -1465,9 +1594,13 @@
1465
1594
  function ShopMenu() {
1466
1595
  return _super !== null && _super.apply(this, arguments) || this;
1467
1596
  }
1468
- ShopMenu.prototype.identifierFields = function () {
1469
- return ['id'];
1470
- };
1597
+ Object.defineProperty(ShopMenu, "identifiersFields", {
1598
+ get: function () {
1599
+ return ['id'];
1600
+ },
1601
+ enumerable: false,
1602
+ configurable: true
1603
+ });
1471
1604
  return ShopMenu;
1472
1605
  }(BaseModel));
1473
1606
 
@@ -1479,7 +1612,7 @@
1479
1612
  return _this;
1480
1613
  }
1481
1614
  return InvalidArgumentError;
1482
- }(Error));
1615
+ }(tsCustomError.CustomError));
1483
1616
 
1484
1617
  var RequiredArgumentError = /** @class */ (function (_super) {
1485
1618
  __extends(RequiredArgumentError, _super);
@@ -1490,7 +1623,7 @@
1490
1623
  return _this;
1491
1624
  }
1492
1625
  return RequiredArgumentError;
1493
- }(Error));
1626
+ }(tsCustomError.CustomError));
1494
1627
 
1495
1628
  var NotFoundError = /** @class */ (function (_super) {
1496
1629
  __extends(NotFoundError, _super);
@@ -1500,7 +1633,7 @@
1500
1633
  return _this;
1501
1634
  }
1502
1635
  return NotFoundError;
1503
- }(Error));
1636
+ }(tsCustomError.CustomError));
1504
1637
 
1505
1638
  var DuplicatedResultsError = /** @class */ (function (_super) {
1506
1639
  __extends(DuplicatedResultsError, _super);
@@ -1510,12 +1643,35 @@
1510
1643
  return _this;
1511
1644
  }
1512
1645
  return DuplicatedResultsError;
1513
- }(Error));
1646
+ }(tsCustomError.CustomError));
1514
1647
 
1515
1648
  var AxiosAdapter = /** @class */ (function () {
1516
1649
  function AxiosAdapter(config) {
1517
1650
  this.config = config;
1518
1651
  }
1652
+ AxiosAdapter.prototype.get = function (index) {
1653
+ return __awaiter(this, void 0, void 0, function () {
1654
+ var data, error_1;
1655
+ return __generator(this, function (_a) {
1656
+ switch (_a.label) {
1657
+ case 0:
1658
+ _a.trys.push([0, 2, , 3]);
1659
+ return [4 /*yield*/, axios__default["default"]({
1660
+ url: this.config.url + "/" + index,
1661
+ method: 'GET',
1662
+ headers: { Authorization: "Basic " + this.config.credential },
1663
+ })];
1664
+ case 1:
1665
+ data = (_a.sent()).data;
1666
+ return [2 /*return*/, data._source];
1667
+ case 2:
1668
+ error_1 = _a.sent();
1669
+ throw new NotFoundError(error_1.message);
1670
+ case 3: return [2 /*return*/];
1671
+ }
1672
+ });
1673
+ });
1674
+ };
1519
1675
  AxiosAdapter.prototype.query = function (index, query) {
1520
1676
  return __awaiter(this, void 0, void 0, function () {
1521
1677
  var data;
@@ -1537,32 +1693,78 @@
1537
1693
  });
1538
1694
  });
1539
1695
  };
1540
- return AxiosAdapter;
1541
- }());
1542
-
1543
- var ProductsIndex = /** @class */ (function () {
1544
- function ProductsIndex(adapter) {
1545
- this.adapter = adapter;
1546
- }
1547
- ProductsIndex.prototype.findById = function (ids, options) {
1696
+ AxiosAdapter.prototype.save = function (index, data) {
1548
1697
  return __awaiter(this, void 0, void 0, function () {
1549
- var publishedField, fields, hits;
1550
- var _a;
1551
- return __generator(this, function (_b) {
1552
- switch (_b.label) {
1553
- case 0:
1554
- publishedField = options.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
1555
- fields = [
1556
- 'brand',
1557
- 'id',
1558
- 'images',
1559
- 'miniatures',
1560
- 'name',
1561
- 'price',
1562
- 'sku',
1563
- 'stock',
1564
- 'slug',
1565
- 'reviews',
1698
+ return __generator(this, function (_a) {
1699
+ switch (_a.label) {
1700
+ case 0: return [4 /*yield*/, axios__default["default"]({
1701
+ url: this.config.url + "/" + index,
1702
+ method: 'PUT',
1703
+ headers: { Authorization: "Basic " + this.config.credential },
1704
+ data: data,
1705
+ })];
1706
+ case 1:
1707
+ _a.sent();
1708
+ return [2 /*return*/];
1709
+ }
1710
+ });
1711
+ });
1712
+ };
1713
+ AxiosAdapter.prototype.delete = function (index) {
1714
+ return __awaiter(this, void 0, void 0, function () {
1715
+ return __generator(this, function (_a) {
1716
+ switch (_a.label) {
1717
+ case 0: return [4 /*yield*/, axios__default["default"]({
1718
+ url: this.config.url + "/" + index,
1719
+ method: 'DELETE',
1720
+ headers: { Authorization: "Basic " + this.config.credential },
1721
+ })];
1722
+ case 1:
1723
+ _a.sent();
1724
+ return [2 /*return*/];
1725
+ }
1726
+ });
1727
+ });
1728
+ };
1729
+ return AxiosAdapter;
1730
+ }());
1731
+
1732
+ var ProductsIndex = /** @class */ (function () {
1733
+ function ProductsIndex(adapter) {
1734
+ this.adapter = adapter;
1735
+ }
1736
+ ProductsIndex.prototype.get = function (id) {
1737
+ return __awaiter(this, void 0, void 0, function () {
1738
+ var data;
1739
+ return __generator(this, function (_a) {
1740
+ switch (_a.label) {
1741
+ case 0: return [4 /*yield*/, this.adapter.get("products/_doc/" + id)];
1742
+ case 1:
1743
+ data = _a.sent();
1744
+ return [2 /*return*/, Product.toInstance(data)];
1745
+ }
1746
+ });
1747
+ });
1748
+ };
1749
+ ProductsIndex.prototype.findById = function (ids, options) {
1750
+ return __awaiter(this, void 0, void 0, function () {
1751
+ var publishedField, fields, hits;
1752
+ var _a;
1753
+ return __generator(this, function (_b) {
1754
+ switch (_b.label) {
1755
+ case 0:
1756
+ publishedField = options.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
1757
+ fields = [
1758
+ 'brand',
1759
+ 'id',
1760
+ 'images',
1761
+ 'miniatures',
1762
+ 'name',
1763
+ 'price',
1764
+ 'sku',
1765
+ 'stock',
1766
+ 'slug',
1767
+ 'reviews',
1566
1768
  'pricePaid',
1567
1769
  'isGift',
1568
1770
  'stock',
@@ -1603,6 +1805,64 @@
1603
1805
  });
1604
1806
  });
1605
1807
  };
1808
+ ProductsIndex.prototype.save = function (product) {
1809
+ return __awaiter(this, void 0, void 0, function () {
1810
+ var error_1;
1811
+ return __generator(this, function (_a) {
1812
+ switch (_a.label) {
1813
+ case 0:
1814
+ delete product.createdAt;
1815
+ delete product.updatedAt;
1816
+ delete product.kitProducts;
1817
+ _a.label = 1;
1818
+ case 1:
1819
+ _a.trys.push([1, 4, , 6]);
1820
+ if (!product.firestoreId)
1821
+ throw new Error('Is not a product from firestore');
1822
+ return [4 /*yield*/, this.get(product.firestoreId)];
1823
+ case 2:
1824
+ _a.sent();
1825
+ return [4 /*yield*/, this.adapter.save("products/_doc/" + product.firestoreId, product.toPlain())];
1826
+ case 3:
1827
+ _a.sent();
1828
+ return [3 /*break*/, 6];
1829
+ case 4:
1830
+ error_1 = _a.sent();
1831
+ console.info(error_1.message);
1832
+ return [4 /*yield*/, this.adapter.save("products/_doc/" + product.id, product.toPlain())];
1833
+ case 5:
1834
+ _a.sent();
1835
+ return [3 /*break*/, 6];
1836
+ case 6: return [2 /*return*/];
1837
+ }
1838
+ });
1839
+ });
1840
+ };
1841
+ ProductsIndex.prototype.delete = function (product) {
1842
+ return __awaiter(this, void 0, void 0, function () {
1843
+ var error_2;
1844
+ return __generator(this, function (_a) {
1845
+ switch (_a.label) {
1846
+ case 0:
1847
+ _a.trys.push([0, 3, , 5]);
1848
+ return [4 /*yield*/, this.get(product.firestoreId)];
1849
+ case 1:
1850
+ _a.sent();
1851
+ return [4 /*yield*/, this.adapter.delete("products/_doc/" + product.firestoreId)];
1852
+ case 2:
1853
+ _a.sent();
1854
+ return [3 /*break*/, 5];
1855
+ case 3:
1856
+ error_2 = _a.sent();
1857
+ return [4 /*yield*/, this.adapter.delete("products/_doc/" + product.id)];
1858
+ case 4:
1859
+ _a.sent();
1860
+ return [3 /*break*/, 5];
1861
+ case 5: return [2 /*return*/];
1862
+ }
1863
+ });
1864
+ });
1865
+ };
1606
1866
  return ProductsIndex;
1607
1867
  }());
1608
1868
 
@@ -1610,11 +1870,7 @@
1610
1870
  return /** @class */ (function (_super) {
1611
1871
  __extends(class_1, _super);
1612
1872
  function class_1() {
1613
- var args = [];
1614
- for (var _i = 0; _i < arguments.length; _i++) {
1615
- args[_i] = arguments[_i];
1616
- }
1617
- return _super.call(this, args) || this;
1873
+ return _super !== null && _super.apply(this, arguments) || this;
1618
1874
  }
1619
1875
  class_1.prototype.collection = function (path) {
1620
1876
  return this.firestore.collection(path || this.collectionName).withConverter(this.buildModelInstance());
@@ -1626,7 +1882,7 @@
1626
1882
  fromFirestore: function (snap) {
1627
1883
  var data = snap.data();
1628
1884
  Object.keys(data).forEach(function (key) {
1629
- if (data[key] instanceof firebase__default["default"].firestore.Timestamp) {
1885
+ if (data[key] && typeof data[key] === 'object' && '_seconds' in data[key]) {
1630
1886
  data[key] = data[key].toDate();
1631
1887
  }
1632
1888
  });
@@ -1725,28 +1981,28 @@
1725
1981
  if ((options === null || options === void 0 ? void 0 : options.operator) === exports.Where.IN && Array.isArray(options === null || options === void 0 ? void 0 : options.value))
1726
1982
  return queryReference.where(firestoreFieldName, 'array-contains', options.value);
1727
1983
  if (lodash.isObject(options) && lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) && lodash.isNil(options === null || options === void 0 ? void 0 : options.value)) {
1728
- return Object.keys(options).reduce(function (queryReferenceWithWhere, key) { return _this.buildWhereSentence(queryReferenceWithWhere, fieldName + "." + key, options[key]); }, queryReference);
1984
+ return Object.keys(options).reduce(function (queryReferenceWithWhere, key) { return _this.buildWhereSentence(queryReferenceWithWhere, fieldName.toString() + "." + key, options[key]); }, queryReference);
1729
1985
  }
1730
1986
  return queryReference.where(firestoreFieldName, (options === null || options === void 0 ? void 0 : options.operator) || '==', (options === null || options === void 0 ? void 0 : options.value) || options);
1731
1987
  };
1732
1988
  return _this;
1733
1989
  }
1734
- FindFirestore.prototype.find = function (filters, limits, orderBy) {
1990
+ FindFirestore.prototype.find = function (_a) {
1991
+ var _b = _a === void 0 ? {} : _a, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy;
1735
1992
  return __awaiter(this, void 0, void 0, function () {
1736
1993
  var query, docs, data;
1737
- var _this = this;
1738
- return __generator(this, function (_b) {
1739
- switch (_b.label) {
1994
+ return __generator(this, function (_a) {
1995
+ switch (_a.label) {
1740
1996
  case 0:
1741
- query = this.collection(this.buildCollectionPathForFind(filters));
1742
- filters === null || filters === void 0 ? void 0 : filters.forEach(function (filterer) { return (query = _this.makeFirestoreWhere(query, filterer)); });
1743
- orderBy === null || orderBy === void 0 ? void 0 : orderBy.forEach(function (orderer) { return Object.keys(orderer).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderer[fieldName])); }); });
1997
+ query = this.collection(this.buildCollectionPathForFind(filters || {}));
1998
+ query = this.makeFirestoreWhere(query, filters || {});
1999
+ Object.keys(orderBy || {}).forEach(function (fieldName) { return (query = query.orderBy(fieldName, orderBy[fieldName])); });
1744
2000
  return [4 /*yield*/, this.defineLimits(query, filters, limits)];
1745
2001
  case 1:
1746
- query = _b.sent();
2002
+ query = _a.sent();
1747
2003
  return [4 /*yield*/, query.get()];
1748
2004
  case 2:
1749
- docs = _b.sent();
2005
+ docs = _a.sent();
1750
2006
  data = docs.docs.map(function (doc) { return doc.data(); });
1751
2007
  return [2 /*return*/, {
1752
2008
  data: data,
@@ -1757,32 +2013,31 @@
1757
2013
  });
1758
2014
  };
1759
2015
  FindFirestore.prototype.buildCollectionPathForFind = function (filters) {
1760
- var _a;
1761
2016
  if (!this.isSubCollection(this))
1762
2017
  return this.collectionName;
1763
2018
  var parentIdField = this.parentIdField;
1764
- var parentId = getValueFromFilter((_a = filters.find(function (groupFilter) { return Boolean(getValueFromFilter(groupFilter[parentIdField])); })) === null || _a === void 0 ? void 0 : _a[parentIdField]);
2019
+ var parentId = getValueFromFilter(filters === null || filters === void 0 ? void 0 : filters[parentIdField]);
1765
2020
  return this.parentRepository.collectionName + "/" + parentId + "/" + this.collectionName;
1766
2021
  };
1767
2022
  FindFirestore.prototype.defineLimits = function (query, filters, limits) {
1768
2023
  return __awaiter(this, void 0, void 0, function () {
1769
- var _b, _c;
1770
- return __generator(this, function (_d) {
1771
- switch (_d.label) {
2024
+ var _a, _b;
2025
+ return __generator(this, function (_c) {
2026
+ switch (_c.label) {
1772
2027
  case 0:
1773
2028
  if (!(limits === null || limits === void 0 ? void 0 : limits.offset)) return [3 /*break*/, 3];
1774
- if (!(limits.offset instanceof this.model)) return [3 /*break*/, 2];
1775
- _c = (_b = query).startAfter;
2029
+ if (!this.model.isModel(limits.offset)) return [3 /*break*/, 2];
2030
+ _b = (_a = query).startAfter;
1776
2031
  return [4 /*yield*/, this.collection(this.buildCollectionPathForFind(filters))
1777
- .doc(limits.offset[limits.offset.identifierFields().shift()])
2032
+ .doc(limits.offset[limits.offset.identifiersFields.shift()])
1778
2033
  .get()];
1779
2034
  case 1:
1780
- query = _c.apply(_b, [_d.sent()]);
2035
+ query = _b.apply(_a, [_c.sent()]);
1781
2036
  return [3 /*break*/, 3];
1782
2037
  case 2:
1783
2038
  if (lodash.isNumber(limits.offset) || lodash.isString(limits.offset))
1784
2039
  query = query.startAt(limits.offset);
1785
- _d.label = 3;
2040
+ _c.label = 3;
1786
2041
  case 3:
1787
2042
  if (limits === null || limits === void 0 ? void 0 : limits.limit)
1788
2043
  query = query.limit(limits.limit);
@@ -1831,7 +2086,7 @@
1831
2086
  return __generator(this, function (_b) {
1832
2087
  switch (_b.label) {
1833
2088
  case 0:
1834
- id = (_a = data[data.identifierFields().shift()]) === null || _a === void 0 ? void 0 : _a.toString();
2089
+ id = (_a = data[data.identifiersFields.shift()]) === null || _a === void 0 ? void 0 : _a.toString();
1835
2090
  collectionPath = this.buildCollectionPathForAdd(data);
1836
2091
  if (lodash.isEmpty(id))
1837
2092
  return [2 /*return*/, this.collection(collectionPath).add(data)];
@@ -1881,7 +2136,7 @@
1881
2136
  switch (_b.label) {
1882
2137
  case 0:
1883
2138
  model = new this.model();
1884
- keyField = model.identifierFields().shift();
2139
+ keyField = model.identifiersFields.shift();
1885
2140
  docRef = this.collection(this.buildCollectionPathForUpdate(data)).doc(getValueFromParams(data, keyField).toString());
1886
2141
  return [4 /*yield*/, docRef.set(this.paramsToPlain(data), { merge: true })];
1887
2142
  case 1:
@@ -1901,8 +2156,8 @@
1901
2156
  };
1902
2157
  UpdateFirestore.prototype.paramsToPlain = function (params) {
1903
2158
  var model = this.model;
1904
- if (params instanceof model)
1905
- return params;
2159
+ if (model.isModel(params))
2160
+ return params.toPlain();
1906
2161
  return Object.keys(params).reduce(function (data, currentKey) {
1907
2162
  var _b;
1908
2163
  return (Object.assign(Object.assign({}, data), (_b = {}, _b[currentKey] = getValueByAction(params[currentKey]), _b)));
@@ -1985,9 +2240,13 @@
1985
2240
  function UserSearch() {
1986
2241
  return _super !== null && _super.apply(this, arguments) || this;
1987
2242
  }
1988
- UserSearch.prototype.identifierFields = function () {
1989
- return ['id'];
1990
- };
2243
+ Object.defineProperty(UserSearch, "identifiersFields", {
2244
+ get: function () {
2245
+ return ['id'];
2246
+ },
2247
+ enumerable: false,
2248
+ configurable: true
2249
+ });
1991
2250
  return UserSearch;
1992
2251
  }(BaseModel));
1993
2252
 
@@ -2044,7 +2303,7 @@
2044
2303
  var _a;
2045
2304
  return __generator(this, function (_b) {
2046
2305
  switch (_b.label) {
2047
- case 0: return [4 /*yield*/, this.userSearchFirestoreRepository.find([(_a = {}, _a[field] = { operator: exports.Where.EQUALS, value: value }, _a)])];
2306
+ case 0: return [4 /*yield*/, this.userSearchFirestoreRepository.find((_a = {}, _a[field] = { operator: exports.Where.EQUALS, value: value }, _a))];
2048
2307
  case 1:
2049
2308
  result = _b.sent();
2050
2309
  return [2 /*return*/, result.count > 0];
@@ -2272,7 +2531,9 @@
2272
2531
  productIds = chunks_1_1.value;
2273
2532
  if ((options === null || options === void 0 ? void 0 : options.limit) && products.length >= (options === null || options === void 0 ? void 0 : options.limit))
2274
2533
  return [3 /*break*/, 6];
2275
- return [4 /*yield*/, this.collection('products').where(publishedField, '==', true).where('id', 'in', productIds)];
2534
+ return [4 /*yield*/, this.collection('productsErpVitrine')
2535
+ .where(publishedField, '==', true)
2536
+ .where('id', 'in', productIds)];
2276
2537
  case 3:
2277
2538
  query = _b.sent();
2278
2539
  if (options === null || options === void 0 ? void 0 : options.hasStock)
@@ -2313,20 +2574,22 @@
2313
2574
  function ProductFirestoreRepository(firestore) {
2314
2575
  var _this = _super.call(this) || this;
2315
2576
  _this.firestore = firestore;
2316
- _this.collectionName = 'products';
2577
+ _this.reviews = {};
2578
+ _this.collectionName = 'productsErpVitrine';
2317
2579
  _this.model = Product;
2318
2580
  return _this;
2319
2581
  }
2320
- ProductFirestoreRepository.prototype.getBySlug = function (slug, shop) {
2582
+ ProductFirestoreRepository.prototype.getBySlug = function (slug) {
2321
2583
  var _a;
2322
2584
  return __awaiter(this, void 0, void 0, function () {
2323
2585
  var result;
2324
2586
  return __generator(this, function (_b) {
2325
2587
  switch (_b.label) {
2326
- case 0: return [4 /*yield*/, this.find([
2327
- { slug: { operator: exports.Where.EQUALS, value: slug } },
2328
- { shopAvailability: { operator: exports.Where.IN, value: [shop] } },
2329
- ])];
2588
+ case 0: return [4 /*yield*/, this.find({
2589
+ filters: {
2590
+ slug: { operator: exports.Where.EQUALS, value: slug },
2591
+ },
2592
+ })];
2330
2593
  case 1:
2331
2594
  result = _b.sent();
2332
2595
  return [2 /*return*/, (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift()];
@@ -2334,6 +2597,41 @@
2334
2597
  });
2335
2598
  });
2336
2599
  };
2600
+ ProductFirestoreRepository.prototype.fetchReviews = function (status) {
2601
+ return __awaiter(this, void 0, void 0, function () {
2602
+ var products;
2603
+ var _this = this;
2604
+ return __generator(this, function (_b) {
2605
+ switch (_b.label) {
2606
+ case 0: return [4 /*yield*/, this.find()];
2607
+ case 1:
2608
+ products = (_b.sent()).data;
2609
+ products.forEach(function (product) {
2610
+ var _a;
2611
+ if ([undefined, 0].includes((_a = product.reviews) === null || _a === void 0 ? void 0 : _a.length))
2612
+ return;
2613
+ var productInfo = {
2614
+ productId: product.id,
2615
+ productName: product.name,
2616
+ productSku: product.sku,
2617
+ };
2618
+ _this.reviews.pending = [];
2619
+ _this.reviews.approved = [];
2620
+ _this.reviews.rejected = [];
2621
+ product.reviews.forEach(function (review) {
2622
+ if ([null, undefined].includes(review.status))
2623
+ return _this.reviews.pending.push(Object.assign(Object.assign({}, review), productInfo));
2624
+ if (review.status === false)
2625
+ return _this.reviews.rejected.push(Object.assign(Object.assign({}, review), productInfo));
2626
+ if (!!review.status)
2627
+ return _this.reviews.approved.push(Object.assign(Object.assign({}, review), productInfo));
2628
+ });
2629
+ });
2630
+ return [2 /*return*/, this.reviews[status]];
2631
+ }
2632
+ });
2633
+ });
2634
+ };
2337
2635
  return ProductFirestoreRepository;
2338
2636
  }(withCrudFirestore(withHelpers(withFirestore(Base)))));
2339
2637
 
@@ -2385,29 +2683,19 @@
2385
2683
  return _this;
2386
2684
  }
2387
2685
  CouponFirestoreRepository.prototype.buildModelInstance = function () {
2388
- var _this = this;
2686
+ var _a = _super.prototype.buildModelInstance.call(this), fromFirestore = _a.fromFirestore, toFirestore = _a.toFirestore;
2389
2687
  return {
2390
2688
  toFirestore: function (data) {
2391
- var _a;
2392
- var plain = (data === null || data === void 0 ? void 0 : data.toPlain) ? data.toPlain() : data;
2393
- if (!!plain.categories)
2394
- plain.categories = (_a = plain === null || plain === void 0 ? void 0 : plain.categories) === null || _a === void 0 ? void 0 : _a.map(function (category) { return category.id; });
2689
+ var plain = toFirestore(data);
2690
+ if (!!data.expiresIn)
2691
+ plain.expiresIn = data.expiresIn.getTime();
2395
2692
  return plain;
2396
2693
  },
2397
2694
  fromFirestore: function (snap) {
2398
- var _a;
2399
- var data = snap.data();
2400
- Object.keys(data).forEach(function (key) {
2401
- if (data[key] instanceof firebase__default["default"].firestore.Timestamp) {
2402
- data[key] = data[key].toDate();
2403
- }
2404
- });
2405
- data.categories = (_a = data === null || data === void 0 ? void 0 : data.categories) === null || _a === void 0 ? void 0 : _a.map(function (category) { return ({ id: category }); });
2406
- if (data.checkout_type === exports.CheckoutTypes.SUBSCRIPTION)
2407
- return ClubCoupon.toInstance(Object.assign({ id: snap.id }, data));
2408
- if (data.checkout_type === exports.CheckoutTypes.ECOMMERCE)
2409
- return StoreCoupon.toInstance(Object.assign({ id: snap.id }, data));
2410
- return _this.model.toInstance(Object.assign({ id: snap.id }, data));
2695
+ var instance = fromFirestore(snap);
2696
+ if (!lodash.isNil(instance.expiresIn))
2697
+ instance.expiresIn = new Date(snap.data().expiresIn);
2698
+ return instance;
2411
2699
  },
2412
2700
  };
2413
2701
  };
@@ -2582,7 +2870,7 @@
2582
2870
  var credentials, user;
2583
2871
  return __generator(this, function (_a) {
2584
2872
  switch (_a.label) {
2585
- case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default$1["default"].auth.GoogleAuthProvider())];
2873
+ case 0: return [4 /*yield*/, this.firebaseAuth.signInWithPopup(new firebase__default["default"].auth.GoogleAuthProvider())];
2586
2874
  case 1:
2587
2875
  credentials = _a.sent();
2588
2876
  user = credentials.user;
@@ -2663,49 +2951,1651 @@
2663
2951
  return RegisterFirebaseAuthService;
2664
2952
  }());
2665
2953
 
2666
- /**
2667
- * Generated bundle index. Do not edit.
2668
- */
2954
+ var AttributeOptionHelper = /** @class */ (function () {
2955
+ function AttributeOptionHelper() {
2956
+ }
2957
+ return AttributeOptionHelper;
2958
+ }());
2959
+ AttributeOptionHelper.FindByAttribute = function (attributeName, fields) {
2960
+ if (fields.includes(attributeName))
2961
+ return { columnName: attributeName.toString(), attributeName: attributeName };
2962
+ var field = fields.find(function (columnOption) { return lodash.isObject(columnOption) && Object.keys(columnOption).includes(attributeName.toString()); });
2963
+ var fieldOption = field === null || field === void 0 ? void 0 : field[attributeName.toString()];
2964
+ if (lodash.isNil(fieldOption))
2965
+ return { columnName: attributeName.toString(), attributeName: attributeName };
2966
+ if (Array.isArray(fieldOption))
2967
+ return { columnName: attributeName.toString(), attributeName: attributeName, fields: fieldOption };
2968
+ return Object.assign({ attributeName: attributeName, columnName: attributeName.toString() }, fieldOption);
2969
+ };
2970
+ AttributeOptionHelper.CheckIsColumnOption = function (fieldValue) { return !!fieldValue.columnName; };
2971
+ AttributeOptionHelper.FindColumnOptionFromList = function (columnName, fields) {
2972
+ if (fields.includes(columnName))
2973
+ return { columnName: columnName, attributeName: columnName };
2974
+ var field = fields.find(function (columnOption) {
2975
+ var _a;
2976
+ return lodash.isObject(columnOption) &&
2977
+ ((_a = Object.values(columnOption).find(function (option) { return AttributeOptionHelper.CheckIsColumnOption(option) && option.columnName === columnName; })) === null || _a === void 0 ? void 0 : _a.columnName) === columnName;
2978
+ }) || {};
2979
+ var attributeName = Object.keys(field).find(function (fieldOptionFromList) { return AttributeOptionHelper.CheckIsColumnOption(field[fieldOptionFromList]) ||
2980
+ Array.isArray(field[fieldOptionFromList]); });
2981
+ var fieldOption = field === null || field === void 0 ? void 0 : field[attributeName];
2982
+ if (Array.isArray(fieldOption))
2983
+ return { attributeName: attributeName, fields: fieldOption };
2984
+ return Object.assign({ attributeName: attributeName || columnName, columnName: columnName }, fieldOption);
2985
+ };
2669
2986
 
2670
- Object.defineProperty(exports, 'add', {
2671
- enumerable: true,
2672
- get: function () { return dateFns.add; }
2673
- });
2674
- Object.defineProperty(exports, 'sub', {
2675
- enumerable: true,
2676
- get: function () { return dateFns.sub; }
2677
- });
2678
- Object.defineProperty(exports, 'chunk', {
2679
- enumerable: true,
2680
- get: function () { return lodash.chunk; }
2681
- });
2682
- Object.defineProperty(exports, 'get', {
2683
- enumerable: true,
2684
- get: function () { return lodash.get; }
2685
- });
2686
- Object.defineProperty(exports, 'isDate', {
2687
- enumerable: true,
2688
- get: function () { return lodash.isDate; }
2689
- });
2690
- Object.defineProperty(exports, 'isEmpty', {
2691
- enumerable: true,
2692
- get: function () { return lodash.isEmpty; }
2693
- });
2694
- Object.defineProperty(exports, 'isNil', {
2695
- enumerable: true,
2696
- get: function () { return lodash.isNil; }
2697
- });
2698
- Object.defineProperty(exports, 'isNumber', {
2699
- enumerable: true,
2700
- get: function () { return lodash.isNumber; }
2701
- });
2702
- Object.defineProperty(exports, 'isObject', {
2703
- enumerable: true,
2704
- get: function () { return lodash.isObject; }
2705
- });
2706
- Object.defineProperty(exports, 'isString', {
2707
- enumerable: true,
2708
- get: function () { return lodash.isString; }
2987
+ var GraphQLFieldHelper = /** @class */ (function () {
2988
+ function GraphQLFieldHelper() {
2989
+ }
2990
+ return GraphQLFieldHelper;
2991
+ }());
2992
+ GraphQLFieldHelper.CheckIsGraphQLParams = function (params) { return !lodash.isString(params) && Array.isArray(params) && params.length >= 0 && !!params[0].operation; };
2993
+ GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields = function (fields) {
2994
+ return fields === null || fields === void 0 ? void 0 : fields.map(function (field) {
2995
+ var _b, _c;
2996
+ if (lodash.isString(field))
2997
+ return field.toString();
2998
+ var fieldName = Object.keys(field).shift();
2999
+ var fieldValue = field[fieldName];
3000
+ if (Array.isArray(fieldValue))
3001
+ return _b = {}, _b[fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue), _b;
3002
+ if (!AttributeOptionHelper.CheckIsColumnOption(fieldValue))
3003
+ return;
3004
+ if (fieldValue.fields)
3005
+ return _c = {},
3006
+ _c[fieldValue.columnName || fieldName] = GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fieldValue.fields),
3007
+ _c;
3008
+ return fieldValue.columnName;
3009
+ }).filter(function (field) { return !!field; });
3010
+ };
3011
+ GraphQLFieldHelper.ConvertFieldValueFrom = function (data, fields) { return Object.keys(data).reduce(function (result, columnName) {
3012
+ var _b, _c, _d, _e;
3013
+ var _f = AttributeOptionHelper.FindColumnOptionFromList(columnName, fields), attributeName = _f.attributeName, attributeFields = _f.fields, from = _f.from;
3014
+ if (!!attributeFields && Array.isArray(attributeFields)) {
3015
+ if (Array.isArray(data[columnName]))
3016
+ return Object.assign(Object.assign({}, result), (_b = {}, _b[attributeName] = from
3017
+ ? from(data[columnName], data)
3018
+ : data[columnName].map(function (value) { return GraphQLFieldHelper.ConvertFieldValueFrom(value, attributeFields); }), _b));
3019
+ if (lodash.isObject(data[columnName]))
3020
+ return Object.assign(Object.assign({}, result), (_c = {}, _c[attributeName] = !!from
3021
+ ? from(data[columnName])
3022
+ : GraphQLFieldHelper.ConvertFieldValueFrom(data[columnName], attributeFields), _c));
3023
+ }
3024
+ if (!!from)
3025
+ return Object.assign(Object.assign({}, result), (_d = {}, _d[attributeName] = from(data[columnName], data), _d));
3026
+ return Object.assign(Object.assign({}, result), (_e = {}, _e[attributeName] = parseDateTime(data[columnName]), _e));
3027
+ }, {}); };
3028
+ GraphQLFieldHelper.ConvertFieldValueTo = function (instance, fields, update) {
3029
+ if (update === void 0) { update = false; }
3030
+ var _a;
3031
+ var data = ((_a = instance.toPlain) === null || _a === void 0 ? void 0 : _a.call(instance)) || instance;
3032
+ return Object.keys(data).reduce(function (result, attributeName) {
3033
+ var _b, _c, _d;
3034
+ var _e = AttributeOptionHelper.FindByAttribute(attributeName, fields), columnName = _e.columnName, attributeFields = _e.fields, foreignKeyColumn = _e.foreignKeyColumn, to = _e.to, bindPersistData = _e.bindPersistData;
3035
+ if (bindPersistData)
3036
+ return Object.assign(Object.assign({}, result), bindPersistData(data[attributeName], instance));
3037
+ if (lodash.isNil(columnName))
3038
+ return result;
3039
+ if (!!foreignKeyColumn &&
3040
+ !lodash.isEmpty(foreignKeyColumn) &&
3041
+ !Object.keys(foreignKeyColumn).filter(function (key) { var _a; return !((_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[key]); }).length)
3042
+ return Object.keys(foreignKeyColumn).reduce(function (object, current) {
3043
+ var _b;
3044
+ var _a;
3045
+ return (Object.assign(Object.assign({}, object), (_b = {}, _b[foreignKeyColumn[current]] = (_a = data[attributeName]) === null || _a === void 0 ? void 0 : _a[current], _b)));
3046
+ }, Object.assign({}, result));
3047
+ if (update && lodash.isObject(data[attributeName]) && !lodash.isNil(attributeFields) && !lodash.isDate(data[attributeName]))
3048
+ return result;
3049
+ if (!!columnName && Array.isArray(attributeFields) && lodash.isObject(data[attributeName])) {
3050
+ var converted = !lodash.isNil(columnName) && to ? to(instance[attributeName], instance) : data[attributeName];
3051
+ return Object.assign(Object.assign({}, result), (converted !== undefined
3052
+ ? (_b = {},
3053
+ _b[columnName] = {
3054
+ data: instance[attributeName] instanceof BaseModel
3055
+ ? GraphQLFieldHelper.ConvertFieldValueTo(data[attributeName], attributeFields)
3056
+ : converted,
3057
+ },
3058
+ _b) : {}));
3059
+ }
3060
+ if (!!to)
3061
+ return Object.assign(Object.assign({}, result), (_c = {}, _c[columnName] = to(instance[attributeName], instance), _c));
3062
+ return Object.assign(Object.assign({}, result), (_d = {}, _d[columnName] = data[attributeName], _d));
3063
+ }, {});
3064
+ };
3065
+
3066
+ var FilterOptionHelper = /** @class */ (function () {
3067
+ function FilterOptionHelper() {
3068
+ }
3069
+ return FilterOptionHelper;
3070
+ }());
3071
+ FilterOptionHelper.CheckIfIsFilterOption = function (filter) { return !lodash.isNil(filter === null || filter === void 0 ? void 0 : filter.operator); };
3072
+ FilterOptionHelper.GetValueFromFilter = function (filter, fieldOption) {
3073
+ if (!FilterOptionHelper.CheckIfIsFilterOption(filter))
3074
+ return filter;
3075
+ if (filter.operator === exports.Where.ISNULL)
3076
+ return true;
3077
+ if (filter.operator === exports.Where.ISNOTNULL)
3078
+ return false;
3079
+ var converter = fieldOption.to ? fieldOption.to : function (value) { return value; };
3080
+ return Array.isArray(filter.value) && !fieldOption.fields && [exports.Where.IN, exports.Where.NOTIN].includes(filter.operator)
3081
+ ? filter.value.map(function (fieldValue) { return converter(fieldValue); })
3082
+ : converter(filter.value);
3083
+ };
3084
+
3085
+ var withCreateHasuraGraphQL = function (MixinBase) {
3086
+ return /** @class */ (function (_super) {
3087
+ __extends(CreateHasuraGraphQLMixin, _super);
3088
+ function CreateHasuraGraphQLMixin() {
3089
+ var params = [];
3090
+ for (var _i = 0; _i < arguments.length; _i++) {
3091
+ params[_i] = arguments[_i];
3092
+ }
3093
+ var _this = this;
3094
+ var options = params === null || params === void 0 ? void 0 : params[0];
3095
+ _this = _super.apply(this, __spreadArray([], __read(params))) || this;
3096
+ _this.insertGraphQLOperation = (options === null || options === void 0 ? void 0 : options.insertGraphQLOperation) || "insert_" + _this.tableName + "_one";
3097
+ _this.insertGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.insertGraphQLObjectType) || _this.tableName + "_insert_input";
3098
+ return _this;
3099
+ }
3100
+ CreateHasuraGraphQLMixin.prototype.create = function (data) {
3101
+ return __awaiter(this, void 0, void 0, function () {
3102
+ var newData;
3103
+ return __generator(this, function (_b) {
3104
+ switch (_b.label) {
3105
+ case 0: return [4 /*yield*/, this.save(this.model.toInstance(data))];
3106
+ case 1:
3107
+ newData = _b.sent();
3108
+ return [2 /*return*/, this.model.toInstance(newData)];
3109
+ }
3110
+ });
3111
+ });
3112
+ };
3113
+ CreateHasuraGraphQLMixin.prototype.save = function (data) {
3114
+ return __awaiter(this, void 0, void 0, function () {
3115
+ var primaryKeyColumns, foreignKeyColumns, result;
3116
+ var _this = this;
3117
+ return __generator(this, function (_b) {
3118
+ switch (_b.label) {
3119
+ case 0:
3120
+ primaryKeyColumns = this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; });
3121
+ foreignKeyColumns = this.fields
3122
+ .map(function (field) {
3123
+ var _b;
3124
+ var columnOptions = Object.values(field).shift();
3125
+ return (AttributeOptionHelper.CheckIsColumnOption(columnOptions) &&
3126
+ columnOptions.foreignKeyColumn && __spreadArray(__spreadArray([], __read(Object.values(columnOptions.foreignKeyColumn))), [
3127
+ (_b = {},
3128
+ _b[columnOptions.columnName] = Object.keys(columnOptions.foreignKeyColumn).map(function (foreignKeyField) {
3129
+ var _a;
3130
+ return ((_a = AttributeOptionHelper.FindByAttribute(foreignKeyField, columnOptions === null || columnOptions === void 0 ? void 0 : columnOptions.fields)) === null || _a === void 0 ? void 0 : _a.columnName) ||
3131
+ foreignKeyField;
3132
+ }),
3133
+ _b),
3134
+ ]));
3135
+ })
3136
+ .filter(Boolean)
3137
+ .reduce(function (keys, current) { return __spreadArray(__spreadArray([], __read(keys)), __read(current)); }, []);
3138
+ return [4 /*yield*/, this.mutation(this.insertGraphQLOperation, __spreadArray(__spreadArray([], __read(primaryKeyColumns)), __read(foreignKeyColumns)), {
3139
+ object: { type: this.insertGraphQLObjectType, required: true, value: this.convertDataToHasura(data) },
3140
+ })];
3141
+ case 1:
3142
+ result = _b.sent();
3143
+ return [2 /*return*/, Object.assign(Object.assign({}, data.toPlain()), this.convertDataFromHasura(result[this.insertGraphQLOperation]).toPlain())];
3144
+ }
3145
+ });
3146
+ });
3147
+ };
3148
+ return CreateHasuraGraphQLMixin;
3149
+ }(MixinBase));
3150
+ };
3151
+
3152
+ var withDeleteHasuraGraphQL = function (MixinBase) {
3153
+ return /** @class */ (function (_super) {
3154
+ __extends(DeleteHasuraGraphQLMixin, _super);
3155
+ function DeleteHasuraGraphQLMixin() {
3156
+ var params = [];
3157
+ for (var _i = 0; _i < arguments.length; _i++) {
3158
+ params[_i] = arguments[_i];
3159
+ }
3160
+ var _this = this;
3161
+ var options = params === null || params === void 0 ? void 0 : params[0];
3162
+ _this = _super.apply(this, __spreadArray([], __read(params))) || this;
3163
+ _this.deleteGraphQLOperation = (options === null || options === void 0 ? void 0 : options.deleteGraphQLOperation) || "delete_" + _this.tableName + "_by_pk";
3164
+ return _this;
3165
+ }
3166
+ DeleteHasuraGraphQLMixin.prototype.delete = function (identifiers) {
3167
+ return __awaiter(this, void 0, void 0, function () {
3168
+ var instance;
3169
+ var _this = this;
3170
+ return __generator(this, function (_a) {
3171
+ switch (_a.label) {
3172
+ case 0:
3173
+ instance = this.model.toInstance(identifiers);
3174
+ return [4 /*yield*/, this.mutation(this.deleteGraphQLOperation, this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; }), this.model.identifiersFields.reduce(function (ids, identifier) {
3175
+ var _a;
3176
+ if (lodash.isNil(instance[identifier]))
3177
+ return ids;
3178
+ var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
3179
+ var value = columnOption.to(identifiers[identifier.toString()], instance);
3180
+ return Object.assign(Object.assign({}, ids), (_a = {}, _a[columnOption.columnName] = {
3181
+ type: _this.getAttributeGraphQLTypeOf(columnOption.type || value),
3182
+ value: value,
3183
+ required: true,
3184
+ }, _a));
3185
+ }, {}))];
3186
+ case 1:
3187
+ _a.sent();
3188
+ return [2 /*return*/];
3189
+ }
3190
+ });
3191
+ });
3192
+ };
3193
+ return DeleteHasuraGraphQLMixin;
3194
+ }(MixinBase));
3195
+ };
3196
+
3197
+ var withHasuraGraphQL = function (MixinBase) {
3198
+ return /** @class */ (function (_super) {
3199
+ __extends(HasuraGraphQLMixin, _super);
3200
+ function HasuraGraphQLMixin() {
3201
+ var params = [];
3202
+ for (var _i = 0; _i < arguments.length; _i++) {
3203
+ params[_i] = arguments[_i];
3204
+ }
3205
+ var _this = this;
3206
+ var options = params[0];
3207
+ _this = _super.apply(this, __spreadArray([], __read(params))) || this;
3208
+ _this.tableName = options.tableName;
3209
+ _this.endpoint = options.endpoint;
3210
+ _this.authOptions = options.authOptions;
3211
+ _this.model = options.model;
3212
+ _this.fields = options.fields || _this.model.identifiersFields;
3213
+ return _this;
3214
+ }
3215
+ Object.defineProperty(HasuraGraphQLMixin.prototype, "headers", {
3216
+ get: function () {
3217
+ return Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (lodash.isNil(this.authOptions.authToken) ? {} : { Authorization: this.authOptions.authToken })), (lodash.isNil(this.authOptions.adminSecret) ? {} : { 'X-Hasura-Admin-Secret': this.authOptions.adminSecret })), (lodash.isNil(this.authOptions.authRole)
3218
+ ? {}
3219
+ : { 'X-Hasura-Role': this.authOptions.authRole.role, 'X-Hasura-User-Id': this.authOptions.authRole.userId }));
3220
+ },
3221
+ enumerable: false,
3222
+ configurable: true
3223
+ });
3224
+ HasuraGraphQLMixin.prototype.mutation = function (operation, fields, variables) {
3225
+ return __awaiter(this, void 0, void 0, function () {
3226
+ var resultQuery;
3227
+ return __generator(this, function (_a) {
3228
+ resultQuery = gqlQueryBuilder.mutation({
3229
+ operation: operation,
3230
+ variables: variables,
3231
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
3232
+ });
3233
+ return [2 /*return*/, this.fetch(resultQuery)];
3234
+ });
3235
+ });
3236
+ };
3237
+ HasuraGraphQLMixin.prototype.query = function (operation, fields, variables) {
3238
+ return __awaiter(this, void 0, void 0, function () {
3239
+ var resultQuery;
3240
+ return __generator(this, function (_a) {
3241
+ resultQuery = GraphQLFieldHelper.CheckIsGraphQLParams(operation)
3242
+ ? gqlQueryBuilder.query(operation.map(function (option) { return ({
3243
+ operation: option.operation,
3244
+ variables: option.variables,
3245
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(option.fields),
3246
+ }); }))
3247
+ : gqlQueryBuilder.query({
3248
+ operation: operation,
3249
+ variables: variables,
3250
+ fields: GraphQLFieldHelper.ConvertModelFieldsToGraphQLFields(fields),
3251
+ });
3252
+ return [2 /*return*/, this.fetch(resultQuery)];
3253
+ });
3254
+ });
3255
+ };
3256
+ HasuraGraphQLMixin.prototype.fetch = function (params) {
3257
+ return __awaiter(this, void 0, void 0, function () {
3258
+ var headers, response, result;
3259
+ return __generator(this, function (_a) {
3260
+ switch (_a.label) {
3261
+ case 0:
3262
+ headers = this.headers;
3263
+ return [4 /*yield*/, fetch__default["default"]("" + this.endpoint, {
3264
+ method: 'POST',
3265
+ body: JSON.stringify(params),
3266
+ headers: headers,
3267
+ })];
3268
+ case 1:
3269
+ response = _a.sent();
3270
+ return [4 /*yield*/, response.json()];
3271
+ case 2:
3272
+ result = _a.sent();
3273
+ if (!lodash.isNil(result.errors))
3274
+ throw new Error(JSON.stringify(result.errors));
3275
+ return [2 /*return*/, result.data];
3276
+ }
3277
+ });
3278
+ });
3279
+ };
3280
+ HasuraGraphQLMixin.prototype.getAttributeGraphQLTypeOf = function (value) {
3281
+ if (isUUID(value))
3282
+ return 'uuid';
3283
+ if (lodash.isString(value))
3284
+ return 'String';
3285
+ if (lodash.isBoolean(value))
3286
+ return 'Boolean';
3287
+ if (value instanceof Date)
3288
+ return 'timestamptz';
3289
+ if (lodash.isInteger(value))
3290
+ return 'Int';
3291
+ if (lodash.isNumber(value))
3292
+ return 'numeric';
3293
+ throw new Error('Type not implemented yet');
3294
+ };
3295
+ HasuraGraphQLMixin.prototype.checkIfIsDateTimeAndParse = function (value) {
3296
+ if (!/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/.test(value))
3297
+ return value;
3298
+ var date = dateFns.parseISO(value);
3299
+ if (lodash.isNaN(date.getTime()))
3300
+ return value;
3301
+ return date;
3302
+ };
3303
+ HasuraGraphQLMixin.prototype.convertDataFromHasura = function (data) {
3304
+ var plain = GraphQLFieldHelper.ConvertFieldValueFrom(data, this.fields);
3305
+ return this.model.toInstance(plain);
3306
+ };
3307
+ HasuraGraphQLMixin.prototype.convertDataToHasura = function (instance, update) {
3308
+ if (update === void 0) { update = false; }
3309
+ return GraphQLFieldHelper.ConvertFieldValueTo(instance, this.fields, update);
3310
+ };
3311
+ return HasuraGraphQLMixin;
3312
+ }(MixinBase));
3313
+ };
3314
+
3315
+ var withUpdateHasuraGraphQL = function (MixinBase) {
3316
+ var getValueByAction = function (options) {
3317
+ if (options instanceof BaseModel)
3318
+ return options.toPlain();
3319
+ if (lodash.isNil(options === null || options === void 0 ? void 0 : options.action))
3320
+ return options;
3321
+ if ([exports.UpdateOptionActions.REMOVE_FIELD.toString(), exports.UpdateOptionActions.NULL.toString()].includes(options.action))
3322
+ return null;
3323
+ return options.value;
3324
+ };
3325
+ return /** @class */ (function (_super) {
3326
+ __extends(UpdateHasuraGraphQLMixin, _super);
3327
+ function UpdateHasuraGraphQLMixin() {
3328
+ var params = [];
3329
+ for (var _i = 0; _i < arguments.length; _i++) {
3330
+ params[_i] = arguments[_i];
3331
+ }
3332
+ var _this = this;
3333
+ var options = params === null || params === void 0 ? void 0 : params[0];
3334
+ _this = _super.apply(this, __spreadArray([], __read(params))) || this;
3335
+ _this.updateGraphQLOperation = (options === null || options === void 0 ? void 0 : options.updateGraphQLOperation) || "update_" + _this.tableName + "_by_pk";
3336
+ _this.updateGraphQLObjectType = (options === null || options === void 0 ? void 0 : options.updateGraphQLObjectType) || _this.tableName + "_set_input";
3337
+ _this.updateGraphQLPKType = (options === null || options === void 0 ? void 0 : options.updateGraphQLPKType) || _this.tableName + "_pk_columns_input";
3338
+ return _this;
3339
+ }
3340
+ UpdateHasuraGraphQLMixin.prototype.update = function (data) {
3341
+ return __awaiter(this, void 0, void 0, function () {
3342
+ var plainData;
3343
+ var _this = this;
3344
+ return __generator(this, function (_b) {
3345
+ switch (_b.label) {
3346
+ case 0:
3347
+ plainData = this.paramsToPlain(data);
3348
+ return [4 /*yield*/, this.mutation(this.updateGraphQLOperation, this.model.identifiersFields.map(function (field) { return AttributeOptionHelper.FindByAttribute(field, _this.fields).columnName; }), {
3349
+ _set: {
3350
+ type: this.updateGraphQLObjectType,
3351
+ value: this.convertDataToHasura(this.model.toInstance(plainData), true),
3352
+ required: true,
3353
+ },
3354
+ pk_columns: { type: this.updateGraphQLPKType, value: this.getUpdateModelKeys(plainData), required: true },
3355
+ })];
3356
+ case 1:
3357
+ _b.sent();
3358
+ return [2 /*return*/, this.model.toInstance(plainData)];
3359
+ }
3360
+ });
3361
+ });
3362
+ };
3363
+ UpdateHasuraGraphQLMixin.prototype.paramsToPlain = function (params) {
3364
+ var model = this.model;
3365
+ if (model.isModel(params))
3366
+ return params.toPlain();
3367
+ return Object.keys(params).reduce(function (data, currentKey) {
3368
+ var _b;
3369
+ return (Object.assign(Object.assign({}, data), (params[currentKey] !== undefined && (_b = {}, _b[currentKey] = getValueByAction(params[currentKey]), _b))));
3370
+ }, {});
3371
+ };
3372
+ UpdateHasuraGraphQLMixin.prototype.getUpdateModelKeys = function (data) {
3373
+ var _this = this;
3374
+ var instance = this.model.toInstance(data);
3375
+ return this.model.identifiersFields.reduce(function (ids, identifier) {
3376
+ var _b;
3377
+ var _a;
3378
+ if (lodash.isNil(instance[identifier]))
3379
+ return ids;
3380
+ var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
3381
+ var value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, data[identifier.toString()], instance)) || data[columnOption.attributeName];
3382
+ return Object.assign(Object.assign({}, ids), (_b = {}, _b[columnOption.columnName] = value, _b));
3383
+ }, {});
3384
+ };
3385
+ return UpdateHasuraGraphQLMixin;
3386
+ }(MixinBase));
3387
+ };
3388
+
3389
+ var withGetHasuraGraphQL = function (MixinBase) {
3390
+ return /** @class */ (function (_super) {
3391
+ __extends(GetHasuraGraphQLMixin, _super);
3392
+ function GetHasuraGraphQLMixin() {
3393
+ var params = [];
3394
+ for (var _i = 0; _i < arguments.length; _i++) {
3395
+ params[_i] = arguments[_i];
3396
+ }
3397
+ var _this = this;
3398
+ var options = params === null || params === void 0 ? void 0 : params[0];
3399
+ _this = _super.apply(this, __spreadArray([], __read(params))) || this;
3400
+ _this.getGraphQLOperation = (options === null || options === void 0 ? void 0 : options.getGraphQLOperation) || _this.tableName + "_by_pk";
3401
+ return _this;
3402
+ }
3403
+ GetHasuraGraphQLMixin.prototype.get = function (identifiers) {
3404
+ return __awaiter(this, void 0, void 0, function () {
3405
+ var instance, result, data;
3406
+ var _this = this;
3407
+ return __generator(this, function (_b) {
3408
+ switch (_b.label) {
3409
+ case 0:
3410
+ instance = this.model.toInstance(identifiers);
3411
+ return [4 /*yield*/, this.query(this.getGraphQLOperation, this.fields, this.model.identifiersFields.reduce(function (ids, identifier) {
3412
+ var _b;
3413
+ var _a;
3414
+ if (lodash.isNil(instance[identifier]))
3415
+ return ids;
3416
+ var columnOption = AttributeOptionHelper.FindByAttribute(identifier, _this.fields);
3417
+ var value = ((_a = columnOption === null || columnOption === void 0 ? void 0 : columnOption.to) === null || _a === void 0 ? void 0 : _a.call(columnOption, identifiers[identifier.toString()], instance)) || identifiers[identifier.toString()];
3418
+ return Object.assign(Object.assign({}, ids), (_b = {}, _b[columnOption.columnName] = {
3419
+ type: _this.getAttributeGraphQLTypeOf(columnOption.type || value),
3420
+ value: value,
3421
+ required: true,
3422
+ }, _b));
3423
+ }, {}))];
3424
+ case 1:
3425
+ result = _b.sent();
3426
+ data = result[this.getGraphQLOperation];
3427
+ if (lodash.isNil(data))
3428
+ throw new NotFoundError(instance.constructor.name + " not found");
3429
+ return [2 /*return*/, this.convertDataFromHasura(result[this.getGraphQLOperation])];
3430
+ }
3431
+ });
3432
+ });
3433
+ };
3434
+ return GetHasuraGraphQLMixin;
3435
+ }(MixinBase));
3436
+ };
3437
+
3438
+ var HasuraGraphQLWhere;
3439
+ (function (HasuraGraphQLWhere) {
3440
+ HasuraGraphQLWhere["EQUALS"] = "_eq";
3441
+ HasuraGraphQLWhere["GT"] = "_gt";
3442
+ HasuraGraphQLWhere["GTE"] = "_gte";
3443
+ HasuraGraphQLWhere["IN"] = "_in";
3444
+ HasuraGraphQLWhere["NOTIN"] = "_nin";
3445
+ HasuraGraphQLWhere["LT"] = "_lt";
3446
+ HasuraGraphQLWhere["LTE"] = "_lte";
3447
+ HasuraGraphQLWhere["LIKE"] = "_like";
3448
+ HasuraGraphQLWhere["NOTLIKE"] = "_nlike";
3449
+ HasuraGraphQLWhere["ISNULL"] = "_is_null";
3450
+ HasuraGraphQLWhere["ISNOTNULL"] = "_is_null";
3451
+ })(HasuraGraphQLWhere || (HasuraGraphQLWhere = {}));
3452
+
3453
+ var HasuraGraphQLColumnType;
3454
+ (function (HasuraGraphQLColumnType) {
3455
+ HasuraGraphQLColumnType["Int"] = "Int";
3456
+ HasuraGraphQLColumnType["Float"] = "Float";
3457
+ HasuraGraphQLColumnType["Boolean"] = "Boolean";
3458
+ HasuraGraphQLColumnType["String"] = "String";
3459
+ HasuraGraphQLColumnType["DateTime"] = "timestampz";
3460
+ HasuraGraphQLColumnType["Json"] = "json";
3461
+ HasuraGraphQLColumnType["Jsonb"] = "jsonb";
3462
+ HasuraGraphQLColumnType["Enum"] = "enum";
3463
+ HasuraGraphQLColumnType["Uuid"] = "uuid";
3464
+ })(HasuraGraphQLColumnType || (HasuraGraphQLColumnType = {}));
3465
+
3466
+ var withFindHasuraGraphQL = function (MixinBase) {
3467
+ return /** @class */ (function (_super) {
3468
+ __extends(FindHasuraGraphQLMixin, _super);
3469
+ function FindHasuraGraphQLMixin() {
3470
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3471
+ _this.makeGraphQLWhere = function (filter, fields) { return Object.keys(filter).reduce(function (variables, fieldName) {
3472
+ var _b;
3473
+ var columnOption = AttributeOptionHelper.FindByAttribute(fieldName, fields);
3474
+ if (!columnOption.bindFindFilter)
3475
+ return Object.assign(Object.assign({}, variables), (_b = {}, _b[columnOption.columnName] = _this.buildWhereSentence(fieldName, filter[fieldName], fields), _b));
3476
+ var builtFilter = columnOption.bindFindFilter(filter[fieldName]);
3477
+ return Object.assign(Object.assign({}, variables), Object.keys(builtFilter).reduce(function (variablesList, columnName) {
3478
+ var _b;
3479
+ return (Object.assign(Object.assign({}, variablesList), (_b = {}, _b[columnName] = _this.buildWhereSentence(fieldName, builtFilter[columnName], fields), _b)));
3480
+ }, {}));
3481
+ }, {}); };
3482
+ _this.buildWhereSentence = function (field, options, fields) {
3483
+ var _b;
3484
+ var fieldSentenceOptions = AttributeOptionHelper.FindByAttribute(field, fields);
3485
+ if (!Array.isArray(options) &&
3486
+ lodash.isObject(options) &&
3487
+ lodash.isNil(options === null || options === void 0 ? void 0 : options.operator) &&
3488
+ lodash.isNil(options === null || options === void 0 ? void 0 : options.value) &&
3489
+ lodash.isNil(fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.to))
3490
+ return Object.keys(options).reduce(function (variables, key) {
3491
+ var _b;
3492
+ var fieldOptions = AttributeOptionHelper.FindByAttribute(key, (fieldSentenceOptions === null || fieldSentenceOptions === void 0 ? void 0 : fieldSentenceOptions.fields) || fields);
3493
+ var columnName = fieldOptions.columnName;
3494
+ var columnFields = fieldOptions.fields;
3495
+ return Object.assign(Object.assign({}, variables), (_b = {}, _b[columnName] = _this.buildWhereSentence(key, options[key], columnFields || []), _b));
3496
+ }, {});
3497
+ if (!Array.isArray(options) && !lodash.isNil(fieldSentenceOptions.fields))
3498
+ return _b = {},
3499
+ _b[fieldSentenceOptions.fields[0]] = _this.buildOperatorSentence(options, fieldSentenceOptions),
3500
+ _b;
3501
+ if (lodash.isObject(options) && !FilterOptionHelper.CheckIfIsFilterOption(options))
3502
+ options = Object.values(options)[0];
3503
+ return Array.isArray(options)
3504
+ ? options.reduce(function (whereSentence, option) { return (Object.assign(Object.assign({}, whereSentence), _this.buildOperatorSentence(option, fieldSentenceOptions))); }, {})
3505
+ : _this.buildOperatorSentence(options, fieldSentenceOptions);
3506
+ };
3507
+ _this.buildOperatorSentence = function (options, fieldOption) {
3508
+ var _b;
3509
+ return (_b = {},
3510
+ _b[_this.getHasuraOperator(options, fieldOption)] = FilterOptionHelper.GetValueFromFilter(options, fieldOption),
3511
+ _b);
3512
+ };
3513
+ _this.getHasuraOperator = function (options, fieldOption) { return FilterOptionHelper.CheckIfIsFilterOption(options)
3514
+ ? fieldOption.type === HasuraGraphQLColumnType.Jsonb
3515
+ ? _this.getHasuraJsonbOperator(options)
3516
+ : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find(function (graphQLOperator) { return graphQLOperator === Object.keys(exports.Where).find(function (operator) { return exports.Where[operator] === (options === null || options === void 0 ? void 0 : options.operator); }); })]
3517
+ : HasuraGraphQLWhere.EQUALS; };
3518
+ _this.getHasuraJsonbOperator = function (options) { return options.operator === exports.Where.IN
3519
+ ? '_contains'
3520
+ : options.operator === exports.Where.LIKE
3521
+ ? '_has_keys_any'
3522
+ : HasuraGraphQLWhere[Object.keys(HasuraGraphQLWhere).find(function (graphQLOperator) { return graphQLOperator === Object.keys(exports.Where).find(function (operator) { return exports.Where[operator] === (options === null || options === void 0 ? void 0 : options.operator); }); })]; };
3523
+ return _this;
3524
+ }
3525
+ FindHasuraGraphQLMixin.prototype.find = function (options) {
3526
+ return __awaiter(this, void 0, void 0, function () {
3527
+ var _b, filters, limits, orderBy, variablesCount, variables, result, data, count;
3528
+ var _this = this;
3529
+ return __generator(this, function (_c) {
3530
+ switch (_c.label) {
3531
+ case 0:
3532
+ _b = options || {}, filters = _b.filters, limits = _b.limits, orderBy = _b.orderBy;
3533
+ variablesCount = Object.assign(Object.assign({}, (lodash.isNil(orderBy) ? {} : { order_by: { type: this.tableName + "_order_by!", list: true, value: orderBy } })), (lodash.isNil(filters)
3534
+ ? {}
3535
+ : {
3536
+ where: {
3537
+ value: this.makeGraphQLWhere(filters, this.fields),
3538
+ type: this.tableName + "_bool_exp",
3539
+ required: true,
3540
+ },
3541
+ }));
3542
+ variables = Object.assign(Object.assign({}, (lodash.isNil(limits) ? {} : limits)), variablesCount);
3543
+ return [4 /*yield*/, this.query([
3544
+ {
3545
+ operation: this.tableName,
3546
+ fields: options.fields
3547
+ ? options.fields
3548
+ .map(function (fieldName) {
3549
+ var _a;
3550
+ return (_a = _this.fields.find(function (fieldOption) { return fieldOption === fieldName; })) !== null && _a !== void 0 ? _a : _this.fields.find(function (fieldOption) { return Object.keys(fieldOption).shift() === fieldName; });
3551
+ })
3552
+ .filter(Boolean)
3553
+ : this.fields,
3554
+ variables: variables,
3555
+ },
3556
+ {
3557
+ operation: this.tableName + "_aggregate",
3558
+ fields: [{ aggregate: ['count'] }],
3559
+ variables: variablesCount,
3560
+ },
3561
+ ])];
3562
+ case 1:
3563
+ result = _c.sent();
3564
+ data = result[this.tableName].map(function (row) { return _this.convertDataFromHasura(row); });
3565
+ count = result[this.tableName + "_aggregate"].aggregate.count;
3566
+ return [2 /*return*/, { count: count, data: data }];
3567
+ }
3568
+ });
3569
+ });
3570
+ };
3571
+ return FindHasuraGraphQLMixin;
3572
+ }(MixinBase));
3573
+ };
3574
+
3575
+ var withCrudHasuraGraphQL = function (MixinBase) {
3576
+ return /** @class */ (function (_super) {
3577
+ __extends(CrudHasuraGraphQLMixin, _super);
3578
+ function CrudHasuraGraphQLMixin() {
3579
+ return _super !== null && _super.apply(this, arguments) || this;
3580
+ }
3581
+ return CrudHasuraGraphQLMixin;
3582
+ }(withUpdateHasuraGraphQL(withGetHasuraGraphQL(withFindHasuraGraphQL(withDeleteHasuraGraphQL(withCreateHasuraGraphQL(MixinBase)))))));
3583
+ };
3584
+
3585
+ var CategoryHasuraGraphQL = /** @class */ (function (_super) {
3586
+ __extends(CategoryHasuraGraphQL, _super);
3587
+ function CategoryHasuraGraphQL() {
3588
+ return _super !== null && _super.apply(this, arguments) || this;
3589
+ }
3590
+ return CategoryHasuraGraphQL;
3591
+ }(Category));
3592
+
3593
+ var ProductHasuraGraphQL = /** @class */ (function (_super) {
3594
+ __extends(ProductHasuraGraphQL, _super);
3595
+ function ProductHasuraGraphQL() {
3596
+ return _super !== null && _super.apply(this, arguments) || this;
3597
+ }
3598
+ return ProductHasuraGraphQL;
3599
+ }(Product));
3600
+ __decorate([
3601
+ classTransformer.Type(function () { return KitProductHasuraGraphQL; }),
3602
+ __metadata("design:type", Array)
3603
+ ], ProductHasuraGraphQL.prototype, "kitProducts", void 0);
3604
+
3605
+ var KitProductHasuraGraphQL = /** @class */ (function (_super) {
3606
+ __extends(KitProductHasuraGraphQL, _super);
3607
+ function KitProductHasuraGraphQL() {
3608
+ return _super !== null && _super.apply(this, arguments) || this;
3609
+ }
3610
+ return KitProductHasuraGraphQL;
3611
+ }(KitProduct));
3612
+ __decorate([
3613
+ classTransformer.Type(function () { return ProductHasuraGraphQL; }),
3614
+ __metadata("design:type", ProductHasuraGraphQL)
3615
+ ], KitProductHasuraGraphQL.prototype, "kit", void 0);
3616
+ __decorate([
3617
+ classTransformer.Type(function () { return ProductHasuraGraphQL; }),
3618
+ __metadata("design:type", ProductHasuraGraphQL)
3619
+ ], KitProductHasuraGraphQL.prototype, "product", void 0);
3620
+
3621
+ var VariantHasuraGraphQL = /** @class */ (function (_super) {
3622
+ __extends(VariantHasuraGraphQL, _super);
3623
+ function VariantHasuraGraphQL() {
3624
+ var _this = _super.apply(this, __spreadArray([], __read(arguments))) || this;
3625
+ _this.name = '';
3626
+ _this.hasVariants = false;
3627
+ return _this;
3628
+ }
3629
+ return VariantHasuraGraphQL;
3630
+ }(Variant));
3631
+
3632
+ var CategoryHasuraGraphQLRepository = /** @class */ (function (_super_1) {
3633
+ __extends(CategoryHasuraGraphQLRepository, _super_1);
3634
+ function CategoryHasuraGraphQLRepository(endpoint, authOptions, productRepository) {
3635
+ var _this = _super_1.call(this, {
3636
+ tableName: 'category',
3637
+ model: Category,
3638
+ endpoint: endpoint,
3639
+ authOptions: authOptions,
3640
+ fields: [
3641
+ { id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
3642
+ { firestoreId: { columnName: 'firestore_id' } },
3643
+ 'name',
3644
+ 'description',
3645
+ 'image',
3646
+ 'published',
3647
+ 'shop',
3648
+ 'slug',
3649
+ { brandCategory: { columnName: 'brand_category' } },
3650
+ { brandCategoryBanner: { columnName: 'brand_banner' } },
3651
+ { brandCategoryBannerMobile: { columnName: 'brand_banner_mobile' } },
3652
+ { brandLogo: { columnName: 'brand_logo' } },
3653
+ { brandCondition: { columnName: 'brand_condition' } },
3654
+ {
3655
+ conditions: {
3656
+ columnName: 'tag_condition',
3657
+ type: HasuraGraphQLColumnType.Jsonb,
3658
+ from: function (tags, row) { return ({ brand: row.brand_condition, tags: Array.isArray(tags) ? tags : [] }); },
3659
+ bindPersistData: function (value) {
3660
+ var _a, _b;
3661
+ return {
3662
+ brand_condition: value.brand,
3663
+ tag_condition: "{\"" + (((_b = (_a = value === null || value === void 0 ? void 0 : value.tags) === null || _a === void 0 ? void 0 : _a.join) === null || _b === void 0 ? void 0 : _b.call(_a, '","')) || '') + "\"}",
3664
+ };
3665
+ },
3666
+ bindFindFilter: function (sentence) {
3667
+ return Object.assign(Object.assign({}, (sentence.brand ? { brand_condition: sentence.brand } : {})), (sentence.tags ? { tag_condition: sentence.tags } : {}));
3668
+ },
3669
+ },
3670
+ },
3671
+ 'filters',
3672
+ { createdAt: { columnName: 'created_at' } },
3673
+ { updatedAt: { columnName: 'updated_at' } },
3674
+ {
3675
+ products: {
3676
+ columnName: 'products',
3677
+ fields: ['product_id'],
3678
+ from: function (value) { return value.map(function (product) { return product.product_id.toString(); }); },
3679
+ to: function (productIds) { return productIds.map(function (productId) { return ({
3680
+ product_id: +productId,
3681
+ }); }); },
3682
+ },
3683
+ },
3684
+ ],
3685
+ }) || this;
3686
+ _this.productRepository = productRepository;
3687
+ return _this;
3688
+ }
3689
+ CategoryHasuraGraphQLRepository.prototype.get = function (identifiers) {
3690
+ var _super = Object.create(null, {
3691
+ get: { get: function () { return _super_1.prototype.get; } }
3692
+ });
3693
+ var _a;
3694
+ return __awaiter(this, void 0, void 0, function () {
3695
+ var _c;
3696
+ return __generator(this, function (_d) {
3697
+ switch (_d.label) {
3698
+ case 0:
3699
+ if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
3700
+ return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
3701
+ case 1:
3702
+ _c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
3703
+ return [3 /*break*/, 3];
3704
+ case 2:
3705
+ _c = _super.get.call(this, identifiers);
3706
+ _d.label = 3;
3707
+ case 3: return [2 /*return*/, _c];
3708
+ }
3709
+ });
3710
+ });
3711
+ };
3712
+ CategoryHasuraGraphQLRepository.prototype.getCategoryBySlug = function (slug, shop) {
3713
+ return __awaiter(this, void 0, void 0, function () {
3714
+ var _c, data, count;
3715
+ return __generator(this, function (_d) {
3716
+ switch (_d.label) {
3717
+ case 0:
3718
+ if (!slug)
3719
+ return [2 /*return*/];
3720
+ return [4 /*yield*/, this.find({ filters: { slug: slug, shop: shop, published: true } })];
3721
+ case 1:
3722
+ _c = _d.sent(), data = _c.data, count = _c.count;
3723
+ if (count > 1)
3724
+ throw new DuplicatedResultsError('Query returned duplicated values');
3725
+ if (!count)
3726
+ throw new NotFoundError("Category with slug " + slug + " not found");
3727
+ return [2 /*return*/, data.shift()];
3728
+ }
3729
+ });
3730
+ });
3731
+ };
3732
+ CategoryHasuraGraphQLRepository.prototype.getCategoriesForHome = function (categoryIds, limit) {
3733
+ if (limit === void 0) { limit = 4; }
3734
+ return __awaiter(this, void 0, void 0, function () {
3735
+ var _c, categories, count, homeSections;
3736
+ var _this = this;
3737
+ return __generator(this, function (_d) {
3738
+ switch (_d.label) {
3739
+ case 0: return [4 /*yield*/, this.find({
3740
+ filters: { firestoreId: { operator: exports.Where.IN, value: categoryIds.filter(Boolean) }, published: true },
3741
+ })];
3742
+ case 1:
3743
+ _c = _d.sent(), categories = _c.data, count = _c.count;
3744
+ if (!count)
3745
+ throw new NotFoundError('Categories not found');
3746
+ return [4 /*yield*/, Promise.all(categories.map(function (category) { return __awaiter(_this, void 0, void 0, function () {
3747
+ var _c;
3748
+ return __generator(this, function (_d) {
3749
+ switch (_d.label) {
3750
+ case 0:
3751
+ _c = {
3752
+ category: category
3753
+ };
3754
+ return [4 /*yield*/, this.mountCategory(category, { limit: limit, hasStock: true })];
3755
+ case 1: return [2 /*return*/, (_c.products = _d.sent(),
3756
+ _c)];
3757
+ }
3758
+ });
3759
+ }); }))];
3760
+ case 2:
3761
+ homeSections = _d.sent();
3762
+ return [2 /*return*/, homeSections];
3763
+ }
3764
+ });
3765
+ });
3766
+ };
3767
+ CategoryHasuraGraphQLRepository.prototype.mountCategory = function (category, options) {
3768
+ return __awaiter(this, void 0, void 0, function () {
3769
+ var products, publishedField, productsData;
3770
+ var _c;
3771
+ return __generator(this, function (_d) {
3772
+ switch (_d.label) {
3773
+ case 0:
3774
+ if (!category.products)
3775
+ throw new RequiredArgumentError(['Category products is empty']);
3776
+ products = [];
3777
+ publishedField = category.shop === exports.Shops.GLAMSHOP ? 'publishedGlam' : 'published';
3778
+ return [4 /*yield*/, this.productRepository.find(Object.assign({ filters: Object.assign((_c = { id: { operator: exports.Where.IN, value: category.products } }, _c[publishedField] = true, _c), ((options === null || options === void 0 ? void 0 : options.hasStock) ? { stock: { quantity: { operator: exports.Where.GT, value: 0 } } } : {})), fields: [
3779
+ 'id',
3780
+ 'name',
3781
+ 'slug',
3782
+ 'images',
3783
+ 'miniatures',
3784
+ 'price',
3785
+ 'fullPrice',
3786
+ 'subscriberDiscountPercentage',
3787
+ 'subscriberPrice',
3788
+ 'stock',
3789
+ 'published',
3790
+ 'publishedGlam',
3791
+ 'CEST',
3792
+ 'EAN',
3793
+ 'NCM',
3794
+ 'brand',
3795
+ 'costPrice',
3796
+ 'hasVariants',
3797
+ 'isKit',
3798
+ 'shopAvailability',
3799
+ 'sku',
3800
+ 'rate',
3801
+ ] }, ((options === null || options === void 0 ? void 0 : options.limit) ? { limits: { limit: options === null || options === void 0 ? void 0 : options.limit } } : {})))];
3802
+ case 1:
3803
+ productsData = (_d.sent()).data;
3804
+ products.push.apply(products, __spreadArray([], __read(productsData)));
3805
+ return [2 /*return*/, products];
3806
+ }
3807
+ });
3808
+ });
3809
+ };
3810
+ return CategoryHasuraGraphQLRepository;
3811
+ }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
3812
+
3813
+ var ProductHasuraGraphQLRepository = /** @class */ (function (_super_1) {
3814
+ __extends(ProductHasuraGraphQLRepository, _super_1);
3815
+ function ProductHasuraGraphQLRepository(endpoint, authOptions) {
3816
+ var _this = _super_1.call(this, {
3817
+ tableName: 'product',
3818
+ model: ProductHasuraGraphQL,
3819
+ endpoint: endpoint,
3820
+ authOptions: authOptions,
3821
+ fields: [],
3822
+ }) || this;
3823
+ _this.bindReviewToModel = function (plain) { return (Object.assign(Object.assign({}, lodash.omit(plain, ['product_id', 'created_at', 'updated_at', 'person_id', 'order_id'])), { createdAt: typeof plain.created_at === 'string' ? new Date(plain.created_at) : plain.created_at, updatedAt: typeof plain.updated_at === 'string' ? new Date(plain.updated_at) : plain.updated_at, personId: plain.person_id, orderId: plain.order_id })); };
3824
+ _this.bindReviewToHasura = function (review) { return (Object.assign(Object.assign({}, lodash.omit(review, ['productId', 'createdAt', 'updatedAt', 'personId', 'orderId'])), { person_id: review.personId, order_id: review.orderId })); };
3825
+ var commonFields = [
3826
+ { id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
3827
+ { firestoreId: { columnName: 'firestore_id' } },
3828
+ { CEST: { columnName: 'cest' } },
3829
+ { EAN: { columnName: 'ean' } },
3830
+ { NCM: { columnName: 'ncm' } },
3831
+ 'brand',
3832
+ { costPrice: { columnName: 'cost_price' } },
3833
+ {
3834
+ description: {
3835
+ columnName: 'description',
3836
+ from: function (description) { return Object.values(exports.Shops).reduce(function (shops, shop) {
3837
+ var _c;
3838
+ return (Object.assign(Object.assign({}, shops), (_c = {}, _c[shop] = { description: description }, _c)));
3839
+ }, {}); },
3840
+ to: function (value) { return Object.values(value).shift().description; },
3841
+ },
3842
+ },
3843
+ { hasVariants: { columnName: 'has_variants' } },
3844
+ { images: { columnName: 'images', to: function (value) { var _a; return "{\"" + (((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, "\",\"")) || '') + "\"}"; } } },
3845
+ { miniatures: { columnName: 'miniatures', to: function (value) { var _a; return "{\"" + (((_a = value === null || value === void 0 ? void 0 : value.join) === null || _a === void 0 ? void 0 : _a.call(value, "\",\"")) || '') + "\"}"; } } },
3846
+ 'name',
3847
+ {
3848
+ price: {
3849
+ columnName: 'price',
3850
+ from: function (price, data) { return Object.values(exports.Shops).reduce(function (prices, shop) {
3851
+ var _c;
3852
+ return (Object.assign(Object.assign({}, prices), (_c = {}, _c[shop] = {
3853
+ price: price,
3854
+ fullPrice: data.full_price,
3855
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
3856
+ subscriberPrice: data.subscriber_price,
3857
+ }, _c)));
3858
+ }, {}); },
3859
+ bindFindFilter: function (sentence) {
3860
+ var filters = Object.values(sentence).shift();
3861
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
3862
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
3863
+ })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
3864
+ subscriber_price: filters.subscriberPrice,
3865
+ }));
3866
+ },
3867
+ bindPersistData: function (value) {
3868
+ var priceData = Object.values(value).shift();
3869
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
3870
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
3871
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
3872
+ },
3873
+ },
3874
+ },
3875
+ { fullPrice: { columnName: 'full_price' } },
3876
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
3877
+ { subscriberPrice: { columnName: 'subscriber_price' } },
3878
+ 'published',
3879
+ { publishedGlam: { columnName: 'published_glam' } },
3880
+ 'sku',
3881
+ {
3882
+ stock: {
3883
+ columnName: 'stock',
3884
+ from: function (quantity) { return ({ quantity: quantity }); },
3885
+ to: function (value) { return (lodash.isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity); },
3886
+ },
3887
+ },
3888
+ 'slug',
3889
+ 'type',
3890
+ 'video',
3891
+ 'weight',
3892
+ {
3893
+ shopAvailability: {
3894
+ columnName: 'shop_availabilities',
3895
+ fields: ['shop'],
3896
+ from: function (shop) { return (Array.isArray(shop) ? shop.map(function (row) { return row.shop; }) : []); },
3897
+ bindPersistData: function (shops) { return ({ shop_availabilities: { data: shops.map(function (shop) { return ({ shop: shop }); }) } }); },
3898
+ },
3899
+ },
3900
+ { tags: { columnName: 'tags', type: HasuraGraphQLColumnType.Jsonb } },
3901
+ { isKit: { columnName: 'is_kit' } },
3902
+ { createdAt: { columnName: 'created_at' } },
3903
+ { updatedAt: { columnName: 'updated_at' } },
3904
+ {
3905
+ rate: {
3906
+ columnName: 'reviews_aggregate',
3907
+ fields: [{ aggregate: [{ avg: ['rate'] }] }],
3908
+ from: function (value) { return value.aggregate.avg.rate; },
3909
+ },
3910
+ },
3911
+ ];
3912
+ _this.fields = __spreadArray(__spreadArray([], __read(commonFields)), [
3913
+ {
3914
+ categories: {
3915
+ columnName: 'categories',
3916
+ fields: ['category_id'],
3917
+ bindPersistData: function (value) { return ({
3918
+ categories: { data: value.map(function (category) { return ({ category_id: +category }); }) },
3919
+ }); },
3920
+ to: function (categories) { return categories.map(function (categoryId) { return +categoryId; }); },
3921
+ from: function (categories) { return (categories === null || categories === void 0 ? void 0 : categories.map(function (category) { var _a; return (_a = category === null || category === void 0 ? void 0 : category.category_id) === null || _a === void 0 ? void 0 : _a.toString(); })) || []; },
3922
+ },
3923
+ },
3924
+ {
3925
+ kitProducts: {
3926
+ columnName: 'kit_products',
3927
+ foreignKeyColumn: { productId: 'id' },
3928
+ fields: [
3929
+ { productId: { columnName: 'product_id' } },
3930
+ { kitProductId: { columnName: 'kit_product_id' } },
3931
+ 'quantity',
3932
+ { product: { columnName: 'product', foreignKeyColumn: { id: 'product_id' }, fields: commonFields } },
3933
+ ],
3934
+ },
3935
+ },
3936
+ ]);
3937
+ return _this;
3938
+ }
3939
+ Object.defineProperty(ProductHasuraGraphQLRepository.prototype, "reviewsFields", {
3940
+ get: function () {
3941
+ return [
3942
+ 'id',
3943
+ 'shop',
3944
+ 'rate',
3945
+ 'author',
3946
+ 'email',
3947
+ 'location',
3948
+ 'review',
3949
+ 'status',
3950
+ 'title',
3951
+ 'person_id',
3952
+ 'points',
3953
+ 'order_id',
3954
+ 'created_at',
3955
+ 'updated_at',
3956
+ ];
3957
+ },
3958
+ enumerable: false,
3959
+ configurable: true
3960
+ });
3961
+ ProductHasuraGraphQLRepository.prototype.create = function (data) {
3962
+ var _super = Object.create(null, {
3963
+ create: { get: function () { return _super_1.prototype.create; } }
3964
+ });
3965
+ return __awaiter(this, void 0, void 0, function () {
3966
+ var product, _c, error_1;
3967
+ return __generator(this, function (_d) {
3968
+ switch (_d.label) {
3969
+ case 0: return [4 /*yield*/, _super.create.call(this, lodash.omit(data, ['reviews']))];
3970
+ case 1:
3971
+ product = _d.sent();
3972
+ _d.label = 2;
3973
+ case 2:
3974
+ _d.trys.push([2, 4, , 6]);
3975
+ _c = product;
3976
+ return [4 /*yield*/, this.updateReviews(+product.id, data)];
3977
+ case 3:
3978
+ _c.reviews = _d.sent();
3979
+ return [3 /*break*/, 6];
3980
+ case 4:
3981
+ error_1 = _d.sent();
3982
+ return [4 /*yield*/, this.delete({ id: product.id })];
3983
+ case 5:
3984
+ _d.sent();
3985
+ throw error_1;
3986
+ case 6: return [2 /*return*/, product];
3987
+ }
3988
+ });
3989
+ });
3990
+ };
3991
+ ProductHasuraGraphQLRepository.prototype.get = function (identifiers) {
3992
+ var _super = Object.create(null, {
3993
+ get: { get: function () { return _super_1.prototype.get; } }
3994
+ });
3995
+ var _a;
3996
+ return __awaiter(this, void 0, void 0, function () {
3997
+ var product, _c, _d;
3998
+ return __generator(this, function (_e) {
3999
+ switch (_e.label) {
4000
+ case 0:
4001
+ if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
4002
+ return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
4003
+ case 1:
4004
+ _c = (_a = (_e.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
4005
+ return [3 /*break*/, 4];
4006
+ case 2: return [4 /*yield*/, _super.get.call(this, identifiers)];
4007
+ case 3:
4008
+ _c = _e.sent();
4009
+ _e.label = 4;
4010
+ case 4:
4011
+ product = _c;
4012
+ _d = product;
4013
+ return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
4014
+ case 5:
4015
+ _d.reviews = _e.sent();
4016
+ return [2 /*return*/, product];
4017
+ }
4018
+ });
4019
+ });
4020
+ };
4021
+ ProductHasuraGraphQLRepository.prototype.getBySlug = function (slug) {
4022
+ var _a;
4023
+ return __awaiter(this, void 0, void 0, function () {
4024
+ var result, product, _c;
4025
+ return __generator(this, function (_d) {
4026
+ switch (_d.label) {
4027
+ case 0: return [4 /*yield*/, this.find({
4028
+ filters: {
4029
+ slug: slug,
4030
+ },
4031
+ })];
4032
+ case 1:
4033
+ result = _d.sent();
4034
+ product = (_a = result === null || result === void 0 ? void 0 : result.data) === null || _a === void 0 ? void 0 : _a.shift();
4035
+ _c = product;
4036
+ return [4 /*yield*/, this.findReviewsByProduct(+product.id)];
4037
+ case 2:
4038
+ _c.reviews = _d.sent();
4039
+ return [2 /*return*/, product];
4040
+ }
4041
+ });
4042
+ });
4043
+ };
4044
+ ProductHasuraGraphQLRepository.prototype.update = function (params) {
4045
+ var _super = Object.create(null, {
4046
+ update: { get: function () { return _super_1.prototype.update; } }
4047
+ });
4048
+ return __awaiter(this, void 0, void 0, function () {
4049
+ var categories, kitProducts, reviews, checkId, shopAvailability, rate, data, plainData, id, product, _c, _d, _e, _f, _g, _h;
4050
+ return __generator(this, function (_j) {
4051
+ switch (_j.label) {
4052
+ case 0:
4053
+ categories = params.categories, kitProducts = params.kitProducts, reviews = params.reviews, checkId = params.id, shopAvailability = params.shopAvailability, rate = params.rate, data = __rest(params, ["categories", "kitProducts", "reviews", "id", "shopAvailability", "rate"]);
4054
+ plainData = this.paramsToPlain({ id: checkId });
4055
+ return [4 /*yield*/, this.getId(plainData.id)];
4056
+ case 1:
4057
+ id = _j.sent();
4058
+ return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
4059
+ case 2:
4060
+ product = _j.sent();
4061
+ _c = product;
4062
+ _d = categories;
4063
+ if (!_d) return [3 /*break*/, 4];
4064
+ return [4 /*yield*/, this.updateCategories(+id, { categories: categories })];
4065
+ case 3:
4066
+ _d = (_j.sent());
4067
+ _j.label = 4;
4068
+ case 4:
4069
+ _c.categories = _d;
4070
+ _e = product;
4071
+ _f = kitProducts;
4072
+ if (!_f) return [3 /*break*/, 6];
4073
+ return [4 /*yield*/, this.updateKitProducts(+id, { kitProducts: kitProducts })];
4074
+ case 5:
4075
+ _f = (_j.sent());
4076
+ _j.label = 6;
4077
+ case 6:
4078
+ _e.kitProducts = _f;
4079
+ _g = product;
4080
+ _h = reviews;
4081
+ if (!_h) return [3 /*break*/, 8];
4082
+ return [4 /*yield*/, this.updateReviews(+id, { reviews: reviews })];
4083
+ case 7:
4084
+ _h = (_j.sent());
4085
+ _j.label = 8;
4086
+ case 8:
4087
+ _g.reviews = _h;
4088
+ return [2 /*return*/, product];
4089
+ }
4090
+ });
4091
+ });
4092
+ };
4093
+ ProductHasuraGraphQLRepository.prototype.fetchReviews = function (status) {
4094
+ return __awaiter(this, void 0, void 0, function () {
4095
+ var reviews, data;
4096
+ var _c, _d;
4097
+ var _this = this;
4098
+ return __generator(this, function (_e) {
4099
+ switch (_e.label) {
4100
+ case 0:
4101
+ reviews = {
4102
+ status: status === 'pending'
4103
+ ? (_c = {}, _c[HasuraGraphQLWhere.ISNULL] = true, _c) : (_d = {}, _d[HasuraGraphQLWhere.EQUALS] = status === 'approved', _d),
4104
+ };
4105
+ return [4 /*yield*/, this.query('product', ['id', 'name', 'sku', { reviews: { columnName: 'reviews', fields: this.reviewsFields } }], {
4106
+ where: { value: { reviews: reviews }, type: 'product_bool_exp', required: true },
4107
+ })];
4108
+ case 1:
4109
+ data = (_e.sent()).product;
4110
+ return [2 /*return*/, data.reduce(function (reviews, product) { return __spreadArray(__spreadArray([], __read(reviews)), __read(product.reviews
4111
+ .filter(function (review) { return (status === 'pending' && [undefined, null].includes(review.status)) ||
4112
+ (status === 'approved' && review.status === true) ||
4113
+ (status === 'rejected' && review.status === false); })
4114
+ .map(function (review) { return (Object.assign(Object.assign({}, _this.bindReviewToModel(review)), { productId: product.id, productName: product.name, productSku: product.sku })); }))); }, [])];
4115
+ }
4116
+ });
4117
+ });
4118
+ };
4119
+ ProductHasuraGraphQLRepository.prototype.updateCategories = function (productId, _c) {
4120
+ var categories = _c.categories;
4121
+ return __awaiter(this, void 0, void 0, function () {
4122
+ var plainData;
4123
+ return __generator(this, function (_c) {
4124
+ switch (_c.label) {
4125
+ case 0:
4126
+ plainData = this.paramsToPlain({ categories: categories });
4127
+ return [4 /*yield*/, this.mutation('delete_category_product', ['affected_rows'], {
4128
+ where: {
4129
+ type: 'category_product_bool_exp',
4130
+ required: true,
4131
+ value: { product_id: { _eq: productId } },
4132
+ },
4133
+ })];
4134
+ case 1:
4135
+ _c.sent();
4136
+ return [4 /*yield*/, this.mutation('insert_category_product', ['affected_rows'], {
4137
+ objects: {
4138
+ type: '[category_product_insert_input!]',
4139
+ required: true,
4140
+ value: plainData.categories.map(function (categoryId) { return ({ category_id: categoryId, product_id: productId }); }),
4141
+ },
4142
+ })];
4143
+ case 2:
4144
+ _c.sent();
4145
+ return [2 /*return*/, plainData.categories];
4146
+ }
4147
+ });
4148
+ });
4149
+ };
4150
+ ProductHasuraGraphQLRepository.prototype.updateKitProducts = function (productId, _c) {
4151
+ var kitProducts = _c.kitProducts;
4152
+ return __awaiter(this, void 0, void 0, function () {
4153
+ var plainData;
4154
+ return __generator(this, function (_c) {
4155
+ switch (_c.label) {
4156
+ case 0:
4157
+ plainData = this.paramsToPlain({ kitProducts: kitProducts });
4158
+ return [4 /*yield*/, this.mutation('delete_product_kit', ['affected_rows'], {
4159
+ where: {
4160
+ type: 'product_kit_bool_exp',
4161
+ required: true,
4162
+ value: { product_id: { _eq: productId } },
4163
+ },
4164
+ })];
4165
+ case 1:
4166
+ _c.sent();
4167
+ return [4 /*yield*/, this.mutation('insert_product_kit', ['affected_rows'], {
4168
+ objects: {
4169
+ type: '[product_kit_insert_input!]',
4170
+ required: true,
4171
+ value: plainData.kitProducts.map(function (kitProduct) { return ({
4172
+ kit_product_id: kitProduct.productId || kitProduct.product.id,
4173
+ product_id: productId,
4174
+ quantity: kitProduct.quantity,
4175
+ }); }),
4176
+ },
4177
+ })];
4178
+ case 2:
4179
+ _c.sent();
4180
+ return [2 /*return*/, plainData.kitProducts];
4181
+ }
4182
+ });
4183
+ });
4184
+ };
4185
+ ProductHasuraGraphQLRepository.prototype.updateReviews = function (productId, _c) {
4186
+ var reviews = _c.reviews;
4187
+ return __awaiter(this, void 0, void 0, function () {
4188
+ var reviewIds_1, plainData;
4189
+ var _this = this;
4190
+ return __generator(this, function (_c) {
4191
+ switch (_c.label) {
4192
+ case 0:
4193
+ if (!reviews)
4194
+ return [2 /*return*/, []];
4195
+ if (!('action' in reviews && reviews.action === 'remove')) return [3 /*break*/, 3];
4196
+ return [4 /*yield*/, Promise.all(reviews.value.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
4197
+ var review;
4198
+ return __generator(this, function (_c) {
4199
+ switch (_c.label) {
4200
+ case 0: return [4 /*yield*/, this.findReview(reviewData, productId)];
4201
+ case 1:
4202
+ review = _c.sent();
4203
+ return [2 /*return*/, review === null || review === void 0 ? void 0 : review.id];
4204
+ }
4205
+ });
4206
+ }); }))];
4207
+ case 1:
4208
+ reviewIds_1 = _c.sent();
4209
+ return [4 /*yield*/, this.mutation('delete_product_review', ['affected_rows'], {
4210
+ where: { value: { id: { _in: reviewIds_1.filter(Boolean) } }, type: 'product_review_bool_exp', required: true },
4211
+ })];
4212
+ case 2:
4213
+ _c.sent();
4214
+ return [2 /*return*/, reviews.value.map(function (review, index) { return !reviewIds_1[index] && review; }).filter(Boolean)];
4215
+ case 3:
4216
+ plainData = this.paramsToPlain({ reviews: reviews });
4217
+ return [2 /*return*/, Promise.all(plainData.reviews.map(function (reviewData) { return __awaiter(_this, void 0, void 0, function () {
4218
+ var review, _c, _d;
4219
+ return __generator(this, function (_e) {
4220
+ switch (_e.label) {
4221
+ case 0: return [4 /*yield*/, this.findReview(reviewData, productId)];
4222
+ case 1:
4223
+ review = _e.sent();
4224
+ if (!review.id) return [3 /*break*/, 3];
4225
+ _c = this.bindReviewToModel;
4226
+ return [4 /*yield*/, this.mutation('update_product_review_by_pk', this.reviewsFields, {
4227
+ pk_columns: {
4228
+ value: { id: review.id },
4229
+ type: 'product_review_pk_columns_input',
4230
+ required: true,
4231
+ },
4232
+ _set: {
4233
+ value: lodash.omit(this.bindReviewToHasura(reviewData), ['id', 'product_id']),
4234
+ type: 'product_review_set_input',
4235
+ required: true,
4236
+ },
4237
+ })];
4238
+ case 2: return [2 /*return*/, _c.apply(this, [(_e.sent()).update_product_review_by_pk])];
4239
+ case 3:
4240
+ _d = this.bindReviewToModel;
4241
+ return [4 /*yield*/, this.mutation('insert_product_review_one', this.reviewsFields, {
4242
+ object: {
4243
+ value: lodash.omit(Object.assign(Object.assign({}, this.bindReviewToHasura(reviewData)), { product_id: productId }), ['id']),
4244
+ type: 'product_review_insert_input',
4245
+ required: true,
4246
+ },
4247
+ })];
4248
+ case 4: return [2 /*return*/, _d.apply(this, [(_e.sent()).insert_product_review_one])];
4249
+ }
4250
+ });
4251
+ }); }))];
4252
+ }
4253
+ });
4254
+ });
4255
+ };
4256
+ ProductHasuraGraphQLRepository.prototype.getId = function (id) {
4257
+ var _a, _b;
4258
+ return __awaiter(this, void 0, void 0, function () {
4259
+ var data;
4260
+ return __generator(this, function (_c) {
4261
+ switch (_c.label) {
4262
+ case 0:
4263
+ if (!Number.isNaN(+id))
4264
+ return [2 /*return*/, id];
4265
+ return [4 /*yield*/, this.find({ filters: { firestoreId: id } })];
4266
+ case 1:
4267
+ data = (_c.sent()).data;
4268
+ if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
4269
+ return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
4270
+ throw new NotFoundError("Product with id " + id + " not found");
4271
+ }
4272
+ });
4273
+ });
4274
+ };
4275
+ ProductHasuraGraphQLRepository.prototype.findReviewsByProduct = function (productId) {
4276
+ return __awaiter(this, void 0, void 0, function () {
4277
+ var data;
4278
+ var _this = this;
4279
+ return __generator(this, function (_c) {
4280
+ switch (_c.label) {
4281
+ case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
4282
+ where: {
4283
+ value: {
4284
+ product_id: { _eq: productId },
4285
+ },
4286
+ type: 'product_review_bool_exp',
4287
+ required: true,
4288
+ },
4289
+ })];
4290
+ case 1:
4291
+ data = (_c.sent()).product_review;
4292
+ return [2 /*return*/, data && data.map(function (review) { return _this.bindReviewToModel(review); })];
4293
+ }
4294
+ });
4295
+ });
4296
+ };
4297
+ ProductHasuraGraphQLRepository.prototype.findReview = function (review, productId) {
4298
+ return __awaiter(this, void 0, void 0, function () {
4299
+ var loadedReview;
4300
+ return __generator(this, function (_c) {
4301
+ switch (_c.label) {
4302
+ case 0:
4303
+ if (review.id)
4304
+ return [2 /*return*/, review];
4305
+ if (!review.personId) return [3 /*break*/, 2];
4306
+ return [4 /*yield*/, this.getReviewByPersonId(review.personId, productId)];
4307
+ case 1:
4308
+ loadedReview = _c.sent();
4309
+ _c.label = 2;
4310
+ case 2:
4311
+ if (!(!loadedReview && review.author && review.email)) return [3 /*break*/, 4];
4312
+ return [4 /*yield*/, this.getReviewByAuthorAndEmail(review.author, review.email, productId)];
4313
+ case 3:
4314
+ loadedReview = _c.sent();
4315
+ _c.label = 4;
4316
+ case 4: return [2 /*return*/, loadedReview || review];
4317
+ }
4318
+ });
4319
+ });
4320
+ };
4321
+ ProductHasuraGraphQLRepository.prototype.getReviewByPersonId = function (personId, productId) {
4322
+ return __awaiter(this, void 0, void 0, function () {
4323
+ var data;
4324
+ return __generator(this, function (_c) {
4325
+ switch (_c.label) {
4326
+ case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
4327
+ where: {
4328
+ value: {
4329
+ product_id: { _eq: productId },
4330
+ person_id: { _eq: personId },
4331
+ },
4332
+ type: "product_review_bool_exp",
4333
+ required: true,
4334
+ },
4335
+ })];
4336
+ case 1:
4337
+ data = (_c.sent()).product_review;
4338
+ return [2 /*return*/, data && data[0] && this.bindReviewToModel(data[0])];
4339
+ }
4340
+ });
4341
+ });
4342
+ };
4343
+ ProductHasuraGraphQLRepository.prototype.getReviewByAuthorAndEmail = function (author, email, productId) {
4344
+ return __awaiter(this, void 0, void 0, function () {
4345
+ var data;
4346
+ return __generator(this, function (_c) {
4347
+ switch (_c.label) {
4348
+ case 0: return [4 /*yield*/, this.query('product_review', this.reviewsFields, {
4349
+ where: {
4350
+ value: {
4351
+ product_id: { _eq: productId },
4352
+ author: { _eq: author },
4353
+ email: { _eq: email },
4354
+ },
4355
+ type: "product_review_bool_exp",
4356
+ required: true,
4357
+ },
4358
+ })];
4359
+ case 1:
4360
+ data = (_c.sent()).product_review;
4361
+ return [2 /*return*/, data && data[0] && this.bindReviewToModel(data[0])];
4362
+ }
4363
+ });
4364
+ });
4365
+ };
4366
+ return ProductHasuraGraphQLRepository;
4367
+ }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
4368
+
4369
+ var VariantHasuraGraphQLRepository = /** @class */ (function (_super_1) {
4370
+ __extends(VariantHasuraGraphQLRepository, _super_1);
4371
+ function VariantHasuraGraphQLRepository(endpoint, authOptions) {
4372
+ return _super_1.call(this, {
4373
+ tableName: 'product',
4374
+ model: VariantHasuraGraphQL,
4375
+ endpoint: endpoint,
4376
+ authOptions: authOptions,
4377
+ fields: [
4378
+ { id: { columnName: 'id', to: function (value) { return +value; }, from: function (value) { return value.toString(); } } },
4379
+ { firestoreId: { columnName: 'firestore_id' } },
4380
+ { productId: { columnName: 'main_product_id', to: function (value) { return +value; }, from: function (value) { return value === null || value === void 0 ? void 0 : value.toString(); } } },
4381
+ { EAN: { columnName: 'ean' } },
4382
+ { costPrice: { columnName: 'cost_price' } },
4383
+ {
4384
+ price: {
4385
+ columnName: 'price',
4386
+ from: function (price, data) { return Object.values(exports.Shops).reduce(function (prices, shop) {
4387
+ var _c;
4388
+ return (Object.assign(Object.assign({}, prices), (_c = {}, _c[shop] = {
4389
+ price: price,
4390
+ fullPrice: data.full_price,
4391
+ subscriberDiscountPercentage: data.subscriber_discount_percentage,
4392
+ subscriberPrice: data.subscriber_price,
4393
+ }, _c)));
4394
+ }, {}); },
4395
+ bindFindFilter: function (sentence) {
4396
+ var filters = Object.values(sentence).shift();
4397
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, (((filters === null || filters === void 0 ? void 0 : filters.price) || (filters === null || filters === void 0 ? void 0 : filters.price) === 0) && { price: filters.price })), ((filters.fullPrice || filters.fullPrice === 0) && { full_price: filters.fullPrice })), ((filters.subscriberDiscountPercentage || filters.subscriberDiscountPercentage === 0) && {
4398
+ subscriber_discount_percentage: filters.subscriberDiscountPercentage,
4399
+ })), ((filters.subscriberPrice || filters.subscriberPrice === 0) && {
4400
+ subscriber_price: filters.subscriberPrice,
4401
+ }));
4402
+ },
4403
+ bindPersistData: function (value) {
4404
+ var priceData = Object.values(value).shift();
4405
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, ((priceData === null || priceData === void 0 ? void 0 : priceData.price) >= 0 && { price: priceData.price })), (priceData.fullPrice >= 0 && { full_price: priceData.fullPrice })), (priceData.subscriberDiscountPercentage >= 0 && {
4406
+ subscriber_discount_percentage: priceData.subscriberDiscountPercentage,
4407
+ })), (priceData.subscriberPrice >= 0 && { subscriber_price: priceData.subscriberPrice }));
4408
+ },
4409
+ },
4410
+ },
4411
+ { fullPrice: { columnName: 'full_price' } },
4412
+ { subscriberDiscountPercentage: { columnName: 'subscriber_discount_percentage' } },
4413
+ { subscriberPrice: { columnName: 'subscriber_price' } },
4414
+ 'sku',
4415
+ {
4416
+ stock: {
4417
+ columnName: 'stock',
4418
+ from: function (quantity) { return ({ quantity: quantity }); },
4419
+ to: function (value) { return (lodash.isNil(value === null || value === void 0 ? void 0 : value.quantity) ? value : value === null || value === void 0 ? void 0 : value.quantity); },
4420
+ },
4421
+ },
4422
+ 'weight',
4423
+ { name: { to: function () { return ''; }, from: function () { return undefined; } } },
4424
+ { hasVariants: { columnName: 'has_variants', to: function () { return false; }, from: function () { return undefined; } } },
4425
+ { createdAt: { columnName: 'created_at' } },
4426
+ { updatedAt: { columnName: 'updated_at' } },
4427
+ {
4428
+ grade: {
4429
+ columnName: 'grade',
4430
+ type: HasuraGraphQLColumnType.Jsonb,
4431
+ },
4432
+ },
4433
+ ],
4434
+ }) || this;
4435
+ }
4436
+ VariantHasuraGraphQLRepository.prototype.get = function (identifiers) {
4437
+ var _super = Object.create(null, {
4438
+ get: { get: function () { return _super_1.prototype.get; } }
4439
+ });
4440
+ var _a;
4441
+ return __awaiter(this, void 0, void 0, function () {
4442
+ var _c;
4443
+ return __generator(this, function (_d) {
4444
+ switch (_d.label) {
4445
+ case 0:
4446
+ if (!Number.isNaN(+identifiers.id)) return [3 /*break*/, 2];
4447
+ return [4 /*yield*/, this.find({ filters: { firestoreId: identifiers.id } })];
4448
+ case 1:
4449
+ _c = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a[0];
4450
+ return [3 /*break*/, 3];
4451
+ case 2:
4452
+ _c = _super.get.call(this, identifiers);
4453
+ _d.label = 3;
4454
+ case 3: return [2 /*return*/, _c];
4455
+ }
4456
+ });
4457
+ });
4458
+ };
4459
+ VariantHasuraGraphQLRepository.prototype.update = function (params) {
4460
+ var _super = Object.create(null, {
4461
+ update: { get: function () { return _super_1.prototype.update; } }
4462
+ });
4463
+ return __awaiter(this, void 0, void 0, function () {
4464
+ var productId, checkId, data, dataWithProductId, id, product;
4465
+ return __generator(this, function (_c) {
4466
+ switch (_c.label) {
4467
+ case 0:
4468
+ productId = params.productId, checkId = params.id, data = __rest(params, ["productId", "id"]);
4469
+ dataWithProductId = this.paramsToPlain({ id: checkId, productId: productId });
4470
+ return [4 /*yield*/, this.getId(dataWithProductId.id)];
4471
+ case 1:
4472
+ id = _c.sent();
4473
+ return [4 /*yield*/, _super.update.call(this, Object.assign({ id: id }, data))];
4474
+ case 2:
4475
+ product = _c.sent();
4476
+ product.productId = dataWithProductId.productId;
4477
+ return [2 /*return*/, product];
4478
+ }
4479
+ });
4480
+ });
4481
+ };
4482
+ VariantHasuraGraphQLRepository.prototype.getId = function (id) {
4483
+ var _a, _b;
4484
+ return __awaiter(this, void 0, void 0, function () {
4485
+ var data;
4486
+ return __generator(this, function (_c) {
4487
+ switch (_c.label) {
4488
+ case 0:
4489
+ if (!Number.isNaN(+id))
4490
+ return [2 /*return*/, id];
4491
+ return [4 /*yield*/, this.find({ filters: { firestoreId: id } })];
4492
+ case 1:
4493
+ data = (_c.sent()).data;
4494
+ if ((_a = data === null || data === void 0 ? void 0 : data[0]) === null || _a === void 0 ? void 0 : _a.id)
4495
+ return [2 /*return*/, (_b = data === null || data === void 0 ? void 0 : data[0]) === null || _b === void 0 ? void 0 : _b.id];
4496
+ throw new NotFoundError("Product with id " + id + " not found");
4497
+ }
4498
+ });
4499
+ });
4500
+ };
4501
+ return VariantHasuraGraphQLRepository;
4502
+ }(withCrudHasuraGraphQL(withHasuraGraphQL(Base))));
4503
+
4504
+ /**
4505
+ * Generated bundle index. Do not edit.
4506
+ */
4507
+
4508
+ Object.defineProperty(exports, 'add', {
4509
+ enumerable: true,
4510
+ get: function () { return dateFns.add; }
4511
+ });
4512
+ Object.defineProperty(exports, 'addBusinessDays', {
4513
+ enumerable: true,
4514
+ get: function () { return dateFns.addBusinessDays; }
4515
+ });
4516
+ Object.defineProperty(exports, 'addDays', {
4517
+ enumerable: true,
4518
+ get: function () { return dateFns.addDays; }
4519
+ });
4520
+ Object.defineProperty(exports, 'addMonths', {
4521
+ enumerable: true,
4522
+ get: function () { return dateFns.addMonths; }
4523
+ });
4524
+ Object.defineProperty(exports, 'addYears', {
4525
+ enumerable: true,
4526
+ get: function () { return dateFns.addYears; }
4527
+ });
4528
+ Object.defineProperty(exports, 'endOfDay', {
4529
+ enumerable: true,
4530
+ get: function () { return dateFns.endOfDay; }
4531
+ });
4532
+ Object.defineProperty(exports, 'format', {
4533
+ enumerable: true,
4534
+ get: function () { return dateFns.format; }
4535
+ });
4536
+ Object.defineProperty(exports, 'formatISO9075', {
4537
+ enumerable: true,
4538
+ get: function () { return dateFns.formatISO9075; }
4539
+ });
4540
+ Object.defineProperty(exports, 'parseISO', {
4541
+ enumerable: true,
4542
+ get: function () { return dateFns.parseISO; }
4543
+ });
4544
+ Object.defineProperty(exports, 'startOfDay', {
4545
+ enumerable: true,
4546
+ get: function () { return dateFns.startOfDay; }
4547
+ });
4548
+ Object.defineProperty(exports, 'sub', {
4549
+ enumerable: true,
4550
+ get: function () { return dateFns.sub; }
4551
+ });
4552
+ Object.defineProperty(exports, 'chunk', {
4553
+ enumerable: true,
4554
+ get: function () { return lodash.chunk; }
4555
+ });
4556
+ Object.defineProperty(exports, 'isBoolean', {
4557
+ enumerable: true,
4558
+ get: function () { return lodash.isBoolean; }
4559
+ });
4560
+ Object.defineProperty(exports, 'isDate', {
4561
+ enumerable: true,
4562
+ get: function () { return lodash.isDate; }
4563
+ });
4564
+ Object.defineProperty(exports, 'isEmpty', {
4565
+ enumerable: true,
4566
+ get: function () { return lodash.isEmpty; }
4567
+ });
4568
+ Object.defineProperty(exports, 'isInteger', {
4569
+ enumerable: true,
4570
+ get: function () { return lodash.isInteger; }
4571
+ });
4572
+ Object.defineProperty(exports, 'isNaN', {
4573
+ enumerable: true,
4574
+ get: function () { return lodash.isNaN; }
4575
+ });
4576
+ Object.defineProperty(exports, 'isNil', {
4577
+ enumerable: true,
4578
+ get: function () { return lodash.isNil; }
4579
+ });
4580
+ Object.defineProperty(exports, 'isNumber', {
4581
+ enumerable: true,
4582
+ get: function () { return lodash.isNumber; }
4583
+ });
4584
+ Object.defineProperty(exports, 'isObject', {
4585
+ enumerable: true,
4586
+ get: function () { return lodash.isObject; }
4587
+ });
4588
+ Object.defineProperty(exports, 'isString', {
4589
+ enumerable: true,
4590
+ get: function () { return lodash.isString; }
4591
+ });
4592
+ Object.defineProperty(exports, 'now', {
4593
+ enumerable: true,
4594
+ get: function () { return lodash.now; }
4595
+ });
4596
+ Object.defineProperty(exports, 'omit', {
4597
+ enumerable: true,
4598
+ get: function () { return lodash.omit; }
2709
4599
  });
2710
4600
  Object.defineProperty(exports, 'pick', {
2711
4601
  enumerable: true,
@@ -2727,18 +4617,22 @@
2727
4617
  exports.Buy2WinFirestoreRepository = Buy2WinFirestoreRepository;
2728
4618
  exports.Category = Category;
2729
4619
  exports.CategoryFirestoreRepository = CategoryFirestoreRepository;
4620
+ exports.CategoryHasuraGraphQL = CategoryHasuraGraphQL;
4621
+ exports.CategoryHasuraGraphQLRepository = CategoryHasuraGraphQLRepository;
2730
4622
  exports.Checkout = Checkout;
2731
4623
  exports.CheckoutFirestoreRepository = CheckoutFirestoreRepository;
2732
4624
  exports.CheckoutSubscription = CheckoutSubscription;
2733
4625
  exports.CheckoutSubscriptionFirestoreRepository = CheckoutSubscriptionFirestoreRepository;
2734
- exports.ClubCoupon = ClubCoupon;
2735
4626
  exports.Coupon = Coupon;
2736
4627
  exports.CouponFirestoreRepository = CouponFirestoreRepository;
2737
4628
  exports.DuplicatedResultsError = DuplicatedResultsError;
2738
4629
  exports.Edition = Edition;
4630
+ exports.FinancialCoupon = FinancialCoupon;
2739
4631
  exports.Home = Home;
2740
4632
  exports.HomeFirestoreRepository = HomeFirestoreRepository;
2741
4633
  exports.InvalidArgumentError = InvalidArgumentError;
4634
+ exports.KitProduct = KitProduct;
4635
+ exports.KitProductHasuraGraphQL = KitProductHasuraGraphQL;
2742
4636
  exports.Lead = Lead;
2743
4637
  exports.LeadFirestoreRepository = LeadFirestoreRepository;
2744
4638
  exports.LegacyOrderFirestoreRepository = LegacyOrderFirestoreRepository;
@@ -2750,6 +4644,8 @@
2750
4644
  exports.PaymentFirestoreRepository = PaymentFirestoreRepository;
2751
4645
  exports.Product = Product;
2752
4646
  exports.ProductFirestoreRepository = ProductFirestoreRepository;
4647
+ exports.ProductHasuraGraphQL = ProductHasuraGraphQL;
4648
+ exports.ProductHasuraGraphQLRepository = ProductHasuraGraphQLRepository;
2753
4649
  exports.ProductVariantFirestoreRepository = ProductVariantFirestoreRepository;
2754
4650
  exports.ProductsIndex = ProductsIndex;
2755
4651
  exports.RecoveryPassword = RecoveryPassword;
@@ -2760,7 +4656,6 @@
2760
4656
  exports.ShopMenu = ShopMenu;
2761
4657
  exports.ShopMenuFirestoreRepository = ShopMenuFirestoreRepository;
2762
4658
  exports.SignOut = SignOut;
2763
- exports.StoreCoupon = StoreCoupon;
2764
4659
  exports.Subscription = Subscription;
2765
4660
  exports.SubscriptionEditionFirestoreRepository = SubscriptionEditionFirestoreRepository;
2766
4661
  exports.SubscriptionFirestoreRepository = SubscriptionFirestoreRepository;
@@ -2780,16 +4675,27 @@
2780
4675
  exports.UserPaymentMethodFirestoreRepository = UserPaymentMethodFirestoreRepository;
2781
4676
  exports.UserSearchFirestoreRepository = UserSearchFirestoreRepository;
2782
4677
  exports.Variant = Variant;
4678
+ exports.VariantHasuraGraphQL = VariantHasuraGraphQL;
4679
+ exports.VariantHasuraGraphQLRepository = VariantHasuraGraphQLRepository;
2783
4680
  exports.WeakPasswordError = WeakPasswordError;
4681
+ exports.isUUID = isUUID;
4682
+ exports.parseDateTime = parseDateTime;
2784
4683
  exports.withCreateFirestore = withCreateFirestore;
4684
+ exports.withCreateHasuraGraphQL = withCreateHasuraGraphQL;
2785
4685
  exports.withCrudFirestore = withCrudFirestore;
4686
+ exports.withCrudHasuraGraphQL = withCrudHasuraGraphQL;
2786
4687
  exports.withDeleteFirestore = withDeleteFirestore;
4688
+ exports.withDeleteHasuraGraphQL = withDeleteHasuraGraphQL;
2787
4689
  exports.withFindFirestore = withFindFirestore;
4690
+ exports.withFindHasuraGraphQL = withFindHasuraGraphQL;
2788
4691
  exports.withFirestore = withFirestore;
2789
4692
  exports.withGetFirestore = withGetFirestore;
4693
+ exports.withGetHasuraGraphQL = withGetHasuraGraphQL;
4694
+ exports.withHasuraGraphQL = withHasuraGraphQL;
2790
4695
  exports.withHelpers = withHelpers;
2791
4696
  exports.withSubCollection = withSubCollection;
2792
4697
  exports.withUpdateFirestore = withUpdateFirestore;
4698
+ exports.withUpdateHasuraGraphQL = withUpdateHasuraGraphQL;
2793
4699
 
2794
4700
  Object.defineProperty(exports, '__esModule', { value: true });
2795
4701