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