@infrab4a/connect-angular 4.3.12-beta.3 → 4.3.13

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 -22
  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 -281
  38. package/esm2020/services/catalog/adapters/category-structure.adapter.mjs +2 -2
  39. package/esm2020/services/catalog/adapters/index.mjs +4 -4
  40. package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +41 -49
  41. package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -23
  42. package/esm2020/services/catalog/catalog.service.mjs +190 -192
  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 +2326 -2333
  68. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
  69. package/fesm2020/infrab4a-connect-angular.mjs +2258 -2268
  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 +2 -2
  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,2298 +56,2288 @@ 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
- 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
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
947
947
  }] });
948
948
 
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']
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']
978
978
  }] }]; } });
979
979
 
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']
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']
1206
1206
  }] }]; } });
1207
1207
 
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]
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]
1265
1265
  }] }]; } });
1266
1266
 
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']
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']
1535
1535
  }] }]; } });
1536
1536
 
1537
- class NewCategoryStructureAdapter {
1538
- constructor(categoryRepository) {
1539
- this.categoryRepository = categoryRepository;
1540
- }
1541
- async buildProductFilterByCategory(category) {
1542
- const loadedCategory = await this.getCategory(category);
1543
- console.log('loadedCategory', loadedCategory);
1544
- if (loadedCategory.isCollection)
1545
- return { id: { operator: Where.IN, value: loadedCategory.products } };
1546
- const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1547
- return {
1548
- category: {
1549
- id: {
1550
- operator: Where.IN,
1551
- value: categoryIds,
1552
- },
1553
- },
1554
- };
1555
- }
1556
- async getAllCategoriesIdFromCategory(category) {
1557
- return this.categoryRepository
1558
- .getChildren(+category.id)
1559
- .then((categories) => categories.map((category) => category.id.toString()));
1560
- }
1561
- async getCategory(category) {
1562
- const collectionCategory = category.isCollection ||
1563
- isNil(category.isCollection) ||
1564
- !category.products?.length ||
1565
- category.isWishlist ||
1566
- category.brandCategory;
1567
- console.log('getCategory', category, collectionCategory);
1568
- // return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
1569
- // ? this.categoryRepository.get({ id: category.id })
1570
- // : category
1571
- return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
1572
- }
1573
- }
1574
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1575
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter });
1576
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1577
- type: Injectable
1578
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1579
- type: Inject,
1580
- 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']
1581
1573
  }] }]; } });
1582
1574
 
1583
- class OldCategoryStructureAdapter {
1584
- constructor(categoryRepository) {
1585
- this.categoryRepository = categoryRepository;
1586
- }
1587
- async buildProductFilterByCategory(category) {
1588
- const productsIds = category.products?.length
1589
- ? category.products
1590
- : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1591
- return { id: { operator: Where.IN, value: productsIds } };
1592
- }
1593
- }
1594
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1595
- OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter });
1596
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1597
- type: Injectable
1598
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1599
- type: Inject,
1600
- 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']
1601
1593
  }] }]; } });
1602
1594
 
1603
- class CatalogService {
1604
- constructor(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex) {
1605
- this.productRepository = productRepository;
1606
- this.categoryRepository = categoryRepository;
1607
- this.categoryStructureAdapter = categoryStructureAdapter;
1608
- this.shop = shop;
1609
- this.productIndex = productIndex;
1610
- this.productsByTerm = {};
1611
- this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1612
- const filters = {};
1613
- if (clubDiscount?.length)
1614
- set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1615
- if (brands?.length)
1616
- filters.brand = { operator: Where.IN, value: brands };
1617
- if (gender?.length)
1618
- filters.gender = { operator: Where.IN, value: gender };
1619
- if (prices?.min || prices?.max)
1620
- set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1621
- ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1622
- ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1623
- ]);
1624
- if (rate)
1625
- filters.rate = { operator: Where.GTE, value: rate };
1626
- if (tags?.length)
1627
- filters.tags = { operator: Where.LIKE, value: tags };
1628
- if (customOptions?.length)
1629
- filters.filters = { operator: Where.LIKE, value: customOptions };
1630
- return filters;
1631
- };
1632
- this.buildSortQuery = (sort) => {
1633
- if (!sort || sort === 'most-relevant')
1634
- return {};
1635
- if (sort === 'best-sellers')
1636
- return { shoppingCount: 'desc' };
1637
- if (sort === 'biggest-price')
1638
- return { subscriberPrice: 'desc' };
1639
- if (sort === 'lowest-price')
1640
- return { subscriberPrice: 'asc' };
1641
- if (sort === 'best-rating')
1642
- return { rate: 'desc' };
1643
- if (sort === 'news')
1644
- return { createdAt: 'desc' };
1645
- if (sort === 'biggest-discount')
1646
- return { subscriberDiscountPercentage: 'desc' };
1647
- };
1648
- this.buildLimitQuery = (options) => {
1649
- const limit = options?.perPage || 20;
1650
- return {
1651
- limit,
1652
- offset: ((options?.page || 1) - 1) * limit,
1653
- };
1654
- };
1655
- this.hasProfile = (options) => 'profile' in options;
1656
- this.hasTerm = (options) => 'term' in options;
1657
- this.hasCategory = (options) => 'category' in options;
1658
- }
1659
- async fetchProducts(options) {
1660
- const limits = this.buildLimitQuery(options);
1661
- if (this.hasProfile(options) && options.filters?.customOptions)
1662
- throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
1663
- if (this.hasProfile(options) && options.filters?.tags)
1664
- throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1665
- if (this.hasTerm(options) && options.filters?.customOptions)
1666
- throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1667
- return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
1668
- products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1669
- pages: Math.ceil(total / limits.limit),
1670
- prices: {
1671
- price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
1672
- subscriberPrice: {
1673
- min: +minimal?.price?.subscriberPrice?.toFixed(2),
1674
- max: +maximum?.price?.subscriberPrice?.toFixed(2),
1675
- },
1676
- },
1677
- brands: distinct?.brand,
1678
- }));
1679
- }
1680
- async findCatalog(options, limits) {
1681
- if (this.hasTerm(options) && options.sort === 'most-relevant') {
1682
- const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
1683
- return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1684
- }
1685
- if (this.hasCategory(options) && options.sort === 'most-relevant') {
1686
- const productsIds = await this.productRepository
1687
- .find({
1688
- filters: {
1689
- ...(await this.buildMainFilter(options)),
1690
- },
1691
- })
1692
- .then((products) => products.data.map((product) => product.id));
1693
- // const productsIds = options.category.products?.length
1694
- // ? options.category.products
1695
- // : await this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products)
1696
- return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1697
- }
1698
- const repoParams = {
1699
- filters: {
1700
- ...(await this.buildMainFilter(options)),
1701
- ...this.buildFilterQuery(options?.filters || {}),
1702
- },
1703
- ...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
1704
- limits,
1705
- options: {
1706
- minimal: ['price'],
1707
- maximum: ['price'],
1708
- ...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
1709
- },
1710
- };
1711
- if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1712
- return this.productRepository.findCatalog(repoParams);
1713
- return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1714
- }
1715
- async buildMainFilter({ category, profile, term, }) {
1716
- if (category)
1717
- return this.categoryStructureAdapter.buildProductFilterByCategory(category);
1718
- if (profile)
1719
- return { tags: { operator: Where.LIKE, value: profile } };
1720
- if (term)
1721
- return this.productIndex
1722
- .search(term, 999, this.shop)
1723
- .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1724
- }
1725
- async findCatalogAndSortByMostRevelant(productIds, options, limits) {
1726
- const totalResult = await this.productRepository.findCatalog({
1727
- fields: ['id', 'stock'],
1728
- filters: {
1729
- id: { operator: Where.IN, value: productIds },
1730
- ...this.buildFilterQuery(options?.filters || {}),
1731
- },
1732
- options: {
1733
- minimal: ['price'],
1734
- maximum: ['price'],
1735
- distinct: ['brand'],
1736
- },
1737
- }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1738
- const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1739
- const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1740
- const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1741
- const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1742
- const limitedProductId = productIdsStock
1743
- .concat(productIdsStockOut)
1744
- .slice(limits.offset, limits.offset + limits.limit);
1745
- const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1746
- const productResult = await this.productRepository.findCatalog({
1747
- filters: {
1748
- id: { operator: Where.IN, value: orderedId },
1749
- },
1750
- });
1751
- return {
1752
- data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1753
- count: totalResult.count,
1754
- maximum: totalResult.maximum,
1755
- minimal: totalResult.minimal,
1756
- distinct: totalResult.distinct,
1757
- };
1758
- }
1759
- async findCatalogIdsByElasticSearch(term) {
1760
- if (this.productsByTerm[term])
1761
- return this.productsByTerm[term];
1762
- return (this.productsByTerm[term] = await this.productIndex
1763
- .search(term, 999, this.shop)
1764
- .then(({ hits: products }) => {
1765
- const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1766
- const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1767
- const sorted = [...withStock, ...withOutStock];
1768
- return [...new Set(sorted.map(({ _source }) => _source.id))];
1769
- }));
1770
- }
1771
- }
1772
- 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 });
1773
- CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1774
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1775
- type: Injectable
1776
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1777
- type: Inject,
1778
- args: ['ProductRepository']
1779
- }] }, { type: undefined, decorators: [{
1780
- type: Inject,
1781
- args: ['CategoryRepository']
1782
- }] }, { type: undefined, decorators: [{
1783
- type: Inject,
1784
- args: [CATEGORY_STRUCTURE]
1785
- }] }, { type: i1$2.Shops, decorators: [{
1786
- type: Inject,
1787
- 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 {
1629
+ shoppingCount: 'desc',
1630
+ rate: 'desc',
1631
+ stock: 'desc',
1632
+ name: 'asc',
1633
+ };
1634
+ if (sort === 'biggest-price')
1635
+ return { subscriberPrice: 'desc', rate: 'desc', shoppingCount: 'desc' };
1636
+ if (sort === 'lowest-price')
1637
+ return { subscriberPrice: 'asc', rate: 'desc', shoppingCount: 'desc' };
1638
+ if (sort === 'best-rating')
1639
+ return { rate: 'desc', shoppingCount: 'desc', stock: 'desc', name: 'asc' };
1640
+ if (sort === 'news')
1641
+ return { createdAt: 'desc' };
1642
+ if (sort === 'biggest-discount')
1643
+ return { subscriberDiscountPercentage: 'desc', rate: 'desc', shoppingCount: 'desc' };
1644
+ };
1645
+ this.buildLimitQuery = (options) => {
1646
+ const limit = options?.perPage || 20;
1647
+ return {
1648
+ limit,
1649
+ offset: ((options?.page || 1) - 1) * limit,
1650
+ };
1651
+ };
1652
+ this.hasProfile = (options) => 'profile' in options;
1653
+ this.hasTerm = (options) => 'term' in options;
1654
+ this.hasCategory = (options) => 'category' in options;
1655
+ }
1656
+ async fetchProducts(options) {
1657
+ const limits = this.buildLimitQuery(options);
1658
+ if (this.hasProfile(options) && options.filters?.customOptions)
1659
+ throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
1660
+ if (this.hasProfile(options) && options.filters?.tags)
1661
+ throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1662
+ if (this.hasTerm(options) && options.filters?.customOptions)
1663
+ throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1664
+ return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
1665
+ products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1666
+ pages: Math.ceil(total / limits.limit),
1667
+ prices: {
1668
+ price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
1669
+ subscriberPrice: {
1670
+ min: +minimal?.price?.subscriberPrice?.toFixed(2),
1671
+ max: +maximum?.price?.subscriberPrice?.toFixed(2),
1672
+ },
1673
+ },
1674
+ brands: distinct?.brand,
1675
+ }));
1676
+ }
1677
+ async findCatalog(options, limits) {
1678
+ if (this.hasTerm(options) && options.sort === 'most-relevant') {
1679
+ const productsIds = await this.findCatalogIdsByElasticSearch(options.term);
1680
+ return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1681
+ }
1682
+ if (this.hasCategory(options) && options.sort === 'most-relevant') {
1683
+ const productsIds = options.category.products?.length
1684
+ ? options.category.products
1685
+ : await this.categoryRepository.get({ id: options.category.id }).then((categoryFound) => categoryFound.products);
1686
+ return this.findCatalogAndSortByMostRevelant(productsIds, options, limits);
1687
+ }
1688
+ const repoParams = {
1689
+ filters: {
1690
+ ...(await this.buildMainFilter(options)),
1691
+ ...this.buildFilterQuery(options?.filters || {}),
1692
+ },
1693
+ ...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
1694
+ limits,
1695
+ options: {
1696
+ minimal: ['price'],
1697
+ maximum: ['price'],
1698
+ ...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
1699
+ },
1700
+ };
1701
+ if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1702
+ return this.productRepository.findCatalog(repoParams);
1703
+ return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1704
+ }
1705
+ async buildMainFilter({ category, profile, term, }) {
1706
+ if (category)
1707
+ return this.categoryStructureAdapter.buildProductFilterByCategory(category);
1708
+ if (profile)
1709
+ return { tags: { operator: Where.LIKE, value: profile } };
1710
+ if (term)
1711
+ return this.productIndex
1712
+ .search(term, 999, this.shop)
1713
+ .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1714
+ }
1715
+ async findCatalogAndSortByMostRevelant(productIds, options, limits) {
1716
+ const totalResult = await this.productRepository.findCatalog({
1717
+ fields: ['id', 'stock'],
1718
+ filters: {
1719
+ id: { operator: Where.IN, value: productIds },
1720
+ ...this.buildFilterQuery(options?.filters || {}),
1721
+ },
1722
+ options: {
1723
+ minimal: ['price'],
1724
+ maximum: ['price'],
1725
+ distinct: ['brand'],
1726
+ },
1727
+ }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1728
+ const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1729
+ const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1730
+ const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1731
+ const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1732
+ const limitedProductId = productIdsStock
1733
+ .concat(productIdsStockOut)
1734
+ .slice(limits.offset, limits.offset + limits.limit);
1735
+ const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1736
+ const productResult = await this.productRepository.findCatalog({
1737
+ filters: {
1738
+ id: { operator: Where.IN, value: orderedId },
1739
+ },
1740
+ });
1741
+ return {
1742
+ data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1743
+ count: totalResult.count,
1744
+ maximum: totalResult.maximum,
1745
+ minimal: totalResult.minimal,
1746
+ distinct: totalResult.distinct,
1747
+ };
1748
+ }
1749
+ async findCatalogIdsByElasticSearch(term) {
1750
+ if (this.productsByTerm[term])
1751
+ return this.productsByTerm[term];
1752
+ return (this.productsByTerm[term] = await this.productIndex
1753
+ .search(term, 999, this.shop)
1754
+ .then(({ hits: products }) => {
1755
+ const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1756
+ const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1757
+ const sorted = [...withStock, ...withOutStock];
1758
+ return [...new Set(sorted.map(({ _source }) => _source.id))];
1759
+ }));
1760
+ }
1761
+ }
1762
+ 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 });
1763
+ CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService });
1764
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CatalogService, decorators: [{
1765
+ type: Injectable
1766
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1767
+ type: Inject,
1768
+ args: ['ProductRepository']
1769
+ }] }, { type: undefined, decorators: [{
1770
+ type: Inject,
1771
+ args: ['CategoryRepository']
1772
+ }] }, { type: undefined, decorators: [{
1773
+ type: Inject,
1774
+ args: [CATEGORY_STRUCTURE]
1775
+ }] }, { type: i1$2.Shops, decorators: [{
1776
+ type: Inject,
1777
+ args: [DEFAULT_SHOP]
1788
1778
  }] }, { type: i1$2.ProductsIndex }]; } });
1789
1779
 
1790
- class CategoryService {
1791
- constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1792
- this.productRepository = productRepository;
1793
- this.categoryRepository = categoryRepository;
1794
- this.categoryFilterRepository = categoryFilterRepository;
1795
- this.categoryStructureAdapter = categoryStructureAdapter;
1796
- this.shop = shop;
1797
- }
1798
- async fetchBrands(category, options) {
1799
- const brands = await this.productRepository
1800
- .findCatalog({
1801
- filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
1802
- fields: ['brand'],
1803
- }, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
1804
- .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1805
- return this.categoryRepository
1806
- .find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
1807
- .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1808
- }
1809
- async fetchFilterOptions(category) {
1810
- return await this.categoryFilterRepository
1811
- .find({ filters: { categoryId: +category.id } })
1812
- .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1813
- }
1814
- }
1815
- 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 });
1816
- CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1817
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1818
- type: Injectable
1819
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1820
- type: Inject,
1821
- args: ['ProductRepository']
1822
- }] }, { type: undefined, decorators: [{
1823
- type: Inject,
1824
- args: ['CategoryRepository']
1825
- }] }, { type: undefined, decorators: [{
1826
- type: Inject,
1827
- args: ['CategoryFilterRepository']
1828
- }] }, { type: undefined, decorators: [{
1829
- type: Inject,
1830
- args: [CATEGORY_STRUCTURE]
1831
- }] }, { type: i1$2.Shops, decorators: [{
1832
- type: Inject,
1833
- args: [DEFAULT_SHOP]
1780
+ class CategoryService {
1781
+ constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1782
+ this.productRepository = productRepository;
1783
+ this.categoryRepository = categoryRepository;
1784
+ this.categoryFilterRepository = categoryFilterRepository;
1785
+ this.categoryStructureAdapter = categoryStructureAdapter;
1786
+ this.shop = shop;
1787
+ }
1788
+ async fetchBrands(category, options) {
1789
+ const brands = await this.productRepository
1790
+ .findCatalog({
1791
+ filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
1792
+ fields: ['brand'],
1793
+ }, options?.mainGender ? options?.mainGender : this.shop === Shops.MENSMARKET ? 'male' : 'female')
1794
+ .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1795
+ return this.categoryRepository
1796
+ .find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } })
1797
+ .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1798
+ }
1799
+ async fetchFilterOptions(category) {
1800
+ return await this.categoryFilterRepository
1801
+ .find({ filters: { categoryId: +category.id } })
1802
+ .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1803
+ }
1804
+ }
1805
+ 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 });
1806
+ CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService });
1807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CategoryService, decorators: [{
1808
+ type: Injectable
1809
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1810
+ type: Inject,
1811
+ args: ['ProductRepository']
1812
+ }] }, { type: undefined, decorators: [{
1813
+ type: Inject,
1814
+ args: ['CategoryRepository']
1815
+ }] }, { type: undefined, decorators: [{
1816
+ type: Inject,
1817
+ args: ['CategoryFilterRepository']
1818
+ }] }, { type: undefined, decorators: [{
1819
+ type: Inject,
1820
+ args: [CATEGORY_STRUCTURE]
1821
+ }] }, { type: i1$2.Shops, decorators: [{
1822
+ type: Inject,
1823
+ args: [DEFAULT_SHOP]
1834
1824
  }] }]; } });
1835
1825
 
1836
- var ProductSorts;
1837
- (function (ProductSorts) {
1838
- ProductSorts["MOST_RELEVANT"] = "most-relevant";
1839
- ProductSorts["BEST_SELLER"] = "best-sellers";
1840
- ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1841
- ProductSorts["LOWEST_PRICE"] = "lowest-price";
1842
- ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1843
- ProductSorts["BEST_RATING"] = "best-rating";
1844
- ProductSorts["NEWS"] = "news";
1826
+ var ProductSorts;
1827
+ (function (ProductSorts) {
1828
+ ProductSorts["MOST_RELEVANT"] = "most-relevant";
1829
+ ProductSorts["BEST_SELLER"] = "best-sellers";
1830
+ ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1831
+ ProductSorts["LOWEST_PRICE"] = "lowest-price";
1832
+ ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1833
+ ProductSorts["BEST_RATING"] = "best-rating";
1834
+ ProductSorts["NEWS"] = "news";
1845
1835
  })(ProductSorts || (ProductSorts = {}));
1846
1836
 
1847
- class CategoryWithTree extends Category {
1848
- }
1849
- __decorate([
1850
- Type(() => CategoryWithTree),
1851
- __metadata("design:type", Array)
1837
+ class CategoryWithTree extends Category {
1838
+ }
1839
+ __decorate([
1840
+ Type(() => CategoryWithTree),
1841
+ __metadata("design:type", Array)
1852
1842
  ], CategoryWithTree.prototype, "children", void 0);
1853
1843
 
1854
- class WishlistService {
1855
- constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
1856
- this.wishlistRepository = wishlistRepository;
1857
- this.shop = shop;
1858
- const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1859
- this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
1860
- this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1861
- }
1862
- getCatalogService() {
1863
- return this.catalogService;
1864
- }
1865
- getCategoryService() {
1866
- return this.categoryService;
1867
- }
1868
- async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1869
- const data = {
1870
- slug: '',
1871
- name: title,
1872
- description,
1873
- metadata: {
1874
- title: `${userFullName} - ${title}`,
1875
- description: `${userFullName} - ${description}`,
1876
- },
1877
- shop: this.shop,
1878
- shops: [this.shop],
1879
- personId,
1880
- personName: userFullName,
1881
- personPhoto: userPhoto,
1882
- brandCategory: false,
1883
- published: true,
1884
- theme,
1885
- bannerUrl,
1886
- };
1887
- const newWishlist = await this.wishlistRepository.create(data);
1888
- await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1889
- return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
1890
- }
1891
- update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1892
- const data = {
1893
- id,
1894
- name: title,
1895
- description,
1896
- metadata: {
1897
- title: `${userFullName} - ${title}`,
1898
- description: `${userFullName} - ${description}`,
1899
- },
1900
- personName: userFullName,
1901
- personPhoto: userPhoto,
1902
- theme,
1903
- bannerUrl,
1904
- };
1905
- return this.wishlistRepository.update(data);
1906
- }
1907
- delete(wishlistId) {
1908
- return this.wishlistRepository.delete({ id: wishlistId });
1909
- }
1910
- getWishlistBySlug(slug) {
1911
- const [id] = slug.split('-');
1912
- if (+id)
1913
- return this.wishlistRepository.get({ id });
1914
- return this.wishlistRepository.getWishlistBySlug(slug);
1915
- }
1916
- getWishlistsByPerson(personId) {
1917
- return this.wishlistRepository.getWishlistByPerson(personId);
1918
- }
1919
- async addProduct(wishlistId, productId) {
1920
- const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1921
- const hasProduct = wishlist.products.some((p) => p == productId);
1922
- if (!hasProduct) {
1923
- wishlist.products = [...wishlist.products, productId];
1924
- return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1925
- }
1926
- return wishlist;
1927
- }
1928
- async removeProduct(wishlistId, productId) {
1929
- const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1930
- const productIndex = wishlist.products.findIndex((p) => p == productId);
1931
- if (productIndex != -1) {
1932
- wishlist.products.splice(productIndex, 1);
1933
- if (!wishlist.products.length)
1934
- return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1935
- return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1936
- }
1937
- return wishlist;
1938
- }
1939
- }
1940
- 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 });
1941
- WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1942
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1943
- type: Injectable
1944
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1945
- type: Inject,
1946
- args: ['WishlistRepository']
1947
- }] }, { type: i1$2.Shops, decorators: [{
1948
- type: Inject,
1949
- args: [DEFAULT_SHOP]
1950
- }] }, { type: undefined, decorators: [{
1951
- type: Inject,
1952
- args: ['ProductRepository']
1953
- }] }, { type: undefined, decorators: [{
1954
- type: Inject,
1955
- args: ['CategoryFilterRepository']
1956
- }] }, { type: undefined, decorators: [{
1957
- type: Inject,
1958
- args: ['CategoryRepository']
1844
+ class WishlistService {
1845
+ constructor(wishlistRepository, shop, productRepository, categoryFilterRepository, categoryRepository, productIndex) {
1846
+ this.wishlistRepository = wishlistRepository;
1847
+ this.shop = shop;
1848
+ const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1849
+ this.catalogService = new CatalogService(productRepository, categoryRepository, categoryStructureAdapter, shop, productIndex);
1850
+ this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1851
+ }
1852
+ getCatalogService() {
1853
+ return this.catalogService;
1854
+ }
1855
+ getCategoryService() {
1856
+ return this.categoryService;
1857
+ }
1858
+ async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1859
+ const data = {
1860
+ slug: '',
1861
+ name: title,
1862
+ description,
1863
+ metadata: {
1864
+ title: `${userFullName} - ${title}`,
1865
+ description: `${userFullName} - ${description}`,
1866
+ },
1867
+ shop: this.shop,
1868
+ shops: [this.shop],
1869
+ personId,
1870
+ personName: userFullName,
1871
+ personPhoto: userPhoto,
1872
+ brandCategory: false,
1873
+ published: true,
1874
+ theme,
1875
+ bannerUrl,
1876
+ };
1877
+ const newWishlist = await this.wishlistRepository.create(data);
1878
+ await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1879
+ return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
1880
+ }
1881
+ update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1882
+ const data = {
1883
+ id,
1884
+ name: title,
1885
+ description,
1886
+ metadata: {
1887
+ title: `${userFullName} - ${title}`,
1888
+ description: `${userFullName} - ${description}`,
1889
+ },
1890
+ personName: userFullName,
1891
+ personPhoto: userPhoto,
1892
+ theme,
1893
+ bannerUrl,
1894
+ };
1895
+ return this.wishlistRepository.update(data);
1896
+ }
1897
+ delete(wishlistId) {
1898
+ return this.wishlistRepository.delete({ id: wishlistId });
1899
+ }
1900
+ getWishlistBySlug(slug) {
1901
+ const [id] = slug.split('-');
1902
+ if (+id)
1903
+ return this.wishlistRepository.get({ id });
1904
+ return this.wishlistRepository.getWishlistBySlug(slug);
1905
+ }
1906
+ getWishlistsByPerson(personId) {
1907
+ return this.wishlistRepository.getWishlistByPerson(personId);
1908
+ }
1909
+ async addProduct(wishlistId, productId) {
1910
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1911
+ const hasProduct = wishlist.products.some((p) => p == productId);
1912
+ if (!hasProduct) {
1913
+ wishlist.products = [...wishlist.products, productId];
1914
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1915
+ }
1916
+ return wishlist;
1917
+ }
1918
+ async removeProduct(wishlistId, productId) {
1919
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1920
+ const productIndex = wishlist.products.findIndex((p) => p == productId);
1921
+ if (productIndex != -1) {
1922
+ wishlist.products.splice(productIndex, 1);
1923
+ if (!wishlist.products.length)
1924
+ return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1925
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1926
+ }
1927
+ return wishlist;
1928
+ }
1929
+ }
1930
+ 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 });
1931
+ WishlistService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService });
1932
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: WishlistService, decorators: [{
1933
+ type: Injectable
1934
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1935
+ type: Inject,
1936
+ args: ['WishlistRepository']
1937
+ }] }, { type: i1$2.Shops, decorators: [{
1938
+ type: Inject,
1939
+ args: [DEFAULT_SHOP]
1940
+ }] }, { type: undefined, decorators: [{
1941
+ type: Inject,
1942
+ args: ['ProductRepository']
1943
+ }] }, { type: undefined, decorators: [{
1944
+ type: Inject,
1945
+ args: ['CategoryFilterRepository']
1946
+ }] }, { type: undefined, decorators: [{
1947
+ type: Inject,
1948
+ args: ['CategoryRepository']
1959
1949
  }] }, { type: i1$2.ProductsIndex }]; } });
1960
1950
 
1961
- class CheckoutSubscriptionService {
1962
- constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
1963
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1964
- this.dataPersistence = dataPersistence;
1965
- this.couponService = couponService;
1966
- }
1967
- getCheckoutSubscription(checkoutData) {
1968
- return this.dataPersistence
1969
- .get('checkoutSubscriptionId')
1970
- .pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
1971
- }
1972
- clearCheckoutSubscriptionFromSession() {
1973
- return this.dataPersistence.remove('checkoutSubscriptionId');
1974
- }
1975
- checkCoupon(nickname, userEmail) {
1976
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
1977
- .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
1978
- .pipe()));
1979
- }
1980
- calcDiscountSubscription(coupon) {
1981
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
1982
- }
1983
- async createCheckoutSubscription(checkoutData) {
1984
- const checkout = await this.checkoutSubscriptionRepository.create({
1985
- createdAt: new Date(),
1986
- ...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1987
- });
1988
- await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
1989
- return checkout;
1990
- }
1991
- }
1992
- 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 });
1993
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
1994
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
1995
- type: Injectable
1996
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1997
- type: Inject,
1998
- args: ['CheckoutSubscriptionRepository']
1999
- }] }, { type: undefined, decorators: [{
2000
- type: Inject,
2001
- args: [PERSISTENCE_PROVIDER]
1951
+ class CheckoutSubscriptionService {
1952
+ constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
1953
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1954
+ this.dataPersistence = dataPersistence;
1955
+ this.couponService = couponService;
1956
+ }
1957
+ getCheckoutSubscription(checkoutData) {
1958
+ return this.dataPersistence
1959
+ .get('checkoutSubscriptionId')
1960
+ .pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
1961
+ }
1962
+ clearCheckoutSubscriptionFromSession() {
1963
+ return this.dataPersistence.remove('checkoutSubscriptionId');
1964
+ }
1965
+ checkCoupon(nickname, userEmail) {
1966
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
1967
+ .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
1968
+ .pipe()));
1969
+ }
1970
+ calcDiscountSubscription(coupon) {
1971
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
1972
+ }
1973
+ async createCheckoutSubscription(checkoutData) {
1974
+ const checkout = await this.checkoutSubscriptionRepository.create({
1975
+ createdAt: new Date(),
1976
+ ...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1977
+ });
1978
+ await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
1979
+ return checkout;
1980
+ }
1981
+ }
1982
+ 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 });
1983
+ CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
1984
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
1985
+ type: Injectable
1986
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1987
+ type: Inject,
1988
+ args: ['CheckoutSubscriptionRepository']
1989
+ }] }, { type: undefined, decorators: [{
1990
+ type: Inject,
1991
+ args: [PERSISTENCE_PROVIDER]
2002
1992
  }] }, { type: CouponService }]; } });
2003
1993
 
2004
- class UtilHelper {
2005
- static createSlug(name) {
2006
- return name
2007
- .toLowerCase()
2008
- .replace(/\s+/g, '-') // Replace spaces with -
2009
- .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
2010
- .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
2011
- .replace(/[ìíïî]/g, 'i') // Replace spaces with -
2012
- .replace(/[õòóöô]/g, 'o') // Replace spaces with -
2013
- .replace(/[ùúüû]/g, 'u') // Replace spaces with -
2014
- .replace(/[ñ]/g, 'n') // Replace spaces with -
2015
- .replace(/[ç]/g, 'c') // Replace spaces with -
2016
- .replace(/[&]/g, 'and') // Replace spaces with -
2017
- .replace(/[^\w\-]+/g, '') // Remove all non-word chars
2018
- .replace(/\-\-+/g, '-'); // Replace multiple - with single -
2019
- }
1994
+ class UtilHelper {
1995
+ static createSlug(name) {
1996
+ return name
1997
+ .toLowerCase()
1998
+ .replace(/\s+/g, '-') // Replace spaces with -
1999
+ .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
2000
+ .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
2001
+ .replace(/[ìíïî]/g, 'i') // Replace spaces with -
2002
+ .replace(/[õòóöô]/g, 'o') // Replace spaces with -
2003
+ .replace(/[ùúüû]/g, 'u') // Replace spaces with -
2004
+ .replace(/[ñ]/g, 'n') // Replace spaces with -
2005
+ .replace(/[ç]/g, 'c') // Replace spaces with -
2006
+ .replace(/[&]/g, 'and') // Replace spaces with -
2007
+ .replace(/[^\w\-]+/g, '') // Remove all non-word chars
2008
+ .replace(/\-\-+/g, '-'); // Replace multiple - with single -
2009
+ }
2020
2010
  }
2021
2011
 
2022
- class HomeShopService {
2023
- get homeId() {
2024
- if (this.defaultShop === Shops.GLAMSHOP)
2025
- return 'glamshop';
2026
- if (this.defaultShop === Shops.MENSMARKET)
2027
- return 'mens_market';
2028
- return null;
2029
- }
2030
- constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
2031
- this.categoryRepository = categoryRepository;
2032
- this.homeRepository = homeRepository;
2033
- this.productRepository = productRepository;
2034
- this.defaultShop = defaultShop;
2035
- this.buildCategoryGroupWithRequiredData = (group) => ({
2036
- category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
2037
- products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
2038
- 'id',
2039
- 'price',
2040
- 'reviews',
2041
- 'hasVariants',
2042
- 'slug',
2043
- 'sku',
2044
- 'stock',
2045
- 'costPrice',
2046
- 'images',
2047
- 'miniatures',
2048
- 'name',
2049
- 'weight',
2050
- 'rate',
2051
- 'type',
2052
- 'brand',
2053
- ]))) || [],
2054
- });
2055
- }
2056
- getHomeData() {
2057
- return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
2058
- ? of(home)
2059
- : forkJoin([
2060
- this.getDiscoverProducts(this.gender),
2061
- this.getFeaturedProducts(this.gender),
2062
- this.getVerticalProducts(this.gender),
2063
- ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2064
- discoverProducts,
2065
- featuredProducts,
2066
- verticalProducts,
2067
- })), concatMap((data) => this.saveHomeData(data)))));
2068
- }
2069
- getBanners(type) {
2070
- return this.getHomeConfiguration().pipe(map((home) => {
2071
- if (type === 'brand')
2072
- return home.brandsCarousel;
2073
- if (type === 'buyToWin')
2074
- return [home.buyToWinBanner];
2075
- if (type === 'block')
2076
- return home.blockBanners;
2077
- if (type === 'blog')
2078
- return [home.blogBanner];
2079
- return [];
2080
- }));
2081
- }
2082
- getMinValueForFreeShipping() {
2083
- return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2084
- }
2085
- getDiscoverProducts(gender) {
2086
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2087
- }
2088
- getFeaturedProducts(gender) {
2089
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2090
- }
2091
- getVerticalProducts(gender) {
2092
- 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({
2093
- filters: {
2094
- categories: { operator: Where.IN, value: [category.id] },
2095
- ...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
2096
- },
2097
- limits: { limit: 12 },
2098
- })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2099
- }
2100
- getHomeConfiguration() {
2101
- return of(this.homeConfiguration).pipe(concatMap((home) => home
2102
- ? of(home)
2103
- : !this.homeId
2104
- ? throwError(new RequiredArgumentError(['homeId']))
2105
- : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2106
- }
2107
- saveHomeData(homeData) {
2108
- const data = {
2109
- createdAt: new Date(),
2110
- expiresAt: add(new Date(), { hours: 1 }),
2111
- data: homeData,
2112
- };
2113
- return from(this.homeRepository.update({
2114
- id: this.homeId,
2115
- data,
2116
- })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2117
- }
2118
- get gender() {
2119
- return this.homeId === 'mens_market' ? 'masculino' : undefined;
2120
- }
2121
- }
2122
- 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 });
2123
- HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
2124
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
2125
- type: Injectable
2126
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2127
- type: Inject,
2128
- args: ['CategoryRepository']
2129
- }] }, { type: undefined, decorators: [{
2130
- type: Inject,
2131
- args: ['HomeRepository']
2132
- }] }, { type: undefined, decorators: [{
2133
- type: Inject,
2134
- args: ['ProductRepository']
2135
- }] }, { type: i1$2.Shops, decorators: [{
2136
- type: Inject,
2137
- args: [DEFAULT_SHOP]
2012
+ class HomeShopService {
2013
+ get homeId() {
2014
+ if (this.defaultShop === Shops.GLAMSHOP)
2015
+ return 'glamshop';
2016
+ if (this.defaultShop === Shops.MENSMARKET)
2017
+ return 'mens_market';
2018
+ return null;
2019
+ }
2020
+ constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
2021
+ this.categoryRepository = categoryRepository;
2022
+ this.homeRepository = homeRepository;
2023
+ this.productRepository = productRepository;
2024
+ this.defaultShop = defaultShop;
2025
+ this.buildCategoryGroupWithRequiredData = (group) => ({
2026
+ category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
2027
+ products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
2028
+ 'id',
2029
+ 'price',
2030
+ 'reviews',
2031
+ 'hasVariants',
2032
+ 'slug',
2033
+ 'sku',
2034
+ 'stock',
2035
+ 'costPrice',
2036
+ 'images',
2037
+ 'miniatures',
2038
+ 'name',
2039
+ 'weight',
2040
+ 'rate',
2041
+ 'type',
2042
+ 'brand',
2043
+ ]))) || [],
2044
+ });
2045
+ }
2046
+ getHomeData() {
2047
+ return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
2048
+ ? of(home)
2049
+ : forkJoin([
2050
+ this.getDiscoverProducts(this.gender),
2051
+ this.getFeaturedProducts(this.gender),
2052
+ this.getVerticalProducts(this.gender),
2053
+ ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2054
+ discoverProducts,
2055
+ featuredProducts,
2056
+ verticalProducts,
2057
+ })), concatMap((data) => this.saveHomeData(data)))));
2058
+ }
2059
+ getBanners(type) {
2060
+ return this.getHomeConfiguration().pipe(map((home) => {
2061
+ if (type === 'brand')
2062
+ return home.brandsCarousel;
2063
+ if (type === 'buyToWin')
2064
+ return [home.buyToWinBanner];
2065
+ if (type === 'block')
2066
+ return home.blockBanners;
2067
+ if (type === 'blog')
2068
+ return [home.blogBanner];
2069
+ return [];
2070
+ }));
2071
+ }
2072
+ getMinValueForFreeShipping() {
2073
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2074
+ }
2075
+ getDiscoverProducts(gender) {
2076
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2077
+ }
2078
+ getFeaturedProducts(gender) {
2079
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2080
+ }
2081
+ getVerticalProducts(gender) {
2082
+ 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({
2083
+ filters: {
2084
+ categories: { operator: Where.IN, value: [category.id] },
2085
+ ...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
2086
+ },
2087
+ limits: { limit: 12 },
2088
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2089
+ }
2090
+ getHomeConfiguration() {
2091
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
2092
+ ? of(home)
2093
+ : !this.homeId
2094
+ ? throwError(new RequiredArgumentError(['homeId']))
2095
+ : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2096
+ }
2097
+ saveHomeData(homeData) {
2098
+ const data = {
2099
+ createdAt: new Date(),
2100
+ expiresAt: add(new Date(), { hours: 1 }),
2101
+ data: homeData,
2102
+ };
2103
+ return from(this.homeRepository.update({
2104
+ id: this.homeId,
2105
+ data,
2106
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2107
+ }
2108
+ get gender() {
2109
+ return this.homeId === 'mens_market' ? 'masculino' : undefined;
2110
+ }
2111
+ }
2112
+ 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 });
2113
+ HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
2114
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
2115
+ type: Injectable
2116
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2117
+ type: Inject,
2118
+ args: ['CategoryRepository']
2119
+ }] }, { type: undefined, decorators: [{
2120
+ type: Inject,
2121
+ args: ['HomeRepository']
2122
+ }] }, { type: undefined, decorators: [{
2123
+ type: Inject,
2124
+ args: ['ProductRepository']
2125
+ }] }, { type: i1$2.Shops, decorators: [{
2126
+ type: Inject,
2127
+ args: [DEFAULT_SHOP]
2138
2128
  }] }]; } });
2139
2129
 
2140
- class OrderService {
2141
- constructor(angularFirestore, orderRepository) {
2142
- this.angularFirestore = angularFirestore;
2143
- this.orderRepository = orderRepository;
2144
- this.orderSubject = new Subject();
2145
- }
2146
- getOrder(id) {
2147
- docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
2148
- .pipe(map((doc) => Order.toInstance(doc.data())))
2149
- .subscribe((doc) => this.orderSubject.next(doc));
2150
- return this.orderSubject;
2151
- }
2152
- }
2153
- 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 });
2154
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2155
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2156
- type: Injectable
2157
- }], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2158
- type: Inject,
2159
- args: ['OrderRepository']
2130
+ class OrderService {
2131
+ constructor(angularFirestore, orderRepository) {
2132
+ this.angularFirestore = angularFirestore;
2133
+ this.orderRepository = orderRepository;
2134
+ this.orderSubject = new Subject();
2135
+ }
2136
+ getOrder(id) {
2137
+ docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
2138
+ .pipe(map((doc) => Order.toInstance(doc.data())))
2139
+ .subscribe((doc) => this.orderSubject.next(doc));
2140
+ return this.orderSubject;
2141
+ }
2142
+ }
2143
+ 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 });
2144
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
2145
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
2146
+ type: Injectable
2147
+ }], ctorParameters: function () { return [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2148
+ type: Inject,
2149
+ args: ['OrderRepository']
2160
2150
  }] }]; } });
2161
2151
 
2162
- class ShippingService {
2163
- constructor(http, apiUrl, homeService) {
2164
- this.http = http;
2165
- this.apiUrl = apiUrl;
2166
- this.homeService = homeService;
2167
- }
2168
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2169
- return combineLatest([
2170
- this.homeService.getHomeData(),
2171
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2172
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
2173
- let shippingMethods = shippingMethodsResponse.result;
2174
- if (!shippingMethods.length)
2175
- return [];
2176
- shippingMethods = shippingMethods.map((shippingMethod) => {
2177
- if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2178
- shippingMethod.ShippingCompanyName = 'Same Day';
2179
- return shippingMethod;
2180
- });
2181
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2182
- if (this.isHolidays(datasSameDayNotAvaliable)) {
2183
- shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2184
- }
2185
- if (totalPrice >= 200) {
2186
- shippingMethods = shippingMethods.map((s) => {
2187
- if (s.serviceName !== 'Same Day')
2188
- return { ...s, totalPrice: 0 };
2189
- else
2190
- return s;
2191
- });
2192
- }
2193
- if (shop == Shops.GLAMSHOP)
2194
- return shippingMethods;
2195
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2196
- shippingMethods = shippingMethods.map((s) => {
2197
- if (s.serviceName == 'Same Day')
2198
- return { ...s, totalPrice: s.totalPrice / 2 };
2199
- else
2200
- return { ...s, totalPrice: 0 };
2201
- });
2202
- }
2203
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2204
- shippingMethods = shippingMethods.map((s) => {
2205
- return { ...s, totalPrice: s.totalPrice / 2 };
2206
- });
2207
- }
2208
- return shippingMethods;
2209
- }));
2210
- }
2211
- isFreeShippingBySubscription(shop, subscriptionPlan) {
2212
- if (!subscriptionPlan)
2213
- return false;
2214
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2215
- return true;
2216
- return false;
2217
- }
2218
- isHalfShippingBySubscription(shop, subscriptionPlan) {
2219
- if (!subscriptionPlan)
2220
- return false;
2221
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2222
- return true;
2223
- }
2224
- return false;
2225
- }
2226
- isHolidays(datas) {
2227
- const today = new Date();
2228
- for (const key in datas) {
2229
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2230
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2231
- if (start > end)
2232
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2233
- if (today >= start && today <= end)
2234
- return true;
2235
- }
2236
- return false;
2237
- }
2238
- }
2239
- 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 });
2240
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2241
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2242
- type: Injectable
2243
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
2244
- type: Inject,
2245
- args: [BACKEND_URL]
2152
+ class ShippingService {
2153
+ constructor(http, apiUrl, homeService) {
2154
+ this.http = http;
2155
+ this.apiUrl = apiUrl;
2156
+ this.homeService = homeService;
2157
+ }
2158
+ getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2159
+ return combineLatest([
2160
+ this.homeService.getHomeData(),
2161
+ this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2162
+ ]).pipe(map(([datas, shippingMethodsResponse]) => {
2163
+ let shippingMethods = shippingMethodsResponse.result;
2164
+ if (!shippingMethods.length)
2165
+ return [];
2166
+ shippingMethods = shippingMethods.map((shippingMethod) => {
2167
+ if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2168
+ shippingMethod.ShippingCompanyName = 'Same Day';
2169
+ return shippingMethod;
2170
+ });
2171
+ const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2172
+ if (this.isHolidays(datasSameDayNotAvaliable)) {
2173
+ shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2174
+ }
2175
+ if (totalPrice >= 200) {
2176
+ shippingMethods = shippingMethods.map((s) => {
2177
+ if (s.serviceName !== 'Same Day')
2178
+ return { ...s, totalPrice: 0 };
2179
+ else
2180
+ return s;
2181
+ });
2182
+ }
2183
+ if (shop == Shops.GLAMSHOP)
2184
+ return shippingMethods;
2185
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2186
+ shippingMethods = shippingMethods.map((s) => {
2187
+ if (s.serviceName == 'Same Day')
2188
+ return { ...s, totalPrice: s.totalPrice / 2 };
2189
+ else
2190
+ return { ...s, totalPrice: 0 };
2191
+ });
2192
+ }
2193
+ if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2194
+ shippingMethods = shippingMethods.map((s) => {
2195
+ return { ...s, totalPrice: s.totalPrice / 2 };
2196
+ });
2197
+ }
2198
+ return shippingMethods;
2199
+ }));
2200
+ }
2201
+ isFreeShippingBySubscription(shop, subscriptionPlan) {
2202
+ if (!subscriptionPlan)
2203
+ return false;
2204
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2205
+ return true;
2206
+ return false;
2207
+ }
2208
+ isHalfShippingBySubscription(shop, subscriptionPlan) {
2209
+ if (!subscriptionPlan)
2210
+ return false;
2211
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2212
+ return true;
2213
+ }
2214
+ return false;
2215
+ }
2216
+ isHolidays(datas) {
2217
+ const today = new Date();
2218
+ for (const key in datas) {
2219
+ let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2220
+ let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2221
+ if (start > end)
2222
+ end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2223
+ if (today >= start && today <= end)
2224
+ return true;
2225
+ }
2226
+ return false;
2227
+ }
2228
+ }
2229
+ 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 });
2230
+ ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService });
2231
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: ShippingService, decorators: [{
2232
+ type: Injectable
2233
+ }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
2234
+ type: Inject,
2235
+ args: [BACKEND_URL]
2246
2236
  }] }, { type: HomeShopService }]; } });
2247
2237
 
2248
- class AngularConnectModule {
2249
- static initializeApp(defaultShop, options, nameOrConfig) {
2250
- return {
2251
- ngModule: AngularConnectModule,
2252
- providers: [
2253
- {
2254
- provide: CATEGORY_STRUCTURE,
2255
- useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
2256
- ? OldCategoryStructureAdapter
2257
- : NewCategoryStructureAdapter,
2258
- },
2259
- { provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
2260
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
2261
- ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
2262
- ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2263
- ...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2264
- ...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2265
- ...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2266
- ...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
2267
- ],
2268
- };
2269
- }
2270
- }
2271
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2272
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
2273
- AngularFirebaseAuthModule,
2274
- AngularFirestoreModule,
2275
- AngularHasuraGraphQLModule] });
2276
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
2277
- AuthService,
2278
- CartService,
2279
- CatalogService,
2280
- CategoryService,
2281
- CheckoutService,
2282
- CheckoutSubscriptionService,
2283
- CouponService,
2284
- HomeShopService,
2285
- OrderService,
2286
- ShippingService,
2287
- WishlistService,
2288
- {
2289
- provide: UpdateUserImage,
2290
- useFactory: (userRepository, fileUploader) => {
2291
- return new UpdateUserImage(userRepository, fileUploader);
2292
- },
2293
- deps: ['UserRepository', 'FileUploaderService'],
2294
- },
2295
- ], imports: [provideFirebaseApp((injector) => {
2296
- const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2297
- try {
2298
- return getApp(appName);
2299
- }
2300
- catch (error) {
2301
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2302
- }
2303
- }),
2304
- AngularElasticSeachModule,
2305
- AngularFirebaseAuthModule,
2306
- AngularFirestoreModule,
2307
- AngularHasuraGraphQLModule] });
2308
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
2309
- type: NgModule,
2310
- args: [{
2311
- imports: [
2312
- provideFirebaseApp((injector) => {
2313
- const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2314
- try {
2315
- return getApp(appName);
2316
- }
2317
- catch (error) {
2318
- return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2319
- }
2320
- }),
2321
- AngularElasticSeachModule,
2322
- AngularFirebaseAuthModule,
2323
- AngularFirestoreModule,
2324
- AngularHasuraGraphQLModule,
2325
- ],
2326
- providers: [
2327
- AuthService,
2328
- CartService,
2329
- CatalogService,
2330
- CategoryService,
2331
- CheckoutService,
2332
- CheckoutSubscriptionService,
2333
- CouponService,
2334
- HomeShopService,
2335
- OrderService,
2336
- ShippingService,
2337
- WishlistService,
2338
- {
2339
- provide: UpdateUserImage,
2340
- useFactory: (userRepository, fileUploader) => {
2341
- return new UpdateUserImage(userRepository, fileUploader);
2342
- },
2343
- deps: ['UserRepository', 'FileUploaderService'],
2344
- },
2345
- ],
2346
- }]
2238
+ class AngularConnectModule {
2239
+ static initializeApp(defaultShop, options, nameOrConfig) {
2240
+ return {
2241
+ ngModule: AngularConnectModule,
2242
+ providers: [
2243
+ {
2244
+ provide: CATEGORY_STRUCTURE,
2245
+ useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
2246
+ ? OldCategoryStructureAdapter
2247
+ : NewCategoryStructureAdapter,
2248
+ },
2249
+ { provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
2250
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
2251
+ ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
2252
+ ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2253
+ ...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2254
+ ...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2255
+ ...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2256
+ ...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
2257
+ ],
2258
+ };
2259
+ }
2260
+ }
2261
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2262
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
2263
+ AngularFirebaseAuthModule,
2264
+ AngularFirestoreModule,
2265
+ AngularHasuraGraphQLModule] });
2266
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
2267
+ AuthService,
2268
+ CartService,
2269
+ CatalogService,
2270
+ CategoryService,
2271
+ CheckoutService,
2272
+ CheckoutSubscriptionService,
2273
+ CouponService,
2274
+ HomeShopService,
2275
+ OrderService,
2276
+ ShippingService,
2277
+ WishlistService,
2278
+ {
2279
+ provide: UpdateUserImage,
2280
+ useFactory: (userRepository, fileUploader) => {
2281
+ return new UpdateUserImage(userRepository, fileUploader);
2282
+ },
2283
+ deps: ['UserRepository', 'FileUploaderService'],
2284
+ },
2285
+ ], imports: [provideFirebaseApp((injector) => {
2286
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2287
+ try {
2288
+ return getApp(appName);
2289
+ }
2290
+ catch (error) {
2291
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2292
+ }
2293
+ }),
2294
+ AngularElasticSeachModule,
2295
+ AngularFirebaseAuthModule,
2296
+ AngularFirestoreModule,
2297
+ AngularHasuraGraphQLModule] });
2298
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
2299
+ type: NgModule,
2300
+ args: [{
2301
+ imports: [
2302
+ provideFirebaseApp((injector) => {
2303
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2304
+ try {
2305
+ return getApp(appName);
2306
+ }
2307
+ catch (error) {
2308
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2309
+ }
2310
+ }),
2311
+ AngularElasticSeachModule,
2312
+ AngularFirebaseAuthModule,
2313
+ AngularFirestoreModule,
2314
+ AngularHasuraGraphQLModule,
2315
+ ],
2316
+ providers: [
2317
+ AuthService,
2318
+ CartService,
2319
+ CatalogService,
2320
+ CategoryService,
2321
+ CheckoutService,
2322
+ CheckoutSubscriptionService,
2323
+ CouponService,
2324
+ HomeShopService,
2325
+ OrderService,
2326
+ ShippingService,
2327
+ WishlistService,
2328
+ {
2329
+ provide: UpdateUserImage,
2330
+ useFactory: (userRepository, fileUploader) => {
2331
+ return new UpdateUserImage(userRepository, fileUploader);
2332
+ },
2333
+ deps: ['UserRepository', 'FileUploaderService'],
2334
+ },
2335
+ ],
2336
+ }]
2347
2337
  }] });
2348
2338
 
2349
- /**
2350
- * Generated bundle index. Do not edit.
2339
+ /**
2340
+ * Generated bundle index. Do not edit.
2351
2341
  */
2352
2342
 
2353
2343
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };