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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +22 -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 +281 -284
  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 +2321 -2325
  68. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
  69. package/fesm2020/infrab4a-connect-angular.mjs +2253 -2257
  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,2287 +56,2283 @@ 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
+ return of(cookie.remove(key));
938
+ }
939
+ set(key, value) {
940
+ return from(cookie.set(key, value)).pipe(map(() => { }));
941
+ }
942
+ }
943
+ CookieDataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
944
+ CookieDataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence });
945
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CookieDataPersistence, decorators: [{
946
+ type: Injectable
948
947
  }] });
949
948
 
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']
949
+ class AuthService {
950
+ constructor(angularFireAuth, userRepository) {
951
+ this.angularFireAuth = angularFireAuth;
952
+ this.userRepository = userRepository;
953
+ }
954
+ getAuthstate() {
955
+ const observables = [this.getFireUser(), this.getUser()];
956
+ return combineLatest(observables).pipe(map(([fireUser, user]) => ({
957
+ user,
958
+ isAnonymous: fireUser?.isAnonymous,
959
+ })));
960
+ }
961
+ getUser() {
962
+ return this.getFireUser().pipe(map((user) => user?.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
963
+ }
964
+ getTokenId() {
965
+ return from(getIdToken(this.angularFireAuth.currentUser));
966
+ }
967
+ getFireUser() {
968
+ return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
969
+ }
970
+ }
971
+ 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 });
972
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
973
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
974
+ type: Injectable
975
+ }], ctorParameters: function () { return [{ type: i1.Auth }, { type: undefined, decorators: [{
976
+ type: Inject,
977
+ args: ['UserRepository']
979
978
  }] }]; } });
980
979
 
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']
980
+ class CouponService {
981
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
982
+ this.couponRepository = couponRepository;
983
+ this.defaultShop = defaultShop;
984
+ this.orderRepository = orderRepository;
985
+ this.categoryRepository = categoryRepository;
986
+ this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
987
+ }
988
+ checkCoupon(nickname, checkoutType, checkout, plan) {
989
+ return from(this.couponRepository
990
+ .find({
991
+ filters: {
992
+ nickname: { operator: Where.EQUALS, value: nickname },
993
+ active: { operator: Where.EQUALS, value: true },
994
+ },
995
+ })
996
+ .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
997
+ }
998
+ async couponValidation(coupon, checkoutType) {
999
+ if (!coupon)
1000
+ throw 'Cupom inválido.';
1001
+ if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
1002
+ throw 'Cupom inválido.';
1003
+ if (coupon?.expiresIn && coupon?.expiresIn.getTime() < new Date().getTime())
1004
+ throw 'Cupom expirado.';
1005
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
1006
+ if (!isInShop)
1007
+ throw 'Cupom inválido para loja.';
1008
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
1009
+ if (!isCheckoutType)
1010
+ throw 'Cupom inválido. Erro de checkout.';
1011
+ return coupon;
1012
+ }
1013
+ async couponRulesValidation(coupon, checkoutType, checkout, plan) {
1014
+ if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
1015
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
1016
+ throw 'Cupom inválido para sua assinatura.';
1017
+ return coupon;
1018
+ }
1019
+ const validUser = this.coupomUserValidation(coupon, checkout?.user);
1020
+ if (!validUser)
1021
+ throw 'Usuário não elegível.';
1022
+ const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
1023
+ if (couponUseLimits.firstOrder) {
1024
+ const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
1025
+ if (couponUseLimits.firstOrder && ordersUser.length >= 1)
1026
+ throw 'Limite de uso atingido';
1027
+ }
1028
+ if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
1029
+ const orders = await this.getOrdersWithCoupon(coupon);
1030
+ if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
1031
+ throw 'Limite de uso atingido.';
1032
+ if (couponUseLimits.limitedPerUser) {
1033
+ const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
1034
+ if (ordersWithUser > 0)
1035
+ throw 'Limite de uso por usuário atingido.';
1036
+ }
1037
+ }
1038
+ const hasProductCategories = await this.hasProductCategories(coupon, checkout);
1039
+ if (!hasProductCategories)
1040
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1041
+ const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
1042
+ if (!hasMinSubTotal)
1043
+ throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
1044
+ return coupon;
1045
+ }
1046
+ calcDiscountSubscription(coupon, checkout) {
1047
+ let discount = 0;
1048
+ if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
1049
+ discount = coupon.discount.subscription.value;
1050
+ else
1051
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
1052
+ return of(discount);
1053
+ }
1054
+ async calcDiscountShopping(coupon, checkout) {
1055
+ let discount = 0;
1056
+ if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
1057
+ discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1058
+ }
1059
+ else {
1060
+ discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1061
+ }
1062
+ return discount;
1063
+ }
1064
+ async calcDiscountByType(type, value, categories, checkout) {
1065
+ let discount = 0;
1066
+ let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
1067
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1068
+ if (type == CouponTypes.ABSOLUTE) {
1069
+ discount = value > subTotal ? subTotal : value;
1070
+ }
1071
+ else {
1072
+ discount = subTotal * (value / 100);
1073
+ }
1074
+ return discount;
1075
+ }
1076
+ async hasMinSubTotal(coupon, checkout) {
1077
+ if (!coupon.minSubTotalValue)
1078
+ return true;
1079
+ let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1080
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1081
+ if (coupon.minSubTotalValue <= subTotal)
1082
+ return true;
1083
+ return false;
1084
+ }
1085
+ async hasProductCategories(coupon, checkout) {
1086
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
1087
+ return true;
1088
+ }
1089
+ const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
1090
+ const hasCategories = checkout.lineItems?.filter((i) => {
1091
+ if (!i.categories || !i.categories?.length)
1092
+ return true;
1093
+ return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1094
+ });
1095
+ return hasCategories.length ? true : false;
1096
+ }
1097
+ coupomUserValidation(coupon, user) {
1098
+ if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
1099
+ return true;
1100
+ let userTypes = [];
1101
+ if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
1102
+ this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
1103
+ userTypes.push(Exclusivities.COLLABORATORS);
1104
+ if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
1105
+ coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
1106
+ userTypes.push(Exclusivities.SPECIFIC_USER);
1107
+ if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
1108
+ user.isSubscriber &&
1109
+ user.subscriptionPlan != '')
1110
+ userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
1111
+ if (user.isSubscriber &&
1112
+ user.subscriptionPlan == '' &&
1113
+ coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
1114
+ userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
1115
+ if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
1116
+ userTypes.push(Exclusivities.NON_SUBSCRIBER);
1117
+ return coupon.exclusivityType.some((r) => userTypes.includes(r));
1118
+ }
1119
+ async getCouponCategoriesId(productsCategories) {
1120
+ const couponCategories = [];
1121
+ for (let index = 0; index < productsCategories.length; index++) {
1122
+ const category = await this.categoryRepository.get({
1123
+ id: productsCategories[index],
1124
+ });
1125
+ if (category) {
1126
+ const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
1127
+ couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
1128
+ }
1129
+ }
1130
+ return [...new Set(couponCategories)];
1131
+ }
1132
+ async getLineItensEligebleForDiscount(productsCategories, checkout) {
1133
+ let lineItensDiscount = [];
1134
+ const couponCategories = await this.getCouponCategoriesId(productsCategories);
1135
+ if (productsCategories && productsCategories.length) {
1136
+ lineItensDiscount = checkout.lineItems?.filter((i) => {
1137
+ if (i.categories?.length) {
1138
+ return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1139
+ }
1140
+ return true;
1141
+ });
1142
+ }
1143
+ else {
1144
+ lineItensDiscount = checkout.lineItems;
1145
+ }
1146
+ return lineItensDiscount;
1147
+ }
1148
+ calcCheckoutSubtotal(lineItens, user, shop) {
1149
+ return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
1150
+ ? acc + curr.price?.subscriberPrice * curr.quantity
1151
+ : acc + curr.pricePaid * curr.quantity, 0) || 0);
1152
+ }
1153
+ async getOrdersWithCoupon(coupon) {
1154
+ return await this.orderRepository
1155
+ .find({
1156
+ filters: {
1157
+ coupon: { id: coupon.id },
1158
+ payment: { status: 'paid' },
1159
+ },
1160
+ })
1161
+ .then((result) => result.data);
1162
+ }
1163
+ async getOrdersFromUser(email) {
1164
+ return await this.orderRepository
1165
+ .find({
1166
+ filters: {
1167
+ user: { email: { operator: Where.EQUALS, value: email } },
1168
+ payment: { status: 'paid' },
1169
+ },
1170
+ })
1171
+ .then((result) => result.data);
1172
+ }
1173
+ countOrdersWithUser(orders, email) {
1174
+ return orders.filter((o) => o.user.email == email).length;
1175
+ }
1176
+ getCouponUseLimits(coupon, checkoutType, user) {
1177
+ let couponUseLimits;
1178
+ if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
1179
+ couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
1180
+ }
1181
+ else {
1182
+ couponUseLimits = coupon.useLimits.subscription;
1183
+ }
1184
+ return couponUseLimits;
1185
+ }
1186
+ }
1187
+ 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 });
1188
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
1189
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
1190
+ type: Injectable,
1191
+ args: [{
1192
+ providedIn: 'root',
1193
+ }]
1194
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1195
+ type: Inject,
1196
+ args: ['CouponRepository']
1197
+ }] }, { type: i1$2.Shops, decorators: [{
1198
+ type: Inject,
1199
+ args: [DEFAULT_SHOP]
1200
+ }] }, { type: undefined, decorators: [{
1201
+ type: Inject,
1202
+ args: ['OrderRepository']
1203
+ }] }, { type: undefined, decorators: [{
1204
+ type: Inject,
1205
+ args: ['CategoryRepository']
1207
1206
  }] }]; } });
1208
1207
 
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]
1208
+ class CheckoutService {
1209
+ constructor(couponService, checkoutRepository, userRepository, defaultShop, dataPersistence) {
1210
+ this.couponService = couponService;
1211
+ this.checkoutRepository = checkoutRepository;
1212
+ this.userRepository = userRepository;
1213
+ this.defaultShop = defaultShop;
1214
+ this.dataPersistence = dataPersistence;
1215
+ }
1216
+ getCheckout(checkoutData) {
1217
+ return this.dataPersistence
1218
+ .get('checkoutId')
1219
+ .pipe(concatMap((id) => (!isNil(id) ? this.checkoutRepository.get({ id }) : this.createCheckout(checkoutData))));
1220
+ }
1221
+ getUserByCheckout(checkoutId) {
1222
+ 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'))));
1223
+ }
1224
+ updateCheckoutLineItems(checkout) {
1225
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1226
+ }
1227
+ updateCheckoutUser(checkout) {
1228
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1229
+ }
1230
+ clearCheckoutFromSession() {
1231
+ return this.dataPersistence.remove('checkoutId');
1232
+ }
1233
+ calcDiscount(coupon) {
1234
+ return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
1235
+ }
1236
+ checkCoupon(nickname, checkoutType) {
1237
+ return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
1238
+ }
1239
+ async createCheckout(checkoutData) {
1240
+ const checkout = await this.checkoutRepository.create({
1241
+ createdAt: new Date(),
1242
+ ...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1243
+ shop: checkoutData?.shop || this.defaultShop,
1244
+ });
1245
+ await this.dataPersistence.set('checkoutId', checkout.id).toPromise();
1246
+ return checkout;
1247
+ }
1248
+ }
1249
+ 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 });
1250
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
1251
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
1252
+ type: Injectable
1253
+ }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
1254
+ type: Inject,
1255
+ args: ['CheckoutRepository']
1256
+ }] }, { type: undefined, decorators: [{
1257
+ type: Inject,
1258
+ args: ['UserRepository']
1259
+ }] }, { type: i1$2.Shops, decorators: [{
1260
+ type: Inject,
1261
+ args: [DEFAULT_SHOP]
1262
+ }] }, { type: undefined, decorators: [{
1263
+ type: Inject,
1264
+ args: [PERSISTENCE_PROVIDER]
1266
1265
  }] }]; } });
1267
1266
 
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']
1267
+ class CartService {
1268
+ constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
1269
+ this.authService = authService;
1270
+ this.checkoutService = checkoutService;
1271
+ this.defaultShop = defaultShop;
1272
+ this.productRepository = productRepository;
1273
+ this.categoryRepository = categoryRepository;
1274
+ this.variantRepository = variantRepository;
1275
+ this.buy2WinRepository = buy2WinRepository;
1276
+ this.cartSubject = new Subject();
1277
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
1278
+ const items = [];
1279
+ const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
1280
+ if (index > -1) {
1281
+ checkoutLoaded.lineItems[index].quantity += quantity;
1282
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
1283
+ }
1284
+ else
1285
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
1286
+ return this.checkoutService
1287
+ .updateCheckoutLineItems(checkoutLoaded)
1288
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
1289
+ }));
1290
+ this.generateCartObject = (items) => items?.reduce((cart, item) => ({
1291
+ ...cart,
1292
+ [item.id]: LineItem.toInstance({
1293
+ ...(cart[item.id] || item),
1294
+ quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
1295
+ }),
1296
+ }), {}) || {};
1297
+ this.buildLineItem = async ({ checkout, item, quantity, }) => {
1298
+ const product = await this.getProductData(item.id);
1299
+ item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
1300
+ if (this.checkMaxStock(item, quantity || 0))
1301
+ throw new Error('Desculpe! Temos apenas ' + item.stock?.quantity + ' em estoque.');
1302
+ const image = item.image || item.images?.shift();
1303
+ const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
1304
+ const isGift = item.isGift || null;
1305
+ const pricePaid = this.getProductPrice({
1306
+ product: item,
1307
+ shop: checkout.shop || this.defaultShop,
1308
+ isSubscriber: checkout.user?.isSubscriber,
1309
+ });
1310
+ RoundProductPricesHelper.roundProductPrices(item);
1311
+ return {
1312
+ checkout,
1313
+ lineItem: LineItem.toInstance({
1314
+ id,
1315
+ name: name ?? product.name,
1316
+ EAN: EAN ?? product.EAN,
1317
+ brand: product.brand,
1318
+ slug: slug ?? product.slug,
1319
+ sku: sku ?? product.sku,
1320
+ stock,
1321
+ price: this.roundPrice(price),
1322
+ image,
1323
+ weight: weight ?? product.weight,
1324
+ quantity: (item.quantity || 0) + (quantity || 0),
1325
+ pricePaid,
1326
+ categories: product.categories ?? [],
1327
+ isGift: isGift ?? null,
1328
+ costPrice: product.costPrice ?? 0,
1329
+ type,
1330
+ }),
1331
+ };
1332
+ };
1333
+ this.getProductPrice = ({ product, isSubscriber, }) => {
1334
+ const info = product.price;
1335
+ if (product.isGift)
1336
+ return 0;
1337
+ return isSubscriber && info.subscriberPrice > 0
1338
+ ? Number(info.subscriberPrice.toFixed(2))
1339
+ : Number(info.price.toFixed(2));
1340
+ };
1341
+ this.checkMaxStock = (item, quantity) => {
1342
+ const maxStock = item.stock?.quantity || 0;
1343
+ const currentItemAmount = item.quantity || 0;
1344
+ return currentItemAmount + quantity > maxStock;
1345
+ };
1346
+ }
1347
+ addItem(item, quantity = 1) {
1348
+ 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)));
1349
+ }
1350
+ decreaseItem(item) {
1351
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1352
+ const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id);
1353
+ if (!isNil(checkoutItem))
1354
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
1355
+ return checkout;
1356
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1357
+ }
1358
+ getCart(checkout) {
1359
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1360
+ return this.cartSubject;
1361
+ }
1362
+ /**
1363
+ * @deprecated The method should not be used
1364
+ */
1365
+ getVariantPriceDiscount(item) {
1366
+ 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)));
1367
+ }
1368
+ removeItem(item) {
1369
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1370
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
1371
+ if (index >= 0)
1372
+ checkout.lineItems.splice(index, 1);
1373
+ return checkout;
1374
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1375
+ }
1376
+ updateUserCart(user) {
1377
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => await this.checkoutService
1378
+ .updateCheckoutLineItems(Checkout.toInstance({
1379
+ ...checkout.toPlain(),
1380
+ lineItems: checkout.lineItems?.length
1381
+ ? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem))
1382
+ : [],
1383
+ }))
1384
+ .toPromise()), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1385
+ }
1386
+ clearCart() {
1387
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1388
+ this.checkoutService.clearCheckoutFromSession();
1389
+ return checkout;
1390
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1391
+ }
1392
+ buildCartFromCheckout(checkoutData) {
1393
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1394
+ }
1395
+ roundPrice(productPrice) {
1396
+ const { price, fullPrice, subscriberPrice } = productPrice;
1397
+ return {
1398
+ ...productPrice,
1399
+ price: Number(price.toFixed(2)),
1400
+ fullPrice: Number(fullPrice.toFixed(2)),
1401
+ ...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
1402
+ };
1403
+ }
1404
+ async getProductData(productId) {
1405
+ let product;
1406
+ let variant;
1407
+ try {
1408
+ product = await this.productRepository.get({ id: productId });
1409
+ }
1410
+ catch (error) {
1411
+ if (!(error instanceof NotFoundError))
1412
+ throw error;
1413
+ const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
1414
+ variant = variants.shift();
1415
+ if (!variant)
1416
+ throw error;
1417
+ product = await this.productRepository.get({ id: variant.productId });
1418
+ }
1419
+ return {
1420
+ ...product.toPlain(),
1421
+ ...(variant && { ...variant.toPlain() }),
1422
+ };
1423
+ }
1424
+ getGifts() {
1425
+ return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
1426
+ const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1427
+ if (!notGiftItems.length)
1428
+ return { ...checkout, lineItems: [] };
1429
+ const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1430
+ const campaigns = await this.buy2WinRepository
1431
+ .find({
1432
+ filters: {
1433
+ active: { operator: Where.EQUALS, value: true },
1434
+ shop: { operator: Where.EQUALS, value: this.defaultShop },
1435
+ },
1436
+ })
1437
+ .then((data) => data.data);
1438
+ if (!campaigns.length)
1439
+ return { ...checkout, lineItems: notGiftItems };
1440
+ const elegibleCampaigns = [];
1441
+ for (const campaign of campaigns) {
1442
+ const today = new Date().getTime();
1443
+ if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
1444
+ continue;
1445
+ if (campaign.activeCategory) {
1446
+ const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1447
+ const categoriesCampaingFullTree = [];
1448
+ for (const id of categoriesCampaing) {
1449
+ const children = await this.categoryRepository.getChildren(parseInt(id));
1450
+ categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1451
+ }
1452
+ const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1453
+ const filterProductsCategories = checkout.lineItems.filter((l) => {
1454
+ if (!l.categories || !l.categories?.length)
1455
+ return true;
1456
+ return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1457
+ });
1458
+ if (filterProductsCategories.length) {
1459
+ const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1460
+ if (cartTotalCategories >= campaign.cartValueMin)
1461
+ elegibleCampaigns.push(campaign);
1462
+ }
1463
+ }
1464
+ else {
1465
+ if (campaign.cartValue && campaign.cartValue > 0) {
1466
+ if (campaign.cartValue <= cartTotal)
1467
+ elegibleCampaigns.push(campaign);
1468
+ }
1469
+ }
1470
+ }
1471
+ if (!elegibleCampaigns.length)
1472
+ return { ...checkout, lineItems: notGiftItems };
1473
+ const campaingnProducts = [];
1474
+ for (const campaign of elegibleCampaigns) {
1475
+ let elegibleProducts = [];
1476
+ for (const product of campaign.products) {
1477
+ const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
1478
+ if (!productData.length)
1479
+ continue;
1480
+ const gift = productData.shift();
1481
+ if (gift.stock.quantity < 1)
1482
+ continue;
1483
+ elegibleProducts.push(gift);
1484
+ }
1485
+ campaingnProducts.push(elegibleProducts);
1486
+ }
1487
+ if (!campaingnProducts.length)
1488
+ return { ...checkout, lineItems: notGiftItems };
1489
+ const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1490
+ return { ...checkout, lineItems: notGiftItems.concat(gifts) };
1491
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1492
+ }
1493
+ giftToLineItems(items) {
1494
+ return items.map((item) => {
1495
+ const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
1496
+ const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
1497
+ return LineItem.toInstance({
1498
+ brand,
1499
+ categories,
1500
+ id: id.toString(),
1501
+ name,
1502
+ price,
1503
+ sku,
1504
+ slug,
1505
+ stock,
1506
+ weight,
1507
+ EAN,
1508
+ image,
1509
+ pricePaid: 0,
1510
+ quantity: 1,
1511
+ isGift: true,
1512
+ });
1513
+ });
1514
+ }
1515
+ }
1516
+ 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 });
1517
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
1518
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
1519
+ type: Injectable
1520
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
1521
+ type: Inject,
1522
+ args: [DEFAULT_SHOP]
1523
+ }] }, { type: undefined, decorators: [{
1524
+ type: Inject,
1525
+ args: ['ProductRepository']
1526
+ }] }, { type: undefined, decorators: [{
1527
+ type: Inject,
1528
+ args: ['CategoryRepository']
1529
+ }] }, { type: undefined, decorators: [{
1530
+ type: Inject,
1531
+ args: ['VariantRepository']
1532
+ }] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
1533
+ type: Inject,
1534
+ args: ['Buy2WinRepository']
1539
1535
  }] }]; } });
1540
1536
 
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']
1537
+ class NewCategoryStructureAdapter {
1538
+ constructor(categoryRepository) {
1539
+ this.categoryRepository = categoryRepository;
1540
+ }
1541
+ async buildProductFilterByCategory(category) {
1542
+ const loadedCategory = await this.getCategory(category);
1543
+ if (loadedCategory.isCollection)
1544
+ return { id: { operator: Where.IN, value: loadedCategory.products } };
1545
+ const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1546
+ return {
1547
+ category: {
1548
+ id: {
1549
+ operator: Where.IN,
1550
+ value: categoryIds,
1551
+ },
1552
+ },
1553
+ };
1554
+ }
1555
+ async getAllCategoriesIdFromCategory(category) {
1556
+ return this.categoryRepository
1557
+ .getChildren(+category.id)
1558
+ .then((categories) => categories.map((category) => category.id.toString()));
1559
+ }
1560
+ async getCategory(category) {
1561
+ return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
1562
+ ? this.categoryRepository.get({ id: category.id })
1563
+ : category;
1564
+ }
1565
+ }
1566
+ NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1567
+ NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1568
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1569
+ type: Injectable
1570
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1571
+ type: Inject,
1572
+ args: ['CategoryRepository']
1577
1573
  }] }]; } });
1578
1574
 
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']
1575
+ class OldCategoryStructureAdapter {
1576
+ constructor(categoryRepository) {
1577
+ this.categoryRepository = categoryRepository;
1578
+ }
1579
+ async buildProductFilterByCategory(category) {
1580
+ const productsIds = category.products?.length
1581
+ ? category.products
1582
+ : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1583
+ return { id: { operator: Where.IN, value: productsIds } };
1584
+ }
1585
+ }
1586
+ OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1587
+ OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1588
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1589
+ type: Injectable
1590
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1591
+ type: Inject,
1592
+ args: ['CategoryRepository']
1597
1593
  }] }]; } });
1598
1594
 
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]
1595
+ class CatalogService {
1596
+ constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
1597
+ this.productRepository = productRepository;
1598
+ this.categoryRepository = categoryRepository;
1599
+ this.categoryStructureAdapter = categoryStructureAdapter;
1600
+ this.shop = shop;
1601
+ this.productIndex = productIndex;
1602
+ this.productsByTerm = {};
1603
+ this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1604
+ const filters = {};
1605
+ if (clubDiscount?.length)
1606
+ set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1607
+ if (brands?.length)
1608
+ filters.brand = { operator: Where.IN, value: brands };
1609
+ if (gender?.length)
1610
+ filters.gender = { operator: Where.IN, value: gender };
1611
+ if (prices?.min || prices?.max)
1612
+ set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1613
+ ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1614
+ ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1615
+ ]);
1616
+ if (rate)
1617
+ filters.rate = { operator: Where.GTE, value: rate };
1618
+ if (tags?.length)
1619
+ filters.tags = { operator: Where.LIKE, value: tags };
1620
+ if (customOptions?.length)
1621
+ filters.filters = { operator: Where.LIKE, value: customOptions };
1622
+ return filters;
1623
+ };
1624
+ this.buildSortQuery = (sort) => {
1625
+ if (!sort || sort === 'most-relevant')
1626
+ return {};
1627
+ if (sort === 'best-sellers')
1628
+ return { shoppingCount: 'desc' };
1629
+ if (sort === 'biggest-price')
1630
+ return { subscriberPrice: 'desc' };
1631
+ if (sort === 'lowest-price')
1632
+ return { subscriberPrice: 'asc' };
1633
+ if (sort === 'best-rating')
1634
+ return { rate: 'desc' };
1635
+ if (sort === 'news')
1636
+ return { createdAt: 'desc' };
1637
+ if (sort === 'biggest-discount')
1638
+ return { subscriberDiscountPercentage: 'desc' };
1639
+ };
1640
+ this.buildLimitQuery = (options) => {
1641
+ const limit = options?.perPage || 20;
1642
+ return {
1643
+ limit,
1644
+ offset: ((options?.page || 1) - 1) * limit,
1645
+ };
1646
+ };
1647
+ this.hasProfile = (options) => 'profile' in options;
1648
+ this.hasTerm = (options) => 'term' in options;
1649
+ this.hasCategory = (options) => 'category' in options;
1650
+ }
1651
+ async fetchProducts(options) {
1652
+ const limits = this.buildLimitQuery(options);
1653
+ if (this.hasProfile(options) && options.filters?.customOptions)
1654
+ throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
1655
+ if (this.hasProfile(options) && options.filters?.tags)
1656
+ throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1657
+ if (this.hasTerm(options) && options.filters?.customOptions)
1658
+ throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1659
+ return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
1660
+ products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1661
+ pages: Math.ceil(total / limits.limit),
1662
+ prices: {
1663
+ price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
1664
+ subscriberPrice: {
1665
+ min: +minimal?.price?.subscriberPrice?.toFixed(2),
1666
+ max: +maximum?.price?.subscriberPrice?.toFixed(2),
1667
+ },
1668
+ },
1669
+ brands: distinct?.brand,
1670
+ }));
1671
+ }
1672
+ async findCatalog(options, limits) {
1673
+ if (this.hasTerm(options) && options.sort === 'most-relevant') {
1674
+ const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
1675
+ return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1676
+ }
1677
+ if (this.hasCategory(options) && options.sort === 'most-relevant') {
1678
+ const productsIds = options.category.products?.length
1679
+ ? options.category.products
1680
+ : await this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products);
1681
+ return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1682
+ }
1683
+ const repoParams = {
1684
+ filters: {
1685
+ ...(await this.buildMainFilter(options)),
1686
+ ...this.buildFilterQuery(options?.filters || {}),
1687
+ },
1688
+ ...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
1689
+ limits,
1690
+ options: {
1691
+ minimal: ['price'],
1692
+ maximum: ['price'],
1693
+ ...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
1694
+ },
1695
+ };
1696
+ if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1697
+ return this.productRepository.findCatalog(repoParams);
1698
+ return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1699
+ }
1700
+ async buildMainFilter({ category, profile, term, }) {
1701
+ if (category)
1702
+ return this.categoryStructureAdapter.buildProductFilterByCategory(category);
1703
+ if (profile)
1704
+ return { tags: { operator: Where.LIKE, value: profile } };
1705
+ if (term)
1706
+ return this.productIndex
1707
+ .search(term, 999, this.shop)
1708
+ .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1709
+ }
1710
+ async findCatalogAndSortByMostRevelant(productIds, options, limits) {
1711
+ const totalResult = await this.productRepository.findCatalog({
1712
+ fields: ['id', 'stock'],
1713
+ filters: {
1714
+ id: { operator: Where.IN, value: productIds },
1715
+ ...this.buildFilterQuery(options?.filters || {}),
1716
+ },
1717
+ options: {
1718
+ minimal: ['price'],
1719
+ maximum: ['price'],
1720
+ distinct: ['brand'],
1721
+ },
1722
+ }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1723
+ const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1724
+ const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1725
+ const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1726
+ const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1727
+ const limitedProductId = productIdsStock
1728
+ .concat(productIdsStockOut)
1729
+ .slice(limits.offset, limits.offset + limits.limit);
1730
+ const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1731
+ const productResult = await this.productRepository.findCatalog({
1732
+ filters: {
1733
+ id: { operator: Where.IN, value: orderedId },
1734
+ },
1735
+ });
1736
+ return {
1737
+ data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1738
+ count: totalResult.count,
1739
+ maximum: totalResult.maximum,
1740
+ minimal: totalResult.minimal,
1741
+ distinct: totalResult.distinct,
1742
+ };
1743
+ }
1744
+ async findCatalogIdsByElasticSearch(term) {
1745
+ if (this.productsByTerm[term])
1746
+ return this.productsByTerm[term];
1747
+ return (this.productsByTerm[term] = await this.productIndex
1748
+ .search(term, 999, this.shop)
1749
+ .then(({ hits: products }) => {
1750
+ const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1751
+ const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1752
+ const sorted = [...withStock, ...withOutStock];
1753
+ return [...new Set(sorted.map(({ _source }) => _source.id))];
1754
+ }));
1755
+ }
1756
+ }
1757
+ 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 });
1758
+ CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1759
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1760
+ type: Injectable
1761
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1762
+ type: Inject,
1763
+ args: ['ProductRepository']
1764
+ }] }, { type: undefined, decorators: [{
1765
+ type: Inject,
1766
+ args: ['CategoryRepository']
1767
+ }] }, { type: undefined, decorators: [{
1768
+ type: Inject,
1769
+ args: [CATEGORY_STRUCTURE]
1770
+ }] }, { type: i1$2.Shops, decorators: [{
1771
+ type: Inject,
1772
+ args: [DEFAULT_SHOP]
1777
1773
  }] }, { type: i1$2.ProductsIndex }]; } });
1778
1774
 
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]
1775
+ class CategoryService {
1776
+ constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1777
+ this.productRepository = productRepository;
1778
+ this.categoryRepository = categoryRepository;
1779
+ this.categoryFilterRepository = categoryFilterRepository;
1780
+ this.categoryStructureAdapter = categoryStructureAdapter;
1781
+ this.shop = shop;
1782
+ }
1783
+ async fetchBrands(category, options) {
1784
+ const brands = await this.productRepository
1785
+ .findCatalog({
1786
+ filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
1787
+ fields: ['brand'],
1788
+ }, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
1789
+ .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1790
+ return this.categoryRepository
1791
+ .find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
1792
+ .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1793
+ }
1794
+ async fetchFilterOptions(category) {
1795
+ return await this.categoryFilterRepository
1796
+ .find({ filters: { categoryId: +category.id } })
1797
+ .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1798
+ }
1799
+ }
1800
+ 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 });
1801
+ CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1802
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1803
+ type: Injectable
1804
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1805
+ type: Inject,
1806
+ args: ['ProductRepository']
1807
+ }] }, { type: undefined, decorators: [{
1808
+ type: Inject,
1809
+ args: ['CategoryRepository']
1810
+ }] }, { type: undefined, decorators: [{
1811
+ type: Inject,
1812
+ args: ['CategoryFilterRepository']
1813
+ }] }, { type: undefined, decorators: [{
1814
+ type: Inject,
1815
+ args: [CATEGORY_STRUCTURE]
1816
+ }] }, { type: i1$2.Shops, decorators: [{
1817
+ type: Inject,
1818
+ args: [DEFAULT_SHOP]
1823
1819
  }] }]; } });
1824
1820
 
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";
1821
+ var ProductSorts;
1822
+ (function (ProductSorts) {
1823
+ ProductSorts["MOST_RELEVANT"] = "most-relevant";
1824
+ ProductSorts["BEST_SELLER"] = "best-sellers";
1825
+ ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1826
+ ProductSorts["LOWEST_PRICE"] = "lowest-price";
1827
+ ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1828
+ ProductSorts["BEST_RATING"] = "best-rating";
1829
+ ProductSorts["NEWS"] = "news";
1834
1830
  })(ProductSorts || (ProductSorts = {}));
1835
1831
 
1836
- class CategoryWithTree extends Category {
1837
- }
1838
- __decorate([
1839
- Type(() => CategoryWithTree),
1840
- __metadata("design:type", Array)
1832
+ class CategoryWithTree extends Category {
1833
+ }
1834
+ __decorate([
1835
+ Type(() => CategoryWithTree),
1836
+ __metadata("design:type", Array)
1841
1837
  ], CategoryWithTree.prototype, "children", void 0);
1842
1838
 
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']
1839
+ class WishlistService {
1840
+ constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
1841
+ this.wishlistRepository = wishlistRepository;
1842
+ this.shop = shop;
1843
+ const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1844
+ this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
1845
+ this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1846
+ }
1847
+ getCatalogService() {
1848
+ return this.catalogService;
1849
+ }
1850
+ getCategoryService() {
1851
+ return this.categoryService;
1852
+ }
1853
+ async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1854
+ const data = {
1855
+ slug: '',
1856
+ name: title,
1857
+ description,
1858
+ metadata: {
1859
+ title: `${userFullName} - ${title}`,
1860
+ description: `${userFullName} - ${description}`,
1861
+ },
1862
+ shop: this.shop,
1863
+ shops: [this.shop],
1864
+ personId,
1865
+ personName: userFullName,
1866
+ personPhoto: userPhoto,
1867
+ brandCategory: false,
1868
+ published: true,
1869
+ theme,
1870
+ bannerUrl,
1871
+ };
1872
+ const newWishlist = await this.wishlistRepository.create(data);
1873
+ await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1874
+ return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
1875
+ }
1876
+ update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1877
+ const data = {
1878
+ id,
1879
+ name: title,
1880
+ description,
1881
+ metadata: {
1882
+ title: `${userFullName} - ${title}`,
1883
+ description: `${userFullName} - ${description}`,
1884
+ },
1885
+ personName: userFullName,
1886
+ personPhoto: userPhoto,
1887
+ theme,
1888
+ bannerUrl,
1889
+ };
1890
+ return this.wishlistRepository.update(data);
1891
+ }
1892
+ delete(wishlistId) {
1893
+ return this.wishlistRepository.delete({ id: wishlistId });
1894
+ }
1895
+ getWishlistBySlug(slug) {
1896
+ const [id] = slug.split('-');
1897
+ if (+id)
1898
+ return this.wishlistRepository.get({ id });
1899
+ return this.wishlistRepository.getWishlistBySlug(slug);
1900
+ }
1901
+ getWishlistsByPerson(personId) {
1902
+ return this.wishlistRepository.getWishlistByPerson(personId);
1903
+ }
1904
+ async addProduct(wishlistId, productId) {
1905
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1906
+ const hasProduct = wishlist.products.some((p) => p == productId);
1907
+ if (!hasProduct) {
1908
+ wishlist.products = [...wishlist.products, productId];
1909
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1910
+ }
1911
+ return wishlist;
1912
+ }
1913
+ async removeProduct(wishlistId, productId) {
1914
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1915
+ const productIndex = wishlist.products.findIndex((p) => p == productId);
1916
+ if (productIndex != -1) {
1917
+ wishlist.products.splice(productIndex, 1);
1918
+ if (!wishlist.products.length)
1919
+ return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1920
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1921
+ }
1922
+ return wishlist;
1923
+ }
1924
+ }
1925
+ 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 });
1926
+ WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1927
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1928
+ type: Injectable
1929
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1930
+ type: Inject,
1931
+ args: ['WishlistRepository']
1932
+ }] }, { type: i1$2.Shops, decorators: [{
1933
+ type: Inject,
1934
+ args: [DEFAULT_SHOP]
1935
+ }] }, { type: undefined, decorators: [{
1936
+ type: Inject,
1937
+ args: ['ProductRepository']
1938
+ }] }, { type: undefined, decorators: [{
1939
+ type: Inject,
1940
+ args: ['CategoryFilterRepository']
1941
+ }] }, { type: undefined, decorators: [{
1942
+ type: Inject,
1943
+ args: ['CategoryRepository']
1948
1944
  }] }, { type: i1$2.ProductsIndex }]; } });
1949
1945
 
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]
1946
+ class CheckoutSubscriptionService {
1947
+ constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
1948
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1949
+ this.dataPersistence = dataPersistence;
1950
+ this.couponService = couponService;
1951
+ }
1952
+ getCheckoutSubscription(checkoutData) {
1953
+ return this.dataPersistence
1954
+ .get('checkoutSubscriptionId')
1955
+ .pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
1956
+ }
1957
+ clearCheckoutSubscriptionFromSession() {
1958
+ return this.dataPersistence.remove('checkoutSubscriptionId');
1959
+ }
1960
+ checkCoupon(nickname, userEmail) {
1961
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
1962
+ .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
1963
+ .pipe()));
1964
+ }
1965
+ calcDiscountSubscription(coupon) {
1966
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
1967
+ }
1968
+ async createCheckoutSubscription(checkoutData) {
1969
+ const checkout = await this.checkoutSubscriptionRepository.create({
1970
+ createdAt: new Date(),
1971
+ ...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1972
+ });
1973
+ await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
1974
+ return checkout;
1975
+ }
1976
+ }
1977
+ 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 });
1978
+ CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
1979
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
1980
+ type: Injectable
1981
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1982
+ type: Inject,
1983
+ args: ['CheckoutSubscriptionRepository']
1984
+ }] }, { type: undefined, decorators: [{
1985
+ type: Inject,
1986
+ args: [PERSISTENCE_PROVIDER]
1991
1987
  }] }, { type: CouponService }]; } });
1992
1988
 
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
- }
1989
+ class UtilHelper {
1990
+ static createSlug(name) {
1991
+ return name
1992
+ .toLowerCase()
1993
+ .replace(/\s+/g, '-') // Replace spaces with -
1994
+ .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
1995
+ .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
1996
+ .replace(/[ìíïî]/g, 'i') // Replace spaces with -
1997
+ .replace(/[õòóöô]/g, 'o') // Replace spaces with -
1998
+ .replace(/[ùúüû]/g, 'u') // Replace spaces with -
1999
+ .replace(/[ñ]/g, 'n') // Replace spaces with -
2000
+ .replace(/[ç]/g, 'c') // Replace spaces with -
2001
+ .replace(/[&]/g, 'and') // Replace spaces with -
2002
+ .replace(/[^\w\-]+/g, '') // Remove all non-word chars
2003
+ .replace(/\-\-+/g, '-'); // Replace multiple - with single -
2004
+ }
2009
2005
  }
2010
2006
 
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]
2007
+ class HomeShopService {
2008
+ get homeId() {
2009
+ if (this.defaultShop === Shops.GLAMSHOP)
2010
+ return 'glamshop';
2011
+ if (this.defaultShop === Shops.MENSMARKET)
2012
+ return 'mens_market';
2013
+ return null;
2014
+ }
2015
+ constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
2016
+ this.categoryRepository = categoryRepository;
2017
+ this.homeRepository = homeRepository;
2018
+ this.productRepository = productRepository;
2019
+ this.defaultShop = defaultShop;
2020
+ this.buildCategoryGroupWithRequiredData = (group) => ({
2021
+ category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
2022
+ products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
2023
+ 'id',
2024
+ 'price',
2025
+ 'reviews',
2026
+ 'hasVariants',
2027
+ 'slug',
2028
+ 'sku',
2029
+ 'stock',
2030
+ 'costPrice',
2031
+ 'images',
2032
+ 'miniatures',
2033
+ 'name',
2034
+ 'weight',
2035
+ 'rate',
2036
+ 'type',
2037
+ 'brand',
2038
+ ]))) || [],
2039
+ });
2040
+ }
2041
+ getHomeData() {
2042
+ return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
2043
+ ? of(home)
2044
+ : forkJoin([
2045
+ this.getDiscoverProducts(this.gender),
2046
+ this.getFeaturedProducts(this.gender),
2047
+ this.getVerticalProducts(this.gender),
2048
+ ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2049
+ discoverProducts,
2050
+ featuredProducts,
2051
+ verticalProducts,
2052
+ })), concatMap((data) => this.saveHomeData(data)))));
2053
+ }
2054
+ getBanners(type) {
2055
+ return this.getHomeConfiguration().pipe(map((home) => {
2056
+ if (type === 'brand')
2057
+ return home.brandsCarousel;
2058
+ if (type === 'buyToWin')
2059
+ return [home.buyToWinBanner];
2060
+ if (type === 'block')
2061
+ return home.blockBanners;
2062
+ if (type === 'blog')
2063
+ return [home.blogBanner];
2064
+ return [];
2065
+ }));
2066
+ }
2067
+ getMinValueForFreeShipping() {
2068
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2069
+ }
2070
+ getDiscoverProducts(gender) {
2071
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2072
+ }
2073
+ getFeaturedProducts(gender) {
2074
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2075
+ }
2076
+ getVerticalProducts(gender) {
2077
+ 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({
2078
+ filters: {
2079
+ categories: { operator: Where.IN, value: [category.id] },
2080
+ ...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
2081
+ },
2082
+ limits: { limit: 12 },
2083
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2084
+ }
2085
+ getHomeConfiguration() {
2086
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
2087
+ ? of(home)
2088
+ : !this.homeId
2089
+ ? throwError(new RequiredArgumentError(['homeId']))
2090
+ : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2091
+ }
2092
+ saveHomeData(homeData) {
2093
+ const data = {
2094
+ createdAt: new Date(),
2095
+ expiresAt: add(new Date(), { hours: 1 }),
2096
+ data: homeData,
2097
+ };
2098
+ return from(this.homeRepository.update({
2099
+ id: this.homeId,
2100
+ data,
2101
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2102
+ }
2103
+ get gender() {
2104
+ return this.homeId === 'mens_market' ? 'masculino' : undefined;
2105
+ }
2106
+ }
2107
+ 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 });
2108
+ HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
2109
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
2110
+ type: Injectable
2111
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2112
+ type: Inject,
2113
+ args: ['CategoryRepository']
2114
+ }] }, { type: undefined, decorators: [{
2115
+ type: Inject,
2116
+ args: ['HomeRepository']
2117
+ }] }, { type: undefined, decorators: [{
2118
+ type: Inject,
2119
+ args: ['ProductRepository']
2120
+ }] }, { type: i1$2.Shops, decorators: [{
2121
+ type: Inject,
2122
+ args: [DEFAULT_SHOP]
2127
2123
  }] }]; } });
2128
2124
 
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']
2125
+ class OrderService {
2126
+ constructor(angularFirestore, orderRepository) {
2127
+ this.angularFirestore = angularFirestore;
2128
+ this.orderRepository = orderRepository;
2129
+ this.orderSubject = new Subject();
2130
+ }
2131
+ getOrder(id) {
2132
+ docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
2133
+ .pipe(map((doc) => Order.toInstance(doc.data())))
2134
+ .subscribe((doc) => this.orderSubject.next(doc));
2135
+ return this.orderSubject;
2136
+ }
2137
+ }
2138
+ 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 });
2139
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2140
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2141
+ type: Injectable
2142
+ }], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2143
+ type: Inject,
2144
+ args: ['OrderRepository']
2149
2145
  }] }]; } });
2150
2146
 
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]
2147
+ class ShippingService {
2148
+ constructor(http, apiUrl, homeService) {
2149
+ this.http = http;
2150
+ this.apiUrl = apiUrl;
2151
+ this.homeService = homeService;
2152
+ }
2153
+ getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2154
+ return combineLatest([
2155
+ this.homeService.getHomeData(),
2156
+ this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2157
+ ]).pipe(map(([datas, shippingMethodsResponse]) => {
2158
+ let shippingMethods = shippingMethodsResponse.result;
2159
+ if (!shippingMethods.length)
2160
+ return [];
2161
+ shippingMethods = shippingMethods.map((shippingMethod) => {
2162
+ if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2163
+ shippingMethod.ShippingCompanyName = 'Same Day';
2164
+ return shippingMethod;
2165
+ });
2166
+ const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2167
+ if (this.isHolidays(datasSameDayNotAvaliable)) {
2168
+ shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2169
+ }
2170
+ if (totalPrice >= 200) {
2171
+ shippingMethods = shippingMethods.map((s) => {
2172
+ if (s.serviceName !== 'Same Day')
2173
+ return { ...s, totalPrice: 0 };
2174
+ else
2175
+ return s;
2176
+ });
2177
+ }
2178
+ if (shop == Shops.GLAMSHOP)
2179
+ return shippingMethods;
2180
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2181
+ shippingMethods = shippingMethods.map((s) => {
2182
+ if (s.serviceName == 'Same Day')
2183
+ return { ...s, totalPrice: s.totalPrice / 2 };
2184
+ else
2185
+ return { ...s, totalPrice: 0 };
2186
+ });
2187
+ }
2188
+ if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2189
+ shippingMethods = shippingMethods.map((s) => {
2190
+ return { ...s, totalPrice: s.totalPrice / 2 };
2191
+ });
2192
+ }
2193
+ return shippingMethods;
2194
+ }));
2195
+ }
2196
+ isFreeShippingBySubscription(shop, subscriptionPlan) {
2197
+ if (!subscriptionPlan)
2198
+ return false;
2199
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2200
+ return true;
2201
+ return false;
2202
+ }
2203
+ isHalfShippingBySubscription(shop, subscriptionPlan) {
2204
+ if (!subscriptionPlan)
2205
+ return false;
2206
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2207
+ return true;
2208
+ }
2209
+ return false;
2210
+ }
2211
+ isHolidays(datas) {
2212
+ const today = new Date();
2213
+ for (const key in datas) {
2214
+ let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2215
+ let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2216
+ if (start > end)
2217
+ end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2218
+ if (today >= start && today <= end)
2219
+ return true;
2220
+ }
2221
+ return false;
2222
+ }
2223
+ }
2224
+ 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 });
2225
+ ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2226
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2227
+ type: Injectable
2228
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
2229
+ type: Inject,
2230
+ args: [BACKEND_URL]
2235
2231
  }] }, { type: HomeShopService }]; } });
2236
2232
 
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
- }]
2233
+ class AngularConnectModule {
2234
+ static initializeApp(defaultShop, options, nameOrConfig) {
2235
+ return {
2236
+ ngModule: AngularConnectModule,
2237
+ providers: [
2238
+ {
2239
+ provide: CATEGORY_STRUCTURE,
2240
+ useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
2241
+ ? OldCategoryStructureAdapter
2242
+ : NewCategoryStructureAdapter,
2243
+ },
2244
+ { provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
2245
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
2246
+ ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
2247
+ ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2248
+ ...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2249
+ ...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2250
+ ...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2251
+ ...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
2252
+ ],
2253
+ };
2254
+ }
2255
+ }
2256
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2257
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
2258
+ AngularFirebaseAuthModule,
2259
+ AngularFirestoreModule,
2260
+ AngularHasuraGraphQLModule] });
2261
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
2262
+ AuthService,
2263
+ CartService,
2264
+ CatalogService,
2265
+ CategoryService,
2266
+ CheckoutService,
2267
+ CheckoutSubscriptionService,
2268
+ CouponService,
2269
+ HomeShopService,
2270
+ OrderService,
2271
+ ShippingService,
2272
+ WishlistService,
2273
+ {
2274
+ provide: UpdateUserImage,
2275
+ useFactory: (userRepository, fileUploader) => {
2276
+ return new UpdateUserImage(userRepository, fileUploader);
2277
+ },
2278
+ deps: ['UserRepository', 'FileUploaderService'],
2279
+ },
2280
+ ], imports: [provideFirebaseApp((injector) => {
2281
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2282
+ try {
2283
+ return getApp(appName);
2284
+ }
2285
+ catch (error) {
2286
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2287
+ }
2288
+ }),
2289
+ AngularElasticSeachModule,
2290
+ AngularFirebaseAuthModule,
2291
+ AngularFirestoreModule,
2292
+ AngularHasuraGraphQLModule] });
2293
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
2294
+ type: NgModule,
2295
+ args: [{
2296
+ imports: [
2297
+ provideFirebaseApp((injector) => {
2298
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2299
+ try {
2300
+ return getApp(appName);
2301
+ }
2302
+ catch (error) {
2303
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2304
+ }
2305
+ }),
2306
+ AngularElasticSeachModule,
2307
+ AngularFirebaseAuthModule,
2308
+ AngularFirestoreModule,
2309
+ AngularHasuraGraphQLModule,
2310
+ ],
2311
+ providers: [
2312
+ AuthService,
2313
+ CartService,
2314
+ CatalogService,
2315
+ CategoryService,
2316
+ CheckoutService,
2317
+ CheckoutSubscriptionService,
2318
+ CouponService,
2319
+ HomeShopService,
2320
+ OrderService,
2321
+ ShippingService,
2322
+ WishlistService,
2323
+ {
2324
+ provide: UpdateUserImage,
2325
+ useFactory: (userRepository, fileUploader) => {
2326
+ return new UpdateUserImage(userRepository, fileUploader);
2327
+ },
2328
+ deps: ['UserRepository', 'FileUploaderService'],
2329
+ },
2330
+ ],
2331
+ }]
2336
2332
  }] });
2337
2333
 
2338
- /**
2339
- * Generated bundle index. Do not edit.
2334
+ /**
2335
+ * Generated bundle index. Do not edit.
2340
2336
  */
2341
2337
 
2342
2338
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };