@infrab4a/connect-angular 4.18.0 → 4.18.1

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