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