@infrab4a/connect-angular 5.1.0 → 6.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/eslint.config.js +18 -0
  2. package/index.ts +1 -0
  3. package/karma.conf.js +32 -0
  4. package/ng-package.json +8 -0
  5. package/package.json +10 -28
  6. package/project.json +37 -0
  7. package/src/angular-connect.module.ts +256 -0
  8. package/src/angular-elastic-search.module.ts +23 -0
  9. package/src/angular-firebase-auth.module.ts +101 -0
  10. package/src/angular-firestore.module.ts +371 -0
  11. package/src/angular-hasura-graphql.module.ts +219 -0
  12. package/src/angular-vertex-search.module.ts +23 -0
  13. package/src/consts/backend-url.const.ts +1 -0
  14. package/src/consts/category-structure.ts +1 -0
  15. package/src/consts/default-shop.const.ts +1 -0
  16. package/src/consts/es-config.const.ts +1 -0
  17. package/src/consts/firebase-const.ts +5 -0
  18. package/src/consts/hasura-options.const.ts +1 -0
  19. package/src/consts/index.ts +8 -0
  20. package/src/consts/persistence.const.ts +1 -0
  21. package/src/consts/storage-base-url.const.ts +1 -0
  22. package/src/consts/vertex-config.const.ts +1 -0
  23. package/src/helpers/index.ts +1 -0
  24. package/src/helpers/mobile-operation-system-checker.helper.ts +10 -0
  25. package/src/index.ts +6 -0
  26. package/src/interfaces/catalog-strategies.interface.ts +36 -0
  27. package/src/interfaces/category-facades.interface.ts +7 -0
  28. package/src/interfaces/index.ts +2 -0
  29. package/src/persistence/cookie-data-persistence.ts +21 -0
  30. package/src/persistence/data-persistence.ts +7 -0
  31. package/src/persistence/index.ts +2 -0
  32. package/src/services/auth.service.ts +39 -0
  33. package/src/services/cart/cart-services.facade.ts +14 -0
  34. package/src/services/cart/index.ts +1 -0
  35. package/src/services/cart.service.ts +124 -0
  36. package/src/services/catalog/adapters/category-structure.adapter.ts +5 -0
  37. package/src/services/catalog/adapters/index.ts +3 -0
  38. package/src/services/catalog/adapters/new-category-structure.adapter.ts +42 -0
  39. package/src/services/catalog/adapters/old-category-structure.adapter.ts +17 -0
  40. package/src/services/catalog/catalog.service.ts +153 -0
  41. package/src/services/catalog/category.service.ts +52 -0
  42. package/src/services/catalog/context/catalog-search.context.ts +61 -0
  43. package/src/services/catalog/enums/index.ts +1 -0
  44. package/src/services/catalog/enums/product-sorts.enum.ts +9 -0
  45. package/src/services/catalog/facades/catalog-service.facade.ts +32 -0
  46. package/src/services/catalog/facades/catalog-strategies.facade.ts +12 -0
  47. package/src/services/catalog/facades/category-repository.facade.ts +10 -0
  48. package/src/services/catalog/facades/category-service.facade.ts +25 -0
  49. package/src/services/catalog/facades/index.ts +5 -0
  50. package/src/services/catalog/facades/product-catalog.facade.ts +13 -0
  51. package/src/services/catalog/helpers/brand-manager.helper.ts +63 -0
  52. package/src/services/catalog/helpers/catalog-filter.helper.ts +50 -0
  53. package/src/services/catalog/helpers/catalog-sort.helper.ts +54 -0
  54. package/src/services/catalog/helpers/index.ts +4 -0
  55. package/src/services/catalog/helpers/product-fields.helper.ts +35 -0
  56. package/src/services/catalog/index.ts +7 -0
  57. package/src/services/catalog/models/category-with-tree.model.ts +7 -0
  58. package/src/services/catalog/models/index.ts +1 -0
  59. package/src/services/catalog/services/catalog-helpers.service.ts +35 -0
  60. package/src/services/catalog/services/catalog-operations.facade.ts +24 -0
  61. package/src/services/catalog/services/catalog-repository.service.ts +20 -0
  62. package/src/services/catalog/services/index.ts +4 -0
  63. package/src/services/catalog/services/product-management.facade.ts +20 -0
  64. package/src/services/catalog/strategies/category-search.strategy.ts +172 -0
  65. package/src/services/catalog/strategies/index.ts +3 -0
  66. package/src/services/catalog/strategies/profile-search.strategy.ts +51 -0
  67. package/src/services/catalog/strategies/term-search.strategy.ts +178 -0
  68. package/src/services/catalog/strategies/types/strategy-params.type.ts +58 -0
  69. package/src/services/catalog/types/fetch-products-options.type.ts +10 -0
  70. package/src/services/catalog/types/fetch-products-params.type.ts +27 -0
  71. package/src/services/catalog/types/fetch-products-response.type.ts +11 -0
  72. package/src/services/catalog/types/index.ts +5 -0
  73. package/src/services/catalog/types/method-params.type.ts +21 -0
  74. package/src/services/catalog/types/product-sort.type.ts +3 -0
  75. package/src/services/catalog/wishlist.service.ts +368 -0
  76. package/src/services/checkout/checkout-dependencies.facade.ts +13 -0
  77. package/src/services/checkout/checkout-repositories.facade.ts +10 -0
  78. package/src/services/checkout/index.ts +2 -0
  79. package/src/services/checkout-subscription.service.ts +76 -0
  80. package/src/services/checkout.service.ts +196 -0
  81. package/src/services/coupon/coupon-repositories.facade.ts +11 -0
  82. package/src/services/coupon/index.ts +1 -0
  83. package/src/services/coupon/types/coupon-params.type.ts +15 -0
  84. package/src/services/coupon.service.ts +347 -0
  85. package/src/services/errors/group-invalid-coupon.error.ts +9 -0
  86. package/src/services/errors/index.ts +2 -0
  87. package/src/services/errors/invalid-coupon.error.ts +7 -0
  88. package/src/services/helpers/index.ts +1 -0
  89. package/src/services/helpers/util.helper.ts +17 -0
  90. package/src/services/home-shop/home-shop-repositories.facade.ts +11 -0
  91. package/src/services/home-shop/index.ts +1 -0
  92. package/src/services/home-shop.service.ts +196 -0
  93. package/src/services/index.ts +9 -0
  94. package/src/services/order.service.ts +23 -0
  95. package/src/services/shared/configuration.facade.ts +21 -0
  96. package/src/services/shared/index.ts +1 -0
  97. package/src/services/types/index.ts +2 -0
  98. package/src/services/types/required-checkout-data.type.ts +3 -0
  99. package/src/services/types/required-checkout-subscription-data.type.ts +3 -0
  100. package/src/types/firebase-app-config.type.ts +1 -0
  101. package/src/types/index.ts +1 -0
  102. package/tsconfig.json +17 -0
  103. package/tsconfig.lib.json +13 -0
  104. package/tsconfig.lib.prod.json +13 -0
  105. package/tsconfig.spec.json +17 -0
  106. package/angular-connect.module.d.ts +0 -26
  107. package/angular-elastic-search.module.d.ts +0 -9
  108. package/angular-firebase-auth.module.d.ts +0 -11
  109. package/angular-firestore.module.d.ts +0 -18
  110. package/angular-hasura-graphql.module.d.ts +0 -16
  111. package/consts/backend-url.const.d.ts +0 -1
  112. package/consts/category-structure.d.ts +0 -1
  113. package/consts/default-shop.const.d.ts +0 -1
  114. package/consts/es-config.const.d.ts +0 -1
  115. package/consts/firebase-const.d.ts +0 -3
  116. package/consts/hasura-options.const.d.ts +0 -1
  117. package/consts/index.d.ts +0 -7
  118. package/consts/persistence.const.d.ts +0 -1
  119. package/consts/storage-base-url.const.d.ts +0 -1
  120. package/esm2020/angular-connect.module.mjs +0 -115
  121. package/esm2020/angular-elastic-search.module.mjs +0 -34
  122. package/esm2020/angular-firebase-auth.module.mjs +0 -115
  123. package/esm2020/angular-firestore.module.mjs +0 -504
  124. package/esm2020/angular-hasura-graphql.module.mjs +0 -265
  125. package/esm2020/consts/backend-url.const.mjs +0 -2
  126. package/esm2020/consts/category-structure.mjs +0 -2
  127. package/esm2020/consts/default-shop.const.mjs +0 -2
  128. package/esm2020/consts/es-config.const.mjs +0 -2
  129. package/esm2020/consts/firebase-const.mjs +0 -4
  130. package/esm2020/consts/hasura-options.const.mjs +0 -2
  131. package/esm2020/consts/index.mjs +0 -8
  132. package/esm2020/consts/persistence.const.mjs +0 -2
  133. package/esm2020/consts/storage-base-url.const.mjs +0 -2
  134. package/esm2020/helpers/index.mjs +0 -2
  135. package/esm2020/helpers/mobile-operation-system-checker.helper.mjs +0 -7
  136. package/esm2020/index.mjs +0 -7
  137. package/esm2020/infrab4a-connect-angular.mjs +0 -5
  138. package/esm2020/persistence/cookie-data-persistence.mjs +0 -22
  139. package/esm2020/persistence/data-persistence.mjs +0 -2
  140. package/esm2020/persistence/index.mjs +0 -3
  141. package/esm2020/services/auth.service.mjs +0 -37
  142. package/esm2020/services/cart.service.mjs +0 -281
  143. package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +0 -2
  144. package/esm2020/services/catalog/adapters/index.mjs +0 -4
  145. package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +0 -43
  146. package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +0 -23
  147. package/esm2020/services/catalog/catalog.service.mjs +0 -194
  148. package/esm2020/services/catalog/category.service.mjs +0 -51
  149. package/esm2020/services/catalog/enums/index.mjs +0 -2
  150. package/esm2020/services/catalog/enums/product-sorts.enum.mjs +0 -11
  151. package/esm2020/services/catalog/index.mjs +0 -8
  152. package/esm2020/services/catalog/models/category-with-tree.model.mjs +0 -10
  153. package/esm2020/services/catalog/models/index.mjs +0 -2
  154. package/esm2020/services/catalog/types/index.mjs +0 -2
  155. package/esm2020/services/catalog/types/product-sort.type.mjs +0 -2
  156. package/esm2020/services/catalog/wishlist.service.mjs +0 -115
  157. package/esm2020/services/checkout-subscription.service.mjs +0 -50
  158. package/esm2020/services/checkout.service.mjs +0 -68
  159. package/esm2020/services/coupon.service.mjs +0 -235
  160. package/esm2020/services/helpers/index.mjs +0 -2
  161. package/esm2020/services/helpers/util.helper.mjs +0 -18
  162. package/esm2020/services/home-shop.service.mjs +0 -125
  163. package/esm2020/services/index.mjs +0 -11
  164. package/esm2020/services/order.service.mjs +0 -30
  165. package/esm2020/services/shipping.service.mjs +0 -96
  166. package/esm2020/services/types/index.mjs +0 -3
  167. package/esm2020/services/types/required-checkout-data.type.mjs +0 -2
  168. package/esm2020/services/types/required-checkout-subscription-data.type.mjs +0 -2
  169. package/esm2020/services/types/shipping-methods.type.mjs +0 -2
  170. package/esm2020/types/firebase-app-config.type.mjs +0 -2
  171. package/esm2020/types/index.mjs +0 -2
  172. package/fesm2015/infrab4a-connect-angular.mjs +0 -2417
  173. package/fesm2015/infrab4a-connect-angular.mjs.map +0 -1
  174. package/fesm2020/infrab4a-connect-angular.mjs +0 -2352
  175. package/fesm2020/infrab4a-connect-angular.mjs.map +0 -1
  176. package/helpers/index.d.ts +0 -1
  177. package/helpers/mobile-operation-system-checker.helper.d.ts +0 -3
  178. package/index.d.ts +0 -6
  179. package/persistence/cookie-data-persistence.d.ts +0 -10
  180. package/persistence/data-persistence.d.ts +0 -6
  181. package/persistence/index.d.ts +0 -2
  182. package/services/auth.service.d.ts +0 -18
  183. package/services/cart.service.d.ts +0 -42
  184. package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
  185. package/services/catalog/adapters/index.d.ts +0 -3
  186. package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -12
  187. package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
  188. package/services/catalog/catalog.service.d.ts +0 -86
  189. package/services/catalog/category.service.d.ts +0 -20
  190. package/services/catalog/enums/index.d.ts +0 -1
  191. package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
  192. package/services/catalog/index.d.ts +0 -7
  193. package/services/catalog/models/category-with-tree.model.d.ts +0 -4
  194. package/services/catalog/models/index.d.ts +0 -1
  195. package/services/catalog/types/index.d.ts +0 -1
  196. package/services/catalog/types/product-sort.type.d.ts +0 -2
  197. package/services/catalog/wishlist.service.d.ts +0 -38
  198. package/services/checkout-subscription.service.d.ts +0 -19
  199. package/services/checkout.service.d.ts +0 -24
  200. package/services/coupon.service.d.ts +0 -29
  201. package/services/helpers/index.d.ts +0 -1
  202. package/services/helpers/util.helper.d.ts +0 -3
  203. package/services/home-shop.service.d.ts +0 -26
  204. package/services/index.d.ts +0 -10
  205. package/services/order.service.d.ts +0 -13
  206. package/services/shipping.service.d.ts +0 -19
  207. package/services/types/index.d.ts +0 -2
  208. package/services/types/required-checkout-data.type.d.ts +0 -2
  209. package/services/types/required-checkout-subscription-data.type.d.ts +0 -2
  210. package/services/types/shipping-methods.type.d.ts +0 -12
  211. package/types/firebase-app-config.type.d.ts +0 -1
  212. package/types/index.d.ts +0 -1
@@ -1,2352 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
3
- import * as i1$4 from '@angular/fire/app';
4
- import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
5
- import * as i1$2 from '@infrab4a/connect';
6
- import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, FirebaseFileUploaderService, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage } from '@infrab4a/connect';
7
- import * as i1 from '@angular/fire/auth';
8
- import { Auth, provideAuth, getAuth, getIdToken, authState } from '@angular/fire/auth';
9
- import { isPlatformBrowser, isPlatformServer } from '@angular/common';
10
- import * as i1$1 from '@angular/fire/firestore';
11
- import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
12
- import * as i2 from '@angular/fire/storage';
13
- import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
14
- import cookie from 'js-cookie';
15
- import { of, from, combineLatest, throwError, Subject, iif, forkJoin } from 'rxjs';
16
- import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
17
- import { __decorate, __metadata } from 'tslib';
18
- import { Type } from 'class-transformer';
19
- import * as i1$3 from '@angular/common/http';
20
-
21
- const ES_CONFIG = 'ES_CONFIG';
22
-
23
- class AngularElasticSeachModule {
24
- static initializeApp(options) {
25
- return {
26
- ngModule: AngularElasticSeachModule,
27
- providers: [{ provide: ES_CONFIG, useValue: options }],
28
- };
29
- }
30
- }
31
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
32
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
33
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
34
- {
35
- provide: ProductsIndex,
36
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
37
- deps: [ES_CONFIG],
38
- },
39
- ] });
40
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
41
- type: NgModule,
42
- args: [{
43
- providers: [
44
- {
45
- provide: ProductsIndex,
46
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
47
- deps: [ES_CONFIG],
48
- },
49
- ],
50
- }]
51
- }] });
52
-
53
- const BACKEND_URL = 'BACKEND_URL';
54
-
55
- const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
56
-
57
- const DEFAULT_SHOP = 'DEFAULT_SHOP';
58
-
59
- const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
60
- const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
61
-
62
- const HASURA_OPTIONS = 'HASURA_OPTIONS';
63
-
64
- const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
65
-
66
- class AngularFirebaseAuthModule {
67
- static initializeApp(options, nameOrConfig) {
68
- return {
69
- ngModule: AngularFirebaseAuthModule,
70
- providers: [
71
- { provide: FIREBASE_OPTIONS, useValue: options },
72
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
73
- ],
74
- };
75
- }
76
- }
77
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
78
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] });
79
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
80
- {
81
- provide: 'Authentication',
82
- useFactory: (authenticationService, userRepository) => {
83
- return new Authentication(authenticationService, userRepository);
84
- },
85
- deps: ['AuthenticationService', 'UserRepository'],
86
- },
87
- {
88
- provide: 'AuthenticationService',
89
- useFactory: (angularFireAuth) => {
90
- return new AuthenticationFirebaseAuthService(angularFireAuth);
91
- },
92
- deps: [Auth],
93
- },
94
- {
95
- provide: 'Register',
96
- useFactory: (registerService, userRepository) => {
97
- return new Register(registerService, userRepository);
98
- },
99
- deps: ['RegisterService', 'UserRepository'],
100
- },
101
- {
102
- provide: 'RegisterService',
103
- useFactory: (angularFireAuth) => {
104
- return new RegisterFirebaseAuthService(angularFireAuth);
105
- },
106
- deps: [Auth],
107
- },
108
- {
109
- provide: 'SignOut',
110
- useFactory: (authenticationService) => {
111
- return new SignOut(authenticationService);
112
- },
113
- deps: ['AuthenticationService'],
114
- },
115
- {
116
- provide: 'RecoveryPassword',
117
- useFactory: (authenticationService) => {
118
- return new RecoveryPassword(authenticationService);
119
- },
120
- deps: ['AuthenticationService'],
121
- },
122
- ], imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))] });
123
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
124
- type: NgModule,
125
- args: [{
126
- imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))],
127
- providers: [
128
- {
129
- provide: 'Authentication',
130
- useFactory: (authenticationService, userRepository) => {
131
- return new Authentication(authenticationService, userRepository);
132
- },
133
- deps: ['AuthenticationService', 'UserRepository'],
134
- },
135
- {
136
- provide: 'AuthenticationService',
137
- useFactory: (angularFireAuth) => {
138
- return new AuthenticationFirebaseAuthService(angularFireAuth);
139
- },
140
- deps: [Auth],
141
- },
142
- {
143
- provide: 'Register',
144
- useFactory: (registerService, userRepository) => {
145
- return new Register(registerService, userRepository);
146
- },
147
- deps: ['RegisterService', 'UserRepository'],
148
- },
149
- {
150
- provide: 'RegisterService',
151
- useFactory: (angularFireAuth) => {
152
- return new RegisterFirebaseAuthService(angularFireAuth);
153
- },
154
- deps: [Auth],
155
- },
156
- {
157
- provide: 'SignOut',
158
- useFactory: (authenticationService) => {
159
- return new SignOut(authenticationService);
160
- },
161
- deps: ['AuthenticationService'],
162
- },
163
- {
164
- provide: 'RecoveryPassword',
165
- useFactory: (authenticationService) => {
166
- return new RecoveryPassword(authenticationService);
167
- },
168
- deps: ['AuthenticationService'],
169
- },
170
- ],
171
- }]
172
- }] });
173
-
174
- const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
175
-
176
- class MobileOperationSystemCheckerHelper {
177
- static isAppleDevice() {
178
- return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
179
- (navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
180
- }
181
- }
182
-
183
- class AngularFirestoreModule {
184
- static initializeApp(options, nameOrConfig) {
185
- return {
186
- ngModule: AngularFirestoreModule,
187
- providers: [
188
- { provide: FIREBASE_OPTIONS, useValue: options.firebase },
189
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
190
- { provide: ES_CONFIG, useValue: options.elasticSearch },
191
- ],
192
- };
193
- }
194
- }
195
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
196
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule, i2.StorageModule] });
197
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
198
- {
199
- provide: 'FirestoreOptions',
200
- useFactory: (firestore, platformId) => ({
201
- firestore: new ConnectFirestoreService(firestore),
202
- interceptors: {
203
- request: (request) => {
204
- if (isPlatformBrowser(platformId))
205
- return request;
206
- const interval = setInterval(() => { }, 100);
207
- request.interval = interval;
208
- return request;
209
- },
210
- response: (response, request) => {
211
- if (isPlatformBrowser(platformId))
212
- return response;
213
- clearInterval(request.interval);
214
- return response;
215
- },
216
- },
217
- }),
218
- deps: [Firestore, PLATFORM_ID],
219
- },
220
- {
221
- provide: 'BeautyProfileRepository',
222
- useFactory: (config, userRepository) => {
223
- return new UserBeautyProfileFirestoreRepository(config, userRepository);
224
- },
225
- deps: ['FirestoreOptions', 'UserRepository'],
226
- },
227
- {
228
- provide: 'Buy2WinRepository',
229
- useFactory: (options) => {
230
- return new Buy2WinFirestoreRepository(options);
231
- },
232
- deps: ['FirestoreOptions'],
233
- },
234
- {
235
- provide: CategoryFirestoreRepository,
236
- useFactory: (options) => {
237
- return new CategoryFirestoreRepository(options);
238
- },
239
- deps: ['FirestoreOptions'],
240
- },
241
- {
242
- provide: 'CheckoutRepository',
243
- useFactory: (options) => {
244
- return new CheckoutFirestoreRepository(options);
245
- },
246
- deps: ['FirestoreOptions'],
247
- },
248
- {
249
- provide: 'CheckoutSubscriptionRepository',
250
- useFactory: (options) => {
251
- return new CheckoutSubscriptionFirestoreRepository(options);
252
- },
253
- deps: ['FirestoreOptions'],
254
- },
255
- {
256
- provide: 'CouponRepository',
257
- useFactory: (options) => {
258
- return new CouponFirestoreRepository(options);
259
- },
260
- deps: ['FirestoreOptions'],
261
- },
262
- {
263
- provide: 'CampaignHashtagRepository',
264
- useFactory: (options) => {
265
- return new CampaignHashtagFirestoreRepository(options);
266
- },
267
- deps: ['FirestoreOptions'],
268
- },
269
- {
270
- provide: 'CampaignDashboardRepository',
271
- useFactory: (options) => {
272
- return new CampaignDashboardFirestoreRepository(options);
273
- },
274
- deps: ['FirestoreOptions'],
275
- },
276
- {
277
- provide: 'EditionRepository',
278
- useFactory: (options, subscriptionRepository) => {
279
- return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
280
- },
281
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
282
- },
283
- {
284
- provide: 'HomeRepository',
285
- useFactory: (options) => {
286
- return new HomeFirestoreRepository(options);
287
- },
288
- deps: ['FirestoreOptions'],
289
- },
290
- {
291
- provide: 'LeadRepository',
292
- useFactory: (options) => {
293
- return new LeadFirestoreRepository(options);
294
- },
295
- deps: ['FirestoreOptions'],
296
- },
297
- {
298
- provide: 'LegacyOrderRepository',
299
- useFactory: (options) => {
300
- return new LegacyOrderFirestoreRepository(options);
301
- },
302
- deps: ['FirestoreOptions'],
303
- },
304
- {
305
- provide: 'ShopMenuRepository',
306
- useFactory: (options) => {
307
- return new ShopMenuFirestoreRepository(options);
308
- },
309
- deps: ['FirestoreOptions'],
310
- },
311
- {
312
- provide: 'OrderRepository',
313
- useFactory: (options) => {
314
- return new OrderFirestoreRepository(options);
315
- },
316
- deps: ['FirestoreOptions'],
317
- },
318
- {
319
- provide: 'PaymentRepository',
320
- useFactory: (options) => {
321
- return new PaymentFirestoreRepository(options);
322
- },
323
- deps: ['FirestoreOptions'],
324
- },
325
- {
326
- provide: ProductFirestoreRepository,
327
- useFactory: (options) => {
328
- return new ProductFirestoreRepository(options);
329
- },
330
- deps: ['FirestoreOptions'],
331
- },
332
- {
333
- provide: 'ShopSettingsRepository',
334
- useFactory: (options) => {
335
- return new ShopSettingsFirestoreRepository(options);
336
- },
337
- deps: ['FirestoreOptions'],
338
- },
339
- {
340
- provide: 'SubscriptionPaymentRepository',
341
- useFactory: (options, subscriptionRepository) => {
342
- return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
343
- },
344
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
345
- },
346
- {
347
- provide: 'SubscriptionPlanRepository',
348
- useFactory: (options) => {
349
- return new SubscriptionPlanFirestoreRepository(options);
350
- },
351
- deps: ['FirestoreOptions'],
352
- },
353
- {
354
- provide: 'SubscriptionProductRepository',
355
- useFactory: (options) => {
356
- return new SubscriptionProductFirestoreRepository(options);
357
- },
358
- deps: ['FirestoreOptions'],
359
- },
360
- {
361
- provide: 'SubscriptionRepository',
362
- useFactory: (options) => {
363
- return new SubscriptionFirestoreRepository(options);
364
- },
365
- deps: ['FirestoreOptions'],
366
- },
367
- {
368
- provide: 'UserRepository',
369
- useFactory: (options) => {
370
- return new UserFirestoreRepository(options);
371
- },
372
- deps: ['FirestoreOptions'],
373
- },
374
- {
375
- provide: 'UserAddressRepository',
376
- useFactory: (options, userRepository) => {
377
- return new UserAddressFirestoreRepository(options, userRepository);
378
- },
379
- deps: ['FirestoreOptions', 'UserRepository'],
380
- },
381
- {
382
- provide: 'UserPaymentMethodRepository',
383
- useFactory: (options, userRepository) => {
384
- return new UserPaymentMethodFirestoreRepository(options, userRepository);
385
- },
386
- deps: ['FirestoreOptions', 'UserRepository'],
387
- },
388
- {
389
- provide: 'SubscriptionMaterializationRepository',
390
- useFactory: (options) => {
391
- return new SubscriptionMaterializationFirestoreRepository(options);
392
- },
393
- deps: ['FirestoreOptions'],
394
- },
395
- {
396
- provide: 'SubscriptionSummaryRepository',
397
- useFactory: (options) => {
398
- return new SubscriptionSummaryFirestoreRepository(options);
399
- },
400
- deps: ['FirestoreOptions'],
401
- },
402
- {
403
- provide: ProductVariantFirestoreRepository,
404
- useFactory: (options, productRepository) => {
405
- return new ProductVariantFirestoreRepository(options, productRepository);
406
- },
407
- deps: ['FirestoreOptions', ProductFirestoreRepository],
408
- },
409
- {
410
- provide: 'FileUploaderService',
411
- useFactory: (storage, baseUrl) => {
412
- return new FirebaseFileUploaderService(storage, baseUrl);
413
- },
414
- deps: [Storage, STORAGE_BASE_URL],
415
- },
416
- ], imports: [AngularElasticSeachModule,
417
- provideFirestore((injector) => {
418
- const platformId = injector.get(PLATFORM_ID);
419
- if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
420
- return initializeFirestore(injector.get(FirebaseApp), {
421
- ignoreUndefinedProperties: true,
422
- });
423
- const firestore = initializeFirestore(injector.get(FirebaseApp), {
424
- experimentalForceLongPolling: true,
425
- ignoreUndefinedProperties: true,
426
- localCache: memoryLocalCache(),
427
- });
428
- return firestore;
429
- }),
430
- provideStorage(() => getStorage())] });
431
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
432
- type: NgModule,
433
- args: [{
434
- imports: [
435
- AngularElasticSeachModule,
436
- provideFirestore((injector) => {
437
- const platformId = injector.get(PLATFORM_ID);
438
- if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
439
- return initializeFirestore(injector.get(FirebaseApp), {
440
- ignoreUndefinedProperties: true,
441
- });
442
- const firestore = initializeFirestore(injector.get(FirebaseApp), {
443
- experimentalForceLongPolling: true,
444
- ignoreUndefinedProperties: true,
445
- localCache: memoryLocalCache(),
446
- });
447
- return firestore;
448
- }),
449
- provideStorage(() => getStorage()),
450
- ],
451
- providers: [
452
- {
453
- provide: 'FirestoreOptions',
454
- useFactory: (firestore, platformId) => ({
455
- firestore: new ConnectFirestoreService(firestore),
456
- interceptors: {
457
- request: (request) => {
458
- if (isPlatformBrowser(platformId))
459
- return request;
460
- const interval = setInterval(() => { }, 100);
461
- request.interval = interval;
462
- return request;
463
- },
464
- response: (response, request) => {
465
- if (isPlatformBrowser(platformId))
466
- return response;
467
- clearInterval(request.interval);
468
- return response;
469
- },
470
- },
471
- }),
472
- deps: [Firestore, PLATFORM_ID],
473
- },
474
- {
475
- provide: 'BeautyProfileRepository',
476
- useFactory: (config, userRepository) => {
477
- return new UserBeautyProfileFirestoreRepository(config, userRepository);
478
- },
479
- deps: ['FirestoreOptions', 'UserRepository'],
480
- },
481
- {
482
- provide: 'Buy2WinRepository',
483
- useFactory: (options) => {
484
- return new Buy2WinFirestoreRepository(options);
485
- },
486
- deps: ['FirestoreOptions'],
487
- },
488
- {
489
- provide: CategoryFirestoreRepository,
490
- useFactory: (options) => {
491
- return new CategoryFirestoreRepository(options);
492
- },
493
- deps: ['FirestoreOptions'],
494
- },
495
- {
496
- provide: 'CheckoutRepository',
497
- useFactory: (options) => {
498
- return new CheckoutFirestoreRepository(options);
499
- },
500
- deps: ['FirestoreOptions'],
501
- },
502
- {
503
- provide: 'CheckoutSubscriptionRepository',
504
- useFactory: (options) => {
505
- return new CheckoutSubscriptionFirestoreRepository(options);
506
- },
507
- deps: ['FirestoreOptions'],
508
- },
509
- {
510
- provide: 'CouponRepository',
511
- useFactory: (options) => {
512
- return new CouponFirestoreRepository(options);
513
- },
514
- deps: ['FirestoreOptions'],
515
- },
516
- {
517
- provide: 'CampaignHashtagRepository',
518
- useFactory: (options) => {
519
- return new CampaignHashtagFirestoreRepository(options);
520
- },
521
- deps: ['FirestoreOptions'],
522
- },
523
- {
524
- provide: 'CampaignDashboardRepository',
525
- useFactory: (options) => {
526
- return new CampaignDashboardFirestoreRepository(options);
527
- },
528
- deps: ['FirestoreOptions'],
529
- },
530
- {
531
- provide: 'EditionRepository',
532
- useFactory: (options, subscriptionRepository) => {
533
- return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
534
- },
535
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
536
- },
537
- {
538
- provide: 'HomeRepository',
539
- useFactory: (options) => {
540
- return new HomeFirestoreRepository(options);
541
- },
542
- deps: ['FirestoreOptions'],
543
- },
544
- {
545
- provide: 'LeadRepository',
546
- useFactory: (options) => {
547
- return new LeadFirestoreRepository(options);
548
- },
549
- deps: ['FirestoreOptions'],
550
- },
551
- {
552
- provide: 'LegacyOrderRepository',
553
- useFactory: (options) => {
554
- return new LegacyOrderFirestoreRepository(options);
555
- },
556
- deps: ['FirestoreOptions'],
557
- },
558
- {
559
- provide: 'ShopMenuRepository',
560
- useFactory: (options) => {
561
- return new ShopMenuFirestoreRepository(options);
562
- },
563
- deps: ['FirestoreOptions'],
564
- },
565
- {
566
- provide: 'OrderRepository',
567
- useFactory: (options) => {
568
- return new OrderFirestoreRepository(options);
569
- },
570
- deps: ['FirestoreOptions'],
571
- },
572
- {
573
- provide: 'PaymentRepository',
574
- useFactory: (options) => {
575
- return new PaymentFirestoreRepository(options);
576
- },
577
- deps: ['FirestoreOptions'],
578
- },
579
- {
580
- provide: ProductFirestoreRepository,
581
- useFactory: (options) => {
582
- return new ProductFirestoreRepository(options);
583
- },
584
- deps: ['FirestoreOptions'],
585
- },
586
- {
587
- provide: 'ShopSettingsRepository',
588
- useFactory: (options) => {
589
- return new ShopSettingsFirestoreRepository(options);
590
- },
591
- deps: ['FirestoreOptions'],
592
- },
593
- {
594
- provide: 'SubscriptionPaymentRepository',
595
- useFactory: (options, subscriptionRepository) => {
596
- return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
597
- },
598
- deps: ['FirestoreOptions', 'SubscriptionRepository'],
599
- },
600
- {
601
- provide: 'SubscriptionPlanRepository',
602
- useFactory: (options) => {
603
- return new SubscriptionPlanFirestoreRepository(options);
604
- },
605
- deps: ['FirestoreOptions'],
606
- },
607
- {
608
- provide: 'SubscriptionProductRepository',
609
- useFactory: (options) => {
610
- return new SubscriptionProductFirestoreRepository(options);
611
- },
612
- deps: ['FirestoreOptions'],
613
- },
614
- {
615
- provide: 'SubscriptionRepository',
616
- useFactory: (options) => {
617
- return new SubscriptionFirestoreRepository(options);
618
- },
619
- deps: ['FirestoreOptions'],
620
- },
621
- {
622
- provide: 'UserRepository',
623
- useFactory: (options) => {
624
- return new UserFirestoreRepository(options);
625
- },
626
- deps: ['FirestoreOptions'],
627
- },
628
- {
629
- provide: 'UserAddressRepository',
630
- useFactory: (options, userRepository) => {
631
- return new UserAddressFirestoreRepository(options, userRepository);
632
- },
633
- deps: ['FirestoreOptions', 'UserRepository'],
634
- },
635
- {
636
- provide: 'UserPaymentMethodRepository',
637
- useFactory: (options, userRepository) => {
638
- return new UserPaymentMethodFirestoreRepository(options, userRepository);
639
- },
640
- deps: ['FirestoreOptions', 'UserRepository'],
641
- },
642
- {
643
- provide: 'SubscriptionMaterializationRepository',
644
- useFactory: (options) => {
645
- return new SubscriptionMaterializationFirestoreRepository(options);
646
- },
647
- deps: ['FirestoreOptions'],
648
- },
649
- {
650
- provide: 'SubscriptionSummaryRepository',
651
- useFactory: (options) => {
652
- return new SubscriptionSummaryFirestoreRepository(options);
653
- },
654
- deps: ['FirestoreOptions'],
655
- },
656
- {
657
- provide: ProductVariantFirestoreRepository,
658
- useFactory: (options, productRepository) => {
659
- return new ProductVariantFirestoreRepository(options, productRepository);
660
- },
661
- deps: ['FirestoreOptions', ProductFirestoreRepository],
662
- },
663
- {
664
- provide: 'FileUploaderService',
665
- useFactory: (storage, baseUrl) => {
666
- return new FirebaseFileUploaderService(storage, baseUrl);
667
- },
668
- deps: [Storage, STORAGE_BASE_URL],
669
- },
670
- ],
671
- }]
672
- }] });
673
-
674
- class AngularHasuraGraphQLModule {
675
- static initializeApp(options) {
676
- return {
677
- ngModule: AngularHasuraGraphQLModule,
678
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
679
- };
680
- }
681
- }
682
- AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
683
- AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
684
- AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
685
- {
686
- provide: 'HasuraConfig',
687
- useFactory: (options, platformId) => ({
688
- endpoint: options.endpoint,
689
- authOptions: options.credentials,
690
- interceptors: {
691
- request: (request) => {
692
- if (isPlatformBrowser(platformId))
693
- return request;
694
- const interval = setInterval(() => { }, 100);
695
- request.interval = interval;
696
- return request;
697
- },
698
- response: (response, request) => {
699
- if (isPlatformBrowser(platformId))
700
- return response;
701
- clearInterval(request.interval);
702
- return response;
703
- },
704
- },
705
- }),
706
- deps: [HASURA_OPTIONS, PLATFORM_ID],
707
- },
708
- {
709
- provide: 'CategoryRepository',
710
- useExisting: CategoryHasuraGraphQLRepository,
711
- },
712
- {
713
- provide: CategoryHasuraGraphQLRepository,
714
- useFactory: (options, productRepository, categoryFilterRepository) => {
715
- return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
716
- },
717
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
718
- },
719
- {
720
- provide: 'ProductRepository',
721
- useExisting: ProductHasuraGraphQLRepository,
722
- },
723
- {
724
- provide: ProductHasuraGraphQLRepository,
725
- useFactory: (hasuraConfig) => {
726
- return new ProductHasuraGraphQLRepository(hasuraConfig);
727
- },
728
- deps: ['HasuraConfig'],
729
- },
730
- {
731
- provide: 'ProductReviewsRepository',
732
- useExisting: ProductReviewsHasuraGraphQLRepository,
733
- },
734
- {
735
- provide: ProductReviewsHasuraGraphQLRepository,
736
- useFactory: (hasuraConfig) => {
737
- return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
738
- },
739
- deps: ['HasuraConfig'],
740
- },
741
- {
742
- provide: 'VariantRepository',
743
- useExisting: VariantHasuraGraphQLRepository,
744
- },
745
- {
746
- provide: VariantHasuraGraphQLRepository,
747
- useFactory: (hasuraConfig) => {
748
- return new VariantHasuraGraphQLRepository(hasuraConfig);
749
- },
750
- deps: ['HasuraConfig'],
751
- },
752
- {
753
- provide: 'CategoryFilterRepository',
754
- useExisting: CategoryFilterHasuraGraphQLRepository,
755
- },
756
- {
757
- provide: CategoryFilterHasuraGraphQLRepository,
758
- useFactory: (options) => {
759
- return new CategoryFilterHasuraGraphQLRepository(options);
760
- },
761
- deps: ['HasuraConfig'],
762
- },
763
- {
764
- provide: 'FilterOptionRepository',
765
- useExisting: FilterOptionHasuraGraphQLRepository,
766
- },
767
- {
768
- provide: FilterOptionHasuraGraphQLRepository,
769
- useFactory: (options) => {
770
- return new FilterOptionHasuraGraphQLRepository(options);
771
- },
772
- deps: ['HasuraConfig'],
773
- },
774
- {
775
- provide: 'FilterRepository',
776
- useExisting: FilterHasuraGraphQLRepository,
777
- },
778
- {
779
- provide: FilterHasuraGraphQLRepository,
780
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
781
- return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
782
- },
783
- deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
784
- },
785
- {
786
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
787
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
788
- deps: ['HasuraConfig'],
789
- },
790
- {
791
- provide: 'CategoryCollectionChildrenRepository',
792
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
793
- },
794
- {
795
- provide: WishlistHasuraGraphQLRepository,
796
- useFactory: (options, categoryFilterRepository) => {
797
- return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
798
- },
799
- deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
800
- },
801
- {
802
- provide: 'WishlistRepository',
803
- useExisting: WishlistHasuraGraphQLRepository,
804
- },
805
- ] });
806
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
807
- type: NgModule,
808
- args: [{
809
- providers: [
810
- {
811
- provide: 'HasuraConfig',
812
- useFactory: (options, platformId) => ({
813
- endpoint: options.endpoint,
814
- authOptions: options.credentials,
815
- interceptors: {
816
- request: (request) => {
817
- if (isPlatformBrowser(platformId))
818
- return request;
819
- const interval = setInterval(() => { }, 100);
820
- request.interval = interval;
821
- return request;
822
- },
823
- response: (response, request) => {
824
- if (isPlatformBrowser(platformId))
825
- return response;
826
- clearInterval(request.interval);
827
- return response;
828
- },
829
- },
830
- }),
831
- deps: [HASURA_OPTIONS, PLATFORM_ID],
832
- },
833
- {
834
- provide: 'CategoryRepository',
835
- useExisting: CategoryHasuraGraphQLRepository,
836
- },
837
- {
838
- provide: CategoryHasuraGraphQLRepository,
839
- useFactory: (options, productRepository, categoryFilterRepository) => {
840
- return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
841
- },
842
- deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
843
- },
844
- {
845
- provide: 'ProductRepository',
846
- useExisting: ProductHasuraGraphQLRepository,
847
- },
848
- {
849
- provide: ProductHasuraGraphQLRepository,
850
- useFactory: (hasuraConfig) => {
851
- return new ProductHasuraGraphQLRepository(hasuraConfig);
852
- },
853
- deps: ['HasuraConfig'],
854
- },
855
- {
856
- provide: 'ProductReviewsRepository',
857
- useExisting: ProductReviewsHasuraGraphQLRepository,
858
- },
859
- {
860
- provide: ProductReviewsHasuraGraphQLRepository,
861
- useFactory: (hasuraConfig) => {
862
- return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
863
- },
864
- deps: ['HasuraConfig'],
865
- },
866
- {
867
- provide: 'VariantRepository',
868
- useExisting: VariantHasuraGraphQLRepository,
869
- },
870
- {
871
- provide: VariantHasuraGraphQLRepository,
872
- useFactory: (hasuraConfig) => {
873
- return new VariantHasuraGraphQLRepository(hasuraConfig);
874
- },
875
- deps: ['HasuraConfig'],
876
- },
877
- {
878
- provide: 'CategoryFilterRepository',
879
- useExisting: CategoryFilterHasuraGraphQLRepository,
880
- },
881
- {
882
- provide: CategoryFilterHasuraGraphQLRepository,
883
- useFactory: (options) => {
884
- return new CategoryFilterHasuraGraphQLRepository(options);
885
- },
886
- deps: ['HasuraConfig'],
887
- },
888
- {
889
- provide: 'FilterOptionRepository',
890
- useExisting: FilterOptionHasuraGraphQLRepository,
891
- },
892
- {
893
- provide: FilterOptionHasuraGraphQLRepository,
894
- useFactory: (options) => {
895
- return new FilterOptionHasuraGraphQLRepository(options);
896
- },
897
- deps: ['HasuraConfig'],
898
- },
899
- {
900
- provide: 'FilterRepository',
901
- useExisting: FilterHasuraGraphQLRepository,
902
- },
903
- {
904
- provide: FilterHasuraGraphQLRepository,
905
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
906
- return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
907
- },
908
- deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
909
- },
910
- {
911
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
912
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
913
- deps: ['HasuraConfig'],
914
- },
915
- {
916
- provide: 'CategoryCollectionChildrenRepository',
917
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
918
- },
919
- {
920
- provide: WishlistHasuraGraphQLRepository,
921
- useFactory: (options, categoryFilterRepository) => {
922
- return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
923
- },
924
- deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
925
- },
926
- {
927
- provide: 'WishlistRepository',
928
- useExisting: WishlistHasuraGraphQLRepository,
929
- },
930
- ],
931
- }]
932
- }] });
933
-
934
- class CookieDataPersistence {
935
- get(key) {
936
- return of(cookie.get(key));
937
- }
938
- remove(key) {
939
- return of(cookie.remove(key));
940
- }
941
- set(key, value) {
942
- return from(cookie.set(key, value)).pipe(map(() => { }));
943
- }
944
- }
945
- CookieDataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
946
- CookieDataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence });
947
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, decorators: [{
948
- type: Injectable
949
- }] });
950
-
951
- class AuthService {
952
- constructor(angularFireAuth, userRepository) {
953
- this.angularFireAuth = angularFireAuth;
954
- this.userRepository = userRepository;
955
- }
956
- getAuthstate() {
957
- const observables = [this.getFireUser(), this.getUser()];
958
- return combineLatest(observables).pipe(map(([fireUser, user]) => ({
959
- user,
960
- isAnonymous: fireUser?.isAnonymous,
961
- })));
962
- }
963
- getUser() {
964
- return this.getFireUser().pipe(map((user) => user?.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
965
- }
966
- getTokenId() {
967
- return from(getIdToken(this.angularFireAuth.currentUser));
968
- }
969
- getFireUser() {
970
- return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
971
- }
972
- }
973
- 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 });
974
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
975
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
976
- type: Injectable
977
- }], ctorParameters: function () { return [{ type: i1.Auth }, { type: undefined, decorators: [{
978
- type: Inject,
979
- args: ['UserRepository']
980
- }] }]; } });
981
-
982
- class CouponService {
983
- constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
984
- this.couponRepository = couponRepository;
985
- this.defaultShop = defaultShop;
986
- this.orderRepository = orderRepository;
987
- this.categoryRepository = categoryRepository;
988
- this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
989
- }
990
- checkCoupon(nickname, checkoutType, checkout, plan) {
991
- return from(this.couponRepository
992
- .find({
993
- filters: {
994
- nickname: { operator: Where.EQUALS, value: nickname },
995
- active: { operator: Where.EQUALS, value: true },
996
- },
997
- })
998
- .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
999
- }
1000
- async couponValidation(coupon, checkoutType) {
1001
- if (!coupon)
1002
- throw 'Cupom inválido.';
1003
- if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
1004
- throw 'Cupom inválido.';
1005
- if (coupon?.expiresIn && coupon?.expiresIn.getTime() < new Date().getTime())
1006
- throw 'Cupom expirado.';
1007
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
1008
- if (!isInShop)
1009
- throw 'Cupom inválido para loja.';
1010
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
1011
- if (!isCheckoutType)
1012
- throw 'Cupom inválido. Erro de checkout.';
1013
- return coupon;
1014
- }
1015
- async couponRulesValidation(coupon, checkoutType, checkout, plan) {
1016
- if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
1017
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
1018
- throw 'Cupom inválido para sua assinatura.';
1019
- return coupon;
1020
- }
1021
- const validUser = this.coupomUserValidation(coupon, checkout?.user);
1022
- if (!validUser)
1023
- throw 'Usuário não elegível.';
1024
- const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
1025
- if (couponUseLimits.firstOrder) {
1026
- const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
1027
- if (couponUseLimits.firstOrder && ordersUser.length >= 1)
1028
- throw 'Limite de uso atingido';
1029
- }
1030
- if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
1031
- const orders = await this.getOrdersWithCoupon(coupon);
1032
- if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
1033
- throw 'Limite de uso atingido.';
1034
- if (couponUseLimits.limitedPerUser) {
1035
- const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
1036
- if (ordersWithUser > 0)
1037
- throw 'Limite de uso por usuário atingido.';
1038
- }
1039
- }
1040
- const hasProductCategories = await this.hasProductCategories(coupon, checkout);
1041
- if (!hasProductCategories)
1042
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1043
- const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
1044
- if (!hasMinSubTotal)
1045
- throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
1046
- return coupon;
1047
- }
1048
- calcDiscountSubscription(coupon, checkout) {
1049
- let discount = 0;
1050
- if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
1051
- discount = coupon.discount.subscription.value;
1052
- else
1053
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
1054
- return of(discount);
1055
- }
1056
- async calcDiscountShopping(coupon, checkout) {
1057
- let discount = 0;
1058
- if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
1059
- discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1060
- }
1061
- else {
1062
- discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1063
- }
1064
- return discount;
1065
- }
1066
- async calcDiscountByType(type, value, categories, checkout) {
1067
- let discount = 0;
1068
- let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
1069
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1070
- if (type == CouponTypes.ABSOLUTE) {
1071
- discount = value > subTotal ? subTotal : value;
1072
- }
1073
- else {
1074
- discount = subTotal * (value / 100);
1075
- }
1076
- return discount;
1077
- }
1078
- async hasMinSubTotal(coupon, checkout) {
1079
- if (!coupon.minSubTotalValue)
1080
- return true;
1081
- let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1082
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1083
- if (coupon.minSubTotalValue <= subTotal)
1084
- return true;
1085
- return false;
1086
- }
1087
- async hasProductCategories(coupon, checkout) {
1088
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
1089
- return true;
1090
- }
1091
- const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
1092
- const hasCategories = checkout.lineItems?.filter((i) => {
1093
- if (!i.categories || !i.categories?.length)
1094
- return true;
1095
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1096
- });
1097
- return hasCategories.length ? true : false;
1098
- }
1099
- coupomUserValidation(coupon, user) {
1100
- if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
1101
- return true;
1102
- let userTypes = [];
1103
- if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
1104
- this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
1105
- userTypes.push(Exclusivities.COLLABORATORS);
1106
- if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
1107
- coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
1108
- userTypes.push(Exclusivities.SPECIFIC_USER);
1109
- if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
1110
- user.isSubscriber &&
1111
- user.subscriptionPlan != '')
1112
- userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
1113
- if (user.isSubscriber &&
1114
- user.subscriptionPlan == '' &&
1115
- coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
1116
- userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
1117
- if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
1118
- userTypes.push(Exclusivities.NON_SUBSCRIBER);
1119
- return coupon.exclusivityType.some((r) => userTypes.includes(r));
1120
- }
1121
- async getCouponCategoriesId(productsCategories) {
1122
- const couponCategories = [];
1123
- for (let index = 0; index < productsCategories.length; index++) {
1124
- const category = await this.categoryRepository.get({
1125
- id: productsCategories[index],
1126
- });
1127
- if (category) {
1128
- const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
1129
- couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
1130
- }
1131
- }
1132
- return [...new Set(couponCategories)];
1133
- }
1134
- async getLineItensEligebleForDiscount(productsCategories, checkout) {
1135
- let lineItensDiscount = [];
1136
- const couponCategories = await this.getCouponCategoriesId(productsCategories);
1137
- if (productsCategories && productsCategories.length) {
1138
- lineItensDiscount = checkout.lineItems?.filter((i) => {
1139
- if (i.categories?.length) {
1140
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1141
- }
1142
- return true;
1143
- });
1144
- }
1145
- else {
1146
- lineItensDiscount = checkout.lineItems;
1147
- }
1148
- return lineItensDiscount;
1149
- }
1150
- calcCheckoutSubtotal(lineItens, user, shop) {
1151
- return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
1152
- ? acc + curr.price?.subscriberPrice * curr.quantity
1153
- : acc + curr.pricePaid * curr.quantity, 0) || 0);
1154
- }
1155
- async getOrdersWithCoupon(coupon) {
1156
- return await this.orderRepository
1157
- .find({
1158
- filters: {
1159
- coupon: { id: coupon.id },
1160
- payment: { status: 'paid' },
1161
- },
1162
- })
1163
- .then((result) => result.data);
1164
- }
1165
- async getOrdersFromUser(email) {
1166
- return await this.orderRepository
1167
- .find({
1168
- filters: {
1169
- user: { email: { operator: Where.EQUALS, value: email } },
1170
- payment: { status: 'paid' },
1171
- },
1172
- })
1173
- .then((result) => result.data);
1174
- }
1175
- countOrdersWithUser(orders, email) {
1176
- return orders.filter((o) => o.user.email == email).length;
1177
- }
1178
- getCouponUseLimits(coupon, checkoutType, user) {
1179
- let couponUseLimits;
1180
- if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
1181
- couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
1182
- }
1183
- else {
1184
- couponUseLimits = coupon.useLimits.subscription;
1185
- }
1186
- return couponUseLimits;
1187
- }
1188
- }
1189
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1190
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
1191
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
1192
- type: Injectable,
1193
- args: [{
1194
- providedIn: 'root',
1195
- }]
1196
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1197
- type: Inject,
1198
- args: ['CouponRepository']
1199
- }] }, { type: i1$2.Shops, decorators: [{
1200
- type: Inject,
1201
- args: [DEFAULT_SHOP]
1202
- }] }, { type: undefined, decorators: [{
1203
- type: Inject,
1204
- args: ['OrderRepository']
1205
- }] }, { type: undefined, decorators: [{
1206
- type: Inject,
1207
- args: ['CategoryRepository']
1208
- }] }]; } });
1209
-
1210
- class CheckoutService {
1211
- constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
1212
- this.couponService = couponService;
1213
- this.checkoutRepository = checkoutRepository;
1214
- this.userRepository = userRepository;
1215
- this.defaultShop = defaultShop;
1216
- this.dataPersistence = dataPersistence;
1217
- }
1218
- getCheckout(checkoutData) {
1219
- return this.dataPersistence
1220
- .get('checkoutId')
1221
- .pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
1222
- }
1223
- getUserByCheckout(checkoutId) {
1224
- return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
1225
- }
1226
- updateCheckoutLineItems(checkout) {
1227
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1228
- }
1229
- updateCheckoutUser(checkout) {
1230
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1231
- }
1232
- clearCheckoutFromSession() {
1233
- return this.dataPersistence.remove('checkoutId');
1234
- }
1235
- calcDiscount(coupon) {
1236
- return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
1237
- }
1238
- checkCoupon(nickname, checkoutType) {
1239
- return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
1240
- }
1241
- async createCheckout(checkoutData) {
1242
- const checkout = await this.checkoutRepository.create({
1243
- createdAt: new Date(),
1244
- ...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1245
- shop: checkoutData?.shop || this.defaultShop,
1246
- });
1247
- await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
1248
- return checkout;
1249
- }
1250
- }
1251
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }, { token: PERSISTENCE_PROVIDER }], target: i0.ɵɵFactoryTarget.Injectable });
1252
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
1253
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
1254
- type: Injectable
1255
- }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
1256
- type: Inject,
1257
- args: ['CheckoutRepository']
1258
- }] }, { type: undefined, decorators: [{
1259
- type: Inject,
1260
- args: ['UserRepository']
1261
- }] }, { type: i1$2.Shops, decorators: [{
1262
- type: Inject,
1263
- args: [DEFAULT_SHOP]
1264
- }] }, { type: undefined, decorators: [{
1265
- type: Inject,
1266
- args: [PERSISTENCE_PROVIDER]
1267
- }] }]; } });
1268
-
1269
- class CartService {
1270
- constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
1271
- this.authService = authService;
1272
- this.checkoutService = checkoutService;
1273
- this.defaultShop = defaultShop;
1274
- this.productRepository = productRepository;
1275
- this.categoryRepository = categoryRepository;
1276
- this.variantRepository = variantRepository;
1277
- this.buy2WinRepository = buy2WinRepository;
1278
- this.cartSubject = new Subject();
1279
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
1280
- const items = [];
1281
- const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
1282
- if (index > -1) {
1283
- checkoutLoaded.lineItems[index].quantity += quantity;
1284
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
1285
- }
1286
- else
1287
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
1288
- return this.checkoutService
1289
- .updateCheckoutLineItems(checkoutLoaded)
1290
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
1291
- }));
1292
- this.generateCartObject = (items) => items?.reduce((cart, item) => ({
1293
- ...cart,
1294
- [item.id]: LineItem.toInstance({
1295
- ...(cart[item.id] || item),
1296
- quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
1297
- }),
1298
- }), {}) || {};
1299
- this.buildLineItem = async ({ checkout, item, quantity, }) => {
1300
- const product = await this.getProductData(item.id);
1301
- item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
1302
- if (this.checkMaxStock(item, quantity || 0))
1303
- throw new Error('Desculpe! Temos apenas ' + item.stock?.quantity + ' em estoque.');
1304
- const image = item.image || item.images?.shift();
1305
- const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
1306
- const isGift = item.isGift || null;
1307
- const pricePaid = this.getProductPrice({
1308
- product: item,
1309
- shop: checkout.shop || this.defaultShop,
1310
- isSubscriber: checkout.user?.isSubscriber,
1311
- });
1312
- RoundProductPricesHelper.roundProductPrices(item);
1313
- return {
1314
- checkout,
1315
- lineItem: LineItem.toInstance({
1316
- id,
1317
- name: name ?? product.name,
1318
- EAN: EAN ?? product.EAN,
1319
- brand: product.brand,
1320
- slug: slug ?? product.slug,
1321
- sku: sku ?? product.sku,
1322
- stock,
1323
- price: this.roundPrice(price),
1324
- image,
1325
- weight: weight ?? product.weight,
1326
- quantity: (item.quantity || 0) + (quantity || 0),
1327
- pricePaid,
1328
- categories: product.categories ?? [],
1329
- isGift: isGift ?? null,
1330
- costPrice: product.costPrice ?? 0,
1331
- type,
1332
- }),
1333
- };
1334
- };
1335
- this.getProductPrice = ({ product, isSubscriber, }) => {
1336
- const info = product.price;
1337
- if (product.isGift)
1338
- return 0;
1339
- return isSubscriber && info.subscriberPrice > 0
1340
- ? Number(info.subscriberPrice.toFixed(2))
1341
- : Number(info.price.toFixed(2));
1342
- };
1343
- this.checkMaxStock = (item, quantity) => {
1344
- const maxStock = item.stock?.quantity || 0;
1345
- const currentItemAmount = item.quantity || 0;
1346
- return currentItemAmount + quantity > maxStock;
1347
- };
1348
- }
1349
- addItem(item, quantity = 1) {
1350
- return from(this.checkoutService.getCheckout()).pipe(concatMap(async (checkout) => await this.buildLineItem({ checkout, item, quantity: quantity || 1 })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
1351
- }
1352
- decreaseItem(item) {
1353
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1354
- const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id);
1355
- if (!isNil(checkoutItem))
1356
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
1357
- return checkout;
1358
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1359
- }
1360
- getCart(checkout) {
1361
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1362
- return this.cartSubject;
1363
- }
1364
- /**
1365
- * @deprecated The method should not be used
1366
- */
1367
- getVariantPriceDiscount(item) {
1368
- return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
1369
- }
1370
- removeItem(item) {
1371
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1372
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
1373
- if (index >= 0)
1374
- checkout.lineItems.splice(index, 1);
1375
- return checkout;
1376
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1377
- }
1378
- updateUserCart(user) {
1379
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
1380
- .updateCheckoutLineItems(Checkout.toInstance({
1381
- ...checkout.toPlain(),
1382
- lineItems: checkout.lineItems?.length
1383
- ? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem))
1384
- : [],
1385
- }))
1386
- .toPromise()), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1387
- }
1388
- clearCart() {
1389
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1390
- this.checkoutService.clearCheckoutFromSession();
1391
- return checkout;
1392
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1393
- }
1394
- buildCartFromCheckout(checkoutData) {
1395
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1396
- }
1397
- roundPrice(productPrice) {
1398
- const { price, fullPrice, subscriberPrice } = productPrice;
1399
- return {
1400
- ...productPrice,
1401
- price: Number(price.toFixed(2)),
1402
- fullPrice: Number(fullPrice.toFixed(2)),
1403
- ...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
1404
- };
1405
- }
1406
- async getProductData(productId) {
1407
- let product;
1408
- let variant;
1409
- try {
1410
- product = await this.productRepository.get({ id: productId });
1411
- }
1412
- catch (error) {
1413
- if (!(error instanceof NotFoundError))
1414
- throw error;
1415
- const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
1416
- variant = variants.shift();
1417
- if (!variant)
1418
- throw error;
1419
- product = await this.productRepository.get({ id: variant.productId });
1420
- }
1421
- return {
1422
- ...product.toPlain(),
1423
- ...(variant && { ...variant.toPlain() }),
1424
- };
1425
- }
1426
- getGifts() {
1427
- return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
1428
- const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1429
- if (!notGiftItems.length)
1430
- return { ...checkout, lineItems: [] };
1431
- const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1432
- const campaigns = await this.buy2WinRepository
1433
- .find({
1434
- filters: {
1435
- active: { operator: Where.EQUALS, value: true },
1436
- shop: { operator: Where.EQUALS, value: this.defaultShop },
1437
- },
1438
- })
1439
- .then((data) => data.data);
1440
- if (!campaigns.length)
1441
- return { ...checkout, lineItems: notGiftItems };
1442
- const elegibleCampaigns = [];
1443
- for (const campaign of campaigns) {
1444
- const today = new Date().getTime();
1445
- if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
1446
- continue;
1447
- if (campaign.activeCategory) {
1448
- const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1449
- const categoriesCampaingFullTree = [];
1450
- for (const id of categoriesCampaing) {
1451
- const children = await this.categoryRepository.getChildren(parseInt(id));
1452
- categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1453
- }
1454
- const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1455
- const filterProductsCategories = checkout.lineItems.filter((l) => {
1456
- if (!l.categories || !l.categories?.length)
1457
- return true;
1458
- return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1459
- });
1460
- if (filterProductsCategories.length) {
1461
- const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1462
- if (cartTotalCategories >= campaign.cartValueMin)
1463
- elegibleCampaigns.push(campaign);
1464
- }
1465
- }
1466
- else {
1467
- if (campaign.cartValue && campaign.cartValue > 0) {
1468
- if (campaign.cartValue <= cartTotal)
1469
- elegibleCampaigns.push(campaign);
1470
- }
1471
- }
1472
- }
1473
- if (!elegibleCampaigns.length)
1474
- return { ...checkout, lineItems: notGiftItems };
1475
- const campaingnProducts = [];
1476
- for (const campaign of elegibleCampaigns) {
1477
- let elegibleProducts = [];
1478
- for (const product of campaign.products) {
1479
- const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
1480
- if (!productData.length)
1481
- continue;
1482
- const gift = productData.shift();
1483
- if (gift.stock.quantity < 1)
1484
- continue;
1485
- elegibleProducts.push(gift);
1486
- }
1487
- campaingnProducts.push(elegibleProducts);
1488
- }
1489
- if (!campaingnProducts.length)
1490
- return { ...checkout, lineItems: notGiftItems };
1491
- const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1492
- return { ...checkout, lineItems: notGiftItems.concat(gifts) };
1493
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1494
- }
1495
- giftToLineItems(items) {
1496
- return items.map((item) => {
1497
- const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
1498
- const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
1499
- return LineItem.toInstance({
1500
- brand,
1501
- categories,
1502
- id: id.toString(),
1503
- name,
1504
- price,
1505
- sku,
1506
- slug,
1507
- stock,
1508
- weight,
1509
- EAN,
1510
- image,
1511
- pricePaid: 0,
1512
- quantity: 1,
1513
- isGift: true,
1514
- });
1515
- });
1516
- }
1517
- }
1518
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1519
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1520
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1521
- type: Injectable
1522
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
1523
- type: Inject,
1524
- args: [DEFAULT_SHOP]
1525
- }] }, { type: undefined, decorators: [{
1526
- type: Inject,
1527
- args: ['ProductRepository']
1528
- }] }, { type: undefined, decorators: [{
1529
- type: Inject,
1530
- args: ['CategoryRepository']
1531
- }] }, { type: undefined, decorators: [{
1532
- type: Inject,
1533
- args: ['VariantRepository']
1534
- }] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
1535
- type: Inject,
1536
- args: ['Buy2WinRepository']
1537
- }] }]; } });
1538
-
1539
- class NewCategoryStructureAdapter {
1540
- constructor(categoryRepository) {
1541
- this.categoryRepository = categoryRepository;
1542
- }
1543
- async buildProductFilterByCategory(category) {
1544
- const loadedCategory = await this.getCategory(category);
1545
- if (loadedCategory.isCollection)
1546
- return { id: { operator: Where.IN, value: loadedCategory.products } };
1547
- const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1548
- return {
1549
- category: {
1550
- id: {
1551
- operator: Where.IN,
1552
- value: categoryIds,
1553
- },
1554
- },
1555
- };
1556
- }
1557
- async getAllCategoriesIdFromCategory(category) {
1558
- return this.categoryRepository
1559
- .getChildren(+category.id)
1560
- .then((categories) => categories.map((category) => category.id.toString()));
1561
- }
1562
- async getCategory(category) {
1563
- const collectionCategory = category.isCollection ||
1564
- (isNil(category.isCollection) && !category.products?.length) ||
1565
- category.isWishlist ||
1566
- category.brandCategory;
1567
- return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
1568
- }
1569
- }
1570
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1571
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1572
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1573
- type: Injectable
1574
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1575
- type: Inject,
1576
- args: ['CategoryRepository']
1577
- }] }]; } });
1578
-
1579
- class OldCategoryStructureAdapter {
1580
- constructor(categoryRepository) {
1581
- this.categoryRepository = categoryRepository;
1582
- }
1583
- async buildProductFilterByCategory(category) {
1584
- const productsIds = category.products?.length
1585
- ? category.products
1586
- : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1587
- return { id: { operator: Where.IN, value: productsIds } };
1588
- }
1589
- }
1590
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1591
- OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1592
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1593
- type: Injectable
1594
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1595
- type: Inject,
1596
- args: ['CategoryRepository']
1597
- }] }]; } });
1598
-
1599
- class CatalogService {
1600
- constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
1601
- this.productRepository = productRepository;
1602
- this.categoryRepository = categoryRepository;
1603
- this.categoryStructureAdapter = categoryStructureAdapter;
1604
- this.shop = shop;
1605
- this.productIndex = productIndex;
1606
- this.productsByTerm = {};
1607
- this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1608
- const filters = {};
1609
- if (clubDiscount?.length)
1610
- set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1611
- if (brands?.length)
1612
- filters.brand = { operator: Where.IN, value: brands };
1613
- if (gender?.length)
1614
- filters.gender = { operator: Where.IN, value: gender };
1615
- if (prices?.min || prices?.max)
1616
- set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1617
- ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1618
- ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1619
- ]);
1620
- if (rate)
1621
- filters.rate = { operator: Where.GTE, value: rate };
1622
- if (tags?.length)
1623
- filters.tags = { operator: Where.LIKE, value: tags };
1624
- if (customOptions?.length)
1625
- filters.filters = { operator: Where.LIKE, value: customOptions };
1626
- return filters;
1627
- };
1628
- this.buildSortQuery = (sort) => {
1629
- if (!sort || sort === 'most-relevant')
1630
- return {};
1631
- if (sort === 'best-sellers')
1632
- return {
1633
- shoppingCount: 'desc',
1634
- rate: 'desc',
1635
- stock: 'desc',
1636
- name: 'asc',
1637
- };
1638
- if (sort === 'biggest-price')
1639
- return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
1640
- if (sort === 'lowest-price')
1641
- return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
1642
- if (sort === 'best-rating')
1643
- return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
1644
- if (sort === 'news')
1645
- return { createdAt: 'desc' };
1646
- if (sort === 'biggest-discount')
1647
- return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
1648
- };
1649
- this.buildLimitQuery = (options) => {
1650
- const limit = options?.perPage || 20;
1651
- return {
1652
- limit,
1653
- offset: ((options?.page || 1) - 1) * limit,
1654
- };
1655
- };
1656
- this.hasProfile = (options) => 'profile' in options;
1657
- this.hasTerm = (options) => 'term' in options;
1658
- this.hasCategory = (options) => 'category' in options;
1659
- }
1660
- async fetchProducts(options) {
1661
- const limits = this.buildLimitQuery(options);
1662
- if (this.hasProfile(options) && options.filters?.customOptions)
1663
- throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
1664
- if (this.hasProfile(options) && options.filters?.tags)
1665
- throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1666
- if (this.hasTerm(options) && options.filters?.customOptions)
1667
- throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1668
- return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
1669
- products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1670
- pages: Math.ceil(total / limits.limit),
1671
- prices: {
1672
- price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
1673
- subscriberPrice: {
1674
- min: +minimal?.price?.subscriberPrice?.toFixed(2),
1675
- max: +maximum?.price?.subscriberPrice?.toFixed(2),
1676
- },
1677
- },
1678
- brands: distinct?.brand,
1679
- }));
1680
- }
1681
- async findCatalog(options, limits) {
1682
- if (this.hasTerm(options) && options.sort === 'most-relevant') {
1683
- const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
1684
- return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1685
- }
1686
- if (this.hasCategory(options) && options.sort === 'most-relevant') {
1687
- const productsIds = await this.productRepository
1688
- .find({
1689
- filters: {
1690
- ...(await this.buildMainFilter(options)),
1691
- },
1692
- })
1693
- .then((products) => products.data.map((product) => product.id));
1694
- return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1695
- }
1696
- const repoParams = {
1697
- filters: {
1698
- ...(await this.buildMainFilter(options)),
1699
- ...this.buildFilterQuery(options?.filters || {}),
1700
- },
1701
- ...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
1702
- limits,
1703
- options: {
1704
- minimal: ['price'],
1705
- maximum: ['price'],
1706
- ...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
1707
- },
1708
- };
1709
- if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1710
- return this.productRepository.findCatalog(repoParams);
1711
- return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1712
- }
1713
- async buildMainFilter({ category, profile, term, }) {
1714
- if (category)
1715
- return this.categoryStructureAdapter.buildProductFilterByCategory(category);
1716
- if (profile)
1717
- return { tags: { operator: Where.LIKE, value: profile } };
1718
- if (term)
1719
- return this.productIndex
1720
- .search(term, 999, this.shop)
1721
- .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1722
- }
1723
- async findCatalogAndSortByMostRevelant(productIds, options, limits) {
1724
- const totalResult = await this.productRepository.findCatalog({
1725
- fields: ['id', 'stock'],
1726
- filters: {
1727
- id: { operator: Where.IN, value: productIds },
1728
- ...this.buildFilterQuery(options?.filters || {}),
1729
- },
1730
- options: {
1731
- minimal: ['price'],
1732
- maximum: ['price'],
1733
- distinct: ['brand'],
1734
- },
1735
- }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1736
- const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1737
- const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1738
- const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1739
- const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1740
- const limitedProductId = productIdsStock
1741
- .concat(productIdsStockOut)
1742
- .slice(limits.offset, limits.offset + limits.limit);
1743
- const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1744
- const productResult = await this.productRepository.findCatalog({
1745
- filters: {
1746
- id: { operator: Where.IN, value: orderedId },
1747
- },
1748
- });
1749
- return {
1750
- data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1751
- count: totalResult.count,
1752
- maximum: totalResult.maximum,
1753
- minimal: totalResult.minimal,
1754
- distinct: totalResult.distinct,
1755
- };
1756
- }
1757
- async findCatalogIdsByElasticSearch(term) {
1758
- if (this.productsByTerm[term])
1759
- return this.productsByTerm[term];
1760
- return (this.productsByTerm[term] = await this.productIndex
1761
- .search(term, 999, this.shop)
1762
- .then(({ hits: products }) => {
1763
- const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1764
- const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1765
- const sorted = [...withStock, ...withOutStock];
1766
- return [...new Set(sorted.map(({ _source }) => _source.id))];
1767
- }));
1768
- }
1769
- }
1770
- CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1771
- CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1772
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1773
- type: Injectable
1774
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1775
- type: Inject,
1776
- args: ['ProductRepository']
1777
- }] }, { type: undefined, decorators: [{
1778
- type: Inject,
1779
- args: ['CategoryRepository']
1780
- }] }, { type: undefined, decorators: [{
1781
- type: Inject,
1782
- args: [CATEGORY_STRUCTURE]
1783
- }] }, { type: i1$2.Shops, decorators: [{
1784
- type: Inject,
1785
- args: [DEFAULT_SHOP]
1786
- }] }, { type: i1$2.ProductsIndex }]; } });
1787
-
1788
- class CategoryService {
1789
- constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1790
- this.productRepository = productRepository;
1791
- this.categoryRepository = categoryRepository;
1792
- this.categoryFilterRepository = categoryFilterRepository;
1793
- this.categoryStructureAdapter = categoryStructureAdapter;
1794
- this.shop = shop;
1795
- }
1796
- async fetchBrands(category, options) {
1797
- const brands = await this.productRepository
1798
- .findCatalog({
1799
- filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
1800
- fields: ['brand'],
1801
- }, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
1802
- .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1803
- return this.categoryRepository
1804
- .find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
1805
- .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1806
- }
1807
- async fetchFilterOptions(category) {
1808
- return await this.categoryFilterRepository
1809
- .find({ filters: { categoryId: +category.id } })
1810
- .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1811
- }
1812
- }
1813
- CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1814
- CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1815
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1816
- type: Injectable
1817
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1818
- type: Inject,
1819
- args: ['ProductRepository']
1820
- }] }, { type: undefined, decorators: [{
1821
- type: Inject,
1822
- args: ['CategoryRepository']
1823
- }] }, { type: undefined, decorators: [{
1824
- type: Inject,
1825
- args: ['CategoryFilterRepository']
1826
- }] }, { type: undefined, decorators: [{
1827
- type: Inject,
1828
- args: [CATEGORY_STRUCTURE]
1829
- }] }, { type: i1$2.Shops, decorators: [{
1830
- type: Inject,
1831
- args: [DEFAULT_SHOP]
1832
- }] }]; } });
1833
-
1834
- var ProductSorts;
1835
- (function (ProductSorts) {
1836
- ProductSorts["MOST_RELEVANT"] = "most-relevant";
1837
- ProductSorts["BEST_SELLER"] = "best-sellers";
1838
- ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1839
- ProductSorts["LOWEST_PRICE"] = "lowest-price";
1840
- ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1841
- ProductSorts["BEST_RATING"] = "best-rating";
1842
- ProductSorts["NEWS"] = "news";
1843
- })(ProductSorts || (ProductSorts = {}));
1844
-
1845
- class CategoryWithTree extends Category {
1846
- }
1847
- __decorate([
1848
- Type(() => CategoryWithTree),
1849
- __metadata("design:type", Array)
1850
- ], CategoryWithTree.prototype, "children", void 0);
1851
-
1852
- class WishlistService {
1853
- constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
1854
- this.wishlistRepository = wishlistRepository;
1855
- this.shop = shop;
1856
- const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1857
- this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
1858
- this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1859
- }
1860
- getCatalogService() {
1861
- return this.catalogService;
1862
- }
1863
- getCategoryService() {
1864
- return this.categoryService;
1865
- }
1866
- async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1867
- const data = {
1868
- slug: '',
1869
- name: title,
1870
- description,
1871
- metadata: {
1872
- title: `${userFullName} - ${title}`,
1873
- description: `${userFullName} - ${description}`,
1874
- },
1875
- shop: this.shop,
1876
- shops: [this.shop],
1877
- personId,
1878
- personName: userFullName,
1879
- personPhoto: userPhoto,
1880
- brandCategory: false,
1881
- published: true,
1882
- theme,
1883
- bannerUrl,
1884
- };
1885
- const newWishlist = await this.wishlistRepository.create(data);
1886
- await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1887
- return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
1888
- }
1889
- update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1890
- const data = {
1891
- id,
1892
- name: title,
1893
- description,
1894
- metadata: {
1895
- title: `${userFullName} - ${title}`,
1896
- description: `${userFullName} - ${description}`,
1897
- },
1898
- personName: userFullName,
1899
- personPhoto: userPhoto,
1900
- theme,
1901
- bannerUrl,
1902
- };
1903
- return this.wishlistRepository.update(data);
1904
- }
1905
- delete(wishlistId) {
1906
- return this.wishlistRepository.delete({ id: wishlistId });
1907
- }
1908
- getWishlistBySlug(slug) {
1909
- const [id] = slug.split('-');
1910
- if (+id)
1911
- return this.wishlistRepository.get({ id });
1912
- return this.wishlistRepository.getWishlistBySlug(slug);
1913
- }
1914
- getWishlistsByPerson(personId) {
1915
- return this.wishlistRepository.getWishlistByPerson(personId);
1916
- }
1917
- async addProduct(wishlistId, productId) {
1918
- const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1919
- const hasProduct = wishlist.products.some((p) => p == productId);
1920
- if (!hasProduct) {
1921
- wishlist.products = [...wishlist.products, productId];
1922
- return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1923
- }
1924
- return wishlist;
1925
- }
1926
- async removeProduct(wishlistId, productId) {
1927
- const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1928
- const productIndex = wishlist.products.findIndex((p) => p == productId);
1929
- if (productIndex != -1) {
1930
- wishlist.products.splice(productIndex, 1);
1931
- if (!wishlist.products.length)
1932
- return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1933
- return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1934
- }
1935
- return wishlist;
1936
- }
1937
- }
1938
- WishlistService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: 'CategoryRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable });
1939
- WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1940
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1941
- type: Injectable
1942
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1943
- type: Inject,
1944
- args: ['WishlistRepository']
1945
- }] }, { type: i1$2.Shops, decorators: [{
1946
- type: Inject,
1947
- args: [DEFAULT_SHOP]
1948
- }] }, { type: undefined, decorators: [{
1949
- type: Inject,
1950
- args: ['ProductRepository']
1951
- }] }, { type: undefined, decorators: [{
1952
- type: Inject,
1953
- args: ['CategoryFilterRepository']
1954
- }] }, { type: undefined, decorators: [{
1955
- type: Inject,
1956
- args: ['CategoryRepository']
1957
- }] }, { type: i1$2.ProductsIndex }]; } });
1958
-
1959
- class CheckoutSubscriptionService {
1960
- constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
1961
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1962
- this.dataPersistence = dataPersistence;
1963
- this.couponService = couponService;
1964
- }
1965
- getCheckoutSubscription(checkoutData) {
1966
- return this.dataPersistence
1967
- .get('checkoutSubscriptionId')
1968
- .pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
1969
- }
1970
- clearCheckoutSubscriptionFromSession() {
1971
- return this.dataPersistence.remove('checkoutSubscriptionId');
1972
- }
1973
- checkCoupon(nickname, userEmail) {
1974
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
1975
- .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
1976
- .pipe()));
1977
- }
1978
- calcDiscountSubscription(coupon) {
1979
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
1980
- }
1981
- async createCheckoutSubscription(checkoutData) {
1982
- const checkout = await this.checkoutSubscriptionRepository.create({
1983
- createdAt: new Date(),
1984
- ...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1985
- });
1986
- await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
1987
- return checkout;
1988
- }
1989
- }
1990
- 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 });
1991
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
1992
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
1993
- type: Injectable
1994
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1995
- type: Inject,
1996
- args: ['CheckoutSubscriptionRepository']
1997
- }] }, { type: undefined, decorators: [{
1998
- type: Inject,
1999
- args: [PERSISTENCE_PROVIDER]
2000
- }] }, { type: CouponService }]; } });
2001
-
2002
- class UtilHelper {
2003
- static createSlug(name) {
2004
- return name
2005
- .toLowerCase()
2006
- .replace(/\s+/g, '-') // Replace spaces with -
2007
- .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
2008
- .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
2009
- .replace(/[ìíïî]/g, 'i') // Replace spaces with -
2010
- .replace(/[õòóöô]/g, 'o') // Replace spaces with -
2011
- .replace(/[ùúüû]/g, 'u') // Replace spaces with -
2012
- .replace(/[ñ]/g, 'n') // Replace spaces with -
2013
- .replace(/[ç]/g, 'c') // Replace spaces with -
2014
- .replace(/[&]/g, 'and') // Replace spaces with -
2015
- .replace(/[^\w\-]+/g, '') // Remove all non-word chars
2016
- .replace(/\-\-+/g, '-'); // Replace multiple - with single -
2017
- }
2018
- }
2019
-
2020
- class HomeShopService {
2021
- get homeId() {
2022
- if (this.defaultShop === Shops.GLAMSHOP)
2023
- return 'glamshop';
2024
- if (this.defaultShop === Shops.MENSMARKET)
2025
- return 'mens_market';
2026
- return null;
2027
- }
2028
- constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
2029
- this.categoryRepository = categoryRepository;
2030
- this.homeRepository = homeRepository;
2031
- this.productRepository = productRepository;
2032
- this.defaultShop = defaultShop;
2033
- this.buildCategoryGroupWithRequiredData = (group) => ({
2034
- category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
2035
- products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
2036
- 'id',
2037
- 'price',
2038
- 'reviews',
2039
- 'hasVariants',
2040
- 'slug',
2041
- 'sku',
2042
- 'stock',
2043
- 'costPrice',
2044
- 'images',
2045
- 'miniatures',
2046
- 'name',
2047
- 'weight',
2048
- 'rate',
2049
- 'type',
2050
- 'brand',
2051
- ]))) || [],
2052
- });
2053
- }
2054
- getHomeData() {
2055
- return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
2056
- ? of(home)
2057
- : forkJoin([
2058
- this.getDiscoverProducts(this.gender),
2059
- this.getFeaturedProducts(this.gender),
2060
- this.getVerticalProducts(this.gender),
2061
- ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2062
- discoverProducts,
2063
- featuredProducts,
2064
- verticalProducts,
2065
- })), concatMap((data) => this.saveHomeData(data)))));
2066
- }
2067
- getBanners(type) {
2068
- return this.getHomeConfiguration().pipe(map((home) => {
2069
- if (type === 'brand')
2070
- return home.brandsCarousel;
2071
- if (type === 'buyToWin')
2072
- return [home.buyToWinBanner];
2073
- if (type === 'block')
2074
- return home.blockBanners;
2075
- if (type === 'blog')
2076
- return [home.blogBanner];
2077
- return [];
2078
- }));
2079
- }
2080
- getMinValueForFreeShipping() {
2081
- return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2082
- }
2083
- getDiscoverProducts(gender) {
2084
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2085
- }
2086
- getFeaturedProducts(gender) {
2087
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2088
- }
2089
- getVerticalProducts(gender) {
2090
- return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
2091
- filters: {
2092
- categories: { operator: Where.IN, value: [category.id] },
2093
- ...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
2094
- },
2095
- limits: { limit: 12 },
2096
- })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2097
- }
2098
- getHomeConfiguration() {
2099
- return of(this.homeConfiguration).pipe(concatMap((home) => home
2100
- ? of(home)
2101
- : !this.homeId
2102
- ? throwError(new RequiredArgumentError(['homeId']))
2103
- : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2104
- }
2105
- saveHomeData(homeData) {
2106
- const data = {
2107
- createdAt: new Date(),
2108
- expiresAt: add(new Date(), { hours: 1 }),
2109
- data: homeData,
2110
- };
2111
- return from(this.homeRepository.update({
2112
- id: this.homeId,
2113
- data,
2114
- })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2115
- }
2116
- get gender() {
2117
- return this.homeId === 'mens_market' ? 'masculino' : undefined;
2118
- }
2119
- }
2120
- HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
2121
- HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
2122
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
2123
- type: Injectable
2124
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2125
- type: Inject,
2126
- args: ['CategoryRepository']
2127
- }] }, { type: undefined, decorators: [{
2128
- type: Inject,
2129
- args: ['HomeRepository']
2130
- }] }, { type: undefined, decorators: [{
2131
- type: Inject,
2132
- args: ['ProductRepository']
2133
- }] }, { type: i1$2.Shops, decorators: [{
2134
- type: Inject,
2135
- args: [DEFAULT_SHOP]
2136
- }] }]; } });
2137
-
2138
- class OrderService {
2139
- constructor(angularFirestore, orderRepository) {
2140
- this.angularFirestore = angularFirestore;
2141
- this.orderRepository = orderRepository;
2142
- this.orderSubject = new Subject();
2143
- }
2144
- getOrder(id) {
2145
- docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
2146
- .pipe(map((doc) => Order.toInstance(doc.data())))
2147
- .subscribe((doc) => this.orderSubject.next(doc));
2148
- return this.orderSubject;
2149
- }
2150
- }
2151
- 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 });
2152
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2153
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2154
- type: Injectable
2155
- }], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2156
- type: Inject,
2157
- args: ['OrderRepository']
2158
- }] }]; } });
2159
-
2160
- class ShippingService {
2161
- constructor(http, apiUrl, homeService) {
2162
- this.http = http;
2163
- this.apiUrl = apiUrl;
2164
- this.homeService = homeService;
2165
- }
2166
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2167
- return combineLatest([
2168
- this.homeService.getHomeData(),
2169
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2170
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
2171
- let shippingMethods = shippingMethodsResponse.result;
2172
- if (!shippingMethods.length)
2173
- return [];
2174
- shippingMethods = shippingMethods.map((shippingMethod) => {
2175
- if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2176
- shippingMethod.ShippingCompanyName = 'Same Day';
2177
- return shippingMethod;
2178
- });
2179
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2180
- if (this.isHolidays(datasSameDayNotAvaliable)) {
2181
- shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2182
- }
2183
- if (totalPrice >= 200) {
2184
- shippingMethods = shippingMethods.map((s) => {
2185
- if (s.serviceName !== 'Same Day')
2186
- return { ...s, totalPrice: 0 };
2187
- else
2188
- return s;
2189
- });
2190
- }
2191
- if (shop == Shops.GLAMSHOP)
2192
- return shippingMethods;
2193
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2194
- shippingMethods = shippingMethods.map((s) => {
2195
- if (s.serviceName == 'Same Day')
2196
- return { ...s, totalPrice: s.totalPrice / 2 };
2197
- else
2198
- return { ...s, totalPrice: 0 };
2199
- });
2200
- }
2201
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2202
- shippingMethods = shippingMethods.map((s) => {
2203
- return { ...s, totalPrice: s.totalPrice / 2 };
2204
- });
2205
- }
2206
- return shippingMethods;
2207
- }));
2208
- }
2209
- isFreeShippingBySubscription(shop, subscriptionPlan) {
2210
- if (!subscriptionPlan)
2211
- return false;
2212
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2213
- return true;
2214
- return false;
2215
- }
2216
- isHalfShippingBySubscription(shop, subscriptionPlan) {
2217
- if (!subscriptionPlan)
2218
- return false;
2219
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2220
- return true;
2221
- }
2222
- return false;
2223
- }
2224
- isHolidays(datas) {
2225
- const today = new Date();
2226
- for (const key in datas) {
2227
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2228
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2229
- if (start > end)
2230
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2231
- if (today >= start && today <= end)
2232
- return true;
2233
- }
2234
- return false;
2235
- }
2236
- }
2237
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
2238
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2239
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2240
- type: Injectable
2241
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
2242
- type: Inject,
2243
- args: [BACKEND_URL]
2244
- }] }, { type: HomeShopService }]; } });
2245
-
2246
- class AngularConnectModule {
2247
- static initializeApp(defaultShop, options, nameOrConfig) {
2248
- return {
2249
- ngModule: AngularConnectModule,
2250
- providers: [
2251
- {
2252
- provide: CATEGORY_STRUCTURE,
2253
- useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
2254
- ? OldCategoryStructureAdapter
2255
- : NewCategoryStructureAdapter,
2256
- },
2257
- { provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
2258
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
2259
- ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
2260
- ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2261
- ...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2262
- ...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2263
- ...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2264
- ...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
2265
- ],
2266
- };
2267
- }
2268
- }
2269
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2270
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
2271
- AngularFirebaseAuthModule,
2272
- AngularFirestoreModule,
2273
- AngularHasuraGraphQLModule] });
2274
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
2275
- AuthService,
2276
- CartService,
2277
- CatalogService,
2278
- CategoryService,
2279
- CheckoutService,
2280
- CheckoutSubscriptionService,
2281
- CouponService,
2282
- HomeShopService,
2283
- OrderService,
2284
- ShippingService,
2285
- WishlistService,
2286
- {
2287
- provide: UpdateUserImage,
2288
- useFactory: (userRepository, fileUploader) => {
2289
- return new UpdateUserImage(userRepository, fileUploader);
2290
- },
2291
- deps: ['UserRepository', 'FileUploaderService'],
2292
- },
2293
- ], imports: [provideFirebaseApp((injector) => {
2294
- const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2295
- try {
2296
- return getApp(appName);
2297
- }
2298
- catch (error) {
2299
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2300
- }
2301
- }),
2302
- AngularElasticSeachModule,
2303
- AngularFirebaseAuthModule,
2304
- AngularFirestoreModule,
2305
- AngularHasuraGraphQLModule] });
2306
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
2307
- type: NgModule,
2308
- args: [{
2309
- imports: [
2310
- provideFirebaseApp((injector) => {
2311
- const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2312
- try {
2313
- return getApp(appName);
2314
- }
2315
- catch (error) {
2316
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2317
- }
2318
- }),
2319
- AngularElasticSeachModule,
2320
- AngularFirebaseAuthModule,
2321
- AngularFirestoreModule,
2322
- AngularHasuraGraphQLModule,
2323
- ],
2324
- providers: [
2325
- AuthService,
2326
- CartService,
2327
- CatalogService,
2328
- CategoryService,
2329
- CheckoutService,
2330
- CheckoutSubscriptionService,
2331
- CouponService,
2332
- HomeShopService,
2333
- OrderService,
2334
- ShippingService,
2335
- WishlistService,
2336
- {
2337
- provide: UpdateUserImage,
2338
- useFactory: (userRepository, fileUploader) => {
2339
- return new UpdateUserImage(userRepository, fileUploader);
2340
- },
2341
- deps: ['UserRepository', 'FileUploaderService'],
2342
- },
2343
- ],
2344
- }]
2345
- }] });
2346
-
2347
- /**
2348
- * Generated bundle index. Do not edit.
2349
- */
2350
-
2351
- export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
2352
- //# sourceMappingURL=infrab4a-connect-angular.mjs.map