@infrab4a/connect-angular 5.8.12 → 5.8.13

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 (301) hide show
  1. package/angular-connect.module.d.ts +36 -0
  2. package/angular-elastic-search.module.d.ts +9 -0
  3. package/angular-firebase-auth.module.d.ts +11 -0
  4. package/angular-firestore.module.d.ts +17 -0
  5. package/angular-hasura-graphql.module.d.ts +14 -0
  6. package/angular-vertex-search.module.d.ts +9 -0
  7. package/consts/backend-url.const.d.ts +1 -0
  8. package/consts/category-structure.d.ts +1 -0
  9. package/consts/default-shop.const.d.ts +1 -0
  10. package/consts/es-config.const.d.ts +1 -0
  11. package/consts/firebase-const.d.ts +4 -0
  12. package/consts/hasura-options.const.d.ts +1 -0
  13. package/consts/index.d.ts +8 -0
  14. package/consts/persistence.const.d.ts +1 -0
  15. package/consts/storage-base-url.const.d.ts +1 -0
  16. package/consts/vertex-config.const.d.ts +1 -0
  17. package/esm2020/angular-connect.module.mjs +293 -0
  18. package/esm2020/angular-elastic-search.module.mjs +34 -0
  19. package/esm2020/angular-firebase-auth.module.mjs +141 -0
  20. package/esm2020/angular-firestore.module.mjs +611 -0
  21. package/esm2020/angular-hasura-graphql.module.mjs +421 -0
  22. package/esm2020/angular-vertex-search.module.mjs +34 -0
  23. package/esm2020/consts/backend-url.const.mjs +2 -0
  24. package/esm2020/consts/category-structure.mjs +2 -0
  25. package/esm2020/consts/default-shop.const.mjs +2 -0
  26. package/esm2020/consts/es-config.const.mjs +2 -0
  27. package/esm2020/consts/firebase-const.mjs +5 -0
  28. package/esm2020/consts/hasura-options.const.mjs +2 -0
  29. package/esm2020/consts/index.mjs +9 -0
  30. package/esm2020/consts/persistence.const.mjs +2 -0
  31. package/esm2020/consts/storage-base-url.const.mjs +2 -0
  32. package/esm2020/consts/vertex-config.const.mjs +2 -0
  33. package/esm2020/helpers/index.mjs +2 -0
  34. package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +7 -0
  35. package/esm2020/index.mjs +7 -0
  36. package/esm2020/infrab4a-connect-angular.mjs +5 -0
  37. package/esm2020/interfaces/catalog-strategies.interface.mjs +2 -0
  38. package/esm2020/interfaces/category-facades.interface.mjs +2 -0
  39. package/esm2020/interfaces/index.mjs +3 -0
  40. package/esm2020/persistence/cookie-data-persistence.mjs +22 -0
  41. package/esm2020/persistence/data-persistence.mjs +2 -0
  42. package/esm2020/persistence/index.mjs +3 -0
  43. package/esm2020/services/auth.service.mjs +37 -0
  44. package/esm2020/services/cart/cart-services.facade.mjs +21 -0
  45. package/esm2020/services/cart/index.mjs +2 -0
  46. package/esm2020/services/cart.service.mjs +84 -0
  47. package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +2 -0
  48. package/esm2020/services/catalog/adapters/index.mjs +4 -0
  49. package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +43 -0
  50. package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -0
  51. package/esm2020/services/catalog/catalog.service.mjs +111 -0
  52. package/esm2020/services/catalog/category.service.mjs +42 -0
  53. package/esm2020/services/catalog/context/catalog-search.context.mjs +40 -0
  54. package/esm2020/services/catalog/enums/index.mjs +2 -0
  55. package/esm2020/services/catalog/enums/product-sorts.enum.mjs +11 -0
  56. package/esm2020/services/catalog/facades/catalog-service.facade.mjs +32 -0
  57. package/esm2020/services/catalog/facades/catalog-strategies.facade.mjs +17 -0
  58. package/esm2020/services/catalog/facades/category-repository.facade.mjs +20 -0
  59. package/esm2020/services/catalog/facades/category-service.facade.mjs +30 -0
  60. package/esm2020/services/catalog/facades/index.mjs +6 -0
  61. package/esm2020/services/catalog/facades/product-catalog.facade.mjs +21 -0
  62. package/esm2020/services/catalog/helpers/brand-manager.helper.mjs +62 -0
  63. package/esm2020/services/catalog/helpers/catalog-filter.helper.mjs +44 -0
  64. package/esm2020/services/catalog/helpers/catalog-sort.helper.mjs +52 -0
  65. package/esm2020/services/catalog/helpers/index.mjs +5 -0
  66. package/esm2020/services/catalog/helpers/product-fields.helper.mjs +43 -0
  67. package/esm2020/services/catalog/index.mjs +8 -0
  68. package/esm2020/services/catalog/models/category-with-tree.model.mjs +10 -0
  69. package/esm2020/services/catalog/models/index.mjs +2 -0
  70. package/esm2020/services/catalog/services/catalog-helpers.service.mjs +33 -0
  71. package/esm2020/services/catalog/services/catalog-operations.facade.mjs +26 -0
  72. package/esm2020/services/catalog/services/catalog-repository.service.mjs +25 -0
  73. package/esm2020/services/catalog/services/index.mjs +5 -0
  74. package/esm2020/services/catalog/services/product-management.facade.mjs +25 -0
  75. package/esm2020/services/catalog/strategies/category-search.strategy.mjs +133 -0
  76. package/esm2020/services/catalog/strategies/index.mjs +4 -0
  77. package/esm2020/services/catalog/strategies/profile-search.strategy.mjs +42 -0
  78. package/esm2020/services/catalog/strategies/term-search.strategy.mjs +126 -0
  79. package/esm2020/services/catalog/strategies/types/strategy-params.type.mjs +2 -0
  80. package/esm2020/services/catalog/types/fetch-products-options.type.mjs +2 -0
  81. package/esm2020/services/catalog/types/fetch-products-params.type.mjs +2 -0
  82. package/esm2020/services/catalog/types/fetch-products-response.type.mjs +2 -0
  83. package/esm2020/services/catalog/types/index.mjs +6 -0
  84. package/esm2020/services/catalog/types/method-params.type.mjs +2 -0
  85. package/esm2020/services/catalog/types/product-sort.type.mjs +2 -0
  86. package/esm2020/services/catalog/wishlist.service.mjs +258 -0
  87. package/esm2020/services/checkout/checkout-dependencies.facade.mjs +20 -0
  88. package/esm2020/services/checkout/checkout-repositories.facade.mjs +20 -0
  89. package/esm2020/services/checkout/index.mjs +3 -0
  90. package/esm2020/services/checkout-subscription.service.mjs +55 -0
  91. package/esm2020/services/checkout.service.mjs +131 -0
  92. package/esm2020/services/coupon/coupon-repositories.facade.mjs +24 -0
  93. package/esm2020/services/coupon/index.mjs +2 -0
  94. package/esm2020/services/coupon/types/coupon-params.type.mjs +2 -0
  95. package/esm2020/services/coupon.service.mjs +248 -0
  96. package/esm2020/services/helpers/index.mjs +2 -0
  97. package/esm2020/services/helpers/util.helper.mjs +18 -0
  98. package/esm2020/services/home-shop/home-shop-repositories.facade.mjs +24 -0
  99. package/esm2020/services/home-shop/index.mjs +2 -0
  100. package/esm2020/services/home-shop.service.mjs +130 -0
  101. package/esm2020/services/index.mjs +12 -0
  102. package/esm2020/services/order-product-review.service.mjs +126 -0
  103. package/esm2020/services/order-recurrence.service.mjs +76 -0
  104. package/esm2020/services/order.service.mjs +30 -0
  105. package/esm2020/services/shared/configuration.facade.mjs +29 -0
  106. package/esm2020/services/shared/index.mjs +2 -0
  107. package/esm2020/services/types/index.mjs +5 -0
  108. package/esm2020/services/types/pending-product-review.type.mjs +2 -0
  109. package/esm2020/services/types/product-review-create.type.mjs +2 -0
  110. package/esm2020/services/types/required-checkout-data.type.mjs +2 -0
  111. package/esm2020/services/types/required-checkout-subscription-data.type.mjs +2 -0
  112. package/esm2020/types/firebase-app-config.type.mjs +2 -0
  113. package/esm2020/types/index.mjs +2 -0
  114. package/fesm2015/infrab4a-connect-angular.mjs +3786 -0
  115. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -0
  116. package/fesm2020/infrab4a-connect-angular.mjs +3688 -0
  117. package/fesm2020/infrab4a-connect-angular.mjs.map +1 -0
  118. package/helpers/index.d.ts +1 -0
  119. package/helpers/mobile-operation-system-checker.helper.d.ts +3 -0
  120. package/index.d.ts +6 -0
  121. package/interfaces/catalog-strategies.interface.d.ts +31 -0
  122. package/interfaces/category-facades.interface.d.ts +6 -0
  123. package/interfaces/index.d.ts +2 -0
  124. package/package.json +24 -4
  125. package/persistence/cookie-data-persistence.d.ts +10 -0
  126. package/persistence/data-persistence.d.ts +6 -0
  127. package/persistence/index.d.ts +2 -0
  128. package/services/auth.service.d.ts +18 -0
  129. package/services/cart/cart-services.facade.d.ts +12 -0
  130. package/services/cart/index.d.ts +1 -0
  131. package/services/cart.service.d.ts +27 -0
  132. package/services/catalog/adapters/category-structure.adapter.d.ts +4 -0
  133. package/services/catalog/adapters/index.d.ts +3 -0
  134. package/services/catalog/adapters/new-category-structure.adapter.d.ts +12 -0
  135. package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -0
  136. package/services/catalog/catalog.service.d.ts +24 -0
  137. package/services/catalog/category.service.d.ts +23 -0
  138. package/services/catalog/context/catalog-search.context.d.ts +14 -0
  139. package/services/catalog/enums/index.d.ts +1 -0
  140. package/services/catalog/enums/product-sorts.enum.d.ts +9 -0
  141. package/services/catalog/facades/catalog-service.facade.d.ts +15 -0
  142. package/services/catalog/facades/catalog-strategies.facade.d.ts +10 -0
  143. package/services/catalog/facades/category-repository.facade.d.ts +9 -0
  144. package/services/catalog/facades/category-service.facade.d.ts +15 -0
  145. package/{src/services/catalog/facades/index.ts → services/catalog/facades/index.d.ts} +5 -5
  146. package/services/catalog/facades/product-catalog.facade.d.ts +10 -0
  147. package/services/catalog/helpers/brand-manager.helper.d.ts +14 -0
  148. package/services/catalog/helpers/catalog-filter.helper.d.ts +8 -0
  149. package/services/catalog/helpers/catalog-sort.helper.d.ts +7 -0
  150. package/services/catalog/helpers/index.d.ts +4 -0
  151. package/services/catalog/helpers/product-fields.helper.d.ts +7 -0
  152. package/services/catalog/index.d.ts +7 -0
  153. package/services/catalog/models/category-with-tree.model.d.ts +4 -0
  154. package/services/catalog/models/index.d.ts +1 -0
  155. package/services/catalog/services/catalog-helpers.service.d.ts +17 -0
  156. package/services/catalog/services/catalog-operations.facade.d.ts +13 -0
  157. package/services/catalog/services/catalog-repository.service.d.ts +12 -0
  158. package/{src/services/catalog/services/index.ts → services/catalog/services/index.d.ts} +4 -4
  159. package/services/catalog/services/product-management.facade.d.ts +12 -0
  160. package/services/catalog/strategies/category-search.strategy.d.ts +19 -0
  161. package/services/catalog/strategies/index.d.ts +3 -0
  162. package/services/catalog/strategies/profile-search.strategy.d.ts +14 -0
  163. package/services/catalog/strategies/term-search.strategy.d.ts +20 -0
  164. package/services/catalog/strategies/types/strategy-params.type.d.ts +59 -0
  165. package/services/catalog/types/fetch-products-options.type.d.ts +8 -0
  166. package/services/catalog/types/fetch-products-params.type.d.ts +25 -0
  167. package/services/catalog/types/fetch-products-response.type.d.ts +19 -0
  168. package/services/catalog/types/index.d.ts +5 -0
  169. package/services/catalog/types/method-params.type.d.ts +17 -0
  170. package/services/catalog/types/product-sort.type.d.ts +2 -0
  171. package/services/catalog/wishlist.service.d.ts +60 -0
  172. package/services/checkout/checkout-dependencies.facade.d.ts +10 -0
  173. package/services/checkout/checkout-repositories.facade.d.ts +9 -0
  174. package/{src/services/checkout/index.ts → services/checkout/index.d.ts} +2 -2
  175. package/services/checkout-subscription.service.d.ts +19 -0
  176. package/services/checkout.service.d.ts +33 -0
  177. package/services/coupon/coupon-repositories.facade.d.ts +10 -0
  178. package/{src/services/coupon/index.ts → services/coupon/index.d.ts} +1 -1
  179. package/services/coupon/types/coupon-params.type.d.ts +13 -0
  180. package/services/coupon.service.d.ts +36 -0
  181. package/services/helpers/index.d.ts +1 -0
  182. package/services/helpers/util.helper.d.ts +3 -0
  183. package/services/home-shop/home-shop-repositories.facade.d.ts +10 -0
  184. package/{src/services/home-shop/index.ts → services/home-shop/index.d.ts} +1 -1
  185. package/services/home-shop.service.d.ts +34 -0
  186. package/services/index.d.ts +11 -0
  187. package/services/order-product-review.service.d.ts +18 -0
  188. package/services/order-recurrence.service.d.ts +25 -0
  189. package/services/order.service.d.ts +13 -0
  190. package/services/shared/configuration.facade.d.ts +12 -0
  191. package/services/shared/index.d.ts +1 -0
  192. package/services/types/index.d.ts +4 -0
  193. package/services/types/pending-product-review.type.d.ts +12 -0
  194. package/services/types/product-review-create.type.d.ts +14 -0
  195. package/services/types/required-checkout-data.type.d.ts +2 -0
  196. package/services/types/required-checkout-subscription-data.type.d.ts +2 -0
  197. package/types/firebase-app-config.type.d.ts +1 -0
  198. package/types/index.d.ts +1 -0
  199. package/eslint.config.js +0 -18
  200. package/index.ts +0 -1
  201. package/karma.conf.js +0 -32
  202. package/ng-package.json +0 -8
  203. package/project.json +0 -37
  204. package/src/angular-connect.module.ts +0 -270
  205. package/src/angular-elastic-search.module.ts +0 -23
  206. package/src/angular-firebase-auth.module.ts +0 -101
  207. package/src/angular-firestore.module.ts +0 -416
  208. package/src/angular-hasura-graphql.module.ts +0 -269
  209. package/src/angular-vertex-search.module.ts +0 -23
  210. package/src/consts/backend-url.const.ts +0 -1
  211. package/src/consts/category-structure.ts +0 -1
  212. package/src/consts/default-shop.const.ts +0 -1
  213. package/src/consts/es-config.const.ts +0 -1
  214. package/src/consts/firebase-const.ts +0 -5
  215. package/src/consts/hasura-options.const.ts +0 -1
  216. package/src/consts/index.ts +0 -8
  217. package/src/consts/persistence.const.ts +0 -1
  218. package/src/consts/storage-base-url.const.ts +0 -1
  219. package/src/consts/vertex-config.const.ts +0 -1
  220. package/src/helpers/index.ts +0 -1
  221. package/src/helpers/mobile-operation-system-checker.helper.ts +0 -10
  222. package/src/index.ts +0 -6
  223. package/src/interfaces/catalog-strategies.interface.ts +0 -36
  224. package/src/interfaces/category-facades.interface.ts +0 -7
  225. package/src/interfaces/index.ts +0 -2
  226. package/src/persistence/cookie-data-persistence.ts +0 -21
  227. package/src/persistence/data-persistence.ts +0 -7
  228. package/src/persistence/index.ts +0 -2
  229. package/src/services/auth.service.ts +0 -39
  230. package/src/services/cart/cart-services.facade.ts +0 -14
  231. package/src/services/cart/index.ts +0 -1
  232. package/src/services/cart.service.ts +0 -148
  233. package/src/services/catalog/adapters/category-structure.adapter.ts +0 -5
  234. package/src/services/catalog/adapters/index.ts +0 -3
  235. package/src/services/catalog/adapters/new-category-structure.adapter.ts +0 -42
  236. package/src/services/catalog/adapters/old-category-structure.adapter.ts +0 -17
  237. package/src/services/catalog/catalog.service.ts +0 -153
  238. package/src/services/catalog/category.service.ts +0 -56
  239. package/src/services/catalog/context/catalog-search.context.ts +0 -59
  240. package/src/services/catalog/enums/index.ts +0 -1
  241. package/src/services/catalog/enums/product-sorts.enum.ts +0 -9
  242. package/src/services/catalog/facades/catalog-service.facade.ts +0 -32
  243. package/src/services/catalog/facades/catalog-strategies.facade.ts +0 -12
  244. package/src/services/catalog/facades/category-repository.facade.ts +0 -10
  245. package/src/services/catalog/facades/category-service.facade.ts +0 -25
  246. package/src/services/catalog/facades/product-catalog.facade.ts +0 -13
  247. package/src/services/catalog/helpers/brand-manager.helper.ts +0 -69
  248. package/src/services/catalog/helpers/catalog-filter.helper.ts +0 -50
  249. package/src/services/catalog/helpers/catalog-sort.helper.ts +0 -54
  250. package/src/services/catalog/helpers/index.ts +0 -4
  251. package/src/services/catalog/helpers/product-fields.helper.ts +0 -39
  252. package/src/services/catalog/index.ts +0 -7
  253. package/src/services/catalog/models/category-with-tree.model.ts +0 -7
  254. package/src/services/catalog/models/index.ts +0 -1
  255. package/src/services/catalog/services/catalog-helpers.service.ts +0 -35
  256. package/src/services/catalog/services/catalog-operations.facade.ts +0 -24
  257. package/src/services/catalog/services/catalog-repository.service.ts +0 -20
  258. package/src/services/catalog/services/product-management.facade.ts +0 -20
  259. package/src/services/catalog/strategies/category-search.strategy.ts +0 -168
  260. package/src/services/catalog/strategies/index.ts +0 -3
  261. package/src/services/catalog/strategies/profile-search.strategy.ts +0 -51
  262. package/src/services/catalog/strategies/term-search.strategy.ts +0 -163
  263. package/src/services/catalog/strategies/types/strategy-params.type.ts +0 -59
  264. package/src/services/catalog/types/fetch-products-options.type.ts +0 -10
  265. package/src/services/catalog/types/fetch-products-params.type.ts +0 -27
  266. package/src/services/catalog/types/fetch-products-response.type.ts +0 -11
  267. package/src/services/catalog/types/index.ts +0 -5
  268. package/src/services/catalog/types/method-params.type.ts +0 -21
  269. package/src/services/catalog/types/product-sort.type.ts +0 -3
  270. package/src/services/catalog/wishlist.service.ts +0 -364
  271. package/src/services/checkout/checkout-dependencies.facade.ts +0 -13
  272. package/src/services/checkout/checkout-repositories.facade.ts +0 -10
  273. package/src/services/checkout-subscription.service.ts +0 -76
  274. package/src/services/checkout.service.ts +0 -236
  275. package/src/services/coupon/coupon-repositories.facade.ts +0 -11
  276. package/src/services/coupon/types/coupon-params.type.ts +0 -15
  277. package/src/services/coupon.service.ts +0 -347
  278. package/src/services/errors/group-invalid-coupon.error.ts +0 -9
  279. package/src/services/errors/index.ts +0 -2
  280. package/src/services/errors/invalid-coupon.error.ts +0 -7
  281. package/src/services/helpers/index.ts +0 -1
  282. package/src/services/helpers/util.helper.ts +0 -17
  283. package/src/services/home-shop/home-shop-repositories.facade.ts +0 -11
  284. package/src/services/home-shop.service.ts +0 -210
  285. package/src/services/index.ts +0 -12
  286. package/src/services/order-product-review.service.ts +0 -135
  287. package/src/services/order-recurrence.service.ts +0 -121
  288. package/src/services/order.service.ts +0 -23
  289. package/src/services/shared/configuration.facade.ts +0 -21
  290. package/src/services/shared/index.ts +0 -1
  291. package/src/services/types/index.ts +0 -4
  292. package/src/services/types/pending-product-review.type.ts +0 -12
  293. package/src/services/types/product-review-create.type.ts +0 -15
  294. package/src/services/types/required-checkout-data.type.ts +0 -3
  295. package/src/services/types/required-checkout-subscription-data.type.ts +0 -3
  296. package/src/types/firebase-app-config.type.ts +0 -1
  297. package/src/types/index.ts +0 -1
  298. package/tsconfig.json +0 -17
  299. package/tsconfig.lib.json +0 -13
  300. package/tsconfig.lib.prod.json +0 -13
  301. package/tsconfig.spec.json +0 -17
@@ -1,364 +0,0 @@
1
- import { Inject, Injectable } from '@angular/core'
2
- import {
3
- LogRepository,
4
- PersonType,
5
- PersonTypes,
6
- Product,
7
- ProductCatalogRepository,
8
- ProductRepository,
9
- Shops,
10
- Wishlist,
11
- WishlistLogType,
12
- WishlistRepository,
13
- } from '@infrab4a/connect'
14
-
15
- import { DEFAULT_SHOP } from '../../consts'
16
-
17
- import { CatalogService } from './catalog.service'
18
- import { CategoryService } from './category.service'
19
- import { CatalogServiceFacade, CategoryServiceFacade } from './facades'
20
-
21
- @Injectable()
22
- export class WishlistService {
23
- private catalogService: CatalogService
24
- private categoryService: CategoryService
25
-
26
- constructor(
27
- @Inject('WishlistRepository') private readonly wishlistRepository: WishlistRepository,
28
- @Inject('ProductRepository') private readonly productRepository: ProductRepository,
29
- @Inject('ProductCatalogRepository') private readonly productCatalogRepository: ProductCatalogRepository,
30
- @Inject('LogRepository') private readonly logRepository: LogRepository,
31
- @Inject(DEFAULT_SHOP) private readonly shop: Shops,
32
- ) {}
33
-
34
- initializeServices(catalogServiceFacade: CatalogServiceFacade, categoryServiceFacade: CategoryServiceFacade): void {
35
- this.catalogService = catalogServiceFacade.getCatalogService()
36
- this.categoryService = categoryServiceFacade.getCategoryService()
37
- }
38
-
39
- getCatalogService() {
40
- return this.catalogService
41
- }
42
-
43
- getCategoryService() {
44
- return this.categoryService
45
- }
46
-
47
- async create({
48
- personId,
49
- title,
50
- description,
51
- published,
52
- userFullName,
53
- userPhoto,
54
- theme,
55
- bannerUrl,
56
- personType,
57
- personIsSubscriber,
58
- }: {
59
- personId: string
60
- title: string
61
- description: string
62
- published: boolean
63
- userFullName: string
64
- userPhoto?: string
65
- theme?: string
66
- bannerUrl?: string
67
- personType?: PersonType
68
- personIsSubscriber?: boolean
69
- }): Promise<Wishlist> {
70
- const wishlistData = this.buildWishlistData({
71
- title,
72
- description,
73
- published,
74
- userFullName,
75
- userPhoto,
76
- theme,
77
- bannerUrl,
78
- personType,
79
- personIsSubscriber,
80
- personId,
81
- })
82
-
83
- const existingWishlist = await this.findExistingWishlistByPersonId(personId)
84
-
85
- await this.createWishlistLog(WishlistLogType.CREATE, wishlistData as Wishlist)
86
-
87
- if (existingWishlist) return existingWishlist
88
-
89
- return this.createNewWishlist(wishlistData)
90
- }
91
-
92
- private buildWishlistData({
93
- title,
94
- description,
95
- published,
96
- userFullName,
97
- userPhoto,
98
- theme,
99
- bannerUrl,
100
- personType,
101
- personIsSubscriber,
102
- personId,
103
- }: {
104
- title: string
105
- description: string
106
- published: boolean
107
- userFullName: string
108
- userPhoto?: string
109
- theme?: string
110
- bannerUrl?: string
111
- personType?: PersonType
112
- personIsSubscriber?: boolean
113
- personId: string
114
- }) {
115
- return {
116
- slug: '',
117
- name: title,
118
- description,
119
- metadatas: [
120
- {
121
- shop: this.shop,
122
- title: `${userFullName} - ${title}`,
123
- description: `${userFullName} - ${description}`,
124
- },
125
- ],
126
- shop: this.shop,
127
- shops: [this.shop],
128
- personId,
129
- personName: userFullName,
130
- personPhoto: userPhoto,
131
- brandCategory: false,
132
- published,
133
- theme,
134
- bannerUrl,
135
- personType: personType ?? PersonTypes.NONE,
136
- personIsSubscriber: personIsSubscriber ?? false,
137
- }
138
- }
139
-
140
- private async findExistingWishlistByPersonId(personId: string): Promise<Wishlist | null> {
141
- const hasWishlist = await this.wishlistRepository
142
- .find({
143
- filters: {
144
- personId,
145
- },
146
- options: {
147
- enableCount: false,
148
- },
149
- orderBy: {
150
- id: 'asc',
151
- },
152
- })
153
- .then((res) => res.data)
154
-
155
- return hasWishlist.length ? hasWishlist.at(0) : null
156
- }
157
-
158
- private async createNewWishlist(data: any): Promise<Wishlist> {
159
- const newWishlist = await this.wishlistRepository.create(data)
160
-
161
- await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id })
162
-
163
- return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id })
164
- }
165
-
166
- async update({
167
- id,
168
- title,
169
- description,
170
- published,
171
- userFullName,
172
- userPhoto,
173
- theme,
174
- bannerUrl,
175
- personType,
176
- personIsSubscriber,
177
- }: {
178
- id: string
179
- title: string
180
- description: string
181
- published: boolean
182
- userFullName: string
183
- userPhoto?: string
184
- theme?: string
185
- bannerUrl?: string
186
- personType?: PersonType
187
- personIsSubscriber?: boolean
188
- }): Promise<Wishlist> {
189
- const data = {
190
- id,
191
- name: title,
192
- description,
193
- published,
194
- metadatas: [
195
- {
196
- shop: this.shop,
197
- title: `${userFullName} - ${title}`,
198
- description: `${userFullName} - ${description}`,
199
- },
200
- ],
201
- personName: userFullName,
202
- personPhoto: userPhoto,
203
- theme,
204
- bannerUrl,
205
- personType: personType ?? PersonTypes.NONE,
206
- personIsSubscriber: personIsSubscriber ?? false,
207
- }
208
-
209
- await this.createWishlistLog(WishlistLogType.UPDATE, data as Wishlist)
210
-
211
- return this.wishlistRepository.update(data)
212
- }
213
-
214
- async delete(wishlistId: string): Promise<void> {
215
- const wishlist = await this.findById(wishlistId)
216
-
217
- await this.createWishlistLog(WishlistLogType.DELETE, wishlist)
218
-
219
- return this.wishlistRepository.delete({ id: wishlistId })
220
- }
221
-
222
- getWishlistBySlug(slug: string): Promise<Wishlist> {
223
- const [id] = slug.split('-')
224
-
225
- if (+id) return this.wishlistRepository.get({ id })
226
-
227
- return this.wishlistRepository.getWishlistBySlug(slug)
228
- }
229
-
230
- getWishlistsByPerson(personId: string): Promise<Wishlist[]> {
231
- return this.wishlistRepository.getWishlistByPerson(personId)
232
- }
233
-
234
- async addProduct(wishlistId: string, productId: string): Promise<Wishlist> {
235
- const wishlist = await this.wishlistRepository.get({ id: wishlistId })
236
- const hasProduct = wishlist.products.some((p) => p == productId)
237
-
238
- const wishlistData = await this.findById(wishlistId)
239
- const productData = await this.findProductById(productId)
240
-
241
- await this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData)
242
-
243
- if (!hasProduct) {
244
- wishlist.products = [...wishlist.products, productId]
245
- await this.wishlistRepository.addProduct(wishlistId, productId)
246
- }
247
-
248
- return wishlist
249
- }
250
-
251
- async removeProduct(wishlistId: string, productId: string): Promise<Wishlist> {
252
- const wishlist = await this.wishlistRepository.get({ id: wishlistId })
253
- const productIndex = wishlist.products.findIndex((p) => p == productId)
254
-
255
- if (productIndex != -1) {
256
- wishlist.products.splice(productIndex, 1)
257
- const wishlistData = await this.findById(wishlistId)
258
- const productData = await this.findProductById(productId)
259
-
260
- await this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData)
261
- await this.wishlistRepository.removeProduct(wishlistId, productId)
262
- }
263
-
264
- return wishlist
265
- }
266
-
267
- private async findById(id: string): Promise<Wishlist> {
268
- return this.wishlistRepository
269
- .find({
270
- fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
271
- filters: {
272
- id,
273
- },
274
- })
275
- .then((res) => res.data.at(0))
276
- }
277
-
278
- private async findProductById(id: string): Promise<Product> {
279
- return this.productCatalogRepository
280
- .find({
281
- fields: ['id', 'sku', 'EAN', 'name', 'brand'],
282
- filters: {
283
- id,
284
- },
285
- })
286
- .then((res) => res.data.at(0))
287
- }
288
-
289
- private async createWishlistLog(type: WishlistLogType, wishlist: Wishlist, product?: Product) {
290
- switch (type) {
291
- case WishlistLogType.CREATE:
292
- case WishlistLogType.UPDATE:
293
- case WishlistLogType.DELETE:
294
- await this.createWishlistOperationLog(type, wishlist)
295
- break
296
-
297
- case WishlistLogType.ADD_PRODUCT:
298
- case WishlistLogType.REMOVE_PRODUCT:
299
- await this.createWishlistProductLog(type, wishlist, product)
300
- break
301
-
302
- default:
303
- break
304
- }
305
- }
306
-
307
- private async createWishlistOperationLog(type: WishlistLogType, wishlist: Wishlist): Promise<void> {
308
- const operation = this.getOperationTypeFromWishlistLogType(type)
309
-
310
- await this.logRepository.create({
311
- collection: 'wishlist',
312
- date: new Date(),
313
- operation,
314
- documentId: wishlist.id,
315
- document: this.buildWishlistLogDocument(wishlist, type),
316
- })
317
- }
318
-
319
- private async createWishlistProductLog(type: WishlistLogType, wishlist: Wishlist, product: Product): Promise<void> {
320
- await this.logRepository.create({
321
- collection: 'wishlist',
322
- date: new Date(),
323
- operation: 'UPDATE',
324
- documentId: wishlist.id,
325
- document: {
326
- ...this.buildWishlistLogDocument(wishlist, type),
327
- ...this.buildProductLogData(product),
328
- },
329
- })
330
- }
331
-
332
- private getOperationTypeFromWishlistLogType(type: WishlistLogType): 'CREATE' | 'UPDATE' | 'DELETE' {
333
- if (type === WishlistLogType.CREATE) return 'CREATE'
334
-
335
- if (type === WishlistLogType.UPDATE) return 'UPDATE'
336
-
337
- return 'DELETE'
338
- }
339
-
340
- private buildWishlistLogDocument(wishlist: Wishlist, type: WishlistLogType) {
341
- return {
342
- id: wishlist.id,
343
- shop: this.shop,
344
- name: wishlist.name,
345
- description: wishlist.description,
346
- published: wishlist.published,
347
- type: type,
348
- personType: wishlist.personType,
349
- personId: wishlist.personId,
350
- personName: wishlist.personName,
351
- personIsSubscriber: wishlist.personIsSubscriber,
352
- }
353
- }
354
-
355
- private buildProductLogData(product: Product) {
356
- return {
357
- productId: product.id,
358
- productEAN: product.EAN,
359
- productSKU: product.sku,
360
- productName: product.name,
361
- productBrand: product.brand,
362
- }
363
- }
364
- }
@@ -1,13 +0,0 @@
1
- import { HttpClient } from '@angular/common/http'
2
- import { Inject, Injectable } from '@angular/core'
3
-
4
- import { PERSISTENCE_PROVIDER } from '../../consts'
5
- import { DataPersistence } from '../../persistence'
6
-
7
- @Injectable()
8
- export class CheckoutDependenciesFacade {
9
- constructor(
10
- @Inject(PERSISTENCE_PROVIDER) public readonly dataPersistence: DataPersistence,
11
- public readonly httpClient: HttpClient,
12
- ) {}
13
- }
@@ -1,10 +0,0 @@
1
- import { Inject, Injectable } from '@angular/core'
2
- import { CheckoutRepository, UserRepository } from '@infrab4a/connect'
3
-
4
- @Injectable()
5
- export class CheckoutRepositoriesFacade {
6
- constructor(
7
- @Inject('CheckoutRepository') public readonly checkoutRepository: CheckoutRepository,
8
- @Inject('UserRepository') public readonly userRepository: UserRepository,
9
- ) {}
10
- }
@@ -1,76 +0,0 @@
1
- import { Inject, Injectable } from '@angular/core'
2
- import {
3
- CheckoutSubscription,
4
- CheckoutSubscriptionRepository,
5
- CheckoutTypes,
6
- Coupon,
7
- isNil,
8
- pick,
9
- } from '@infrab4a/connect'
10
- import { Observable } from 'rxjs'
11
- import { concatMap } from 'rxjs/operators'
12
-
13
-
14
- import { PERSISTENCE_PROVIDER } from '../consts'
15
- import { DataPersistence } from '../persistence'
16
-
17
- import { RequiredCheckoutSubscriptionData } from './types'
18
- import { CouponService } from './coupon.service'
19
-
20
- @Injectable()
21
- export class CheckoutSubscriptionService {
22
- constructor(
23
- @Inject('CheckoutSubscriptionRepository')
24
- private readonly checkoutSubscriptionRepository: CheckoutSubscriptionRepository,
25
- @Inject(PERSISTENCE_PROVIDER) private readonly dataPersistence: DataPersistence,
26
- private readonly couponService: CouponService,
27
- ) {}
28
-
29
- getCheckoutSubscription(checkoutData?: RequiredCheckoutSubscriptionData): Observable<CheckoutSubscription> {
30
- return this.dataPersistence
31
- .get('checkoutSubscriptionId')
32
- .pipe(
33
- concatMap((id) =>
34
- !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData),
35
- ),
36
- )
37
- }
38
-
39
- clearCheckoutSubscriptionFromSession(): Observable<void> {
40
- return this.dataPersistence.remove('checkoutSubscriptionId')
41
- }
42
-
43
- checkCoupon(nickname: string, _userEmail: string): Observable<Coupon> {
44
- return this.getCheckoutSubscription().pipe(
45
- concatMap((checkout) =>
46
- this.couponService
47
- .checkCoupon({
48
- nickname,
49
- checkoutType: CheckoutTypes.SUBSCRIPTION,
50
- checkout,
51
- plan: checkout.subscriptionPlan.name,
52
- })
53
- .pipe(),
54
- ),
55
- )
56
- }
57
-
58
- calcDiscountSubscription(coupon: Coupon) {
59
- return this.getCheckoutSubscription().pipe(
60
- concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()),
61
- )
62
- }
63
-
64
- private async createCheckoutSubscription(
65
- checkoutData?: RequiredCheckoutSubscriptionData,
66
- ): Promise<CheckoutSubscription> {
67
- const checkout = await this.checkoutSubscriptionRepository.create({
68
- createdAt: new Date(),
69
- ...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
70
- })
71
-
72
- await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise()
73
-
74
- return checkout
75
- }
76
- }
@@ -1,236 +0,0 @@
1
- import { Injectable } from '@angular/core'
2
- import {
3
- Checkout,
4
- CheckoutPayloadRequest,
5
- CheckoutResponse,
6
- CheckoutStockValidation,
7
- CheckoutTypes,
8
- Coupon,
9
- isNil,
10
- NotFoundError,
11
- pick,
12
- ShippingMethodResponse,
13
- ShippingProductRequest,
14
- User,
15
- UserAddress,
16
- } from '@infrab4a/connect'
17
- import { from, Observable, of, throwError } from 'rxjs'
18
- import { concatMap, map } from 'rxjs/operators'
19
-
20
- import { CheckoutDependenciesFacade, CheckoutRepositoriesFacade } from './checkout'
21
- import { ConfigurationFacade } from './shared'
22
- import { RequiredCheckoutData } from './types'
23
-
24
- @Injectable()
25
- export class CheckoutService {
26
- private checkoutUrl: string = null
27
-
28
- constructor(
29
- private readonly repositoriesFacade: CheckoutRepositoriesFacade,
30
- private readonly dependenciesFacade: CheckoutDependenciesFacade,
31
- private readonly configurationFacade: ConfigurationFacade,
32
- ) {
33
- this.checkoutUrl = this.configurationFacade.getCheckoutUrl()
34
- }
35
-
36
- getCheckout(checkoutData?: RequiredCheckoutData): Observable<Checkout> {
37
- return this.dependenciesFacade.dataPersistence
38
- .get('checkoutId')
39
- .pipe(
40
- concatMap((id) =>
41
- !isNil(id) ? this.repositoriesFacade.checkoutRepository.get({ id }) : this.createCheckout(checkoutData),
42
- ),
43
- )
44
- }
45
-
46
- getUserByCheckout(checkoutId: string): Observable<User> {
47
- return from(this.repositoriesFacade.checkoutRepository.get({ id: checkoutId })).pipe(
48
- concatMap((checkout) =>
49
- checkout?.user?.id
50
- ? of(checkout.user)
51
- : from(this.repositoriesFacade.userRepository.get({ id: checkout.user.id })),
52
- ),
53
- concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))),
54
- )
55
- }
56
-
57
- updateCheckoutLineItems(checkout: Partial<Checkout>): Observable<Checkout> {
58
- return from(
59
- this.repositoriesFacade.checkoutRepository.update(
60
- Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems }),
61
- ),
62
- )
63
- }
64
-
65
- updateCheckoutUser(checkout: Partial<Checkout>): Observable<Checkout> {
66
- return from(
67
- this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })),
68
- )
69
- }
70
-
71
- clearCheckoutFromSession(): Observable<void> {
72
- return this.dependenciesFacade.dataPersistence.remove('checkoutId')
73
- }
74
-
75
- resetCheckoutValues(): Observable<Checkout> {
76
- return this.getCheckout().pipe(
77
- concatMap((checkout) =>
78
- this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutResetValues`, {
79
- checkoutId: checkout.id,
80
- }),
81
- ),
82
- concatMap(() => this.getCheckout()),
83
- )
84
- }
85
-
86
- applyCouponDiscount(nickname: string, checkoutType: CheckoutTypes): Observable<Coupon> {
87
- return this.getCheckout().pipe(
88
- concatMap((checkout) =>
89
- this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutApplyDiscount`, {
90
- checkoutId: checkout.id,
91
- coupon: nickname,
92
- checkoutType,
93
- }),
94
- ),
95
- concatMap(() => this.getCheckout()),
96
- map((checkout) => checkout.coupon),
97
- )
98
- }
99
-
100
- removeCouponDiscount(): Observable<Checkout> {
101
- return this.getCheckout().pipe(
102
- concatMap((checkout) =>
103
- this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemoveDiscount`, {
104
- checkoutId: checkout.id,
105
- }),
106
- ),
107
- concatMap(() => this.getCheckout()),
108
- )
109
- }
110
-
111
- applyPointsDiscount(points: number): Observable<Checkout> {
112
- return this.getCheckout().pipe(
113
- concatMap((checkout) =>
114
- this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutApplyPointsDiscount`, {
115
- checkoutId: checkout.id,
116
- points,
117
- }),
118
- ),
119
- concatMap(() => this.getCheckout()),
120
- )
121
- }
122
-
123
- removePointsDiscount(): Observable<Checkout> {
124
- return this.getCheckout().pipe(
125
- concatMap((checkout) =>
126
- this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemovePointsDiscount`, {
127
- checkoutId: checkout.id,
128
- }),
129
- ),
130
- concatMap(() => this.getCheckout()),
131
- )
132
- }
133
-
134
- validateStockProducts(): Observable<CheckoutStockValidation> {
135
- return this.getCheckout().pipe(
136
- concatMap((checkout) =>
137
- this.dependenciesFacade.httpClient.post<{
138
- valid: boolean
139
- outOfStock: string[]
140
- limitedStock: string[]
141
- }>(`${this.checkoutUrl}/checkoutValidateProductStock`, {
142
- checkoutId: checkout.id,
143
- }),
144
- ),
145
- )
146
- }
147
-
148
- selectShippingAddress(address: UserAddress): Observable<Checkout> {
149
- const formattedAddress: UserAddress = {
150
- ...address,
151
- zip: this.formatZip(address.zip),
152
- } as UserAddress
153
-
154
- return this.getCheckout().pipe(
155
- concatMap((checkout) => {
156
- return this.repositoriesFacade.checkoutRepository.update(
157
- Checkout.toInstance({
158
- id: checkout.id,
159
- shippingAddress: formattedAddress,
160
- billingAddress: formattedAddress,
161
- }),
162
- )
163
- }),
164
- )
165
- }
166
-
167
- private formatZip(zip?: string): string | undefined {
168
- if (!zip) return zip
169
-
170
- const digits = zip.replace(/\D/g, '')
171
-
172
- return digits
173
- }
174
-
175
- getAvailableShippingForProduct(productShipping: ShippingProductRequest): Observable<ShippingMethodResponse[]> {
176
- return this.dependenciesFacade.httpClient.post<ShippingMethodResponse[]>(
177
- `${this.checkoutUrl}/checkoutGetAvailableShipping`,
178
- {
179
- checkoutId: null,
180
- productShipping,
181
- },
182
- )
183
- }
184
-
185
- getAvailableShippingForCheckout(): Observable<ShippingMethodResponse[]> {
186
- return this.getCheckout().pipe(
187
- concatMap((checkout) =>
188
- this.dependenciesFacade.httpClient.post<ShippingMethodResponse[]>(
189
- `${this.checkoutUrl}/checkoutGetAvailableShipping`,
190
- {
191
- checkoutId: checkout.id,
192
- productShipping: null,
193
- },
194
- ),
195
- ),
196
- )
197
- }
198
-
199
- selectShipping(option: string): Observable<Checkout> {
200
- return this.getCheckout().pipe(
201
- concatMap((checkout) =>
202
- this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutSelectShipping`, {
203
- checkoutId: checkout.id,
204
- shippingOption: option,
205
- }),
206
- ),
207
- concatMap(() => this.getCheckout()),
208
- )
209
- }
210
-
211
- createOrder(
212
- checkoutPayload: CheckoutPayloadRequest,
213
- paymentProvider: string,
214
- applicationVersion: string,
215
- ): Observable<CheckoutResponse> {
216
- return this.dependenciesFacade.httpClient.post<CheckoutResponse>(`${this.checkoutUrl}/checkout`, {
217
- data: {
218
- ...checkoutPayload,
219
- applicationVersion,
220
- paymentProvider,
221
- },
222
- })
223
- }
224
-
225
- private async createCheckout(checkoutData?: RequiredCheckoutData): Promise<Checkout> {
226
- const checkout = await this.repositoriesFacade.checkoutRepository.create({
227
- createdAt: new Date(),
228
- ...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
229
- shop: checkoutData?.shop || this.configurationFacade.defaultShop,
230
- })
231
-
232
- await this.dependenciesFacade.dataPersistence.set('checkoutId', checkout.id).toPromise()
233
-
234
- return checkout
235
- }
236
- }
@@ -1,11 +0,0 @@
1
- import { Inject, Injectable } from '@angular/core'
2
- import { CategoryRepository, CouponRepository, OrderRepository } from '@infrab4a/connect'
3
-
4
- @Injectable()
5
- export class CouponRepositoriesFacade {
6
- constructor(
7
- @Inject('CouponRepository') public readonly couponRepository: CouponRepository,
8
- @Inject('OrderRepository') public readonly orderRepository: OrderRepository,
9
- @Inject('CategoryRepository') public readonly categoryRepository: CategoryRepository,
10
- ) {}
11
- }