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