@infrab4a/connect-angular 4.2.3-beta.1 → 4.2.3-beta.3

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