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