@infrab4a/connect-angular 5.4.6-beta.0 → 5.5.0-alpha.1

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 (227) hide show
  1. package/angular-connect.module.d.ts +33 -36
  2. package/angular-elastic-search.module.d.ts +9 -9
  3. package/angular-firebase-auth.module.d.ts +10 -11
  4. package/angular-firestore.module.d.ts +16 -17
  5. package/angular-hasura-graphql.module.d.ts +14 -14
  6. package/angular-vertex-search.module.d.ts +9 -9
  7. package/consts/backend-url.const.d.ts +1 -1
  8. package/consts/category-structure.d.ts +1 -1
  9. package/consts/default-shop.const.d.ts +1 -1
  10. package/consts/es-config.const.d.ts +1 -1
  11. package/consts/firebase-const.d.ts +4 -4
  12. package/consts/hasura-options.const.d.ts +1 -1
  13. package/consts/index.d.ts +8 -8
  14. package/consts/persistence.const.d.ts +1 -1
  15. package/consts/storage-base-url.const.d.ts +1 -1
  16. package/consts/vertex-config.const.d.ts +1 -1
  17. package/esm2022/angular-connect.module.mjs +288 -0
  18. package/esm2022/angular-elastic-search.module.mjs +34 -0
  19. package/esm2022/angular-firebase-auth.module.mjs +140 -0
  20. package/esm2022/angular-firestore.module.mjs +538 -0
  21. package/esm2022/angular-hasura-graphql.module.mjs +333 -0
  22. package/esm2022/angular-vertex-search.module.mjs +34 -0
  23. package/{esm2020 → esm2022}/consts/backend-url.const.mjs +2 -2
  24. package/{esm2020 → esm2022}/consts/category-structure.mjs +2 -2
  25. package/{esm2020 → esm2022}/consts/default-shop.const.mjs +2 -2
  26. package/{esm2020 → esm2022}/consts/es-config.const.mjs +2 -2
  27. package/{esm2020 → esm2022}/consts/firebase-const.mjs +5 -5
  28. package/{esm2020 → esm2022}/consts/hasura-options.const.mjs +2 -2
  29. package/{esm2020 → esm2022}/consts/index.mjs +9 -9
  30. package/{esm2020 → esm2022}/consts/persistence.const.mjs +2 -2
  31. package/{esm2020 → esm2022}/consts/storage-base-url.const.mjs +2 -2
  32. package/{esm2020 → esm2022}/consts/vertex-config.const.mjs +2 -2
  33. package/{esm2020 → esm2022}/helpers/index.mjs +2 -2
  34. package/{esm2020 → esm2022}/helpers/mobile-operation-system-checker.helper.mjs +7 -7
  35. package/{esm2020 → esm2022}/index.mjs +7 -7
  36. package/{esm2020 → esm2022}/infrab4a-connect-angular.mjs +4 -4
  37. package/esm2022/interfaces/catalog-strategies.interface.mjs +2 -0
  38. package/{esm2020 → esm2022}/interfaces/category-facades.interface.mjs +2 -2
  39. package/{esm2020 → esm2022}/interfaces/index.mjs +3 -3
  40. package/{esm2020 → esm2022}/persistence/cookie-data-persistence.mjs +22 -22
  41. package/{esm2020 → esm2022}/persistence/data-persistence.mjs +2 -2
  42. package/{esm2020 → esm2022}/persistence/index.mjs +3 -3
  43. package/{esm2020 → esm2022}/services/auth.service.mjs +37 -37
  44. package/{esm2020 → esm2022}/services/cart/cart-services.facade.mjs +21 -21
  45. package/{esm2020 → esm2022}/services/cart/index.mjs +2 -2
  46. package/{esm2020 → esm2022}/services/cart.service.mjs +73 -73
  47. package/{esm2020 → esm2022}/services/catalog/adapters/category-structure.adapter.mjs +2 -2
  48. package/{esm2020 → esm2022}/services/catalog/adapters/index.mjs +4 -4
  49. package/{esm2020 → esm2022}/services/catalog/adapters/new-category-structure.adapter.mjs +43 -43
  50. package/{esm2020 → esm2022}/services/catalog/adapters/old-category-structure.adapter.mjs +23 -23
  51. package/esm2022/services/catalog/catalog.service.mjs +111 -0
  52. package/{esm2020 → esm2022}/services/catalog/category.service.mjs +42 -42
  53. package/esm2022/services/catalog/context/catalog-search.context.mjs +40 -0
  54. package/{esm2020 → esm2022}/services/catalog/enums/index.mjs +2 -2
  55. package/{esm2020 → esm2022}/services/catalog/enums/product-sorts.enum.mjs +11 -11
  56. package/{esm2020 → esm2022}/services/catalog/facades/catalog-service.facade.mjs +32 -32
  57. package/esm2022/services/catalog/facades/catalog-strategies.facade.mjs +17 -0
  58. package/esm2022/services/catalog/facades/category-repository.facade.mjs +20 -0
  59. package/{esm2020 → esm2022}/services/catalog/facades/category-service.facade.mjs +30 -30
  60. package/{esm2020 → esm2022}/services/catalog/facades/index.mjs +6 -6
  61. package/esm2022/services/catalog/facades/product-catalog.facade.mjs +21 -0
  62. package/esm2022/services/catalog/helpers/brand-manager.helper.mjs +57 -0
  63. package/esm2022/services/catalog/helpers/catalog-filter.helper.mjs +44 -0
  64. package/esm2022/services/catalog/helpers/catalog-sort.helper.mjs +52 -0
  65. package/{esm2020 → esm2022}/services/catalog/helpers/index.mjs +5 -5
  66. package/{esm2020 → esm2022}/services/catalog/helpers/product-fields.helper.mjs +40 -40
  67. package/{esm2020 → esm2022}/services/catalog/index.mjs +8 -8
  68. package/{esm2020 → esm2022}/services/catalog/models/category-with-tree.model.mjs +10 -10
  69. package/{esm2020 → esm2022}/services/catalog/models/index.mjs +2 -2
  70. package/esm2022/services/catalog/services/catalog-helpers.service.mjs +33 -0
  71. package/{esm2020 → esm2022}/services/catalog/services/catalog-operations.facade.mjs +26 -26
  72. package/esm2022/services/catalog/services/catalog-repository.service.mjs +25 -0
  73. package/{esm2020 → esm2022}/services/catalog/services/index.mjs +5 -5
  74. package/esm2022/services/catalog/services/product-management.facade.mjs +25 -0
  75. package/esm2022/services/catalog/strategies/category-search.strategy.mjs +133 -0
  76. package/{esm2020 → esm2022}/services/catalog/strategies/index.mjs +4 -4
  77. package/esm2022/services/catalog/strategies/profile-search.strategy.mjs +42 -0
  78. package/esm2022/services/catalog/strategies/term-search.strategy.mjs +123 -0
  79. package/esm2022/services/catalog/strategies/types/strategy-params.type.mjs +2 -0
  80. package/{esm2020 → esm2022}/services/catalog/types/fetch-products-options.type.mjs +2 -2
  81. package/esm2022/services/catalog/types/fetch-products-params.type.mjs +2 -0
  82. package/{esm2020 → esm2022}/services/catalog/types/fetch-products-response.type.mjs +2 -2
  83. package/{esm2020 → esm2022}/services/catalog/types/index.mjs +6 -6
  84. package/esm2022/services/catalog/types/method-params.type.mjs +2 -0
  85. package/{esm2020 → esm2022}/services/catalog/types/product-sort.type.mjs +2 -2
  86. package/esm2022/services/catalog/wishlist.service.mjs +254 -0
  87. package/esm2022/services/checkout/checkout-dependencies.facade.mjs +20 -0
  88. package/esm2022/services/checkout/checkout-repositories.facade.mjs +20 -0
  89. package/{esm2020 → esm2022}/services/checkout/index.mjs +3 -3
  90. package/{esm2020 → esm2022}/services/checkout-subscription.service.mjs +55 -55
  91. package/{esm2020 → esm2022}/services/checkout.service.mjs +106 -106
  92. package/{esm2020 → esm2022}/services/coupon/coupon-repositories.facade.mjs +24 -24
  93. package/{esm2020 → esm2022}/services/coupon/index.mjs +2 -2
  94. package/esm2022/services/coupon/types/coupon-params.type.mjs +2 -0
  95. package/esm2022/services/coupon.service.mjs +248 -0
  96. package/{esm2020 → esm2022}/services/helpers/index.mjs +2 -2
  97. package/{esm2020 → esm2022}/services/helpers/util.helper.mjs +18 -18
  98. package/{esm2020 → esm2022}/services/home-shop/home-shop-repositories.facade.mjs +24 -24
  99. package/{esm2020 → esm2022}/services/home-shop/index.mjs +2 -2
  100. package/{esm2020 → esm2022}/services/home-shop.service.mjs +119 -119
  101. package/{esm2020 → esm2022}/services/index.mjs +11 -11
  102. package/esm2022/services/order-product-review.service.mjs +110 -0
  103. package/{esm2020 → esm2022}/services/order.service.mjs +30 -30
  104. package/{esm2020 → esm2022}/services/shared/configuration.facade.mjs +29 -29
  105. package/{esm2020 → esm2022}/services/shared/index.mjs +2 -2
  106. package/{esm2020 → esm2022}/services/types/index.mjs +5 -5
  107. package/{esm2020 → esm2022}/services/types/pending-product-review.type.mjs +2 -2
  108. package/{esm2020 → esm2022}/services/types/product-review-create.type.mjs +2 -2
  109. package/{esm2020 → esm2022}/services/types/required-checkout-data.type.mjs +2 -2
  110. package/{esm2020 → esm2022}/services/types/required-checkout-subscription-data.type.mjs +2 -2
  111. package/{esm2020 → esm2022}/types/firebase-app-config.type.mjs +2 -2
  112. package/{esm2020 → esm2022}/types/index.mjs +2 -2
  113. package/{fesm2020 → fesm2022}/infrab4a-connect-angular.mjs +3284 -3289
  114. package/fesm2022/infrab4a-connect-angular.mjs.map +1 -0
  115. package/helpers/index.d.ts +1 -1
  116. package/helpers/mobile-operation-system-checker.helper.d.ts +3 -3
  117. package/index.d.ts +6 -6
  118. package/interfaces/catalog-strategies.interface.d.ts +31 -31
  119. package/interfaces/category-facades.interface.d.ts +6 -6
  120. package/interfaces/index.d.ts +2 -2
  121. package/package.json +9 -15
  122. package/persistence/cookie-data-persistence.d.ts +10 -10
  123. package/persistence/data-persistence.d.ts +6 -6
  124. package/persistence/index.d.ts +2 -2
  125. package/services/auth.service.d.ts +18 -18
  126. package/services/cart/cart-services.facade.d.ts +12 -12
  127. package/services/cart/index.d.ts +1 -1
  128. package/services/cart.service.d.ts +26 -26
  129. package/services/catalog/adapters/category-structure.adapter.d.ts +4 -4
  130. package/services/catalog/adapters/index.d.ts +3 -3
  131. package/services/catalog/adapters/new-category-structure.adapter.d.ts +12 -12
  132. package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -10
  133. package/services/catalog/catalog.service.d.ts +24 -24
  134. package/services/catalog/category.service.d.ts +23 -23
  135. package/services/catalog/context/catalog-search.context.d.ts +14 -14
  136. package/services/catalog/enums/index.d.ts +1 -1
  137. package/services/catalog/enums/product-sorts.enum.d.ts +9 -9
  138. package/services/catalog/facades/catalog-service.facade.d.ts +15 -15
  139. package/services/catalog/facades/catalog-strategies.facade.d.ts +10 -10
  140. package/services/catalog/facades/category-repository.facade.d.ts +9 -9
  141. package/services/catalog/facades/category-service.facade.d.ts +15 -15
  142. package/services/catalog/facades/index.d.ts +5 -5
  143. package/services/catalog/facades/product-catalog.facade.d.ts +10 -10
  144. package/services/catalog/helpers/brand-manager.helper.d.ts +14 -14
  145. package/services/catalog/helpers/catalog-filter.helper.d.ts +8 -8
  146. package/services/catalog/helpers/catalog-sort.helper.d.ts +7 -7
  147. package/services/catalog/helpers/index.d.ts +4 -4
  148. package/services/catalog/helpers/product-fields.helper.d.ts +7 -7
  149. package/services/catalog/index.d.ts +7 -7
  150. package/services/catalog/models/category-with-tree.model.d.ts +4 -4
  151. package/services/catalog/models/index.d.ts +1 -1
  152. package/services/catalog/services/catalog-helpers.service.d.ts +17 -17
  153. package/services/catalog/services/catalog-operations.facade.d.ts +13 -13
  154. package/services/catalog/services/catalog-repository.service.d.ts +12 -12
  155. package/services/catalog/services/index.d.ts +4 -4
  156. package/services/catalog/services/product-management.facade.d.ts +12 -12
  157. package/services/catalog/strategies/category-search.strategy.d.ts +19 -19
  158. package/services/catalog/strategies/index.d.ts +3 -3
  159. package/services/catalog/strategies/profile-search.strategy.d.ts +14 -14
  160. package/services/catalog/strategies/term-search.strategy.d.ts +20 -20
  161. package/services/catalog/strategies/types/strategy-params.type.d.ts +58 -58
  162. package/services/catalog/types/fetch-products-options.type.d.ts +8 -8
  163. package/services/catalog/types/fetch-products-params.type.d.ts +25 -25
  164. package/services/catalog/types/fetch-products-response.type.d.ts +19 -19
  165. package/services/catalog/types/index.d.ts +5 -5
  166. package/services/catalog/types/method-params.type.d.ts +17 -17
  167. package/services/catalog/types/product-sort.type.d.ts +2 -2
  168. package/services/catalog/wishlist.service.d.ts +59 -59
  169. package/services/checkout/checkout-dependencies.facade.d.ts +10 -10
  170. package/services/checkout/checkout-repositories.facade.d.ts +9 -9
  171. package/services/checkout/index.d.ts +2 -2
  172. package/services/checkout-subscription.service.d.ts +19 -19
  173. package/services/checkout.service.d.ts +30 -30
  174. package/services/coupon/coupon-repositories.facade.d.ts +10 -10
  175. package/services/coupon/index.d.ts +1 -1
  176. package/services/coupon/types/coupon-params.type.d.ts +13 -13
  177. package/services/coupon.service.d.ts +36 -36
  178. package/services/helpers/index.d.ts +1 -1
  179. package/services/helpers/util.helper.d.ts +3 -3
  180. package/services/home-shop/home-shop-repositories.facade.d.ts +10 -10
  181. package/services/home-shop/index.d.ts +1 -1
  182. package/services/home-shop.service.d.ts +26 -26
  183. package/services/index.d.ts +10 -10
  184. package/services/order-product-review.service.d.ts +16 -16
  185. package/services/order.service.d.ts +13 -13
  186. package/services/shared/configuration.facade.d.ts +12 -12
  187. package/services/shared/index.d.ts +1 -1
  188. package/services/types/index.d.ts +4 -4
  189. package/services/types/pending-product-review.type.d.ts +12 -12
  190. package/services/types/product-review-create.type.d.ts +14 -14
  191. package/services/types/required-checkout-data.type.d.ts +2 -2
  192. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
  193. package/types/firebase-app-config.type.d.ts +1 -1
  194. package/types/index.d.ts +1 -1
  195. package/esm2020/angular-connect.module.mjs +0 -291
  196. package/esm2020/angular-elastic-search.module.mjs +0 -34
  197. package/esm2020/angular-firebase-auth.module.mjs +0 -141
  198. package/esm2020/angular-firestore.module.mjs +0 -541
  199. package/esm2020/angular-hasura-graphql.module.mjs +0 -333
  200. package/esm2020/angular-vertex-search.module.mjs +0 -34
  201. package/esm2020/interfaces/catalog-strategies.interface.mjs +0 -2
  202. package/esm2020/services/catalog/catalog.service.mjs +0 -111
  203. package/esm2020/services/catalog/context/catalog-search.context.mjs +0 -40
  204. package/esm2020/services/catalog/facades/catalog-strategies.facade.mjs +0 -17
  205. package/esm2020/services/catalog/facades/category-repository.facade.mjs +0 -20
  206. package/esm2020/services/catalog/facades/product-catalog.facade.mjs +0 -21
  207. package/esm2020/services/catalog/helpers/brand-manager.helper.mjs +0 -57
  208. package/esm2020/services/catalog/helpers/catalog-filter.helper.mjs +0 -44
  209. package/esm2020/services/catalog/helpers/catalog-sort.helper.mjs +0 -52
  210. package/esm2020/services/catalog/services/catalog-helpers.service.mjs +0 -33
  211. package/esm2020/services/catalog/services/catalog-repository.service.mjs +0 -25
  212. package/esm2020/services/catalog/services/product-management.facade.mjs +0 -25
  213. package/esm2020/services/catalog/strategies/category-search.strategy.mjs +0 -133
  214. package/esm2020/services/catalog/strategies/profile-search.strategy.mjs +0 -42
  215. package/esm2020/services/catalog/strategies/term-search.strategy.mjs +0 -123
  216. package/esm2020/services/catalog/strategies/types/strategy-params.type.mjs +0 -2
  217. package/esm2020/services/catalog/types/fetch-products-params.type.mjs +0 -2
  218. package/esm2020/services/catalog/types/method-params.type.mjs +0 -2
  219. package/esm2020/services/catalog/wishlist.service.mjs +0 -254
  220. package/esm2020/services/checkout/checkout-dependencies.facade.mjs +0 -20
  221. package/esm2020/services/checkout/checkout-repositories.facade.mjs +0 -20
  222. package/esm2020/services/coupon/types/coupon-params.type.mjs +0 -2
  223. package/esm2020/services/coupon.service.mjs +0 -248
  224. package/esm2020/services/order-product-review.service.mjs +0 -110
  225. package/fesm2015/infrab4a-connect-angular.mjs +0 -3491
  226. package/fesm2015/infrab4a-connect-angular.mjs.map +0 -1
  227. package/fesm2020/infrab4a-connect-angular.mjs.map +0 -1
@@ -1,3491 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
3
- import * as i1$3 from '@angular/fire/app';
4
- import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
5
- import * as i2 from '@angular/fire/app-check';
6
- import { provideAppCheck, initializeAppCheck } from '@angular/fire/app-check';
7
- import * as i3$1 from '@angular/fire/storage';
8
- import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
9
- import * as i3 from '@infrab4a/connect';
10
- import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, GroupFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, isEmpty, Shops, set, InvalidArgumentError, RoundProductPricesHelper, Category, WishlistLogType, PersonTypes, Wishlist, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, CheckoutSubscription, Product, RequiredArgumentError, add, ProductReview, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
11
- import * as i1 from '@angular/fire/auth';
12
- import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence, getAuth, getIdToken, authState } from '@angular/fire/auth';
13
- import { isPlatformBrowser, isPlatformServer } from '@angular/common';
14
- import * as i1$1 from '@angular/fire/firestore';
15
- import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
16
- import cookie from 'js-cookie';
17
- import { of, from, combineLatest, throwError, Subject, forkJoin } from 'rxjs';
18
- import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
19
- import { __awaiter, __decorate, __metadata } from 'tslib';
20
- import * as i1$2 from '@angular/common/http';
21
- import { Type } from 'class-transformer';
22
-
23
- const ES_CONFIG = 'ES_CONFIG';
24
-
25
- class AngularElasticSeachModule {
26
- static initializeApp(options) {
27
- return {
28
- ngModule: AngularElasticSeachModule,
29
- providers: [{ provide: ES_CONFIG, useValue: options }],
30
- };
31
- }
32
- }
33
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
34
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
35
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
36
- {
37
- provide: ProductsIndex,
38
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
39
- deps: [ES_CONFIG],
40
- },
41
- ] });
42
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
43
- type: NgModule,
44
- args: [{
45
- providers: [
46
- {
47
- provide: ProductsIndex,
48
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
49
- deps: [ES_CONFIG],
50
- },
51
- ],
52
- }]
53
- }] });
54
-
55
- const BACKEND_URL = 'BACKEND_URL';
56
-
57
- const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
58
-
59
- const DEFAULT_SHOP = 'DEFAULT_SHOP';
60
-
61
- const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
62
- const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
63
- const APP_CHECK_PROVIDER = new InjectionToken('appCheckProvider');
64
-
65
- const HASURA_OPTIONS = 'HASURA_OPTIONS';
66
-
67
- const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
68
-
69
- const VERTEX_CONFIG = 'VERTEX_CONFIG';
70
-
71
- class AngularFirebaseAuthModule {
72
- static initializeApp(options, nameOrConfig) {
73
- return {
74
- ngModule: AngularFirebaseAuthModule,
75
- providers: [
76
- { provide: FIREBASE_OPTIONS, useValue: options },
77
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
78
- ],
79
- };
80
- }
81
- }
82
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
83
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] });
84
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
85
- {
86
- provide: 'Authentication',
87
- useFactory: (authenticationService, userRepository) => {
88
- return new Authentication(authenticationService, userRepository);
89
- },
90
- deps: ['AuthenticationService', 'UserRepository'],
91
- },
92
- {
93
- provide: 'AuthenticationService',
94
- useFactory: (angularFireAuth) => {
95
- return new AuthenticationFirebaseAuthService(angularFireAuth);
96
- },
97
- deps: [Auth],
98
- },
99
- {
100
- provide: 'Register',
101
- useFactory: (registerService, userRepository) => {
102
- return new Register(registerService, userRepository);
103
- },
104
- deps: ['RegisterService', 'UserRepository'],
105
- },
106
- {
107
- provide: 'RegisterService',
108
- useFactory: (angularFireAuth) => {
109
- return new RegisterFirebaseAuthService(angularFireAuth);
110
- },
111
- deps: [Auth],
112
- },
113
- {
114
- provide: 'SignOut',
115
- useFactory: (authenticationService) => {
116
- return new SignOut(authenticationService);
117
- },
118
- deps: ['AuthenticationService'],
119
- },
120
- {
121
- provide: 'RecoveryPassword',
122
- useFactory: (authenticationService) => {
123
- return new RecoveryPassword(authenticationService);
124
- },
125
- deps: ['AuthenticationService'],
126
- },
127
- ], imports: [provideAuth((injector) => {
128
- const app = injector.get(FirebaseApp);
129
- try {
130
- return initializeAuth(app, {
131
- persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence],
132
- });
133
- }
134
- catch (error) {
135
- if (error instanceof Error)
136
- console.error('Error initializing auth', error.message);
137
- return getAuth(app);
138
- }
139
- })] });
140
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
141
- type: NgModule,
142
- args: [{
143
- imports: [
144
- provideAuth((injector) => {
145
- const app = injector.get(FirebaseApp);
146
- try {
147
- return initializeAuth(app, {
148
- persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence],
149
- });
150
- }
151
- catch (error) {
152
- if (error instanceof Error)
153
- console.error('Error initializing auth', error.message);
154
- return getAuth(app);
155
- }
156
- }),
157
- ],
158
- providers: [
159
- {
160
- provide: 'Authentication',
161
- useFactory: (authenticationService, userRepository) => {
162
- return new Authentication(authenticationService, userRepository);
163
- },
164
- deps: ['AuthenticationService', 'UserRepository'],
165
- },
166
- {
167
- provide: 'AuthenticationService',
168
- useFactory: (angularFireAuth) => {
169
- return new AuthenticationFirebaseAuthService(angularFireAuth);
170
- },
171
- deps: [Auth],
172
- },
173
- {
174
- provide: 'Register',
175
- useFactory: (registerService, userRepository) => {
176
- return new Register(registerService, userRepository);
177
- },
178
- deps: ['RegisterService', 'UserRepository'],
179
- },
180
- {
181
- provide: 'RegisterService',
182
- useFactory: (angularFireAuth) => {
183
- return new RegisterFirebaseAuthService(angularFireAuth);
184
- },
185
- deps: [Auth],
186
- },
187
- {
188
- provide: 'SignOut',
189
- useFactory: (authenticationService) => {
190
- return new SignOut(authenticationService);
191
- },
192
- deps: ['AuthenticationService'],
193
- },
194
- {
195
- provide: 'RecoveryPassword',
196
- useFactory: (authenticationService) => {
197
- return new RecoveryPassword(authenticationService);
198
- },
199
- deps: ['AuthenticationService'],
200
- },
201
- ],
202
- }]
203
- }] });
204
-
205
- class MobileOperationSystemCheckerHelper {
206
- static isAppleDevice() {
207
- var _a, _b;
208
- return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator === null || navigator === void 0 ? void 0 : navigator.platform) ||
209
- (((_b = (_a = navigator === null || navigator === void 0 ? void 0 : navigator.userAgent) === null || _a === void 0 ? void 0 : _a.includes) === null || _b === void 0 ? void 0 : _b.call(_a, 'Mac')) && 'ontouchend' in (document || {})));
210
- }
211
- }
212
-
213
- class AngularFirestoreModule {
214
- static initializeApp(options, nameOrConfig) {
215
- return {
216
- ngModule: AngularFirestoreModule,
217
- providers: [
218
- { provide: FIREBASE_OPTIONS, useValue: options.firebase },
219
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
220
- { provide: ES_CONFIG, useValue: options.elasticSearch },
221
- ],
222
- };
223
- }
224
- }
225
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
226
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule] });
227
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
228
- {
229
- provide: 'FirestoreOptions',
230
- useFactory: (firestore, platformId) => ({
231
- firestore: new ConnectFirestoreService(firestore),
232
- interceptors: {
233
- request: (request) => {
234
- if (isPlatformBrowser(platformId))
235
- return request;
236
- const interval = setInterval(() => { }, 100);
237
- request.interval = interval;
238
- return request;
239
- },
240
- response: (response, request) => {
241
- if (isPlatformBrowser(platformId))
242
- return response;
243
- clearInterval(request.interval);
244
- return response;
245
- },
246
- },
247
- }),
248
- deps: [Firestore, PLATFORM_ID],
249
- },
250
- {
251
- provide: 'BeautyProfileRepository',
252
- useFactory: (config, userRepository) => {
253
- return new UserBeautyProfileFirestoreRepository(config, userRepository);
254
- },
255
- deps: ['FirestoreOptions', 'UserRepository'],
256
- },
257
- {
258
- provide: 'Buy2WinRepository',
259
- useFactory: (options) => {
260
- return new Buy2WinFirestoreRepository(options);
261
- },
262
- deps: ['FirestoreOptions'],
263
- },
264
- {
265
- provide: CategoryFirestoreRepository,
266
- useFactory: (options) => {
267
- return new CategoryFirestoreRepository(options);
268
- },
269
- deps: ['FirestoreOptions'],
270
- },
271
- {
272
- provide: 'CheckoutRepository',
273
- useFactory: (options) => {
274
- return new CheckoutFirestoreRepository(options);
275
- },
276
- deps: ['FirestoreOptions'],
277
- },
278
- {
279
- provide: 'CheckoutSubscriptionRepository',
280
- useFactory: (options) => {
281
- return new CheckoutSubscriptionFirestoreRepository(options);
282
- },
283
- deps: ['FirestoreOptions'],
284
- },
285
- {
286
- provide: 'CouponRepository',
287
- useFactory: (options) => {
288
- return new CouponFirestoreRepository(options);
289
- },
290
- deps: ['FirestoreOptions'],
291
- },
292
- {
293
- provide: 'CampaignHashtagRepository',
294
- useFactory: (options) => {
295
- return new CampaignHashtagFirestoreRepository(options);
296
- },
297
- deps: ['FirestoreOptions'],
298
- },
299
- {
300
- provide: 'CampaignDashboardRepository',
301
- useFactory: (options) => {
302
- return new CampaignDashboardFirestoreRepository(options);
303
- },
304
- deps: ['FirestoreOptions'],
305
- },
306
- {
307
- provide: 'EditionRepository',
308
- useFactory: (options, subscriptionRepository) => {
309
- return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
310
- },
311
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
312
- },
313
- {
314
- provide: 'GroupRepository',
315
- useFactory: (options) => {
316
- return new GroupFirestoreRepository(options);
317
- },
318
- deps: ['FirestoreOptions'],
319
- },
320
- {
321
- provide: 'HomeRepository',
322
- useFactory: (options) => {
323
- return new HomeFirestoreRepository(options);
324
- },
325
- deps: ['FirestoreOptions'],
326
- },
327
- {
328
- provide: 'LeadRepository',
329
- useFactory: (options) => {
330
- return new LeadFirestoreRepository(options);
331
- },
332
- deps: ['FirestoreOptions'],
333
- },
334
- {
335
- provide: 'LegacyOrderRepository',
336
- useFactory: (options) => {
337
- return new LegacyOrderFirestoreRepository(options);
338
- },
339
- deps: ['FirestoreOptions'],
340
- },
341
- {
342
- provide: 'ShopMenuRepository',
343
- useFactory: (options) => {
344
- return new ShopMenuFirestoreRepository(options);
345
- },
346
- deps: ['FirestoreOptions'],
347
- },
348
- {
349
- provide: 'OrderRepository',
350
- useFactory: (options) => {
351
- return new OrderFirestoreRepository(options);
352
- },
353
- deps: ['FirestoreOptions'],
354
- },
355
- {
356
- provide: 'PaymentRepository',
357
- useFactory: (options) => {
358
- return new PaymentFirestoreRepository(options);
359
- },
360
- deps: ['FirestoreOptions'],
361
- },
362
- {
363
- provide: ProductFirestoreRepository,
364
- useFactory: (options) => {
365
- return new ProductFirestoreRepository(options);
366
- },
367
- deps: ['FirestoreOptions'],
368
- },
369
- {
370
- provide: 'ShopSettingsRepository',
371
- useFactory: (options) => {
372
- return new ShopSettingsFirestoreRepository(options);
373
- },
374
- deps: ['FirestoreOptions'],
375
- },
376
- {
377
- provide: 'SubscriptionPaymentRepository',
378
- useFactory: (options, subscriptionRepository) => {
379
- return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
380
- },
381
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
382
- },
383
- {
384
- provide: 'SubscriptionPlanRepository',
385
- useFactory: (options) => {
386
- return new SubscriptionPlanFirestoreRepository(options);
387
- },
388
- deps: ['FirestoreOptions'],
389
- },
390
- {
391
- provide: 'SubscriptionProductRepository',
392
- useFactory: (options) => {
393
- return new SubscriptionProductFirestoreRepository(options);
394
- },
395
- deps: ['FirestoreOptions'],
396
- },
397
- {
398
- provide: 'SubscriptionRepository',
399
- useFactory: (options) => {
400
- return new SubscriptionFirestoreRepository(options);
401
- },
402
- deps: ['FirestoreOptions'],
403
- },
404
- {
405
- provide: 'UserRepository',
406
- useFactory: (options) => {
407
- return new UserFirestoreRepository(options);
408
- },
409
- deps: ['FirestoreOptions'],
410
- },
411
- {
412
- provide: 'UserAddressRepository',
413
- useFactory: (options, userRepository) => {
414
- return new UserAddressFirestoreRepository(options, userRepository);
415
- },
416
- deps: ['FirestoreOptions', 'UserRepository'],
417
- },
418
- {
419
- provide: 'UserPaymentMethodRepository',
420
- useFactory: (options, userRepository) => {
421
- return new UserPaymentMethodFirestoreRepository(options, userRepository);
422
- },
423
- deps: ['FirestoreOptions', 'UserRepository'],
424
- },
425
- {
426
- provide: 'SubscriptionMaterializationRepository',
427
- useFactory: (options) => {
428
- return new SubscriptionMaterializationFirestoreRepository(options);
429
- },
430
- deps: ['FirestoreOptions'],
431
- },
432
- {
433
- provide: 'SubscriptionSummaryRepository',
434
- useFactory: (options) => {
435
- return new SubscriptionSummaryFirestoreRepository(options);
436
- },
437
- deps: ['FirestoreOptions'],
438
- },
439
- {
440
- provide: ProductVariantFirestoreRepository,
441
- useFactory: (options, productRepository) => {
442
- return new ProductVariantFirestoreRepository(options, productRepository);
443
- },
444
- deps: ['FirestoreOptions', ProductFirestoreRepository],
445
- },
446
- {
447
- provide: 'OrderBlockedRepository',
448
- useFactory: (options) => {
449
- return new OrderBlockedFirestoreRepository(options);
450
- },
451
- deps: ['FirestoreOptions'],
452
- },
453
- {
454
- provide: 'LogRepository',
455
- useFactory: (options) => {
456
- return new LogFirestoreRepository(options);
457
- },
458
- deps: ['FirestoreOptions'],
459
- },
460
- {
461
- provide: 'SequenceRepository',
462
- useFactory: (options) => {
463
- return new SequenceFirestoreRepository(options);
464
- },
465
- deps: ['FirestoreOptions'],
466
- },
467
- ], imports: [AngularElasticSeachModule,
468
- provideFirestore((injector) => {
469
- const platformId = injector.get(PLATFORM_ID);
470
- if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
471
- return initializeFirestore(injector.get(FirebaseApp), {
472
- ignoreUndefinedProperties: true,
473
- });
474
- const firestore = initializeFirestore(injector.get(FirebaseApp), {
475
- experimentalForceLongPolling: true,
476
- ignoreUndefinedProperties: true,
477
- localCache: memoryLocalCache(),
478
- });
479
- return firestore;
480
- })] });
481
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
482
- type: NgModule,
483
- args: [{
484
- imports: [
485
- AngularElasticSeachModule,
486
- provideFirestore((injector) => {
487
- const platformId = injector.get(PLATFORM_ID);
488
- if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
489
- return initializeFirestore(injector.get(FirebaseApp), {
490
- ignoreUndefinedProperties: true,
491
- });
492
- const firestore = initializeFirestore(injector.get(FirebaseApp), {
493
- experimentalForceLongPolling: true,
494
- ignoreUndefinedProperties: true,
495
- localCache: memoryLocalCache(),
496
- });
497
- return firestore;
498
- }),
499
- ],
500
- providers: [
501
- {
502
- provide: 'FirestoreOptions',
503
- useFactory: (firestore, platformId) => ({
504
- firestore: new ConnectFirestoreService(firestore),
505
- interceptors: {
506
- request: (request) => {
507
- if (isPlatformBrowser(platformId))
508
- return request;
509
- const interval = setInterval(() => { }, 100);
510
- request.interval = interval;
511
- return request;
512
- },
513
- response: (response, request) => {
514
- if (isPlatformBrowser(platformId))
515
- return response;
516
- clearInterval(request.interval);
517
- return response;
518
- },
519
- },
520
- }),
521
- deps: [Firestore, PLATFORM_ID],
522
- },
523
- {
524
- provide: 'BeautyProfileRepository',
525
- useFactory: (config, userRepository) => {
526
- return new UserBeautyProfileFirestoreRepository(config, userRepository);
527
- },
528
- deps: ['FirestoreOptions', 'UserRepository'],
529
- },
530
- {
531
- provide: 'Buy2WinRepository',
532
- useFactory: (options) => {
533
- return new Buy2WinFirestoreRepository(options);
534
- },
535
- deps: ['FirestoreOptions'],
536
- },
537
- {
538
- provide: CategoryFirestoreRepository,
539
- useFactory: (options) => {
540
- return new CategoryFirestoreRepository(options);
541
- },
542
- deps: ['FirestoreOptions'],
543
- },
544
- {
545
- provide: 'CheckoutRepository',
546
- useFactory: (options) => {
547
- return new CheckoutFirestoreRepository(options);
548
- },
549
- deps: ['FirestoreOptions'],
550
- },
551
- {
552
- provide: 'CheckoutSubscriptionRepository',
553
- useFactory: (options) => {
554
- return new CheckoutSubscriptionFirestoreRepository(options);
555
- },
556
- deps: ['FirestoreOptions'],
557
- },
558
- {
559
- provide: 'CouponRepository',
560
- useFactory: (options) => {
561
- return new CouponFirestoreRepository(options);
562
- },
563
- deps: ['FirestoreOptions'],
564
- },
565
- {
566
- provide: 'CampaignHashtagRepository',
567
- useFactory: (options) => {
568
- return new CampaignHashtagFirestoreRepository(options);
569
- },
570
- deps: ['FirestoreOptions'],
571
- },
572
- {
573
- provide: 'CampaignDashboardRepository',
574
- useFactory: (options) => {
575
- return new CampaignDashboardFirestoreRepository(options);
576
- },
577
- deps: ['FirestoreOptions'],
578
- },
579
- {
580
- provide: 'EditionRepository',
581
- useFactory: (options, subscriptionRepository) => {
582
- return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
583
- },
584
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
585
- },
586
- {
587
- provide: 'GroupRepository',
588
- useFactory: (options) => {
589
- return new GroupFirestoreRepository(options);
590
- },
591
- deps: ['FirestoreOptions'],
592
- },
593
- {
594
- provide: 'HomeRepository',
595
- useFactory: (options) => {
596
- return new HomeFirestoreRepository(options);
597
- },
598
- deps: ['FirestoreOptions'],
599
- },
600
- {
601
- provide: 'LeadRepository',
602
- useFactory: (options) => {
603
- return new LeadFirestoreRepository(options);
604
- },
605
- deps: ['FirestoreOptions'],
606
- },
607
- {
608
- provide: 'LegacyOrderRepository',
609
- useFactory: (options) => {
610
- return new LegacyOrderFirestoreRepository(options);
611
- },
612
- deps: ['FirestoreOptions'],
613
- },
614
- {
615
- provide: 'ShopMenuRepository',
616
- useFactory: (options) => {
617
- return new ShopMenuFirestoreRepository(options);
618
- },
619
- deps: ['FirestoreOptions'],
620
- },
621
- {
622
- provide: 'OrderRepository',
623
- useFactory: (options) => {
624
- return new OrderFirestoreRepository(options);
625
- },
626
- deps: ['FirestoreOptions'],
627
- },
628
- {
629
- provide: 'PaymentRepository',
630
- useFactory: (options) => {
631
- return new PaymentFirestoreRepository(options);
632
- },
633
- deps: ['FirestoreOptions'],
634
- },
635
- {
636
- provide: ProductFirestoreRepository,
637
- useFactory: (options) => {
638
- return new ProductFirestoreRepository(options);
639
- },
640
- deps: ['FirestoreOptions'],
641
- },
642
- {
643
- provide: 'ShopSettingsRepository',
644
- useFactory: (options) => {
645
- return new ShopSettingsFirestoreRepository(options);
646
- },
647
- deps: ['FirestoreOptions'],
648
- },
649
- {
650
- provide: 'SubscriptionPaymentRepository',
651
- useFactory: (options, subscriptionRepository) => {
652
- return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
653
- },
654
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
655
- },
656
- {
657
- provide: 'SubscriptionPlanRepository',
658
- useFactory: (options) => {
659
- return new SubscriptionPlanFirestoreRepository(options);
660
- },
661
- deps: ['FirestoreOptions'],
662
- },
663
- {
664
- provide: 'SubscriptionProductRepository',
665
- useFactory: (options) => {
666
- return new SubscriptionProductFirestoreRepository(options);
667
- },
668
- deps: ['FirestoreOptions'],
669
- },
670
- {
671
- provide: 'SubscriptionRepository',
672
- useFactory: (options) => {
673
- return new SubscriptionFirestoreRepository(options);
674
- },
675
- deps: ['FirestoreOptions'],
676
- },
677
- {
678
- provide: 'UserRepository',
679
- useFactory: (options) => {
680
- return new UserFirestoreRepository(options);
681
- },
682
- deps: ['FirestoreOptions'],
683
- },
684
- {
685
- provide: 'UserAddressRepository',
686
- useFactory: (options, userRepository) => {
687
- return new UserAddressFirestoreRepository(options, userRepository);
688
- },
689
- deps: ['FirestoreOptions', 'UserRepository'],
690
- },
691
- {
692
- provide: 'UserPaymentMethodRepository',
693
- useFactory: (options, userRepository) => {
694
- return new UserPaymentMethodFirestoreRepository(options, userRepository);
695
- },
696
- deps: ['FirestoreOptions', 'UserRepository'],
697
- },
698
- {
699
- provide: 'SubscriptionMaterializationRepository',
700
- useFactory: (options) => {
701
- return new SubscriptionMaterializationFirestoreRepository(options);
702
- },
703
- deps: ['FirestoreOptions'],
704
- },
705
- {
706
- provide: 'SubscriptionSummaryRepository',
707
- useFactory: (options) => {
708
- return new SubscriptionSummaryFirestoreRepository(options);
709
- },
710
- deps: ['FirestoreOptions'],
711
- },
712
- {
713
- provide: ProductVariantFirestoreRepository,
714
- useFactory: (options, productRepository) => {
715
- return new ProductVariantFirestoreRepository(options, productRepository);
716
- },
717
- deps: ['FirestoreOptions', ProductFirestoreRepository],
718
- },
719
- {
720
- provide: 'OrderBlockedRepository',
721
- useFactory: (options) => {
722
- return new OrderBlockedFirestoreRepository(options);
723
- },
724
- deps: ['FirestoreOptions'],
725
- },
726
- {
727
- provide: 'LogRepository',
728
- useFactory: (options) => {
729
- return new LogFirestoreRepository(options);
730
- },
731
- deps: ['FirestoreOptions'],
732
- },
733
- {
734
- provide: 'SequenceRepository',
735
- useFactory: (options) => {
736
- return new SequenceFirestoreRepository(options);
737
- },
738
- deps: ['FirestoreOptions'],
739
- },
740
- ],
741
- }]
742
- }] });
743
-
744
- class AngularHasuraGraphQLModule {
745
- static initializeApp(options) {
746
- return {
747
- ngModule: AngularHasuraGraphQLModule,
748
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
749
- };
750
- }
751
- }
752
- AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
753
- AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
754
- AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
755
- {
756
- provide: 'HasuraConfig',
757
- useFactory: (options, platformId) => ({
758
- endpoint: options.endpoint,
759
- authOptions: options.credentials,
760
- cache: options.cache,
761
- interceptors: {
762
- request: (request) => {
763
- if (isPlatformBrowser(platformId))
764
- return request;
765
- const interval = setInterval(() => { }, 100);
766
- request.interval = interval;
767
- return request;
768
- },
769
- response: (response, request) => {
770
- if (isPlatformBrowser(platformId))
771
- return response;
772
- clearInterval(request.interval);
773
- return response;
774
- },
775
- },
776
- }),
777
- deps: [HASURA_OPTIONS, PLATFORM_ID],
778
- },
779
- {
780
- provide: 'CategoryRepository',
781
- useExisting: CategoryHasuraGraphQLRepository,
782
- },
783
- {
784
- provide: CategoryHasuraGraphQLRepository,
785
- useFactory: (options, productRepository, categoryFilterRepository) => {
786
- return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
787
- },
788
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
789
- },
790
- {
791
- provide: 'ProductRepository',
792
- useExisting: ProductHasuraGraphQLRepository,
793
- },
794
- {
795
- provide: ProductHasuraGraphQLRepository,
796
- useFactory: (hasuraConfig) => {
797
- return new ProductHasuraGraphQLRepository(hasuraConfig);
798
- },
799
- deps: ['HasuraConfig'],
800
- },
801
- {
802
- provide: 'ProductReviewRepository',
803
- useExisting: ProductReviewHasuraGraphQLRepository,
804
- },
805
- {
806
- provide: ProductReviewHasuraGraphQLRepository,
807
- useFactory: (hasuraConfig) => {
808
- return new ProductReviewHasuraGraphQLRepository(hasuraConfig);
809
- },
810
- deps: ['HasuraConfig'],
811
- },
812
- {
813
- provide: 'VariantRepository',
814
- useExisting: VariantHasuraGraphQLRepository,
815
- },
816
- {
817
- provide: VariantHasuraGraphQLRepository,
818
- useFactory: (hasuraConfig) => {
819
- return new VariantHasuraGraphQLRepository(hasuraConfig);
820
- },
821
- deps: ['HasuraConfig'],
822
- },
823
- {
824
- provide: 'ProductStockNotificationRepository',
825
- useExisting: ProductStockNotificationHasuraGraphQLRepository,
826
- },
827
- {
828
- provide: ProductStockNotificationHasuraGraphQLRepository,
829
- useFactory: (hasuraConfig) => {
830
- return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
831
- },
832
- deps: ['HasuraConfig'],
833
- },
834
- {
835
- provide: 'CategoryFilterRepository',
836
- useExisting: CategoryFilterHasuraGraphQLRepository,
837
- },
838
- {
839
- provide: CategoryFilterHasuraGraphQLRepository,
840
- useFactory: (options) => {
841
- return new CategoryFilterHasuraGraphQLRepository(options);
842
- },
843
- deps: ['HasuraConfig'],
844
- },
845
- {
846
- provide: 'FilterOptionRepository',
847
- useExisting: FilterOptionHasuraGraphQLRepository,
848
- },
849
- {
850
- provide: FilterOptionHasuraGraphQLRepository,
851
- useFactory: (options) => {
852
- return new FilterOptionHasuraGraphQLRepository(options);
853
- },
854
- deps: ['HasuraConfig'],
855
- },
856
- {
857
- provide: 'FilterRepository',
858
- useExisting: FilterHasuraGraphQLRepository,
859
- },
860
- {
861
- provide: FilterHasuraGraphQLRepository,
862
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
863
- return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
864
- },
865
- deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
866
- },
867
- {
868
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
869
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
870
- deps: ['HasuraConfig'],
871
- },
872
- {
873
- provide: 'CategoryCollectionChildrenRepository',
874
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
875
- },
876
- {
877
- provide: CategoryProductHasuraGraphQLRepository,
878
- useFactory: (options) => {
879
- return new CategoryProductHasuraGraphQLRepository(options);
880
- },
881
- deps: ['HasuraConfig'],
882
- },
883
- {
884
- provide: 'CategoryProductRepository',
885
- useExisting: CategoryProductHasuraGraphQLRepository,
886
- },
887
- {
888
- provide: WishlistHasuraGraphQLRepository,
889
- useFactory: (options, categoryProductRepository) => {
890
- return new WishlistHasuraGraphQLRepository(options, categoryProductRepository);
891
- },
892
- deps: ['HasuraConfig', CategoryProductHasuraGraphQLRepository],
893
- },
894
- {
895
- provide: 'WishlistRepository',
896
- useExisting: WishlistHasuraGraphQLRepository,
897
- },
898
- {
899
- provide: ProductErrorsHasuraGraphQLRepository,
900
- useFactory: (options, productRepository) => {
901
- return new ProductErrorsHasuraGraphQLRepository(options, productRepository);
902
- },
903
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
904
- },
905
- {
906
- provide: 'ProductErrorsRepository',
907
- useExisting: ProductErrorsHasuraGraphQLRepository,
908
- },
909
- ] });
910
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
911
- type: NgModule,
912
- args: [{
913
- providers: [
914
- {
915
- provide: 'HasuraConfig',
916
- useFactory: (options, platformId) => ({
917
- endpoint: options.endpoint,
918
- authOptions: options.credentials,
919
- cache: options.cache,
920
- interceptors: {
921
- request: (request) => {
922
- if (isPlatformBrowser(platformId))
923
- return request;
924
- const interval = setInterval(() => { }, 100);
925
- request.interval = interval;
926
- return request;
927
- },
928
- response: (response, request) => {
929
- if (isPlatformBrowser(platformId))
930
- return response;
931
- clearInterval(request.interval);
932
- return response;
933
- },
934
- },
935
- }),
936
- deps: [HASURA_OPTIONS, PLATFORM_ID],
937
- },
938
- {
939
- provide: 'CategoryRepository',
940
- useExisting: CategoryHasuraGraphQLRepository,
941
- },
942
- {
943
- provide: CategoryHasuraGraphQLRepository,
944
- useFactory: (options, productRepository, categoryFilterRepository) => {
945
- return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
946
- },
947
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
948
- },
949
- {
950
- provide: 'ProductRepository',
951
- useExisting: ProductHasuraGraphQLRepository,
952
- },
953
- {
954
- provide: ProductHasuraGraphQLRepository,
955
- useFactory: (hasuraConfig) => {
956
- return new ProductHasuraGraphQLRepository(hasuraConfig);
957
- },
958
- deps: ['HasuraConfig'],
959
- },
960
- {
961
- provide: 'ProductReviewRepository',
962
- useExisting: ProductReviewHasuraGraphQLRepository,
963
- },
964
- {
965
- provide: ProductReviewHasuraGraphQLRepository,
966
- useFactory: (hasuraConfig) => {
967
- return new ProductReviewHasuraGraphQLRepository(hasuraConfig);
968
- },
969
- deps: ['HasuraConfig'],
970
- },
971
- {
972
- provide: 'VariantRepository',
973
- useExisting: VariantHasuraGraphQLRepository,
974
- },
975
- {
976
- provide: VariantHasuraGraphQLRepository,
977
- useFactory: (hasuraConfig) => {
978
- return new VariantHasuraGraphQLRepository(hasuraConfig);
979
- },
980
- deps: ['HasuraConfig'],
981
- },
982
- {
983
- provide: 'ProductStockNotificationRepository',
984
- useExisting: ProductStockNotificationHasuraGraphQLRepository,
985
- },
986
- {
987
- provide: ProductStockNotificationHasuraGraphQLRepository,
988
- useFactory: (hasuraConfig) => {
989
- return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
990
- },
991
- deps: ['HasuraConfig'],
992
- },
993
- {
994
- provide: 'CategoryFilterRepository',
995
- useExisting: CategoryFilterHasuraGraphQLRepository,
996
- },
997
- {
998
- provide: CategoryFilterHasuraGraphQLRepository,
999
- useFactory: (options) => {
1000
- return new CategoryFilterHasuraGraphQLRepository(options);
1001
- },
1002
- deps: ['HasuraConfig'],
1003
- },
1004
- {
1005
- provide: 'FilterOptionRepository',
1006
- useExisting: FilterOptionHasuraGraphQLRepository,
1007
- },
1008
- {
1009
- provide: FilterOptionHasuraGraphQLRepository,
1010
- useFactory: (options) => {
1011
- return new FilterOptionHasuraGraphQLRepository(options);
1012
- },
1013
- deps: ['HasuraConfig'],
1014
- },
1015
- {
1016
- provide: 'FilterRepository',
1017
- useExisting: FilterHasuraGraphQLRepository,
1018
- },
1019
- {
1020
- provide: FilterHasuraGraphQLRepository,
1021
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1022
- return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
1023
- },
1024
- deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1025
- },
1026
- {
1027
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
1028
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
1029
- deps: ['HasuraConfig'],
1030
- },
1031
- {
1032
- provide: 'CategoryCollectionChildrenRepository',
1033
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
1034
- },
1035
- {
1036
- provide: CategoryProductHasuraGraphQLRepository,
1037
- useFactory: (options) => {
1038
- return new CategoryProductHasuraGraphQLRepository(options);
1039
- },
1040
- deps: ['HasuraConfig'],
1041
- },
1042
- {
1043
- provide: 'CategoryProductRepository',
1044
- useExisting: CategoryProductHasuraGraphQLRepository,
1045
- },
1046
- {
1047
- provide: WishlistHasuraGraphQLRepository,
1048
- useFactory: (options, categoryProductRepository) => {
1049
- return new WishlistHasuraGraphQLRepository(options, categoryProductRepository);
1050
- },
1051
- deps: ['HasuraConfig', CategoryProductHasuraGraphQLRepository],
1052
- },
1053
- {
1054
- provide: 'WishlistRepository',
1055
- useExisting: WishlistHasuraGraphQLRepository,
1056
- },
1057
- {
1058
- provide: ProductErrorsHasuraGraphQLRepository,
1059
- useFactory: (options, productRepository) => {
1060
- return new ProductErrorsHasuraGraphQLRepository(options, productRepository);
1061
- },
1062
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1063
- },
1064
- {
1065
- provide: 'ProductErrorsRepository',
1066
- useExisting: ProductErrorsHasuraGraphQLRepository,
1067
- },
1068
- ],
1069
- }]
1070
- }] });
1071
-
1072
- class AngularVertexSeachModule {
1073
- static initializeApp(options) {
1074
- return {
1075
- ngModule: AngularVertexSeachModule,
1076
- providers: [{ provide: VERTEX_CONFIG, useValue: options }],
1077
- };
1078
- }
1079
- }
1080
- AngularVertexSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1081
- AngularVertexSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule });
1082
- AngularVertexSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule, providers: [
1083
- {
1084
- provide: ProductsVertexSearch,
1085
- useFactory: (configuration) => new ProductsVertexSearch(new VertexAxiosAdapter(configuration)),
1086
- deps: [VERTEX_CONFIG],
1087
- },
1088
- ] });
1089
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularVertexSeachModule, decorators: [{
1090
- type: NgModule,
1091
- args: [{
1092
- providers: [
1093
- {
1094
- provide: ProductsVertexSearch,
1095
- useFactory: (configuration) => new ProductsVertexSearch(new VertexAxiosAdapter(configuration)),
1096
- deps: [VERTEX_CONFIG],
1097
- },
1098
- ],
1099
- }]
1100
- }] });
1101
-
1102
- const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
1103
-
1104
- class CookieDataPersistence {
1105
- get(key) {
1106
- return of(cookie.get(key));
1107
- }
1108
- remove(key) {
1109
- return of(cookie.remove(key));
1110
- }
1111
- set(key, value) {
1112
- return from(cookie.set(key, value)).pipe(map(() => { }));
1113
- }
1114
- }
1115
- CookieDataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1116
- CookieDataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence });
1117
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, decorators: [{
1118
- type: Injectable
1119
- }] });
1120
-
1121
- class AuthService {
1122
- constructor(angularFireAuth, userRepository) {
1123
- this.angularFireAuth = angularFireAuth;
1124
- this.userRepository = userRepository;
1125
- }
1126
- getAuthstate() {
1127
- const observables = [this.getFireUser(), this.getUser()];
1128
- return combineLatest(observables).pipe(map(([fireUser, user]) => ({
1129
- user,
1130
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
1131
- })));
1132
- }
1133
- getUser() {
1134
- return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
1135
- }
1136
- getTokenId() {
1137
- return from(getIdToken(this.angularFireAuth.currentUser));
1138
- }
1139
- getFireUser() {
1140
- return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
1141
- }
1142
- }
1143
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1144
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
1145
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
1146
- type: Injectable
1147
- }], ctorParameters: function () {
1148
- return [{ type: i1.Auth }, { type: undefined, decorators: [{
1149
- type: Inject,
1150
- args: ['UserRepository']
1151
- }] }];
1152
- } });
1153
-
1154
- class CheckoutRepositoriesFacade {
1155
- constructor(checkoutRepository, userRepository) {
1156
- this.checkoutRepository = checkoutRepository;
1157
- this.userRepository = userRepository;
1158
- }
1159
- }
1160
- CheckoutRepositoriesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutRepositoriesFacade, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1161
- CheckoutRepositoriesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutRepositoriesFacade });
1162
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutRepositoriesFacade, decorators: [{
1163
- type: Injectable
1164
- }], ctorParameters: function () {
1165
- return [{ type: undefined, decorators: [{
1166
- type: Inject,
1167
- args: ['CheckoutRepository']
1168
- }] }, { type: undefined, decorators: [{
1169
- type: Inject,
1170
- args: ['UserRepository']
1171
- }] }];
1172
- } });
1173
-
1174
- class CheckoutDependenciesFacade {
1175
- constructor(dataPersistence, httpClient) {
1176
- this.dataPersistence = dataPersistence;
1177
- this.httpClient = httpClient;
1178
- }
1179
- }
1180
- CheckoutDependenciesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutDependenciesFacade, deps: [{ token: PERSISTENCE_PROVIDER }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1181
- CheckoutDependenciesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutDependenciesFacade });
1182
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutDependenciesFacade, decorators: [{
1183
- type: Injectable
1184
- }], ctorParameters: function () {
1185
- return [{ type: undefined, decorators: [{
1186
- type: Inject,
1187
- args: [PERSISTENCE_PROVIDER]
1188
- }] }, { type: i1$2.HttpClient }];
1189
- } });
1190
-
1191
- class ConfigurationFacade {
1192
- constructor(defaultShop, firebaseOptions) {
1193
- this.defaultShop = defaultShop;
1194
- this.firebaseOptions = firebaseOptions;
1195
- }
1196
- getCheckoutUrl() {
1197
- return `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`;
1198
- }
1199
- getProjectId() {
1200
- return this.firebaseOptions.projectId;
1201
- }
1202
- }
1203
- ConfigurationFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ConfigurationFacade, deps: [{ token: DEFAULT_SHOP }, { token: FIREBASE_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable });
1204
- ConfigurationFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ConfigurationFacade });
1205
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ConfigurationFacade, decorators: [{
1206
- type: Injectable
1207
- }], ctorParameters: function () {
1208
- return [{ type: i3.Shops, decorators: [{
1209
- type: Inject,
1210
- args: [DEFAULT_SHOP]
1211
- }] }, { type: undefined, decorators: [{
1212
- type: Inject,
1213
- args: [FIREBASE_OPTIONS]
1214
- }] }];
1215
- } });
1216
-
1217
- class CheckoutService {
1218
- constructor(repositoriesFacade, dependenciesFacade, configurationFacade) {
1219
- this.repositoriesFacade = repositoriesFacade;
1220
- this.dependenciesFacade = dependenciesFacade;
1221
- this.configurationFacade = configurationFacade;
1222
- this.checkoutUrl = null;
1223
- this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
1224
- }
1225
- getCheckout(checkoutData) {
1226
- return this.dependenciesFacade.dataPersistence
1227
- .get('checkoutId')
1228
- .pipe(concatMap((id) => !isNil(id) ? this.repositoriesFacade.checkoutRepository.get({ id }) : this.createCheckout(checkoutData)));
1229
- }
1230
- getUserByCheckout(checkoutId) {
1231
- return from(this.repositoriesFacade.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => {
1232
- var _a;
1233
- return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id)
1234
- ? of(checkout.user)
1235
- : from(this.repositoriesFacade.userRepository.get({ id: checkout.user.id }));
1236
- }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
1237
- }
1238
- updateCheckoutLineItems(checkout) {
1239
- return from(this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1240
- }
1241
- updateCheckoutUser(checkout) {
1242
- return from(this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1243
- }
1244
- clearCheckoutFromSession() {
1245
- return this.dependenciesFacade.dataPersistence.remove('checkoutId');
1246
- }
1247
- resetCheckoutValues() {
1248
- return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutResetValues`, {
1249
- checkoutId: checkout.id,
1250
- })), concatMap(() => this.getCheckout()));
1251
- }
1252
- applyCouponDiscount(nickname, checkoutType) {
1253
- return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutApplyDiscount`, {
1254
- checkoutId: checkout.id,
1255
- coupon: nickname,
1256
- checkoutType,
1257
- })), concatMap(() => this.getCheckout()), map((checkout) => checkout.coupon));
1258
- }
1259
- removeCouponDiscount() {
1260
- return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemoveDiscount`, {
1261
- checkoutId: checkout.id,
1262
- })), concatMap(() => this.getCheckout()));
1263
- }
1264
- validateStockProducts() {
1265
- return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
1266
- checkoutId: checkout.id,
1267
- })));
1268
- }
1269
- selectShippingAddress(address) {
1270
- return this.getCheckout().pipe(concatMap((checkout) => {
1271
- return this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, shippingAddress: address, billingAddress: address }));
1272
- }));
1273
- }
1274
- getAvailableShippingForProduct(productShipping) {
1275
- return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
1276
- checkoutId: null,
1277
- productShipping,
1278
- });
1279
- }
1280
- getAvailableShippingForCheckout() {
1281
- return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
1282
- checkoutId: checkout.id,
1283
- productShipping: null,
1284
- })));
1285
- }
1286
- selectShipping(option) {
1287
- return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutSelectShipping`, {
1288
- checkoutId: checkout.id,
1289
- shippingOption: option,
1290
- })), concatMap(() => this.getCheckout()));
1291
- }
1292
- createOrder(checkoutPayload, paymentProvider, applicationVersion) {
1293
- return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutV5`, {
1294
- data: Object.assign(Object.assign({}, checkoutPayload), { applicationVersion,
1295
- paymentProvider }),
1296
- });
1297
- }
1298
- createCheckout(checkoutData) {
1299
- return __awaiter(this, void 0, void 0, function* () {
1300
- const checkout = yield this.repositoriesFacade.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.configurationFacade.defaultShop }));
1301
- yield this.dependenciesFacade.dataPersistence.set('checkoutId', checkout.id).toPromise();
1302
- return checkout;
1303
- });
1304
- }
1305
- }
1306
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CheckoutRepositoriesFacade }, { token: CheckoutDependenciesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
1307
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
1308
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
1309
- type: Injectable
1310
- }], ctorParameters: function () { return [{ type: CheckoutRepositoriesFacade }, { type: CheckoutDependenciesFacade }, { type: ConfigurationFacade }]; } });
1311
-
1312
- class CartServicesFacade {
1313
- constructor(authService, checkoutService, httpClient) {
1314
- this.authService = authService;
1315
- this.checkoutService = checkoutService;
1316
- this.httpClient = httpClient;
1317
- }
1318
- }
1319
- CartServicesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartServicesFacade, deps: [{ token: AuthService }, { token: CheckoutService }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1320
- CartServicesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartServicesFacade });
1321
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartServicesFacade, decorators: [{
1322
- type: Injectable
1323
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.HttpClient }]; } });
1324
-
1325
- class CartService {
1326
- constructor(servicesFacade, configurationFacade) {
1327
- this.servicesFacade = servicesFacade;
1328
- this.configurationFacade = configurationFacade;
1329
- this.cartSubject = new Subject();
1330
- this.checkoutUrl = null;
1331
- this.generateCartObject = (items) => (items === null || items === void 0 ? void 0 : items.reduce((cart, item) => {
1332
- var _a;
1333
- return (Object.assign(Object.assign({}, cart), { [item.id]: LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })) }));
1334
- }, {})) || {};
1335
- this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
1336
- }
1337
- addItem(item, quantity = 1) {
1338
- return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
1339
- checkoutId: checkout.id,
1340
- productId: item.id,
1341
- quantity,
1342
- })), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1343
- }
1344
- decreaseItem(item) {
1345
- return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutDecreaseProductFromCart`, {
1346
- checkoutId: checkout.id,
1347
- productId: item.id,
1348
- quantity: 1,
1349
- })), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1350
- }
1351
- removeItem(item) {
1352
- return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemoveProductFromCart`, {
1353
- checkoutId: checkout.id,
1354
- productId: item.id,
1355
- })), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1356
- }
1357
- updateUserCart(user) {
1358
- return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => {
1359
- return this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutUpdateUserCart`, {
1360
- checkoutId: checkout.id,
1361
- });
1362
- }), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => {
1363
- return this.generateCartObject(updatedCheckout.lineItems);
1364
- }), tap((cart) => this.cartSubject.next(cart)));
1365
- }
1366
- getCart(checkout) {
1367
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1368
- return this.cartSubject;
1369
- }
1370
- clearCart() {
1371
- return this.servicesFacade.checkoutService.getCheckout().pipe(map((checkout) => {
1372
- this.servicesFacade.checkoutService.clearCheckoutFromSession();
1373
- return checkout;
1374
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1375
- }
1376
- buildCartFromCheckout(checkoutData) {
1377
- return this.servicesFacade.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1378
- }
1379
- }
1380
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: CartServicesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
1381
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1382
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1383
- type: Injectable
1384
- }], ctorParameters: function () { return [{ type: CartServicesFacade }, { type: ConfigurationFacade }]; } });
1385
-
1386
- class NewCategoryStructureAdapter {
1387
- constructor(categoryRepository) {
1388
- this.categoryRepository = categoryRepository;
1389
- }
1390
- buildProductFilterByCategory(category) {
1391
- return __awaiter(this, void 0, void 0, function* () {
1392
- const loadedCategory = yield this.getCategory(category);
1393
- if (loadedCategory.isCollection)
1394
- return { id: { operator: Where.IN, value: loadedCategory.products } };
1395
- const categoryIds = [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1396
- return {
1397
- category: {
1398
- id: {
1399
- operator: Where.IN,
1400
- value: categoryIds,
1401
- },
1402
- },
1403
- };
1404
- });
1405
- }
1406
- getAllCategoriesIdFromCategory(category) {
1407
- return __awaiter(this, void 0, void 0, function* () {
1408
- return this.categoryRepository
1409
- .getChildren(+category.id)
1410
- .then((categories) => categories.map((category) => category.id.toString()));
1411
- });
1412
- }
1413
- getCategory(category) {
1414
- var _a;
1415
- return __awaiter(this, void 0, void 0, function* () {
1416
- const collectionCategory = category.isCollection ||
1417
- (isNil(category.isCollection) && !((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)) ||
1418
- category.isWishlist ||
1419
- category.brandCategory;
1420
- return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
1421
- });
1422
- }
1423
- }
1424
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1425
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1426
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1427
- type: Injectable
1428
- }], ctorParameters: function () {
1429
- return [{ type: undefined, decorators: [{
1430
- type: Inject,
1431
- args: ['CategoryRepository']
1432
- }] }];
1433
- } });
1434
-
1435
- class OldCategoryStructureAdapter {
1436
- constructor(categoryRepository) {
1437
- this.categoryRepository = categoryRepository;
1438
- }
1439
- buildProductFilterByCategory(category) {
1440
- var _a;
1441
- return __awaiter(this, void 0, void 0, function* () {
1442
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1443
- ? category.products
1444
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1445
- return { id: { operator: Where.IN, value: productsIds } };
1446
- });
1447
- }
1448
- }
1449
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1450
- OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1451
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1452
- type: Injectable
1453
- }], ctorParameters: function () {
1454
- return [{ type: undefined, decorators: [{
1455
- type: Inject,
1456
- args: ['CategoryRepository']
1457
- }] }];
1458
- } });
1459
-
1460
- class CatalogSearchContext {
1461
- constructor(categoryStrategy, termStrategy, profileStrategy) {
1462
- this.categoryStrategy = categoryStrategy;
1463
- this.termStrategy = termStrategy;
1464
- this.profileStrategy = profileStrategy;
1465
- this.strategies = new Map();
1466
- this.initializeStrategies();
1467
- }
1468
- executeSearch(params, shop, optionsCache) {
1469
- return __awaiter(this, void 0, void 0, function* () {
1470
- const strategy = this.selectStrategy(params);
1471
- return strategy.search(params, shop, optionsCache);
1472
- });
1473
- }
1474
- initializeStrategies() {
1475
- this.strategies.set('category', this.categoryStrategy);
1476
- this.strategies.set('term', this.termStrategy);
1477
- this.strategies.set('profile', this.profileStrategy);
1478
- }
1479
- selectStrategy(params) {
1480
- var _a;
1481
- if (params.category) {
1482
- const strategy = this.strategies.get('category');
1483
- if (!strategy)
1484
- throw new Error('Category strategy not found');
1485
- return strategy;
1486
- }
1487
- if (params.term) {
1488
- const strategy = this.strategies.get('term');
1489
- if (!strategy)
1490
- throw new Error('Term strategy not found');
1491
- return strategy;
1492
- }
1493
- if ((_a = params.profile) === null || _a === void 0 ? void 0 : _a.length) {
1494
- const strategy = this.strategies.get('profile');
1495
- if (!strategy)
1496
- throw new Error('Profile strategy not found');
1497
- return strategy;
1498
- }
1499
- throw new Error('No valid search strategy found for the given parameters');
1500
- }
1501
- }
1502
-
1503
- class CategorySearchStrategy {
1504
- constructor(repositoryService, helpersService) {
1505
- this.repositoryService = repositoryService;
1506
- this.helpersService = helpersService;
1507
- }
1508
- search(params, shop, optionsCache) {
1509
- return __awaiter(this, void 0, void 0, function* () {
1510
- const { category, filters, limits, sort, mainGender } = params;
1511
- if (!category) {
1512
- throw new Error('Category is required for CategorySearchStrategy');
1513
- }
1514
- const fields = this.helpersService.getFieldsHelper().getStandardFields();
1515
- if (sort === 'most-relevant') {
1516
- return this.searchWithMostRelevant({
1517
- category,
1518
- filters,
1519
- limits,
1520
- shop,
1521
- mainGender,
1522
- optionsCache,
1523
- fields,
1524
- });
1525
- }
1526
- return this.searchDefault({
1527
- category,
1528
- filters,
1529
- limits,
1530
- shop,
1531
- mainGender,
1532
- sort,
1533
- optionsCache,
1534
- fields,
1535
- });
1536
- });
1537
- }
1538
- searchWithMostRelevant(params) {
1539
- return __awaiter(this, void 0, void 0, function* () {
1540
- const { category, filters, shop, optionsCache } = params;
1541
- const mostRelevant = category.isWishlist ? [] : category.getMostRelevantByShop(shop);
1542
- const productsIds = yield this.getProductIds(category, filters, optionsCache);
1543
- return this.findAndSortByMostRelevant({
1544
- mostRelevants: mostRelevant,
1545
- productIds: productsIds,
1546
- filters: params.filters,
1547
- limits: params.limits,
1548
- shop: params.shop,
1549
- mainGender: params.mainGender,
1550
- optionsCache: params.optionsCache,
1551
- fields: params.fields,
1552
- });
1553
- });
1554
- }
1555
- searchDefault(params) {
1556
- return __awaiter(this, void 0, void 0, function* () {
1557
- const { category, filters, limits, sort, optionsCache, fields } = params;
1558
- const productCatalog = this.repositoryService.getProductCatalog();
1559
- const filterHelper = this.helpersService.getFilterHelper();
1560
- const sortHelper = this.helpersService.getSortHelper();
1561
- const repoParams = Object.assign(Object.assign({ fields, filters: Object.assign(Object.assign({}, (yield productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category))), filterHelper.buildFilterQuery(filters || {})) }, (sort ? { orderBy: sortHelper.buildSortQuery(sort) } : {})), { limits, options: {
1562
- minimal: ['price'],
1563
- maximum: ['price'],
1564
- distinct: ['brand'],
1565
- } });
1566
- return productCatalog.productRepository.findCatalog(repoParams, null, optionsCache);
1567
- });
1568
- }
1569
- getProductIds(category, filters, optionsCache) {
1570
- return __awaiter(this, void 0, void 0, function* () {
1571
- const productCatalog = this.repositoryService.getProductCatalog();
1572
- const filterHelper = this.helpersService.getFilterHelper();
1573
- return productCatalog.productRepository
1574
- .findCatalog({
1575
- fields: ['id'],
1576
- filters: Object.assign(Object.assign({}, (yield productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category))), filterHelper.buildFilterQuery(filters || {})),
1577
- }, undefined, optionsCache)
1578
- .then((products) => products.data.map((product) => product.id));
1579
- });
1580
- }
1581
- findAndSortByMostRelevant(params) {
1582
- return __awaiter(this, void 0, void 0, function* () {
1583
- const { mostRelevants, productIds, filters, shop, mainGender, optionsCache, fields, limits } = params;
1584
- const productCatalog = this.repositoryService.getProductCatalog();
1585
- const filterHelper = this.helpersService.getFilterHelper();
1586
- const sortHelper = this.helpersService.getSortHelper();
1587
- const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
1588
- const totalResult = yield productCatalog.productRepository.findCatalog({
1589
- fields,
1590
- filters: Object.assign({ id: { operator: Where.IN, value: mostRelevantProductsIds } }, filterHelper.buildFilterQuery(filters || {})),
1591
- orderBy: sortHelper.buildSortQuery('best-sellers'),
1592
- options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (isEmpty(filters === null || filters === void 0 ? void 0 : filters.brands) ? { distinct: ['brand'] } : {})),
1593
- }, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'), optionsCache);
1594
- return this.sortProductsByRelevance(totalResult, mostRelevants, limits);
1595
- });
1596
- }
1597
- sortProductsByRelevance(totalResult, mostRelevants, limits) {
1598
- const mostRelevantWithoutStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
1599
- const firstProducts = totalResult.data
1600
- .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
1601
- .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
1602
- const lastProducts = totalResult.data
1603
- .filter((product) => !mostRelevants.includes(product.id))
1604
- .concat(mostRelevantWithoutStock);
1605
- const categoryMostRelevants = firstProducts.concat(lastProducts);
1606
- const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
1607
- return {
1608
- data: resultFinal,
1609
- count: totalResult.count,
1610
- maximum: totalResult.maximum,
1611
- minimal: totalResult.minimal,
1612
- distinct: totalResult.distinct,
1613
- };
1614
- }
1615
- }
1616
- CategorySearchStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategorySearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable });
1617
- CategorySearchStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategorySearchStrategy });
1618
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategorySearchStrategy, decorators: [{
1619
- type: Injectable
1620
- }], ctorParameters: function () { return [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }]; } });
1621
-
1622
- class ProfileSearchStrategy {
1623
- constructor(repositoryService, helpersService) {
1624
- this.repositoryService = repositoryService;
1625
- this.helpersService = helpersService;
1626
- }
1627
- search(params, shop, optionsCache) {
1628
- return __awaiter(this, void 0, void 0, function* () {
1629
- const { profile, filters, limits, sort, mainGender } = params;
1630
- if (!profile) {
1631
- throw new Error('Profile is required for ProfileSearchStrategy');
1632
- }
1633
- const productCatalog = this.repositoryService.getProductCatalog();
1634
- const filterHelper = this.helpersService.getFilterHelper();
1635
- const sortHelper = this.helpersService.getSortHelper();
1636
- const fieldsHelper = this.helpersService.getFieldsHelper();
1637
- const repoParams = Object.assign(Object.assign({ fields: fieldsHelper.getStandardFields(), filters: Object.assign({ tagsProfile: { operator: Where.LIKE, value: profile } }, filterHelper.buildFilterQuery(filters || {})) }, (sort ? { orderBy: sortHelper.buildSortQuery(sort) } : {})), { limits, options: {
1638
- minimal: ['price'],
1639
- maximum: ['price'],
1640
- distinct: ['brand'],
1641
- } });
1642
- return productCatalog.productRepository.findCatalog(repoParams, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'), optionsCache);
1643
- });
1644
- }
1645
- }
1646
- ProfileSearchStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProfileSearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable });
1647
- ProfileSearchStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProfileSearchStrategy });
1648
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProfileSearchStrategy, decorators: [{
1649
- type: Injectable
1650
- }], ctorParameters: function () { return [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }]; } });
1651
-
1652
- class TermSearchStrategy {
1653
- constructor(repositoryService, helpersService) {
1654
- this.repositoryService = repositoryService;
1655
- this.helpersService = helpersService;
1656
- this.productsByTerm = {};
1657
- }
1658
- search(params, shop, _optionsCache) {
1659
- return __awaiter(this, void 0, void 0, function* () {
1660
- const { term, filters, limits, sort, mainGender } = params;
1661
- if (!term) {
1662
- throw new Error('Term is required for TermSearchStrategy');
1663
- }
1664
- const productIds = yield this.findCatalogIdsBySearch(term, shop);
1665
- if (sort === 'most-relevant') {
1666
- return this.searchWithMostRelevant({
1667
- productIds,
1668
- filters,
1669
- limits,
1670
- shop,
1671
- mainGender,
1672
- });
1673
- }
1674
- return this.searchDefault({
1675
- productIds,
1676
- filters,
1677
- limits,
1678
- shop,
1679
- mainGender,
1680
- fields: this.helpersService.getFieldsHelper().getStandardFields(),
1681
- });
1682
- });
1683
- }
1684
- searchWithMostRelevant(params) {
1685
- return __awaiter(this, void 0, void 0, function* () {
1686
- const { productIds, filters, shop, mainGender } = params;
1687
- const productCatalog = this.repositoryService.getProductCatalog();
1688
- const filterHelper = this.helpersService.getFilterHelper();
1689
- const totalResult = yield productCatalog.productRepository.findCatalog({
1690
- fields: ['id', 'stock', 'gender'],
1691
- filters: Object.assign({ id: { operator: Where.IN, value: productIds }, published: { operator: Where.EQUALS, value: true } }, filterHelper.buildFilterQuery(filters || {})),
1692
- options: Object.assign({ minimal: ['price'], maximum: ['price'] }, (isEmpty(filters === null || filters === void 0 ? void 0 : filters.brands) ? { distinct: ['brand'] } : {})),
1693
- });
1694
- return this.sortByTermRelevance({
1695
- productIds,
1696
- totalResult,
1697
- limits: params.limits,
1698
- filters,
1699
- fieldsHelper: this.helpersService.getFieldsHelper(),
1700
- });
1701
- });
1702
- }
1703
- searchDefault(params) {
1704
- return __awaiter(this, void 0, void 0, function* () {
1705
- const { productIds, filters, limits, shop, mainGender, fields } = params;
1706
- const productCatalog = this.repositoryService.getProductCatalog();
1707
- const filterHelper = this.helpersService.getFilterHelper();
1708
- return productCatalog.productRepository.findCatalog({
1709
- fields,
1710
- filters: Object.assign({ id: { operator: Where.IN, value: productIds }, published: { operator: Where.EQUALS, value: true } }, filterHelper.buildFilterQuery(filters || {})),
1711
- limits,
1712
- options: {
1713
- minimal: ['price'],
1714
- maximum: ['price'],
1715
- distinct: ['brand'],
1716
- },
1717
- });
1718
- });
1719
- }
1720
- sortByTermRelevance(params) {
1721
- const { productIds, totalResult, limits, filters, fieldsHelper } = params;
1722
- // const defaultGender = filters?.gender?.at(0) || 'male'
1723
- const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1724
- const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1725
- const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id === product));
1726
- const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id === product));
1727
- const limitedProductId = productIdsStock
1728
- .concat(productIdsStockOut)
1729
- .slice(limits.offset, limits.offset + limits.limit);
1730
- return this.getDetailedProducts(limitedProductId, totalResult, fieldsHelper);
1731
- }
1732
- getDetailedProducts(orderedId, totalResult, fieldsHelper) {
1733
- return __awaiter(this, void 0, void 0, function* () {
1734
- const productCatalog = this.repositoryService.getProductCatalog();
1735
- const fields = fieldsHelper.getStandardFields();
1736
- const productResult = yield productCatalog.productRepository.findCatalog({
1737
- filters: {
1738
- id: { operator: Where.IN, value: orderedId },
1739
- },
1740
- fields,
1741
- });
1742
- return {
1743
- data: orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1744
- count: totalResult.count,
1745
- maximum: totalResult.maximum,
1746
- minimal: totalResult.minimal,
1747
- distinct: totalResult.distinct,
1748
- };
1749
- });
1750
- }
1751
- findCatalogIdsBySearch(term, shop) {
1752
- return __awaiter(this, void 0, void 0, function* () {
1753
- if (this.productsByTerm[term])
1754
- return this.productsByTerm[term];
1755
- const productServices = this.repositoryService.getProductServices();
1756
- return (this.productsByTerm[term] = yield productServices.productSearch
1757
- .search(term, 999, shop === Shops.GLAMSHOP ? 'female' : 'male')
1758
- .then((products) => [...new Set(products.map((product) => product.id))]));
1759
- });
1760
- }
1761
- }
1762
- TermSearchStrategy.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: TermSearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable });
1763
- TermSearchStrategy.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: TermSearchStrategy });
1764
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: TermSearchStrategy, decorators: [{
1765
- type: Injectable
1766
- }], ctorParameters: function () { return [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }]; } });
1767
-
1768
- class CatalogStrategiesFacade {
1769
- constructor(categoryStrategy, termStrategy, profileStrategy) {
1770
- this.categoryStrategy = categoryStrategy;
1771
- this.termStrategy = termStrategy;
1772
- this.profileStrategy = profileStrategy;
1773
- }
1774
- }
1775
- CatalogStrategiesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogStrategiesFacade, deps: [{ token: CategorySearchStrategy }, { token: TermSearchStrategy }, { token: ProfileSearchStrategy }], target: i0.ɵɵFactoryTarget.Injectable });
1776
- CatalogStrategiesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogStrategiesFacade });
1777
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogStrategiesFacade, decorators: [{
1778
- type: Injectable
1779
- }], ctorParameters: function () { return [{ type: CategorySearchStrategy }, { type: TermSearchStrategy }, { type: ProfileSearchStrategy }]; } });
1780
-
1781
- class CatalogServiceFacade {
1782
- constructor(helpersService, strategiesFacade, shop) {
1783
- this.helpersService = helpersService;
1784
- this.strategiesFacade = strategiesFacade;
1785
- this.shop = shop;
1786
- const searchContext = new CatalogSearchContext(this.strategiesFacade.categoryStrategy, this.strategiesFacade.termStrategy, this.strategiesFacade.profileStrategy);
1787
- this.catalogService = new CatalogService(searchContext, this.helpersService, this.shop);
1788
- }
1789
- getCatalogService() {
1790
- return this.catalogService;
1791
- }
1792
- }
1793
- CatalogServiceFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogServiceFacade, deps: [{ token: CatalogHelpersService }, { token: CatalogStrategiesFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1794
- CatalogServiceFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogServiceFacade });
1795
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogServiceFacade, decorators: [{
1796
- type: Injectable
1797
- }], ctorParameters: function () {
1798
- return [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type: i3.Shops, decorators: [{
1799
- type: Inject,
1800
- args: [DEFAULT_SHOP]
1801
- }] }];
1802
- } });
1803
-
1804
- class CategoryRepositoryFacade {
1805
- constructor(categoryRepository, categoryFilterRepository) {
1806
- this.categoryRepository = categoryRepository;
1807
- this.categoryFilterRepository = categoryFilterRepository;
1808
- }
1809
- }
1810
- CategoryRepositoryFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryRepositoryFacade, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1811
- CategoryRepositoryFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryRepositoryFacade });
1812
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryRepositoryFacade, decorators: [{
1813
- type: Injectable
1814
- }], ctorParameters: function () {
1815
- return [{ type: undefined, decorators: [{
1816
- type: Inject,
1817
- args: ['CategoryRepository']
1818
- }] }, { type: undefined, decorators: [{
1819
- type: Inject,
1820
- args: ['CategoryFilterRepository']
1821
- }] }];
1822
- } });
1823
-
1824
- class CategoryService {
1825
- constructor(categoryFacade, productCatalog, shop) {
1826
- this.categoryFacade = categoryFacade;
1827
- this.productCatalog = productCatalog;
1828
- this.shop = shop;
1829
- }
1830
- fetchBrands(category, options, optionsCache) {
1831
- return __awaiter(this, void 0, void 0, function* () {
1832
- const brands = yield this.productCatalog.productRepository
1833
- .findCatalog({
1834
- filters: yield this.productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category),
1835
- fields: ['brand'],
1836
- }, null, optionsCache)
1837
- .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
1838
- return this.categoryFacade.categoryRepository
1839
- .find({ filters: { brandCategory: true, shop: (options === null || options === void 0 ? void 0 : options.shop) || this.shop }, orderBy: { name: 'asc' } }, optionsCache)
1840
- .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1841
- });
1842
- }
1843
- getMenuBrands() {
1844
- return __awaiter(this, void 0, void 0, function* () {
1845
- return this.categoryFacade.categoryRepository.getBrandsWithProducts();
1846
- });
1847
- }
1848
- fetchFilterOptions(category, optionsCache) {
1849
- return __awaiter(this, void 0, void 0, function* () {
1850
- return yield this.categoryFacade.categoryFilterRepository
1851
- .find({ filters: { categoryId: +category.id } }, optionsCache)
1852
- .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1853
- });
1854
- }
1855
- }
1856
- CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: CategoryRepositoryFacade }, { token: ProductCatalogFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1857
- CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1858
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1859
- type: Injectable
1860
- }], ctorParameters: function () {
1861
- return [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
1862
- type: Inject,
1863
- args: [DEFAULT_SHOP]
1864
- }] }];
1865
- } });
1866
-
1867
- class ProductCatalogFacade {
1868
- constructor(productRepository, categoryStructureAdapter) {
1869
- this.productRepository = productRepository;
1870
- this.categoryStructureAdapter = categoryStructureAdapter;
1871
- }
1872
- }
1873
- ProductCatalogFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductCatalogFacade, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }], target: i0.ɵɵFactoryTarget.Injectable });
1874
- ProductCatalogFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductCatalogFacade });
1875
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductCatalogFacade, decorators: [{
1876
- type: Injectable
1877
- }], ctorParameters: function () {
1878
- return [{ type: undefined, decorators: [{
1879
- type: Inject,
1880
- args: ['ProductRepository']
1881
- }] }, { type: undefined, decorators: [{
1882
- type: Inject,
1883
- args: [CATEGORY_STRUCTURE]
1884
- }] }];
1885
- } });
1886
-
1887
- class CategoryServiceFacade {
1888
- constructor(categoryRepositoryFacade, productCatalogFacade, shop) {
1889
- this.categoryRepositoryFacade = categoryRepositoryFacade;
1890
- this.productCatalogFacade = productCatalogFacade;
1891
- this.shop = shop;
1892
- this.categoryService = new CategoryService(this.categoryRepositoryFacade, this.productCatalogFacade, this.shop);
1893
- }
1894
- getCategoryService() {
1895
- return this.categoryService;
1896
- }
1897
- }
1898
- CategoryServiceFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryServiceFacade, deps: [{ token: CategoryRepositoryFacade }, { token: ProductCatalogFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1899
- CategoryServiceFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryServiceFacade });
1900
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryServiceFacade, decorators: [{
1901
- type: Injectable
1902
- }], ctorParameters: function () {
1903
- return [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
1904
- type: Inject,
1905
- args: [DEFAULT_SHOP]
1906
- }] }];
1907
- } });
1908
-
1909
- class BrandManagerHelper {
1910
- constructor(productCatalog) {
1911
- this.productCatalog = productCatalog;
1912
- this.brandsList = {};
1913
- }
1914
- setBrandsList(options, brands) {
1915
- var _a;
1916
- return __awaiter(this, void 0, void 0, function* () {
1917
- const filterBrands = (_a = options.filters) === null || _a === void 0 ? void 0 : _a.brands;
1918
- const indexKey = this.buildIndexBrands(options);
1919
- if (isEmpty(brands) && options.filters) {
1920
- delete options.filters.brands;
1921
- }
1922
- this.brandsList[indexKey] = this.brandsList[indexKey] || brands || (yield this.fetchBrandsOnly(options));
1923
- this.brandsList[indexKey] = this.brandsList[indexKey].filter(Boolean);
1924
- if (options.filters) {
1925
- options.filters = Object.assign(Object.assign({}, options.filters), { brands: filterBrands });
1926
- }
1927
- });
1928
- }
1929
- getBrandsList(indexKey) {
1930
- return this.brandsList[indexKey];
1931
- }
1932
- buildIndexBrands(options) {
1933
- if (options.category)
1934
- return `category-${options.category.id}`;
1935
- if (options.term)
1936
- return `term-${options.term}`;
1937
- if (options.profile)
1938
- return `profile-${options.profile.join(',')}`;
1939
- return '';
1940
- }
1941
- fetchBrandsOnly(options) {
1942
- return __awaiter(this, void 0, void 0, function* () {
1943
- return this.productCatalog.productRepository
1944
- .findCatalog({
1945
- fields: ['id'],
1946
- filters: {
1947
- published: { operator: Where.EQUALS, value: true },
1948
- },
1949
- options: {
1950
- distinct: ['brand'],
1951
- },
1952
- }, options.mainGender)
1953
- .then((result) => result.distinct.brand);
1954
- });
1955
- }
1956
- }
1957
- BrandManagerHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BrandManagerHelper, deps: [{ token: ProductCatalogFacade }], target: i0.ɵɵFactoryTarget.Injectable });
1958
- BrandManagerHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BrandManagerHelper });
1959
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: BrandManagerHelper, decorators: [{
1960
- type: Injectable
1961
- }], ctorParameters: function () { return [{ type: ProductCatalogFacade }]; } });
1962
-
1963
- class CatalogFilterHelper {
1964
- buildFilterQuery(filters) {
1965
- var _a, _b, _c, _d, _e, _f, _g;
1966
- const filterQuery = {};
1967
- if ((_a = filters.clubDiscount) === null || _a === void 0 ? void 0 : _a.length) {
1968
- set(filterQuery, 'price.subscriberDiscountPercentage', {
1969
- operator: Where.IN,
1970
- value: filters.clubDiscount,
1971
- });
1972
- }
1973
- if ((_b = filters.brands) === null || _b === void 0 ? void 0 : _b.length) {
1974
- filterQuery.brand = { operator: Where.IN, value: filters.brands };
1975
- }
1976
- if ((_c = filters.gender) === null || _c === void 0 ? void 0 : _c.length) {
1977
- filterQuery.gender = { operator: Where.IN, value: filters.gender };
1978
- }
1979
- if (((_d = filters.prices) === null || _d === void 0 ? void 0 : _d.min) || ((_e = filters.prices) === null || _e === void 0 ? void 0 : _e.max)) {
1980
- const priceField = filters.prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price';
1981
- const priceFilters = [
1982
- ...(filters.prices.min ? [{ operator: Where.GTE, value: Math.floor(filters.prices.min) }] : []),
1983
- ...(filters.prices.max ? [{ operator: Where.LTE, value: Math.ceil(filters.prices.max) }] : []),
1984
- ];
1985
- set(filterQuery, priceField, priceFilters);
1986
- }
1987
- if (filters.rate) {
1988
- filterQuery.rate = { operator: Where.GTE, value: filters.rate };
1989
- }
1990
- if ((_f = filters.tags) === null || _f === void 0 ? void 0 : _f.length) {
1991
- filterQuery.tagsProfile = { operator: Where.LIKE, value: filters.tags };
1992
- }
1993
- if ((_g = filters.customOptions) === null || _g === void 0 ? void 0 : _g.length) {
1994
- filterQuery.filters = { operator: Where.LIKE, value: filters.customOptions };
1995
- }
1996
- return filterQuery;
1997
- }
1998
- }
1999
- CatalogFilterHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogFilterHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2000
- CatalogFilterHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogFilterHelper });
2001
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogFilterHelper, decorators: [{
2002
- type: Injectable
2003
- }] });
2004
-
2005
- class CatalogSortHelper {
2006
- buildSortQuery(sort) {
2007
- if (!sort || sort === 'most-relevant')
2008
- return {};
2009
- switch (sort) {
2010
- case 'best-sellers':
2011
- return {
2012
- shoppingCount: 'desc',
2013
- rate: 'desc',
2014
- stock: 'desc',
2015
- name: 'asc',
2016
- };
2017
- case 'biggest-price':
2018
- return {
2019
- subscriberPrice: 'desc',
2020
- rate: 'desc',
2021
- shoppingCount: 'desc',
2022
- };
2023
- case 'lowest-price':
2024
- return {
2025
- subscriberPrice: 'asc',
2026
- rate: 'desc',
2027
- shoppingCount: 'desc',
2028
- };
2029
- case 'best-rating':
2030
- return {
2031
- rate: 'desc',
2032
- shoppingCount: 'desc',
2033
- stock: 'desc',
2034
- name: 'asc',
2035
- };
2036
- case 'news':
2037
- return { createdAt: 'desc' };
2038
- case 'biggest-discount':
2039
- return {
2040
- subscriberDiscountPercentage: 'desc',
2041
- rate: 'desc',
2042
- shoppingCount: 'desc',
2043
- };
2044
- default:
2045
- return {};
2046
- }
2047
- }
2048
- }
2049
- CatalogSortHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogSortHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2050
- CatalogSortHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogSortHelper });
2051
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogSortHelper, decorators: [{
2052
- type: Injectable
2053
- }] });
2054
-
2055
- class ProductFieldsHelper {
2056
- getStandardFields() {
2057
- return [
2058
- 'id',
2059
- 'name',
2060
- 'slug',
2061
- 'images',
2062
- 'miniatures',
2063
- 'price',
2064
- 'stock',
2065
- 'published',
2066
- 'CEST',
2067
- 'EAN',
2068
- 'NCM',
2069
- 'brand',
2070
- 'costPrice',
2071
- 'hasVariants',
2072
- 'isKit',
2073
- 'sku',
2074
- 'rate',
2075
- 'tagsProfile',
2076
- 'tagsCollection',
2077
- 'type',
2078
- 'shoppingCount',
2079
- 'gender',
2080
- 'createdAt',
2081
- 'label',
2082
- 'outlet',
2083
- 'group',
2084
- ];
2085
- }
2086
- }
2087
- ProductFieldsHelper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductFieldsHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2088
- ProductFieldsHelper.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductFieldsHelper });
2089
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductFieldsHelper, decorators: [{
2090
- type: Injectable
2091
- }] });
2092
-
2093
- class CatalogOperationsFacade {
2094
- constructor(filterHelper, sortHelper, fieldsHelper) {
2095
- this.filterHelper = filterHelper;
2096
- this.sortHelper = sortHelper;
2097
- this.fieldsHelper = fieldsHelper;
2098
- }
2099
- getFilterHelper() {
2100
- return this.filterHelper;
2101
- }
2102
- getSortHelper() {
2103
- return this.sortHelper;
2104
- }
2105
- getFieldsHelper() {
2106
- return this.fieldsHelper;
2107
- }
2108
- }
2109
- CatalogOperationsFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogOperationsFacade, deps: [{ token: CatalogFilterHelper }, { token: CatalogSortHelper }, { token: ProductFieldsHelper }], target: i0.ɵɵFactoryTarget.Injectable });
2110
- CatalogOperationsFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogOperationsFacade });
2111
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogOperationsFacade, decorators: [{
2112
- type: Injectable
2113
- }], ctorParameters: function () { return [{ type: CatalogFilterHelper }, { type: CatalogSortHelper }, { type: ProductFieldsHelper }]; } });
2114
-
2115
- class ProductManagementFacade {
2116
- constructor(brandManager, productServices) {
2117
- this.brandManager = brandManager;
2118
- this.productServices = productServices;
2119
- }
2120
- getBrandManager() {
2121
- return this.brandManager;
2122
- }
2123
- getProductServices() {
2124
- return this.productServices;
2125
- }
2126
- }
2127
- ProductManagementFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductManagementFacade, deps: [{ token: BrandManagerHelper }, { token: 'ProductServicesFacade' }], target: i0.ɵɵFactoryTarget.Injectable });
2128
- ProductManagementFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductManagementFacade });
2129
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ProductManagementFacade, decorators: [{
2130
- type: Injectable
2131
- }], ctorParameters: function () {
2132
- return [{ type: BrandManagerHelper }, { type: undefined, decorators: [{
2133
- type: Inject,
2134
- args: ['ProductServicesFacade']
2135
- }] }];
2136
- } });
2137
-
2138
- class CatalogHelpersService {
2139
- constructor(catalogOperations, productManagement) {
2140
- this.catalogOperations = catalogOperations;
2141
- this.productManagement = productManagement;
2142
- }
2143
- getFilterHelper() {
2144
- return this.catalogOperations.getFilterHelper();
2145
- }
2146
- getSortHelper() {
2147
- return this.catalogOperations.getSortHelper();
2148
- }
2149
- getFieldsHelper() {
2150
- return this.catalogOperations.getFieldsHelper();
2151
- }
2152
- getBrandManager() {
2153
- return this.productManagement.getBrandManager();
2154
- }
2155
- getProductServices() {
2156
- return this.productManagement.getProductServices();
2157
- }
2158
- }
2159
- CatalogHelpersService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogHelpersService, deps: [{ token: CatalogOperationsFacade }, { token: ProductManagementFacade }], target: i0.ɵɵFactoryTarget.Injectable });
2160
- CatalogHelpersService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogHelpersService });
2161
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogHelpersService, decorators: [{
2162
- type: Injectable
2163
- }], ctorParameters: function () { return [{ type: CatalogOperationsFacade }, { type: ProductManagementFacade }]; } });
2164
-
2165
- class CatalogRepositoryService {
2166
- constructor(productCatalog, productServices) {
2167
- this.productCatalog = productCatalog;
2168
- this.productServices = productServices;
2169
- }
2170
- getProductCatalog() {
2171
- return this.productCatalog;
2172
- }
2173
- getProductServices() {
2174
- return this.productServices;
2175
- }
2176
- }
2177
- CatalogRepositoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogRepositoryService, deps: [{ token: ProductCatalogFacade }, { token: 'ProductServicesFacade' }], target: i0.ɵɵFactoryTarget.Injectable });
2178
- CatalogRepositoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogRepositoryService });
2179
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogRepositoryService, decorators: [{
2180
- type: Injectable
2181
- }], ctorParameters: function () {
2182
- return [{ type: ProductCatalogFacade }, { type: undefined, decorators: [{
2183
- type: Inject,
2184
- args: ['ProductServicesFacade']
2185
- }] }];
2186
- } });
2187
-
2188
- class CatalogService {
2189
- constructor(searchContext, helpersService, shop) {
2190
- this.searchContext = searchContext;
2191
- this.helpersService = helpersService;
2192
- this.shop = shop;
2193
- }
2194
- fetchProducts(options, optionsCache) {
2195
- return __awaiter(this, void 0, void 0, function* () {
2196
- this.validateRequest(options);
2197
- const searchParams = this.buildSearchParams(options);
2198
- const { data, count: total, maximum, minimal, distinct, } = yield this.searchContext.executeSearch(searchParams, this.shop, optionsCache);
2199
- yield this.helpersService.getBrandManager().setBrandsList(searchParams, distinct === null || distinct === void 0 ? void 0 : distinct.brand);
2200
- return this.buildResponse({
2201
- data,
2202
- total,
2203
- maximum,
2204
- minimal,
2205
- searchParams,
2206
- options,
2207
- });
2208
- });
2209
- }
2210
- addCustomerToStockNotification(params) {
2211
- return __awaiter(this, void 0, void 0, function* () {
2212
- const { shop, productId, name, email } = params;
2213
- const productServices = this.helpersService.getProductServices();
2214
- return productServices.productStockNotificationRepository.addCustomerEmail({
2215
- shop,
2216
- productId,
2217
- name,
2218
- email,
2219
- });
2220
- });
2221
- }
2222
- validateRequest(options) {
2223
- var _a, _b, _c;
2224
- if (this.hasProfile(options) && ((_a = options.filters) === null || _a === void 0 ? void 0 : _a.customOptions)) {
2225
- throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
2226
- }
2227
- if (this.hasProfile(options) && ((_b = options.filters) === null || _b === void 0 ? void 0 : _b.tags)) {
2228
- throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
2229
- }
2230
- if (this.hasTerm(options) && ((_c = options.filters) === null || _c === void 0 ? void 0 : _c.customOptions)) {
2231
- throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
2232
- }
2233
- }
2234
- buildSearchParams(options) {
2235
- const limits = this.buildLimitQuery(options);
2236
- return {
2237
- category: this.hasCategory(options) ? options.category : undefined,
2238
- profile: this.hasProfile(options) ? options.profile : undefined,
2239
- term: this.hasTerm(options) ? options.term : undefined,
2240
- filters: options.filters,
2241
- mainGender: options.mainGender,
2242
- sort: options.sort,
2243
- limits,
2244
- };
2245
- }
2246
- buildResponse(params) {
2247
- var _a, _b, _c, _d, _e, _f, _g, _h;
2248
- const { data, total, maximum, minimal, searchParams } = params;
2249
- const limits = searchParams.limits;
2250
- const indexKey = this.helpersService.getBrandManager().buildIndexBrands(searchParams);
2251
- return {
2252
- products: {
2253
- data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)),
2254
- total,
2255
- },
2256
- pages: Math.ceil(total / limits.limit),
2257
- prices: {
2258
- price: {
2259
- min: +(((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)) || 0),
2260
- max: +(((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) || 0),
2261
- },
2262
- subscriberPrice: {
2263
- min: +(((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)) || 0),
2264
- max: +(((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)) || 0),
2265
- },
2266
- },
2267
- brands: this.helpersService.getBrandManager().getBrandsList(indexKey),
2268
- };
2269
- }
2270
- buildLimitQuery(options) {
2271
- const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
2272
- return {
2273
- limit,
2274
- offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
2275
- };
2276
- }
2277
- hasProfile(options) {
2278
- return 'profile' in options;
2279
- }
2280
- hasTerm(options) {
2281
- return 'term' in options;
2282
- }
2283
- hasCategory(options) {
2284
- return 'category' in options;
2285
- }
2286
- }
2287
- CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: CatalogSearchContext }, { token: CatalogHelpersService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
2288
- CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
2289
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
2290
- type: Injectable
2291
- }], ctorParameters: function () {
2292
- return [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type: i3.Shops, decorators: [{
2293
- type: Inject,
2294
- args: [DEFAULT_SHOP]
2295
- }] }];
2296
- } });
2297
-
2298
- var ProductSorts;
2299
- (function (ProductSorts) {
2300
- ProductSorts["MOST_RELEVANT"] = "most-relevant";
2301
- ProductSorts["BEST_SELLER"] = "best-sellers";
2302
- ProductSorts["BIGGEST_PRICE"] = "biggest-price";
2303
- ProductSorts["LOWEST_PRICE"] = "lowest-price";
2304
- ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
2305
- ProductSorts["BEST_RATING"] = "best-rating";
2306
- ProductSorts["NEWS"] = "news";
2307
- })(ProductSorts || (ProductSorts = {}));
2308
-
2309
- class CategoryWithTree extends Category {
2310
- }
2311
- __decorate([
2312
- Type(() => CategoryWithTree),
2313
- __metadata("design:type", Array)
2314
- ], CategoryWithTree.prototype, "children", void 0);
2315
-
2316
- class WishlistService {
2317
- constructor(wishlistRepository, productRepository, logRepository, shop) {
2318
- this.wishlistRepository = wishlistRepository;
2319
- this.productRepository = productRepository;
2320
- this.logRepository = logRepository;
2321
- this.shop = shop;
2322
- }
2323
- initializeServices(catalogServiceFacade, categoryServiceFacade) {
2324
- this.catalogService = catalogServiceFacade.getCatalogService();
2325
- this.categoryService = categoryServiceFacade.getCategoryService();
2326
- }
2327
- getCatalogService() {
2328
- return this.catalogService;
2329
- }
2330
- getCategoryService() {
2331
- return this.categoryService;
2332
- }
2333
- create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
2334
- return __awaiter(this, void 0, void 0, function* () {
2335
- const wishlistData = this.buildWishlistData({
2336
- title,
2337
- description,
2338
- published,
2339
- userFullName,
2340
- userPhoto,
2341
- theme,
2342
- bannerUrl,
2343
- personType,
2344
- personIsSubscriber,
2345
- personId,
2346
- });
2347
- const existingWishlist = yield this.findExistingWishlistByPersonId(personId);
2348
- yield this.createWishlistLog(WishlistLogType.CREATE, wishlistData);
2349
- if (existingWishlist)
2350
- return existingWishlist;
2351
- return this.createNewWishlist(wishlistData);
2352
- });
2353
- }
2354
- buildWishlistData({ title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, personId, }) {
2355
- return {
2356
- slug: '',
2357
- name: title,
2358
- description,
2359
- metadatas: [
2360
- {
2361
- shop: this.shop,
2362
- title: `${userFullName} - ${title}`,
2363
- description: `${userFullName} - ${description}`,
2364
- },
2365
- ],
2366
- shop: this.shop,
2367
- shops: [this.shop],
2368
- personId,
2369
- personName: userFullName,
2370
- personPhoto: userPhoto,
2371
- brandCategory: false,
2372
- published,
2373
- theme,
2374
- bannerUrl,
2375
- personType: personType !== null && personType !== void 0 ? personType : PersonTypes.NONE,
2376
- personIsSubscriber: personIsSubscriber !== null && personIsSubscriber !== void 0 ? personIsSubscriber : false,
2377
- };
2378
- }
2379
- findExistingWishlistByPersonId(personId) {
2380
- return __awaiter(this, void 0, void 0, function* () {
2381
- const hasWishlist = yield this.wishlistRepository
2382
- .find({
2383
- filters: {
2384
- personId,
2385
- },
2386
- options: {
2387
- enableCount: false,
2388
- },
2389
- orderBy: {
2390
- id: 'asc',
2391
- },
2392
- })
2393
- .then((res) => res.data);
2394
- return hasWishlist.length ? hasWishlist.at(0) : null;
2395
- });
2396
- }
2397
- createNewWishlist(data) {
2398
- return __awaiter(this, void 0, void 0, function* () {
2399
- const newWishlist = yield this.wishlistRepository.create(data);
2400
- yield this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
2401
- return Wishlist.toInstance(Object.assign(Object.assign({}, newWishlist.toPlain()), { slug: newWishlist.id }));
2402
- });
2403
- }
2404
- update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
2405
- return __awaiter(this, void 0, void 0, function* () {
2406
- const data = {
2407
- id,
2408
- name: title,
2409
- description,
2410
- published,
2411
- metadatas: [
2412
- {
2413
- shop: this.shop,
2414
- title: `${userFullName} - ${title}`,
2415
- description: `${userFullName} - ${description}`,
2416
- },
2417
- ],
2418
- personName: userFullName,
2419
- personPhoto: userPhoto,
2420
- theme,
2421
- bannerUrl,
2422
- personType: personType !== null && personType !== void 0 ? personType : PersonTypes.NONE,
2423
- personIsSubscriber: personIsSubscriber !== null && personIsSubscriber !== void 0 ? personIsSubscriber : false,
2424
- };
2425
- yield this.createWishlistLog(WishlistLogType.UPDATE, data);
2426
- return this.wishlistRepository.update(data);
2427
- });
2428
- }
2429
- delete(wishlistId) {
2430
- return __awaiter(this, void 0, void 0, function* () {
2431
- const wishlist = yield this.findById(wishlistId);
2432
- yield this.createWishlistLog(WishlistLogType.DELETE, wishlist);
2433
- return this.wishlistRepository.delete({ id: wishlistId });
2434
- });
2435
- }
2436
- getWishlistBySlug(slug) {
2437
- const [id] = slug.split('-');
2438
- if (+id)
2439
- return this.wishlistRepository.get({ id });
2440
- return this.wishlistRepository.getWishlistBySlug(slug);
2441
- }
2442
- getWishlistsByPerson(personId) {
2443
- return this.wishlistRepository.getWishlistByPerson(personId);
2444
- }
2445
- addProduct(wishlistId, productId) {
2446
- return __awaiter(this, void 0, void 0, function* () {
2447
- const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
2448
- const hasProduct = wishlist.products.some((p) => p == productId);
2449
- const wishlistData = yield this.findById(wishlistId);
2450
- const productData = yield this.findProductById(productId);
2451
- yield this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData);
2452
- if (!hasProduct) {
2453
- wishlist.products = [...wishlist.products, productId];
2454
- yield this.wishlistRepository.addProduct(wishlistId, productId);
2455
- }
2456
- return wishlist;
2457
- });
2458
- }
2459
- removeProduct(wishlistId, productId) {
2460
- return __awaiter(this, void 0, void 0, function* () {
2461
- const wishlist = yield this.wishlistRepository.get({ id: wishlistId });
2462
- const productIndex = wishlist.products.findIndex((p) => p == productId);
2463
- if (productIndex != -1) {
2464
- wishlist.products.splice(productIndex, 1);
2465
- const wishlistData = yield this.findById(wishlistId);
2466
- const productData = yield this.findProductById(productId);
2467
- yield this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData);
2468
- yield this.wishlistRepository.removeProduct(wishlistId, productId);
2469
- }
2470
- return wishlist;
2471
- });
2472
- }
2473
- findById(id) {
2474
- return __awaiter(this, void 0, void 0, function* () {
2475
- return this.wishlistRepository
2476
- .find({
2477
- fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
2478
- filters: {
2479
- id,
2480
- },
2481
- })
2482
- .then((res) => res.data.at(0));
2483
- });
2484
- }
2485
- findProductById(id) {
2486
- return __awaiter(this, void 0, void 0, function* () {
2487
- return this.productRepository
2488
- .find({
2489
- fields: ['id', 'sku', 'EAN', 'name', 'brand'],
2490
- filters: {
2491
- id,
2492
- },
2493
- })
2494
- .then((res) => res.data.at(0));
2495
- });
2496
- }
2497
- createWishlistLog(type, wishlist, product) {
2498
- return __awaiter(this, void 0, void 0, function* () {
2499
- switch (type) {
2500
- case WishlistLogType.CREATE:
2501
- case WishlistLogType.UPDATE:
2502
- case WishlistLogType.DELETE:
2503
- yield this.createWishlistOperationLog(type, wishlist);
2504
- break;
2505
- case WishlistLogType.ADD_PRODUCT:
2506
- case WishlistLogType.REMOVE_PRODUCT:
2507
- yield this.createWishlistProductLog(type, wishlist, product);
2508
- break;
2509
- default:
2510
- break;
2511
- }
2512
- });
2513
- }
2514
- createWishlistOperationLog(type, wishlist) {
2515
- return __awaiter(this, void 0, void 0, function* () {
2516
- const operation = this.getOperationTypeFromWishlistLogType(type);
2517
- yield this.logRepository.create({
2518
- collection: 'wishlist',
2519
- date: new Date(),
2520
- operation,
2521
- documentId: wishlist.id,
2522
- document: this.buildWishlistLogDocument(wishlist, type),
2523
- });
2524
- });
2525
- }
2526
- createWishlistProductLog(type, wishlist, product) {
2527
- return __awaiter(this, void 0, void 0, function* () {
2528
- yield this.logRepository.create({
2529
- collection: 'wishlist',
2530
- date: new Date(),
2531
- operation: 'UPDATE',
2532
- documentId: wishlist.id,
2533
- document: Object.assign(Object.assign({}, this.buildWishlistLogDocument(wishlist, type)), this.buildProductLogData(product)),
2534
- });
2535
- });
2536
- }
2537
- getOperationTypeFromWishlistLogType(type) {
2538
- if (type === WishlistLogType.CREATE)
2539
- return 'CREATE';
2540
- if (type === WishlistLogType.UPDATE)
2541
- return 'UPDATE';
2542
- return 'DELETE';
2543
- }
2544
- buildWishlistLogDocument(wishlist, type) {
2545
- return {
2546
- id: wishlist.id,
2547
- shop: this.shop,
2548
- name: wishlist.name,
2549
- description: wishlist.description,
2550
- published: wishlist.published,
2551
- type: type,
2552
- personType: wishlist.personType,
2553
- personId: wishlist.personId,
2554
- personName: wishlist.personName,
2555
- personIsSubscriber: wishlist.personIsSubscriber,
2556
- };
2557
- }
2558
- buildProductLogData(product) {
2559
- return {
2560
- productId: product.id,
2561
- productEAN: product.EAN,
2562
- productSKU: product.sku,
2563
- productName: product.name,
2564
- productBrand: product.brand,
2565
- };
2566
- }
2567
- }
2568
- WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: 'ProductRepository' }, { token: 'LogRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
2569
- WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
2570
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
2571
- type: Injectable
2572
- }], ctorParameters: function () {
2573
- return [{ type: undefined, decorators: [{
2574
- type: Inject,
2575
- args: ['WishlistRepository']
2576
- }] }, { type: undefined, decorators: [{
2577
- type: Inject,
2578
- args: ['ProductRepository']
2579
- }] }, { type: undefined, decorators: [{
2580
- type: Inject,
2581
- args: ['LogRepository']
2582
- }] }, { type: i3.Shops, decorators: [{
2583
- type: Inject,
2584
- args: [DEFAULT_SHOP]
2585
- }] }];
2586
- } });
2587
-
2588
- class CouponRepositoriesFacade {
2589
- constructor(couponRepository, orderRepository, categoryRepository) {
2590
- this.couponRepository = couponRepository;
2591
- this.orderRepository = orderRepository;
2592
- this.categoryRepository = categoryRepository;
2593
- }
2594
- }
2595
- CouponRepositoriesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponRepositoriesFacade, deps: [{ token: 'CouponRepository' }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
2596
- CouponRepositoriesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponRepositoriesFacade });
2597
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
2598
- type: Injectable
2599
- }], ctorParameters: function () {
2600
- return [{ type: undefined, decorators: [{
2601
- type: Inject,
2602
- args: ['CouponRepository']
2603
- }] }, { type: undefined, decorators: [{
2604
- type: Inject,
2605
- args: ['OrderRepository']
2606
- }] }, { type: undefined, decorators: [{
2607
- type: Inject,
2608
- args: ['CategoryRepository']
2609
- }] }];
2610
- } });
2611
-
2612
- class CouponService {
2613
- constructor(repositoriesFacade, configurationFacade) {
2614
- this.repositoriesFacade = repositoriesFacade;
2615
- this.configurationFacade = configurationFacade;
2616
- this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
2617
- }
2618
- checkCoupon(params) {
2619
- const { nickname, checkoutType, checkout, plan } = params;
2620
- return from(this.repositoriesFacade.couponRepository
2621
- .find({
2622
- filters: {
2623
- nickname: { operator: Where.EQUALS, value: nickname },
2624
- active: { operator: Where.EQUALS, value: true },
2625
- },
2626
- })
2627
- .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation({ coupon: couponValid, checkoutType, checkout, plan })), map((couponValidated) => couponValidated));
2628
- }
2629
- couponValidation(coupon, checkoutType) {
2630
- return __awaiter(this, void 0, void 0, function* () {
2631
- if (!coupon)
2632
- throw 'Cupom inválido.';
2633
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
2634
- throw 'Cupom inválido.';
2635
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn).getTime() < new Date().getTime())
2636
- throw 'Cupom expirado.';
2637
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.configurationFacade.defaultShop;
2638
- if (!isInShop)
2639
- throw 'Cupom inválido para loja.';
2640
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
2641
- if (!isCheckoutType)
2642
- throw 'Cupom inválido. Erro de checkout.';
2643
- return coupon;
2644
- });
2645
- }
2646
- couponRulesValidation(params) {
2647
- return __awaiter(this, void 0, void 0, function* () {
2648
- const { coupon, checkoutType, checkout, plan } = params;
2649
- if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
2650
- return this.validateSubscriptionCoupon(coupon, plan);
2651
- }
2652
- return this.validateEcommerceCoupon(coupon, checkoutType, checkout);
2653
- });
2654
- }
2655
- validateSubscriptionCoupon(coupon, plan) {
2656
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase()) {
2657
- throw 'Cupom inválido para sua assinatura.';
2658
- }
2659
- return coupon;
2660
- }
2661
- validateEcommerceCoupon(coupon, checkoutType, checkout) {
2662
- return __awaiter(this, void 0, void 0, function* () {
2663
- this.validateUserEligibility(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
2664
- yield this.validateUsageLimits(coupon, checkoutType, checkout);
2665
- yield this.validateProductEligibility(coupon, checkout);
2666
- return coupon;
2667
- });
2668
- }
2669
- validateUserEligibility(coupon, user) {
2670
- const validUser = this.coupomUserValidation(coupon, user);
2671
- if (!validUser)
2672
- throw 'Usuário não elegível.';
2673
- }
2674
- validateUsageLimits(coupon, checkoutType, checkout) {
2675
- return __awaiter(this, void 0, void 0, function* () {
2676
- const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
2677
- if (couponUseLimits.firstOrder) {
2678
- yield this.validateFirstOrderLimit(checkout.user.email);
2679
- }
2680
- if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
2681
- yield this.validateCouponUsageLimits(coupon, couponUseLimits, checkout.user.email);
2682
- }
2683
- });
2684
- }
2685
- validateFirstOrderLimit(userEmail) {
2686
- return __awaiter(this, void 0, void 0, function* () {
2687
- const ordersUser = yield this.getOrdersFromUser(userEmail.toLocaleLowerCase());
2688
- if (ordersUser.length >= 1)
2689
- throw 'Limite de uso atingido';
2690
- });
2691
- }
2692
- validateCouponUsageLimits(coupon, couponUseLimits, userEmail) {
2693
- return __awaiter(this, void 0, void 0, function* () {
2694
- const ordersCoupon = yield this.getOrdersWithCoupon(coupon);
2695
- if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total) {
2696
- throw 'Limite de uso atingido.';
2697
- }
2698
- if (couponUseLimits.limitedPerUser) {
2699
- const ordersWithUser = this.countOrdersWithUser(ordersCoupon, userEmail);
2700
- if (ordersWithUser > 0)
2701
- throw 'Limite de uso por usuário atingido.';
2702
- }
2703
- });
2704
- }
2705
- validateProductEligibility(coupon, checkout) {
2706
- return __awaiter(this, void 0, void 0, function* () {
2707
- const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
2708
- if (!hasProductCategories)
2709
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
2710
- const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
2711
- if (!hasMinSubTotal) {
2712
- this.throwMinSubTotalError(coupon);
2713
- }
2714
- });
2715
- }
2716
- throwMinSubTotalError(coupon) {
2717
- var _a;
2718
- const formattedValue = Intl.NumberFormat('pt-BR', {
2719
- style: 'currency',
2720
- currency: 'BRL',
2721
- }).format(coupon.minSubTotalValue);
2722
- if ((_a = coupon.productsCategories) === null || _a === void 0 ? void 0 : _a.length) {
2723
- throw `Valor mínimo de ${formattedValue} não atingido na(s) categoria(s) elegíveis para o desconto.`;
2724
- }
2725
- throw `Valor mínimo de ${formattedValue} não atingido.`;
2726
- }
2727
- calcDiscountSubscription(coupon, checkout) {
2728
- let discount = 0;
2729
- if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
2730
- discount = coupon.discount.subscription.value;
2731
- else
2732
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
2733
- return of(discount);
2734
- }
2735
- hasMinSubTotal(coupon, checkout) {
2736
- return __awaiter(this, void 0, void 0, function* () {
2737
- if (!coupon.minSubTotalValue)
2738
- return true;
2739
- const lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
2740
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
2741
- if (coupon.minSubTotalValue <= subTotal)
2742
- return true;
2743
- return false;
2744
- });
2745
- }
2746
- hasProductCategories(coupon, checkout) {
2747
- var _a, _b;
2748
- return __awaiter(this, void 0, void 0, function* () {
2749
- if (!((_a = coupon.productsCategories) === null || _a === void 0 ? void 0 : _a.length)) {
2750
- return true;
2751
- }
2752
- const couponCategories = yield this.getCouponCategoriesId(coupon.productsCategories);
2753
- const hasCategories = (_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.filter((item) => {
2754
- var _a;
2755
- if (item.isGift)
2756
- return false;
2757
- if (!((_a = item.categories) === null || _a === void 0 ? void 0 : _a.length))
2758
- return true;
2759
- return item.categories.some((c) => couponCategories.some((cat) => cat == c));
2760
- });
2761
- return (hasCategories === null || hasCategories === void 0 ? void 0 : hasCategories.length) ? true : false;
2762
- });
2763
- }
2764
- coupomUserValidation(coupon, user) {
2765
- if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
2766
- return true;
2767
- const userTypes = [];
2768
- if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
2769
- this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
2770
- userTypes.push(Exclusivities.COLLABORATORS);
2771
- if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
2772
- coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
2773
- userTypes.push(Exclusivities.SPECIFIC_USER);
2774
- if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
2775
- user.isSubscriber &&
2776
- user.subscriptionPlan != '')
2777
- userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
2778
- if (user.isSubscriber &&
2779
- user.subscriptionPlan == '' &&
2780
- coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
2781
- userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
2782
- if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
2783
- userTypes.push(Exclusivities.NON_SUBSCRIBER);
2784
- return coupon.exclusivityType.some((r) => userTypes.includes(r));
2785
- }
2786
- getCouponCategoriesId(productsCategories) {
2787
- return __awaiter(this, void 0, void 0, function* () {
2788
- const couponCategories = [];
2789
- for (let index = 0; index < productsCategories.length; index++) {
2790
- const category = yield this.repositoriesFacade.categoryRepository.get({
2791
- id: productsCategories[index],
2792
- });
2793
- if (category) {
2794
- const children = yield this.repositoriesFacade.categoryRepository.getChildren(parseInt(productsCategories[index]));
2795
- couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
2796
- }
2797
- }
2798
- return [...new Set(couponCategories)];
2799
- });
2800
- }
2801
- getLineItensEligebleForDiscount(productsCategories, checkout) {
2802
- var _a;
2803
- return __awaiter(this, void 0, void 0, function* () {
2804
- let lineItensDiscount = [];
2805
- const couponCategories = yield this.getCouponCategoriesId(productsCategories);
2806
- if (productsCategories === null || productsCategories === void 0 ? void 0 : productsCategories.length) {
2807
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((item) => {
2808
- var _a;
2809
- if (item.isGift)
2810
- return false;
2811
- if ((_a = item.categories) === null || _a === void 0 ? void 0 : _a.length) {
2812
- return item.categories.some((c) => couponCategories.some((cat) => cat == c));
2813
- }
2814
- return true;
2815
- });
2816
- }
2817
- else {
2818
- lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
2819
- }
2820
- return lineItensDiscount;
2821
- });
2822
- }
2823
- calcCheckoutSubtotal(lineItens, user) {
2824
- return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.filter((item) => !item.isGift).reduce((acc, curr) => {
2825
- var _a, _b;
2826
- return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
2827
- ? acc + ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
2828
- : acc + curr.pricePaid * curr.quantity;
2829
- }, 0)) || 0);
2830
- }
2831
- getOrdersWithCoupon(coupon) {
2832
- return __awaiter(this, void 0, void 0, function* () {
2833
- return yield this.repositoriesFacade.orderRepository
2834
- .find({
2835
- filters: {
2836
- coupon: { id: coupon.id },
2837
- status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
2838
- },
2839
- })
2840
- .then((result) => result.data);
2841
- });
2842
- }
2843
- getOrdersFromUser(email) {
2844
- return __awaiter(this, void 0, void 0, function* () {
2845
- return yield this.repositoriesFacade.orderRepository
2846
- .find({
2847
- filters: {
2848
- user: { email: { operator: Where.EQUALS, value: email } },
2849
- status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
2850
- },
2851
- })
2852
- .then((result) => result.data);
2853
- });
2854
- }
2855
- countOrdersWithUser(orders, email) {
2856
- return orders.filter((o) => o.user.email == email).length;
2857
- }
2858
- getCouponUseLimits(coupon, checkoutType, user) {
2859
- let couponUseLimits;
2860
- if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
2861
- if (coupon.exclusivityType.length === 1 &&
2862
- (coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
2863
- coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
2864
- couponUseLimits = coupon.useLimits.non_subscriber;
2865
- else
2866
- couponUseLimits = (user === null || user === void 0 ? void 0 : user.isSubscriber) ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
2867
- }
2868
- else {
2869
- couponUseLimits = coupon.useLimits.subscription;
2870
- }
2871
- return couponUseLimits;
2872
- }
2873
- }
2874
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: CouponRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
2875
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
2876
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
2877
- type: Injectable,
2878
- args: [{
2879
- providedIn: 'root',
2880
- }]
2881
- }], ctorParameters: function () { return [{ type: CouponRepositoriesFacade }, { type: ConfigurationFacade }]; } });
2882
-
2883
- class CheckoutSubscriptionService {
2884
- constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
2885
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
2886
- this.dataPersistence = dataPersistence;
2887
- this.couponService = couponService;
2888
- }
2889
- getCheckoutSubscription(checkoutData) {
2890
- return this.dataPersistence
2891
- .get('checkoutSubscriptionId')
2892
- .pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
2893
- }
2894
- clearCheckoutSubscriptionFromSession() {
2895
- return this.dataPersistence.remove('checkoutSubscriptionId');
2896
- }
2897
- checkCoupon(nickname, _userEmail) {
2898
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
2899
- .checkCoupon({
2900
- nickname,
2901
- checkoutType: CheckoutTypes.SUBSCRIPTION,
2902
- checkout,
2903
- plan: checkout.subscriptionPlan.name,
2904
- })
2905
- .pipe()));
2906
- }
2907
- calcDiscountSubscription(coupon) {
2908
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
2909
- }
2910
- createCheckoutSubscription(checkoutData) {
2911
- return __awaiter(this, void 0, void 0, function* () {
2912
- const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
2913
- yield this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
2914
- return checkout;
2915
- });
2916
- }
2917
- }
2918
- CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
2919
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
2920
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
2921
- type: Injectable
2922
- }], ctorParameters: function () {
2923
- return [{ type: undefined, decorators: [{
2924
- type: Inject,
2925
- args: ['CheckoutSubscriptionRepository']
2926
- }] }, { type: undefined, decorators: [{
2927
- type: Inject,
2928
- args: [PERSISTENCE_PROVIDER]
2929
- }] }, { type: CouponService }];
2930
- } });
2931
-
2932
- class UtilHelper {
2933
- static createSlug(name) {
2934
- return name
2935
- .toLowerCase()
2936
- .replace(/\s+/g, '-')
2937
- .replace(/[ãàáäâ]/g, 'a')
2938
- .replace(/[ẽèéëê]/g, 'e')
2939
- .replace(/[ìíïî]/g, 'i')
2940
- .replace(/[õòóöô]/g, 'o')
2941
- .replace(/[ùúüû]/g, 'u')
2942
- .replace(/[ñ]/g, 'n')
2943
- .replace(/[ç]/g, 'c')
2944
- .replace(/[&]/g, 'and')
2945
- .replace(/[^\w-]+/g, '')
2946
- .replace(/--+/g, '-');
2947
- }
2948
- }
2949
-
2950
- class HomeShopRepositoriesFacade {
2951
- constructor(categoryRepository, homeRepository, productRepository) {
2952
- this.categoryRepository = categoryRepository;
2953
- this.homeRepository = homeRepository;
2954
- this.productRepository = productRepository;
2955
- }
2956
- }
2957
- HomeShopRepositoriesFacade.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopRepositoriesFacade, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
2958
- HomeShopRepositoriesFacade.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopRepositoriesFacade });
2959
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopRepositoriesFacade, decorators: [{
2960
- type: Injectable
2961
- }], ctorParameters: function () {
2962
- return [{ type: undefined, decorators: [{
2963
- type: Inject,
2964
- args: ['CategoryRepository']
2965
- }] }, { type: undefined, decorators: [{
2966
- type: Inject,
2967
- args: ['HomeRepository']
2968
- }] }, { type: undefined, decorators: [{
2969
- type: Inject,
2970
- args: ['ProductRepository']
2971
- }] }];
2972
- } });
2973
-
2974
- class HomeShopService {
2975
- get homeId() {
2976
- if (this.configurationFacade.defaultShop === Shops.GLAMSHOP)
2977
- return 'glamshop';
2978
- if (this.configurationFacade.defaultShop === Shops.MENSMARKET)
2979
- return 'mens_market';
2980
- return null;
2981
- }
2982
- constructor(repositoriesFacade, configurationFacade) {
2983
- this.repositoriesFacade = repositoriesFacade;
2984
- this.configurationFacade = configurationFacade;
2985
- this.buildCategoryGroupWithRequiredData = (group) => {
2986
- var _a, _b;
2987
- return ({
2988
- category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
2989
- products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
2990
- 'id',
2991
- 'price',
2992
- 'reviews',
2993
- 'hasVariants',
2994
- 'slug',
2995
- 'sku',
2996
- 'stock',
2997
- 'costPrice',
2998
- 'images',
2999
- 'miniatures',
3000
- 'name',
3001
- 'weight',
3002
- 'rate',
3003
- 'type',
3004
- 'brand',
3005
- ])))) || [],
3006
- });
3007
- };
3008
- }
3009
- getHomeData() {
3010
- return this.getHomeConfiguration().pipe(map((home) => { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), concatMap((home) => home
3011
- ? of(home)
3012
- : forkJoin([
3013
- this.getDiscoverProducts(this.gender),
3014
- this.getFeaturedProducts(this.gender),
3015
- this.getVerticalProducts(this.gender),
3016
- ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
3017
- discoverProducts,
3018
- featuredProducts,
3019
- verticalProducts,
3020
- })), concatMap((data) => this.saveHomeData(data)))));
3021
- }
3022
- getBanners(type) {
3023
- return this.getHomeConfiguration().pipe(map((home) => {
3024
- if (type === 'brand')
3025
- return home.brandsCarousel;
3026
- if (type === 'buyToWin')
3027
- return [home.buyToWinBanner];
3028
- if (type === 'block')
3029
- return home.blockBanners;
3030
- if (type === 'blog')
3031
- return [home.blogBanner];
3032
- return [];
3033
- }));
3034
- }
3035
- getMinValueForFreeShipping() {
3036
- return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
3037
- }
3038
- getDiscoverProducts(_gender) {
3039
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
3040
- categoryIds: home.discoverCategories,
3041
- shop: this.configurationFacade.defaultShop,
3042
- })).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
3043
- }
3044
- getFeaturedProducts(_gender) {
3045
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
3046
- categoryIds: home.featuredCategories,
3047
- shop: this.configurationFacade.defaultShop,
3048
- })).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
3049
- }
3050
- getVerticalProducts(gender) {
3051
- return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.repositoriesFacade.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.repositoriesFacade.productRepository.find({
3052
- filters: Object.assign({ categories: { operator: Where.IN, value: [category.id] } }, (gender ? { tags: { operator: Where.IN, value: [gender] } } : {})),
3053
- limits: { limit: 12 },
3054
- })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
3055
- }
3056
- getHomeConfiguration() {
3057
- return of(this.homeConfiguration).pipe(concatMap((home) => home
3058
- ? of(home)
3059
- : !this.homeId
3060
- ? throwError(() => new RequiredArgumentError(['homeId']))
3061
- : from(this.repositoriesFacade.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
3062
- }
3063
- saveHomeData(homeData) {
3064
- const data = {
3065
- createdAt: new Date(),
3066
- expiresAt: add(new Date(), { hours: 1 }),
3067
- data: homeData,
3068
- };
3069
- return from(this.repositoriesFacade.homeRepository.update({
3070
- id: this.homeId,
3071
- data,
3072
- })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
3073
- }
3074
- get gender() {
3075
- return this.homeId === 'mens_market' ? 'masculino' : undefined;
3076
- }
3077
- }
3078
- HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: HomeShopRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable });
3079
- HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
3080
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
3081
- type: Injectable
3082
- }], ctorParameters: function () { return [{ type: HomeShopRepositoriesFacade }, { type: ConfigurationFacade }]; } });
3083
-
3084
- class OrderProductReviewService {
3085
- constructor(orderRepository, productReviewRepository, variantRepository) {
3086
- this.orderRepository = orderRepository;
3087
- this.productReviewRepository = productReviewRepository;
3088
- this.variantRepository = variantRepository;
3089
- }
3090
- getPendingReviewsByEmail(email) {
3091
- return __awaiter(this, void 0, void 0, function* () {
3092
- const products = [];
3093
- const orders = yield this.getOrdersByEmail(email);
3094
- if (orders.length) {
3095
- for (const order of orders) {
3096
- const lineItems = order.lineItems.filter((item) => !item.isGift);
3097
- for (const item of lineItems) {
3098
- const productReview = yield this.getProductReview(order, item);
3099
- if ((productReview === null || productReview === void 0 ? void 0 : productReview.status) != null)
3100
- continue;
3101
- products.push(this.buildProductReview(order, item, productReview));
3102
- }
3103
- }
3104
- }
3105
- return products;
3106
- });
3107
- }
3108
- getOrdersByEmail(email) {
3109
- return __awaiter(this, void 0, void 0, function* () {
3110
- const { data: orders } = yield this.orderRepository.find({
3111
- filters: {
3112
- user: {
3113
- email: email,
3114
- },
3115
- status: OrderStatus.ENTREGUE,
3116
- createdAt: {
3117
- operator: Where.GTE,
3118
- value: new Date(2024, 0, 0, 0, 0, 0).getTime(),
3119
- },
3120
- },
3121
- orderBy: {
3122
- createdAt: 'desc',
3123
- },
3124
- });
3125
- return orders;
3126
- });
3127
- }
3128
- getProductReview(order, item) {
3129
- return __awaiter(this, void 0, void 0, function* () {
3130
- const products = [item.id];
3131
- const isVariant = yield this.variantRepository
3132
- .find({
3133
- filters: {
3134
- id: item.id,
3135
- },
3136
- })
3137
- .then((res) => res.data.at(0));
3138
- if (isVariant)
3139
- products.push(isVariant.productId);
3140
- const productReview = yield this.productReviewRepository
3141
- .find({
3142
- filters: {
3143
- orderId: { operator: Where.IN, value: [order.id, order.orderNumber].filter(Boolean) },
3144
- productId: { operator: Where.IN, value: products },
3145
- },
3146
- })
3147
- .then((res) => res.data.at(0));
3148
- return productReview;
3149
- });
3150
- }
3151
- buildProductReview(order, item, review) {
3152
- return {
3153
- id: item.id,
3154
- orderId: order.id,
3155
- orderNumber: order.orderNumber,
3156
- isEdition: false,
3157
- name: item.name,
3158
- image: item.image,
3159
- deliveryDate: order.deliveredAt || null,
3160
- evaluationInAnalysis: review ? true : false,
3161
- rating: review ? review.rate : null,
3162
- shopProductSlug: item.slug,
3163
- };
3164
- }
3165
- createReview(review) {
3166
- return __awaiter(this, void 0, void 0, function* () {
3167
- return this.productReviewRepository.create(ProductReview.toInstance({
3168
- productId: review.productId.toString(),
3169
- shop: review.shop,
3170
- rate: review.rate,
3171
- author: review.author,
3172
- email: review.email,
3173
- location: review.location,
3174
- review: review.comment,
3175
- title: review.title,
3176
- personId: review.personId,
3177
- points: review.points,
3178
- orderId: review.orderId,
3179
- }));
3180
- });
3181
- }
3182
- }
3183
- OrderProductReviewService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderProductReviewService, deps: [{ token: 'OrderRepository' }, { token: 'ProductReviewRepository' }, { token: 'VariantRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
3184
- OrderProductReviewService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderProductReviewService });
3185
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderProductReviewService, decorators: [{
3186
- type: Injectable
3187
- }], ctorParameters: function () {
3188
- return [{ type: i3.OrderFirestoreRepository, decorators: [{
3189
- type: Inject,
3190
- args: ['OrderRepository']
3191
- }] }, { type: undefined, decorators: [{
3192
- type: Inject,
3193
- args: ['ProductReviewRepository']
3194
- }] }, { type: undefined, decorators: [{
3195
- type: Inject,
3196
- args: ['VariantRepository']
3197
- }] }];
3198
- } });
3199
-
3200
- class OrderService {
3201
- constructor(angularFirestore, orderRepository) {
3202
- this.angularFirestore = angularFirestore;
3203
- this.orderRepository = orderRepository;
3204
- this.orderSubject = new Subject();
3205
- }
3206
- getOrder(id) {
3207
- docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
3208
- .pipe(map((doc) => Order.toInstance(doc.data())))
3209
- .subscribe((doc) => this.orderSubject.next(doc));
3210
- return this.orderSubject;
3211
- }
3212
- }
3213
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
3214
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
3215
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
3216
- type: Injectable
3217
- }], ctorParameters: function () {
3218
- return [{ type: i1$1.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
3219
- type: Inject,
3220
- args: ['OrderRepository']
3221
- }] }];
3222
- } });
3223
-
3224
- class AngularConnectModule {
3225
- static initializeApp(defaultShop, options, nameOrConfig) {
3226
- return {
3227
- ngModule: AngularConnectModule,
3228
- providers: [
3229
- ...this.buildCoreProviders(nameOrConfig, options),
3230
- ...this.buildConditionalProviders(defaultShop, options),
3231
- ],
3232
- };
3233
- }
3234
- static buildCoreProviders(nameOrConfig, options) {
3235
- return [
3236
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
3237
- { provide: APP_CHECK_PROVIDER, useValue: options.appCheckProvider },
3238
- {
3239
- provide: CATEGORY_STRUCTURE,
3240
- useClass: this.selectCategoryStructureAdapter(options.oldCategoryStructure),
3241
- },
3242
- { provide: PERSISTENCE_PROVIDER, useClass: (options === null || options === void 0 ? void 0 : options.persistenceProvider) || CookieDataPersistence },
3243
- ];
3244
- }
3245
- static buildConditionalProviders(defaultShop, options) {
3246
- return [
3247
- ...this.createProviderIfExists(DEFAULT_SHOP, defaultShop),
3248
- ...this.createProviderIfExists(FIREBASE_OPTIONS, options.firebase),
3249
- ...this.createProviderIfExists(ES_CONFIG, options.elasticSearch),
3250
- ...this.createProviderIfExists(VERTEX_CONFIG, options.vertexConfig),
3251
- ...this.createProviderIfExists(HASURA_OPTIONS, options.hasura),
3252
- ...this.createProviderIfExists(BACKEND_URL, options.backendUrl),
3253
- ...this.createProviderIfExists(STORAGE_BASE_URL, options.storageBaseUrl),
3254
- ];
3255
- }
3256
- static selectCategoryStructureAdapter(oldCategoryStructure) {
3257
- return isNil(oldCategoryStructure) || oldCategoryStructure
3258
- ? OldCategoryStructureAdapter
3259
- : NewCategoryStructureAdapter;
3260
- }
3261
- static createProviderIfExists(token, value) {
3262
- return isNil(value) ? [] : [{ provide: token, useValue: value }];
3263
- }
3264
- }
3265
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
3266
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$3.FirebaseAppModule, i2.AppCheckModule, i3$1.StorageModule, AngularElasticSeachModule,
3267
- AngularVertexSeachModule,
3268
- AngularFirebaseAuthModule,
3269
- AngularFirestoreModule,
3270
- AngularHasuraGraphQLModule] });
3271
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
3272
- AuthService,
3273
- CartService,
3274
- CatalogService,
3275
- CategoryService,
3276
- CheckoutService,
3277
- CheckoutSubscriptionService,
3278
- CouponService,
3279
- HomeShopService,
3280
- OrderService,
3281
- WishlistService,
3282
- ConfigurationFacade,
3283
- CartServicesFacade,
3284
- CheckoutRepositoriesFacade,
3285
- CheckoutDependenciesFacade,
3286
- CategoryRepositoryFacade,
3287
- ProductCatalogFacade,
3288
- CatalogServiceFacade,
3289
- CategoryServiceFacade,
3290
- CatalogStrategiesFacade,
3291
- CatalogOperationsFacade,
3292
- ProductManagementFacade,
3293
- {
3294
- provide: 'ProductServicesFacade',
3295
- useFactory: (productStockNotificationRepository, categoryRepository, productSearch) => ({
3296
- productStockNotificationRepository,
3297
- categoryRepository,
3298
- productSearch,
3299
- }),
3300
- deps: ['ProductStockNotificationRepository', 'CategoryRepository', 'ProductSearch'],
3301
- },
3302
- CatalogFilterHelper,
3303
- CatalogSortHelper,
3304
- ProductFieldsHelper,
3305
- BrandManagerHelper,
3306
- CatalogRepositoryService,
3307
- CatalogHelpersService,
3308
- CategorySearchStrategy,
3309
- TermSearchStrategy,
3310
- ProfileSearchStrategy,
3311
- {
3312
- provide: CatalogSearchContext,
3313
- useFactory: (categoryStrategy, termStrategy, profileStrategy) => {
3314
- return new CatalogSearchContext(categoryStrategy, termStrategy, profileStrategy);
3315
- },
3316
- deps: [CategorySearchStrategy, TermSearchStrategy, ProfileSearchStrategy],
3317
- },
3318
- {
3319
- provide: UpdateUserImage,
3320
- useFactory: (userRepository, fileUploader) => {
3321
- return new UpdateUserImage(userRepository, fileUploader);
3322
- },
3323
- deps: ['UserRepository', 'FileUploaderService'],
3324
- },
3325
- {
3326
- provide: 'FileUploaderService',
3327
- useFactory: (storage, baseUrl) => {
3328
- return new FirebaseFileUploaderService(storage, baseUrl);
3329
- },
3330
- deps: [Storage, STORAGE_BASE_URL],
3331
- },
3332
- {
3333
- provide: 'ProductSearch',
3334
- useExisting: ProductsVertexSearch,
3335
- },
3336
- CouponRepositoriesFacade,
3337
- HomeShopRepositoriesFacade,
3338
- OrderProductReviewService,
3339
- ], imports: [provideFirebaseApp((injector) => {
3340
- const appName = injector.get(FIREBASE_APP_NAME);
3341
- try {
3342
- const app = appName ? getApp(appName) : getApp();
3343
- return app;
3344
- }
3345
- catch (error) {
3346
- console.warn('Firebase app not found, initializing new app');
3347
- if (error instanceof Error)
3348
- console.error(error.message);
3349
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
3350
- }
3351
- }),
3352
- provideAppCheck((injector) => {
3353
- const app = injector.get(FirebaseApp);
3354
- try {
3355
- const provider = injector.get(APP_CHECK_PROVIDER);
3356
- if (provider)
3357
- return initializeAppCheck(app, {
3358
- provider,
3359
- isTokenAutoRefreshEnabled: true,
3360
- });
3361
- }
3362
- catch (error) {
3363
- if (error instanceof Error)
3364
- console.error(error.message);
3365
- return;
3366
- }
3367
- }),
3368
- provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
3369
- AngularElasticSeachModule,
3370
- AngularVertexSeachModule,
3371
- AngularFirebaseAuthModule,
3372
- AngularFirestoreModule,
3373
- AngularHasuraGraphQLModule] });
3374
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
3375
- type: NgModule,
3376
- args: [{
3377
- imports: [
3378
- provideFirebaseApp((injector) => {
3379
- const appName = injector.get(FIREBASE_APP_NAME);
3380
- try {
3381
- const app = appName ? getApp(appName) : getApp();
3382
- return app;
3383
- }
3384
- catch (error) {
3385
- console.warn('Firebase app not found, initializing new app');
3386
- if (error instanceof Error)
3387
- console.error(error.message);
3388
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
3389
- }
3390
- }),
3391
- provideAppCheck((injector) => {
3392
- const app = injector.get(FirebaseApp);
3393
- try {
3394
- const provider = injector.get(APP_CHECK_PROVIDER);
3395
- if (provider)
3396
- return initializeAppCheck(app, {
3397
- provider,
3398
- isTokenAutoRefreshEnabled: true,
3399
- });
3400
- }
3401
- catch (error) {
3402
- if (error instanceof Error)
3403
- console.error(error.message);
3404
- return;
3405
- }
3406
- }),
3407
- provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
3408
- AngularElasticSeachModule,
3409
- AngularVertexSeachModule,
3410
- AngularFirebaseAuthModule,
3411
- AngularFirestoreModule,
3412
- AngularHasuraGraphQLModule,
3413
- ],
3414
- providers: [
3415
- AuthService,
3416
- CartService,
3417
- CatalogService,
3418
- CategoryService,
3419
- CheckoutService,
3420
- CheckoutSubscriptionService,
3421
- CouponService,
3422
- HomeShopService,
3423
- OrderService,
3424
- WishlistService,
3425
- ConfigurationFacade,
3426
- CartServicesFacade,
3427
- CheckoutRepositoriesFacade,
3428
- CheckoutDependenciesFacade,
3429
- CategoryRepositoryFacade,
3430
- ProductCatalogFacade,
3431
- CatalogServiceFacade,
3432
- CategoryServiceFacade,
3433
- CatalogStrategiesFacade,
3434
- CatalogOperationsFacade,
3435
- ProductManagementFacade,
3436
- {
3437
- provide: 'ProductServicesFacade',
3438
- useFactory: (productStockNotificationRepository, categoryRepository, productSearch) => ({
3439
- productStockNotificationRepository,
3440
- categoryRepository,
3441
- productSearch,
3442
- }),
3443
- deps: ['ProductStockNotificationRepository', 'CategoryRepository', 'ProductSearch'],
3444
- },
3445
- CatalogFilterHelper,
3446
- CatalogSortHelper,
3447
- ProductFieldsHelper,
3448
- BrandManagerHelper,
3449
- CatalogRepositoryService,
3450
- CatalogHelpersService,
3451
- CategorySearchStrategy,
3452
- TermSearchStrategy,
3453
- ProfileSearchStrategy,
3454
- {
3455
- provide: CatalogSearchContext,
3456
- useFactory: (categoryStrategy, termStrategy, profileStrategy) => {
3457
- return new CatalogSearchContext(categoryStrategy, termStrategy, profileStrategy);
3458
- },
3459
- deps: [CategorySearchStrategy, TermSearchStrategy, ProfileSearchStrategy],
3460
- },
3461
- {
3462
- provide: UpdateUserImage,
3463
- useFactory: (userRepository, fileUploader) => {
3464
- return new UpdateUserImage(userRepository, fileUploader);
3465
- },
3466
- deps: ['UserRepository', 'FileUploaderService'],
3467
- },
3468
- {
3469
- provide: 'FileUploaderService',
3470
- useFactory: (storage, baseUrl) => {
3471
- return new FirebaseFileUploaderService(storage, baseUrl);
3472
- },
3473
- deps: [Storage, STORAGE_BASE_URL],
3474
- },
3475
- {
3476
- provide: 'ProductSearch',
3477
- useExisting: ProductsVertexSearch,
3478
- },
3479
- CouponRepositoriesFacade,
3480
- HomeShopRepositoriesFacade,
3481
- OrderProductReviewService,
3482
- ],
3483
- }]
3484
- }] });
3485
-
3486
- /**
3487
- * Generated bundle index. Do not edit.
3488
- */
3489
-
3490
- export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderProductReviewService, OrderService, ProductSorts, UtilHelper, WishlistService };
3491
- //# sourceMappingURL=infrab4a-connect-angular.mjs.map