@infrab4a/connect-angular 4.3.10-beta.0 → 4.3.10-beta.1

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