@infrab4a/connect-angular 4.21.0 → 5.0.0-alpha.0

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