@infrab4a/connect-angular 4.1.1-beta.0 → 4.1.2-beta.0

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