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