@infrab4a/connect-angular 4.18.2 → 4.18.3-beta.0

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