@infrab4a/connect-angular 4.3.12 → 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 -41
  41. package/esm2020/services/catalog/adapters/old-category-structure.adapter.mjs +23 -23
  42. package/esm2020/services/catalog/catalog.service.mjs +190 -190
  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 -2326
  68. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -1
  69. package/fesm2020/infrab4a-connect-angular.mjs +2258 -2258
  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,2288 +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
- 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']
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']
1573
1573
  }] }]; } });
1574
1574
 
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']
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']
1593
1593
  }] }]; } });
1594
1594
 
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]
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]
1778
1778
  }] }, { type: i1$2.ProductsIndex }]; } });
1779
1779
 
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]
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]
1824
1824
  }] }]; } });
1825
1825
 
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";
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";
1835
1835
  })(ProductSorts || (ProductSorts = {}));
1836
1836
 
1837
- class CategoryWithTree extends Category {
1838
- }
1839
- __decorate([
1840
- Type(() => CategoryWithTree),
1841
- __metadata("design:type", Array)
1837
+ class CategoryWithTree extends Category {
1838
+ }
1839
+ __decorate([
1840
+ Type(() => CategoryWithTree),
1841
+ __metadata("design:type", Array)
1842
1842
  ], CategoryWithTree.prototype, "children", void 0);
1843
1843
 
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']
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']
1949
1949
  }] }, { type: i1$2.ProductsIndex }]; } });
1950
1950
 
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]
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]
1992
1992
  }] }, { type: CouponService }]; } });
1993
1993
 
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
- }
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
+ }
2010
2010
  }
2011
2011
 
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]
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]
2128
2128
  }] }]; } });
2129
2129
 
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']
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']
2150
2150
  }] }]; } });
2151
2151
 
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]
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]
2236
2236
  }] }, { type: HomeShopService }]; } });
2237
2237
 
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
- }]
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
+ }]
2337
2337
  }] });
2338
2338
 
2339
- /**
2340
- * Generated bundle index. Do not edit.
2339
+ /**
2340
+ * Generated bundle index. Do not edit.
2341
2341
  */
2342
2342
 
2343
2343
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };