@infrab4a/connect-angular 4.1.6-beta.3 → 4.1.6

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