@infrab4a/connect-angular 3.11.0-beta.1 → 4.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/angular-connect.module.d.ts +5 -6
  2. package/angular-firebase-auth.module.d.ts +6 -4
  3. package/angular-firestore.module.d.ts +7 -5
  4. package/consts/firebase-const.d.ts +3 -0
  5. package/consts/index.d.ts +1 -2
  6. package/esm2020/angular-connect.module.mjs +49 -0
  7. package/esm2020/angular-elastic-search.module.mjs +38 -0
  8. package/esm2020/angular-firebase-auth.module.mjs +130 -0
  9. package/esm2020/angular-firestore.module.mjs +358 -0
  10. package/esm2020/angular-hasura-graphql.module.mjs +90 -0
  11. package/esm2020/consts/firebase-const.mjs +4 -0
  12. package/esm2020/consts/index.mjs +5 -0
  13. package/esm2020/index.mjs +6 -0
  14. package/esm2020/services/auth.service.mjs +37 -0
  15. package/esm2020/services/cart.service.mjs +143 -0
  16. package/esm2020/services/checkout-subscription.service.mjs +51 -0
  17. package/esm2020/services/checkout.service.mjs +73 -0
  18. package/esm2020/services/coupon.service.mjs +226 -0
  19. package/esm2020/services/errors/group-invalid-coupon.error.mjs +8 -0
  20. package/esm2020/services/errors/index.mjs +3 -0
  21. package/esm2020/services/errors/invalid-coupon.error.mjs +7 -0
  22. package/esm2020/services/home-shop.service.mjs +114 -0
  23. package/esm2020/services/index.mjs +8 -0
  24. package/esm2020/services/order.service.mjs +30 -0
  25. package/esm2020/types/firebase-app-config.type.mjs +2 -0
  26. package/esm2020/types/index.mjs +2 -0
  27. package/fesm2015/infrab4a-connect-angular.mjs +1336 -0
  28. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -0
  29. package/fesm2020/infrab4a-connect-angular.mjs +1291 -0
  30. package/fesm2020/infrab4a-connect-angular.mjs.map +1 -0
  31. package/index.d.ts +2 -2
  32. package/package.json +24 -12
  33. package/services/auth.service.d.ts +3 -4
  34. package/services/cart.service.d.ts +2 -9
  35. package/services/coupon.service.d.ts +10 -13
  36. package/services/errors/group-invalid-coupon.error.d.ts +6 -0
  37. package/services/errors/index.d.ts +2 -0
  38. package/services/errors/invalid-coupon.error.d.ts +4 -0
  39. package/services/index.d.ts +2 -4
  40. package/services/order.service.d.ts +2 -2
  41. package/types/firebase-app-config.type.d.ts +1 -0
  42. package/types/index.d.ts +1 -0
  43. package/bundles/infrab4a-connect-angular.umd.js +0 -2649
  44. package/bundles/infrab4a-connect-angular.umd.js.map +0 -1
  45. package/consts/backend-url.const.d.ts +0 -1
  46. package/consts/category-structure.d.ts +0 -1
  47. package/esm2015/angular-connect.module.js +0 -63
  48. package/esm2015/angular-elastic-search.module.js +0 -34
  49. package/esm2015/angular-firebase-auth.module.js +0 -113
  50. package/esm2015/angular-firestore.module.js +0 -394
  51. package/esm2015/angular-hasura-graphql.module.js +0 -172
  52. package/esm2015/consts/backend-url.const.js +0 -2
  53. package/esm2015/consts/category-structure.js +0 -2
  54. package/esm2015/consts/index.js +0 -6
  55. package/esm2015/index.js +0 -6
  56. package/esm2015/services/auth.service.js +0 -42
  57. package/esm2015/services/cart.service.js +0 -281
  58. package/esm2015/services/catalog/adapters/category-structure.adapter.js +0 -2
  59. package/esm2015/services/catalog/adapters/index.js +0 -4
  60. package/esm2015/services/catalog/adapters/new-category-structure.adapter.js +0 -51
  61. package/esm2015/services/catalog/adapters/old-category-structure.adapter.js +0 -27
  62. package/esm2015/services/catalog/catalog.service.js +0 -96
  63. package/esm2015/services/catalog/category.service.js +0 -56
  64. package/esm2015/services/catalog/enums/index.js +0 -2
  65. package/esm2015/services/catalog/enums/product-sorts.enum.js +0 -11
  66. package/esm2015/services/catalog/index.js +0 -6
  67. package/esm2015/services/catalog/models/category-with-tree.model.js +0 -10
  68. package/esm2015/services/catalog/models/index.js +0 -2
  69. package/esm2015/services/catalog/types/index.js +0 -2
  70. package/esm2015/services/catalog/types/product-sort.type.js +0 -2
  71. package/esm2015/services/checkout-subscription.service.js +0 -53
  72. package/esm2015/services/checkout.service.js +0 -70
  73. package/esm2015/services/coupon.service.js +0 -240
  74. package/esm2015/services/home-shop.service.js +0 -116
  75. package/esm2015/services/index.js +0 -10
  76. package/esm2015/services/order.service.js +0 -32
  77. package/esm2015/services/shipping.service.js +0 -98
  78. package/esm2015/services/types/shipping-methods.type.js +0 -2
  79. package/fesm2015/infrab4a-connect-angular.js +0 -1868
  80. package/fesm2015/infrab4a-connect-angular.js.map +0 -1
  81. package/infrab4a-connect-angular.d.ts +0 -5
  82. package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
  83. package/services/catalog/adapters/index.d.ts +0 -3
  84. package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -14
  85. package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
  86. package/services/catalog/catalog.service.d.ts +0 -54
  87. package/services/catalog/category.service.d.ts +0 -15
  88. package/services/catalog/enums/index.d.ts +0 -1
  89. package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
  90. package/services/catalog/index.d.ts +0 -5
  91. package/services/catalog/models/category-with-tree.model.d.ts +0 -4
  92. package/services/catalog/models/index.d.ts +0 -1
  93. package/services/catalog/types/index.d.ts +0 -1
  94. package/services/catalog/types/product-sort.type.d.ts +0 -2
  95. package/services/shipping.service.d.ts +0 -19
  96. package/services/types/shipping-methods.type.d.ts +0 -12
  97. /package/{esm2015/consts/default-shop.const.js → esm2020/consts/default-shop.const.mjs} +0 -0
  98. /package/{esm2015/consts/es-config.const.js → esm2020/consts/es-config.const.mjs} +0 -0
  99. /package/{esm2015/consts/hasura-options.const.js → esm2020/consts/hasura-options.const.mjs} +0 -0
  100. /package/{esm2015/infrab4a-connect-angular.js → esm2020/infrab4a-connect-angular.mjs} +0 -0
  101. /package/{esm2015/services/types/index.js → esm2020/services/types/index.mjs} +0 -0
  102. /package/{esm2015/services/types/required-checkout-data.type.js → esm2020/services/types/required-checkout-data.type.mjs} +0 -0
  103. /package/{esm2015/services/types/required-checkout-subscription-data.type.js → esm2020/services/types/required-checkout-subscription-data.type.mjs} +0 -0
@@ -1,1868 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { NgModule, APP_INITIALIZER, Injectable, Inject } from '@angular/core';
3
- import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
4
- import * as i1$1 from '@infrab4a/connect';
5
- import { ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword } from '@infrab4a/connect';
6
- import * as i1$2 from '@angular/fire/firestore';
7
- import { AngularFirestore } from '@angular/fire/firestore';
8
- import * as i1 from '@angular/fire/auth';
9
- import { AngularFireAuth } from '@angular/fire/auth';
10
- import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxjs';
11
- import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
12
- import { __awaiter, __decorate, __metadata } from 'tslib';
13
- import cookie from 'js-cookie';
14
- import { Type } from 'class-transformer';
15
- import * as i1$3 from '@angular/common/http';
16
-
17
- const ES_CONFIG = 'ES_CONFIG';
18
-
19
- class AngularElasticSeachModule {
20
- static initializeApp(options) {
21
- return {
22
- ngModule: AngularElasticSeachModule,
23
- providers: [{ provide: ES_CONFIG, useValue: options }],
24
- };
25
- }
26
- }
27
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
28
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
29
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
30
- {
31
- provide: ProductsIndex,
32
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
33
- deps: [ES_CONFIG],
34
- },
35
- ] });
36
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
37
- type: NgModule,
38
- args: [{
39
- providers: [
40
- {
41
- provide: ProductsIndex,
42
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
43
- deps: [ES_CONFIG],
44
- },
45
- ],
46
- }]
47
- }] });
48
-
49
- class AngularFirestoreModule {
50
- static initializeApp(options, nameOrConfig) {
51
- return {
52
- ngModule: AngularFirestoreModule,
53
- providers: [
54
- { provide: FIREBASE_OPTIONS, useValue: options.firebase },
55
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
56
- { provide: ES_CONFIG, useValue: options.elasticSearch },
57
- ],
58
- };
59
- }
60
- }
61
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
62
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
63
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
64
- {
65
- provide: 'BeautyProfileRepository',
66
- useFactory: (firestore, userRepository) => {
67
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
68
- },
69
- deps: [AngularFirestore, 'UserRepository'],
70
- },
71
- {
72
- provide: 'Buy2WinRepository',
73
- useFactory: (firestore) => {
74
- return new Buy2WinFirestoreRepository(firestore.firestore);
75
- },
76
- deps: [AngularFirestore],
77
- },
78
- {
79
- provide: CategoryFirestoreRepository,
80
- useFactory: (firestore) => {
81
- return new CategoryFirestoreRepository(firestore.firestore);
82
- },
83
- deps: [AngularFirestore],
84
- },
85
- {
86
- provide: 'CheckoutRepository',
87
- useFactory: (firestore) => {
88
- return new CheckoutFirestoreRepository(firestore.firestore);
89
- },
90
- deps: [AngularFirestore],
91
- },
92
- {
93
- provide: 'CheckoutSubscriptionRepository',
94
- useFactory: (firestore) => {
95
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
96
- },
97
- deps: [AngularFirestore],
98
- },
99
- {
100
- provide: 'CouponRepository',
101
- useFactory: (firestore) => {
102
- return new CouponFirestoreRepository(firestore.firestore);
103
- },
104
- deps: [AngularFirestore],
105
- },
106
- {
107
- provide: 'CampaignHashtagRepository',
108
- useFactory: (firestore) => {
109
- return new CampaignHashtagFirestoreRepository(firestore.firestore);
110
- },
111
- deps: [AngularFirestore],
112
- },
113
- {
114
- provide: 'CampaignDashboardRepository',
115
- useFactory: (firestore) => {
116
- return new CampaignDashboardFirestoreRepository(firestore.firestore);
117
- },
118
- deps: [AngularFirestore],
119
- },
120
- {
121
- provide: 'EditionRepository',
122
- useFactory: (firestore, subscriptionRepository) => {
123
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
124
- },
125
- deps: [AngularFirestore, 'SubscriptionRepository'],
126
- },
127
- {
128
- provide: 'HomeRepository',
129
- useFactory: (firestore) => {
130
- return new HomeFirestoreRepository(firestore.firestore);
131
- },
132
- deps: [AngularFirestore],
133
- },
134
- {
135
- provide: 'LeadRepository',
136
- useFactory: (firestore) => {
137
- return new LeadFirestoreRepository(firestore.firestore);
138
- },
139
- deps: [AngularFirestore],
140
- },
141
- {
142
- provide: 'LegacyOrderRepository',
143
- useFactory: (firestore) => {
144
- return new LegacyOrderFirestoreRepository(firestore.firestore);
145
- },
146
- deps: [AngularFirestore],
147
- },
148
- {
149
- provide: 'ShopMenuRepository',
150
- useFactory: (firestore) => {
151
- return new ShopMenuFirestoreRepository(firestore.firestore);
152
- },
153
- deps: [AngularFirestore],
154
- },
155
- {
156
- provide: 'OrderRepository',
157
- useFactory: (firestore) => {
158
- return new OrderFirestoreRepository(firestore.firestore);
159
- },
160
- deps: [AngularFirestore],
161
- },
162
- {
163
- provide: 'PaymentRepository',
164
- useFactory: (firestore) => {
165
- return new PaymentFirestoreRepository(firestore.firestore);
166
- },
167
- deps: [AngularFirestore],
168
- },
169
- {
170
- provide: ProductFirestoreRepository,
171
- useFactory: (firestore) => {
172
- return new ProductFirestoreRepository(firestore.firestore);
173
- },
174
- deps: [AngularFirestore],
175
- },
176
- {
177
- provide: 'ShopSettingsRepository',
178
- useFactory: (firestore) => {
179
- return new ShopSettingsFirestoreRepository(firestore.firestore);
180
- },
181
- deps: [AngularFirestore],
182
- },
183
- {
184
- provide: 'SubscriptionPaymentRepository',
185
- useFactory: (firestore, subscriptionRepository) => {
186
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
187
- },
188
- deps: [AngularFirestore, 'SubscriptionRepository'],
189
- },
190
- {
191
- provide: 'SubscriptionPlanRepository',
192
- useFactory: (firestore) => {
193
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
194
- },
195
- deps: [AngularFirestore],
196
- },
197
- {
198
- provide: 'SubscriptionProductRepository',
199
- useFactory: (firestore) => {
200
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
201
- },
202
- deps: [AngularFirestore],
203
- },
204
- {
205
- provide: 'SubscriptionRepository',
206
- useFactory: (firestore) => {
207
- return new SubscriptionFirestoreRepository(firestore.firestore);
208
- },
209
- deps: [AngularFirestore],
210
- },
211
- {
212
- provide: 'UserRepository',
213
- useFactory: (firestore) => {
214
- return new UserFirestoreRepository(firestore.firestore);
215
- },
216
- deps: [AngularFirestore],
217
- },
218
- {
219
- provide: 'UserAddressRepository',
220
- useFactory: (firestore, userRepository) => {
221
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
222
- },
223
- deps: [AngularFirestore, 'UserRepository'],
224
- },
225
- {
226
- provide: 'UserPaymentMethodRepository',
227
- useFactory: (firestore, userRepository) => {
228
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
229
- },
230
- deps: [AngularFirestore, 'UserRepository'],
231
- },
232
- {
233
- provide: ProductVariantFirestoreRepository,
234
- useFactory: (firestore, productRepository) => {
235
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
236
- },
237
- deps: [AngularFirestore, ProductFirestoreRepository],
238
- },
239
- {
240
- provide: APP_INITIALIZER,
241
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
242
- deps: [AngularFirestore],
243
- multi: true,
244
- },
245
- ], imports: [[AngularFireModule, AngularElasticSeachModule]] });
246
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
247
- type: NgModule,
248
- args: [{
249
- imports: [AngularFireModule, AngularElasticSeachModule],
250
- providers: [
251
- {
252
- provide: 'BeautyProfileRepository',
253
- useFactory: (firestore, userRepository) => {
254
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
255
- },
256
- deps: [AngularFirestore, 'UserRepository'],
257
- },
258
- {
259
- provide: 'Buy2WinRepository',
260
- useFactory: (firestore) => {
261
- return new Buy2WinFirestoreRepository(firestore.firestore);
262
- },
263
- deps: [AngularFirestore],
264
- },
265
- {
266
- provide: CategoryFirestoreRepository,
267
- useFactory: (firestore) => {
268
- return new CategoryFirestoreRepository(firestore.firestore);
269
- },
270
- deps: [AngularFirestore],
271
- },
272
- {
273
- provide: 'CheckoutRepository',
274
- useFactory: (firestore) => {
275
- return new CheckoutFirestoreRepository(firestore.firestore);
276
- },
277
- deps: [AngularFirestore],
278
- },
279
- {
280
- provide: 'CheckoutSubscriptionRepository',
281
- useFactory: (firestore) => {
282
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
283
- },
284
- deps: [AngularFirestore],
285
- },
286
- {
287
- provide: 'CouponRepository',
288
- useFactory: (firestore) => {
289
- return new CouponFirestoreRepository(firestore.firestore);
290
- },
291
- deps: [AngularFirestore],
292
- },
293
- {
294
- provide: 'CampaignHashtagRepository',
295
- useFactory: (firestore) => {
296
- return new CampaignHashtagFirestoreRepository(firestore.firestore);
297
- },
298
- deps: [AngularFirestore],
299
- },
300
- {
301
- provide: 'CampaignDashboardRepository',
302
- useFactory: (firestore) => {
303
- return new CampaignDashboardFirestoreRepository(firestore.firestore);
304
- },
305
- deps: [AngularFirestore],
306
- },
307
- {
308
- provide: 'EditionRepository',
309
- useFactory: (firestore, subscriptionRepository) => {
310
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
311
- },
312
- deps: [AngularFirestore, 'SubscriptionRepository'],
313
- },
314
- {
315
- provide: 'HomeRepository',
316
- useFactory: (firestore) => {
317
- return new HomeFirestoreRepository(firestore.firestore);
318
- },
319
- deps: [AngularFirestore],
320
- },
321
- {
322
- provide: 'LeadRepository',
323
- useFactory: (firestore) => {
324
- return new LeadFirestoreRepository(firestore.firestore);
325
- },
326
- deps: [AngularFirestore],
327
- },
328
- {
329
- provide: 'LegacyOrderRepository',
330
- useFactory: (firestore) => {
331
- return new LegacyOrderFirestoreRepository(firestore.firestore);
332
- },
333
- deps: [AngularFirestore],
334
- },
335
- {
336
- provide: 'ShopMenuRepository',
337
- useFactory: (firestore) => {
338
- return new ShopMenuFirestoreRepository(firestore.firestore);
339
- },
340
- deps: [AngularFirestore],
341
- },
342
- {
343
- provide: 'OrderRepository',
344
- useFactory: (firestore) => {
345
- return new OrderFirestoreRepository(firestore.firestore);
346
- },
347
- deps: [AngularFirestore],
348
- },
349
- {
350
- provide: 'PaymentRepository',
351
- useFactory: (firestore) => {
352
- return new PaymentFirestoreRepository(firestore.firestore);
353
- },
354
- deps: [AngularFirestore],
355
- },
356
- {
357
- provide: ProductFirestoreRepository,
358
- useFactory: (firestore) => {
359
- return new ProductFirestoreRepository(firestore.firestore);
360
- },
361
- deps: [AngularFirestore],
362
- },
363
- {
364
- provide: 'ShopSettingsRepository',
365
- useFactory: (firestore) => {
366
- return new ShopSettingsFirestoreRepository(firestore.firestore);
367
- },
368
- deps: [AngularFirestore],
369
- },
370
- {
371
- provide: 'SubscriptionPaymentRepository',
372
- useFactory: (firestore, subscriptionRepository) => {
373
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
374
- },
375
- deps: [AngularFirestore, 'SubscriptionRepository'],
376
- },
377
- {
378
- provide: 'SubscriptionPlanRepository',
379
- useFactory: (firestore) => {
380
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
381
- },
382
- deps: [AngularFirestore],
383
- },
384
- {
385
- provide: 'SubscriptionProductRepository',
386
- useFactory: (firestore) => {
387
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
388
- },
389
- deps: [AngularFirestore],
390
- },
391
- {
392
- provide: 'SubscriptionRepository',
393
- useFactory: (firestore) => {
394
- return new SubscriptionFirestoreRepository(firestore.firestore);
395
- },
396
- deps: [AngularFirestore],
397
- },
398
- {
399
- provide: 'UserRepository',
400
- useFactory: (firestore) => {
401
- return new UserFirestoreRepository(firestore.firestore);
402
- },
403
- deps: [AngularFirestore],
404
- },
405
- {
406
- provide: 'UserAddressRepository',
407
- useFactory: (firestore, userRepository) => {
408
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
409
- },
410
- deps: [AngularFirestore, 'UserRepository'],
411
- },
412
- {
413
- provide: 'UserPaymentMethodRepository',
414
- useFactory: (firestore, userRepository) => {
415
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
416
- },
417
- deps: [AngularFirestore, 'UserRepository'],
418
- },
419
- {
420
- provide: ProductVariantFirestoreRepository,
421
- useFactory: (firestore, productRepository) => {
422
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
423
- },
424
- deps: [AngularFirestore, ProductFirestoreRepository],
425
- },
426
- {
427
- provide: APP_INITIALIZER,
428
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
429
- deps: [AngularFirestore],
430
- multi: true,
431
- },
432
- ],
433
- }]
434
- }] });
435
-
436
- const BACKEND_URL = 'BACKEND_URL';
437
-
438
- const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
439
-
440
- const DEFAULT_SHOP = 'DEFAULT_SHOP';
441
-
442
- const HASURA_OPTIONS = 'HASURA_OPTIONS';
443
-
444
- class AngularHasuraGraphQLModule {
445
- static initializeApp(options) {
446
- return {
447
- ngModule: AngularHasuraGraphQLModule,
448
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
449
- };
450
- }
451
- }
452
- AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
453
- AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
454
- AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
455
- {
456
- provide: 'CategoryRepository',
457
- useExisting: CategoryHasuraGraphQLRepository,
458
- },
459
- {
460
- provide: CategoryHasuraGraphQLRepository,
461
- useFactory: (options, productRepository, categoryFilterRepository) => {
462
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
463
- },
464
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
465
- },
466
- {
467
- provide: 'ProductRepository',
468
- useExisting: ProductHasuraGraphQLRepository,
469
- },
470
- {
471
- provide: ProductHasuraGraphQLRepository,
472
- useFactory: (options) => {
473
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
474
- },
475
- deps: [HASURA_OPTIONS],
476
- },
477
- {
478
- provide: 'VariantRepository',
479
- useExisting: VariantHasuraGraphQLRepository,
480
- },
481
- {
482
- provide: VariantHasuraGraphQLRepository,
483
- useFactory: (options) => {
484
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
485
- },
486
- deps: [HASURA_OPTIONS],
487
- },
488
- {
489
- provide: 'CategoryFilterRepository',
490
- useExisting: CategoryFilterHasuraGraphQLRepository,
491
- },
492
- {
493
- provide: CategoryFilterHasuraGraphQLRepository,
494
- useFactory: (options) => {
495
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
496
- },
497
- deps: [HASURA_OPTIONS],
498
- },
499
- {
500
- provide: 'FilterOptionRepository',
501
- useExisting: FilterOptionHasuraGraphQLRepository,
502
- },
503
- {
504
- provide: FilterOptionHasuraGraphQLRepository,
505
- useFactory: (options) => {
506
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
507
- },
508
- deps: [HASURA_OPTIONS],
509
- },
510
- {
511
- provide: 'FilterRepository',
512
- useExisting: FilterHasuraGraphQLRepository,
513
- },
514
- {
515
- provide: FilterHasuraGraphQLRepository,
516
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
517
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
518
- },
519
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
520
- },
521
- {
522
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
523
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
524
- },
525
- {
526
- provide: 'CategoryCollectionChildrenRepository',
527
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
528
- },
529
- ] });
530
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
531
- type: NgModule,
532
- args: [{
533
- providers: [
534
- {
535
- provide: 'CategoryRepository',
536
- useExisting: CategoryHasuraGraphQLRepository,
537
- },
538
- {
539
- provide: CategoryHasuraGraphQLRepository,
540
- useFactory: (options, productRepository, categoryFilterRepository) => {
541
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
542
- },
543
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
544
- },
545
- {
546
- provide: 'ProductRepository',
547
- useExisting: ProductHasuraGraphQLRepository,
548
- },
549
- {
550
- provide: ProductHasuraGraphQLRepository,
551
- useFactory: (options) => {
552
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
553
- },
554
- deps: [HASURA_OPTIONS],
555
- },
556
- {
557
- provide: 'VariantRepository',
558
- useExisting: VariantHasuraGraphQLRepository,
559
- },
560
- {
561
- provide: VariantHasuraGraphQLRepository,
562
- useFactory: (options) => {
563
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
564
- },
565
- deps: [HASURA_OPTIONS],
566
- },
567
- {
568
- provide: 'CategoryFilterRepository',
569
- useExisting: CategoryFilterHasuraGraphQLRepository,
570
- },
571
- {
572
- provide: CategoryFilterHasuraGraphQLRepository,
573
- useFactory: (options) => {
574
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
575
- },
576
- deps: [HASURA_OPTIONS],
577
- },
578
- {
579
- provide: 'FilterOptionRepository',
580
- useExisting: FilterOptionHasuraGraphQLRepository,
581
- },
582
- {
583
- provide: FilterOptionHasuraGraphQLRepository,
584
- useFactory: (options) => {
585
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
586
- },
587
- deps: [HASURA_OPTIONS],
588
- },
589
- {
590
- provide: 'FilterRepository',
591
- useExisting: FilterHasuraGraphQLRepository,
592
- },
593
- {
594
- provide: FilterHasuraGraphQLRepository,
595
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
596
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
597
- },
598
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
599
- },
600
- {
601
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
602
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
603
- },
604
- {
605
- provide: 'CategoryCollectionChildrenRepository',
606
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
607
- },
608
- ],
609
- }]
610
- }] });
611
-
612
- class AuthService {
613
- constructor(angularFireAuth, userRepository) {
614
- this.angularFireAuth = angularFireAuth;
615
- this.userRepository = userRepository;
616
- }
617
- getAuthstate() {
618
- const observables = [
619
- this.angularFireAuth.authState.pipe(catchError(() => of(null))),
620
- this.getUser().pipe(catchError(() => of(null))),
621
- ];
622
- return combineLatest(observables).pipe(map(([fireUser, user]) => {
623
- return {
624
- user,
625
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
626
- };
627
- }));
628
- }
629
- getUser() {
630
- return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
631
- }
632
- getTokenId() {
633
- return this.angularFireAuth.idToken;
634
- }
635
- getFireUser() {
636
- return this.angularFireAuth.user.pipe(catchError(() => of(null)));
637
- }
638
- }
639
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
640
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
641
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
642
- type: Injectable
643
- }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
644
- type: Inject,
645
- args: ['UserRepository']
646
- }] }]; } });
647
-
648
- class CouponService {
649
- constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
650
- this.couponRepository = couponRepository;
651
- this.defaultShop = defaultShop;
652
- this.orderRepository = orderRepository;
653
- this.categoryRepository = categoryRepository;
654
- this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
655
- }
656
- checkCoupon(nickname, checkoutType, checkout, plan) {
657
- return from(this.couponRepository
658
- .find({
659
- filters: {
660
- nickname: { operator: Where.EQUALS, value: nickname },
661
- active: { operator: Where.EQUALS, value: true },
662
- },
663
- })
664
- .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
665
- }
666
- couponValidation(coupon, checkoutType) {
667
- return __awaiter(this, void 0, void 0, function* () {
668
- if (!coupon)
669
- throw 'Cupom inválido.';
670
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
671
- throw 'Cupom inválido.';
672
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
673
- throw 'Cupom expirado.';
674
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
675
- if (!isInShop)
676
- throw 'Cupom inválido para loja.';
677
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
678
- if (!isCheckoutType)
679
- throw 'Cupom inválido. Erro de checkout.';
680
- return coupon;
681
- });
682
- }
683
- couponRulesValidation(coupon, checkoutType, checkout, plan) {
684
- return __awaiter(this, void 0, void 0, function* () {
685
- if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
686
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
687
- throw 'Cupom inválido para sua assinatura.';
688
- return coupon;
689
- }
690
- const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
691
- if (!validUser)
692
- throw 'Usuário não elegível.';
693
- const orders = yield this.getOrdersWithCoupon(coupon);
694
- const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
695
- const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
696
- if (couponUseLimits.limitedPerUser && ordersWithUser > 0)
697
- throw 'Limite de uso por usuário atingido.';
698
- if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
699
- throw 'Limite de uso atingido.';
700
- const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
701
- if (!hasProductCategories)
702
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
703
- const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
704
- if (!hasMinSubTotal)
705
- throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
706
- return coupon;
707
- });
708
- }
709
- calcDiscountSubscription(coupon, checkout) {
710
- let discount = 0;
711
- if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
712
- discount = coupon.discount.subscription.value;
713
- else
714
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
715
- return of(discount);
716
- }
717
- calcDiscountShopping(coupon, checkout) {
718
- return __awaiter(this, void 0, void 0, function* () {
719
- let discount = 0;
720
- if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
721
- discount = yield this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
722
- }
723
- else {
724
- discount = yield this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
725
- }
726
- return discount;
727
- });
728
- }
729
- calcDiscountByType(type, value, categories, checkout) {
730
- return __awaiter(this, void 0, void 0, function* () {
731
- let discount = 0;
732
- let lineItensDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
733
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
734
- if (type == CouponTypes.ABSOLUTE) {
735
- discount = value > subTotal ? subTotal : value;
736
- }
737
- else {
738
- discount = subTotal * (value / 100);
739
- }
740
- return discount;
741
- });
742
- }
743
- hasMinSubTotal(coupon, checkout) {
744
- return __awaiter(this, void 0, void 0, function* () {
745
- if (!coupon.minSubTotalValue)
746
- return true;
747
- let lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
748
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
749
- if (coupon.minSubTotalValue <= subTotal)
750
- return true;
751
- return false;
752
- });
753
- }
754
- hasProductCategories(coupon, checkout) {
755
- var _a;
756
- return __awaiter(this, void 0, void 0, function* () {
757
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
758
- return true;
759
- }
760
- const couponCategories = yield this.getCouponCategoriesId(coupon.productsCategories);
761
- const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
762
- var _a;
763
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
764
- return true;
765
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
766
- });
767
- return hasCategories.length ? true : false;
768
- });
769
- }
770
- coupomUserValidation(coupon, user) {
771
- if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
772
- return true;
773
- let userTypes = [];
774
- if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
775
- userTypes.push(Exclusivities.COLLABORATORS);
776
- if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
777
- userTypes.push(Exclusivities.SPECIFIC_USER);
778
- if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
779
- user.isSubscriber &&
780
- user.subscriptionPlan != '')
781
- userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
782
- if (user.isSubscriber &&
783
- user.subscriptionPlan == '' &&
784
- coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
785
- userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
786
- if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
787
- userTypes.push(Exclusivities.NON_SUBSCRIBER);
788
- return coupon.exclusivityType.some((r) => userTypes.includes(r));
789
- }
790
- getCouponCategoriesId(productsCategories) {
791
- return __awaiter(this, void 0, void 0, function* () {
792
- const couponCategories = [];
793
- for (let index = 0; index < productsCategories.length; index++) {
794
- const category = yield this.categoryRepository.get({
795
- id: productsCategories[index],
796
- });
797
- if (category) {
798
- const children = yield this.categoryRepository.getChildren(parseInt(productsCategories[index]));
799
- couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
800
- }
801
- }
802
- return [...new Set(couponCategories)];
803
- });
804
- }
805
- getLineItensEligebleForDiscount(productsCategories, checkout) {
806
- var _a;
807
- return __awaiter(this, void 0, void 0, function* () {
808
- let lineItensDiscount = [];
809
- const couponCategories = yield this.getCouponCategoriesId(productsCategories);
810
- if (productsCategories && productsCategories.length) {
811
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
812
- var _a;
813
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
814
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
815
- }
816
- return true;
817
- });
818
- }
819
- else {
820
- lineItensDiscount = checkout.lineItems;
821
- }
822
- return lineItensDiscount;
823
- });
824
- }
825
- calcCheckoutSubtotal(lineItens, user, shop) {
826
- return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce((acc, curr) => {
827
- var _a, _b;
828
- return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price[shop]) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
829
- ? acc + ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
830
- : acc + curr.pricePaid * curr.quantity;
831
- }, 0)) || 0);
832
- }
833
- getOrdersWithCoupon(coupon) {
834
- return __awaiter(this, void 0, void 0, function* () {
835
- return yield this.orderRepository
836
- .find({
837
- filters: {
838
- coupon: { id: coupon.id },
839
- payment: { status: 'paid' },
840
- },
841
- })
842
- .then((result) => result.data);
843
- });
844
- }
845
- countOrdersWithUser(orders, email) {
846
- return orders.filter((o) => o.user.email == email).length;
847
- }
848
- getCouponUseLimits(coupon, checkoutType, user) {
849
- let couponUseLimits;
850
- if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
851
- couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
852
- }
853
- else {
854
- couponUseLimits = coupon.useLimits.subscription;
855
- }
856
- return couponUseLimits;
857
- }
858
- }
859
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
860
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
861
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
862
- type: Injectable,
863
- args: [{
864
- providedIn: 'root',
865
- }]
866
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
867
- type: Inject,
868
- args: ['CouponRepository']
869
- }] }, { type: i1$1.Shops, decorators: [{
870
- type: Inject,
871
- args: [DEFAULT_SHOP]
872
- }] }, { type: undefined, decorators: [{
873
- type: Inject,
874
- args: ['OrderRepository']
875
- }] }, { type: undefined, decorators: [{
876
- type: Inject,
877
- args: ['CategoryRepository']
878
- }] }]; } });
879
-
880
- class CheckoutService {
881
- constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
882
- this.couponService = couponService;
883
- this.checkoutRepository = checkoutRepository;
884
- this.orderRepository = orderRepository;
885
- this.userRepository = userRepository;
886
- this.defaultShop = defaultShop;
887
- }
888
- getCheckout(checkoutData) {
889
- const checkoutId = cookie.get('checkoutId');
890
- if (!isNil(checkoutId))
891
- return from(this.checkoutRepository.get({ id: checkoutId }));
892
- return from(this.createCheckout(checkoutData));
893
- }
894
- getUserByCheckout(checkoutId) {
895
- return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => { var _a; return ((_a = checkout === null || checkout === void 0 ? void 0 : checkout.user) === null || _a === void 0 ? void 0 : _a.id) ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id })); }), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
896
- }
897
- updateCheckoutLineItems(checkout) {
898
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
899
- }
900
- updateCheckoutUser(checkout) {
901
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
902
- }
903
- clearCheckoutFromSession() {
904
- cookie.remove('checkoutId');
905
- return of();
906
- }
907
- calcDiscount(coupon) {
908
- return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
909
- }
910
- checkCoupon(nickname, checkoutType) {
911
- return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
912
- }
913
- createCheckout(checkoutData) {
914
- return __awaiter(this, void 0, void 0, function* () {
915
- const checkout = yield this.checkoutRepository.create(Object.assign(Object.assign({ createdAt: new Date() }, Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()), { shop: (checkoutData === null || checkoutData === void 0 ? void 0 : checkoutData.shop) || this.defaultShop }));
916
- cookie.set('checkoutId', checkout.id);
917
- return checkout;
918
- });
919
- }
920
- }
921
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
922
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService });
923
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, decorators: [{
924
- type: Injectable
925
- }], ctorParameters: function () { return [{ type: CouponService }, { type: undefined, decorators: [{
926
- type: Inject,
927
- args: ['CheckoutRepository']
928
- }] }, { type: undefined, decorators: [{
929
- type: Inject,
930
- args: ['OrderRepository']
931
- }] }, { type: undefined, decorators: [{
932
- type: Inject,
933
- args: ['UserRepository']
934
- }] }, { type: i1$1.Shops, decorators: [{
935
- type: Inject,
936
- args: [DEFAULT_SHOP]
937
- }] }]; } });
938
-
939
- class CartService {
940
- constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
941
- this.authService = authService;
942
- this.checkoutService = checkoutService;
943
- this.defaultShop = defaultShop;
944
- this.productRepository = productRepository;
945
- this.categoryRepository = categoryRepository;
946
- this.variantRepository = variantRepository;
947
- this.buy2WinRepository = buy2WinRepository;
948
- this.cartSubject = new Subject();
949
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
950
- var _a;
951
- const items = [];
952
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
953
- if (index > -1) {
954
- checkoutLoaded.lineItems[index].quantity += quantity;
955
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
956
- }
957
- else
958
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
959
- return this.checkoutService
960
- .updateCheckoutLineItems(checkoutLoaded)
961
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
962
- }));
963
- this.generateCartObject = (items) => items
964
- ? items.reduce((cart, item) => {
965
- var _a;
966
- return (Object.assign(Object.assign({}, cart), { [item.id]: LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.id] || item)), { quantity: (((_a = cart[item.id]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })) }));
967
- }, {})
968
- : [];
969
- this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
970
- var _a, _b, _c, _d, _e, _f, _g;
971
- const product = yield this.getProductData(item.id);
972
- item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
973
- if (this.checkMaxStock(item, quantity || 0))
974
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
975
- const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
976
- const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
977
- const isGift = item.isGift || null;
978
- const pricePaid = this.getProductPrice({
979
- product: item,
980
- shop: checkout.shop || this.defaultShop,
981
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
982
- });
983
- RoundProductPricesHelper.roundProductPrices(item);
984
- return {
985
- checkout,
986
- lineItem: LineItem.toInstance({
987
- id,
988
- name: name !== null && name !== void 0 ? name : product.name,
989
- EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
990
- brand: product.brand,
991
- slug: slug !== null && slug !== void 0 ? slug : product.slug,
992
- sku: sku !== null && sku !== void 0 ? sku : product.sku,
993
- stock,
994
- price: this.roundPrice(price),
995
- image,
996
- weight: weight !== null && weight !== void 0 ? weight : product.weight,
997
- quantity: (item.quantity || 0) + (quantity || 0),
998
- pricePaid,
999
- categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
1000
- isGift: isGift !== null && isGift !== void 0 ? isGift : null,
1001
- costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
1002
- type,
1003
- }),
1004
- };
1005
- });
1006
- this.getProductPrice = ({ product, isSubscriber, }) => {
1007
- const info = product.price;
1008
- if (product.isGift)
1009
- return 0;
1010
- return isSubscriber && info.subscriberPrice > 0
1011
- ? Number(info.subscriberPrice.toFixed(2))
1012
- : Number(info.price.toFixed(2));
1013
- };
1014
- this.checkMaxStock = (item, quantity) => {
1015
- var _a;
1016
- const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
1017
- const currentItemAmount = item.quantity || 0;
1018
- return currentItemAmount + quantity > maxStock;
1019
- };
1020
- }
1021
- addItem(item, quantity = 1) {
1022
- return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
1023
- }
1024
- decreaseItem(item) {
1025
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1026
- var _a;
1027
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.id === item.id);
1028
- if (!isNil(checkoutItem))
1029
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
1030
- return checkout;
1031
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1032
- }
1033
- getCart(checkout) {
1034
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1035
- return this.cartSubject;
1036
- }
1037
- /**
1038
- * @deprecated The method should not be used
1039
- */
1040
- getVariantPriceDiscount(item) {
1041
- 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)));
1042
- }
1043
- removeItem(item) {
1044
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1045
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
1046
- if (index >= 0)
1047
- checkout.lineItems.splice(index, 1);
1048
- return checkout;
1049
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1050
- }
1051
- updateUserCart(user) {
1052
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
1053
- var _a, _b;
1054
- return this.checkoutService
1055
- .updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length)
1056
- ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; })))
1057
- : [] })))
1058
- .toPromise();
1059
- })), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1060
- }
1061
- clearCart() {
1062
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
1063
- this.checkoutService.clearCheckoutFromSession();
1064
- return checkout;
1065
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1066
- }
1067
- buildCartFromCheckout(checkoutData) {
1068
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1069
- }
1070
- roundPrice(productPrice) {
1071
- const { price, fullPrice, subscriberPrice } = productPrice;
1072
- return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
1073
- }
1074
- getProductData(productId) {
1075
- return __awaiter(this, void 0, void 0, function* () {
1076
- let product;
1077
- let variant;
1078
- try {
1079
- product = yield this.productRepository.get({ id: productId });
1080
- }
1081
- catch (error) {
1082
- if (!(error instanceof NotFoundError))
1083
- throw error;
1084
- const { data: variants } = yield this.variantRepository.find({ filters: { id: productId } });
1085
- variant = variants.shift();
1086
- if (!variant)
1087
- throw error;
1088
- product = yield this.productRepository.get({ id: variant.productId });
1089
- }
1090
- return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
1091
- });
1092
- }
1093
- getGifts() {
1094
- return this.checkoutService.getCheckout().pipe(mergeMap((checkout) => __awaiter(this, void 0, void 0, function* () {
1095
- const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1096
- if (!notGiftItems.length)
1097
- return Object.assign(Object.assign({}, checkout), { lineItems: [] });
1098
- const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1099
- const campaigns = yield this.buy2WinRepository
1100
- .find({
1101
- filters: {
1102
- active: { operator: Where.EQUALS, value: true },
1103
- shop: { operator: Where.EQUALS, value: this.defaultShop },
1104
- },
1105
- })
1106
- .then((data) => data.data);
1107
- if (!campaigns.length)
1108
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1109
- const elegibleCampaigns = [];
1110
- for (const campaign of campaigns) {
1111
- const today = new Date().getDate();
1112
- if (!(campaign.startDate.getDate() <= today) && !(campaign.endDate.getDate() >= today))
1113
- continue;
1114
- if (campaign.activeCategory) {
1115
- const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1116
- const categoriesCampaingFullTree = [];
1117
- for (const id of categoriesCampaing) {
1118
- const children = yield this.categoryRepository.getChildren(parseInt(id));
1119
- categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1120
- }
1121
- const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1122
- const filterProductsCategories = checkout.lineItems.filter((l) => {
1123
- var _a;
1124
- if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
1125
- return true;
1126
- return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1127
- });
1128
- if (filterProductsCategories.length) {
1129
- const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1130
- if (cartTotalCategories >= campaign.cartValueMin)
1131
- elegibleCampaigns.push(campaign);
1132
- }
1133
- }
1134
- else {
1135
- if (campaign.cartValue && campaign.cartValue > 0) {
1136
- if (campaign.cartValue <= cartTotal)
1137
- elegibleCampaigns.push(campaign);
1138
- }
1139
- }
1140
- }
1141
- if (!elegibleCampaigns.length)
1142
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1143
- const campaingnProducts = [];
1144
- for (const campaign of elegibleCampaigns) {
1145
- let elegibleProducts = [];
1146
- for (const product of campaign.products) {
1147
- const { data: productData } = yield this.productRepository.find({ filters: { sku: product } });
1148
- if (!productData.length)
1149
- continue;
1150
- const gift = productData.shift();
1151
- if (gift.stock.quantity < 1)
1152
- continue;
1153
- elegibleProducts.push(gift);
1154
- }
1155
- campaingnProducts.push(elegibleProducts);
1156
- }
1157
- if (!campaingnProducts.length)
1158
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1159
- const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1160
- return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems.concat(gifts) });
1161
- })), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1162
- }
1163
- giftToLineItems(items) {
1164
- return items.map((item) => {
1165
- var _a;
1166
- const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
1167
- const image = ((_a = item === null || item === void 0 ? void 0 : item.miniatures) === null || _a === void 0 ? void 0 : _a.length) ? item.miniatures[0] : item.images[0];
1168
- return LineItem.toInstance({
1169
- brand,
1170
- categories,
1171
- id: id.toString(),
1172
- name,
1173
- price,
1174
- sku,
1175
- slug,
1176
- stock,
1177
- weight,
1178
- EAN,
1179
- image,
1180
- pricePaid: 0,
1181
- quantity: 1,
1182
- isGift: true,
1183
- });
1184
- });
1185
- }
1186
- }
1187
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1188
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
1189
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
1190
- type: Injectable
1191
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
1192
- type: Inject,
1193
- args: [DEFAULT_SHOP]
1194
- }] }, { type: undefined, decorators: [{
1195
- type: Inject,
1196
- args: ['ProductRepository']
1197
- }] }, { type: undefined, decorators: [{
1198
- type: Inject,
1199
- args: ['CategoryRepository']
1200
- }] }, { type: undefined, decorators: [{
1201
- type: Inject,
1202
- args: ['VariantRepository']
1203
- }] }, { type: i1$1.Buy2WinFirestoreRepository, decorators: [{
1204
- type: Inject,
1205
- args: ['Buy2WinRepository']
1206
- }] }]; } });
1207
-
1208
- class CatalogService {
1209
- constructor(productRepository, categoryStructureAdapter, shop) {
1210
- this.productRepository = productRepository;
1211
- this.categoryStructureAdapter = categoryStructureAdapter;
1212
- this.shop = shop;
1213
- this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1214
- const filters = {};
1215
- if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
1216
- set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1217
- if (brands === null || brands === void 0 ? void 0 : brands.length)
1218
- filters.brand = { operator: Where.IN, value: brands };
1219
- if (gender === null || gender === void 0 ? void 0 : gender.length)
1220
- filters.tags = {
1221
- operator: Where.IN,
1222
- value: gender
1223
- .map((genderOptions) => genderOptions === 'female' ? 'feminino' : genderOptions === 'male' ? 'masculino' : null)
1224
- .filter(Boolean),
1225
- };
1226
- if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
1227
- set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1228
- ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1229
- ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1230
- ]);
1231
- if (rate)
1232
- filters.rate = { operator: Where.GTE, value: rate };
1233
- if (tags === null || tags === void 0 ? void 0 : tags.length)
1234
- filters.tags = { operator: Where.LIKE, value: tags };
1235
- if (customOptions === null || customOptions === void 0 ? void 0 : customOptions.length)
1236
- filters.filters = { operator: Where.LIKE, value: customOptions };
1237
- return filters;
1238
- };
1239
- this.buildSortQuery = (sort) => {
1240
- if (!sort || sort === 'most-relevant')
1241
- return {};
1242
- if (sort === 'best-sellers')
1243
- return { shoppingCount: 'desc' };
1244
- if (sort === 'biggest-price')
1245
- return { price: 'desc' };
1246
- if (sort === 'lowest-price')
1247
- return { price: 'asc' };
1248
- if (sort === 'best-rating')
1249
- return { rate: 'desc' };
1250
- if (sort === 'news')
1251
- return { createdAt: 'desc' };
1252
- };
1253
- this.buildLimitQuery = (options) => {
1254
- const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
1255
- return {
1256
- limit,
1257
- offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
1258
- };
1259
- };
1260
- }
1261
- fetchProducts(category, options) {
1262
- return __awaiter(this, void 0, void 0, function* () {
1263
- const limits = this.buildLimitQuery(options);
1264
- return yield this.productRepository
1265
- .findCatalog(Object.assign(Object.assign({ filters: Object.assign(Object.assign({}, (yield this.categoryStructureAdapter.buildProductFilterByCategory(category))), this.buildFilterQuery((options === null || options === void 0 ? void 0 : options.filters) || {})) }, ((options === null || options === void 0 ? void 0 : options.sort) ? { orderBy: this.buildSortQuery(options === null || options === void 0 ? void 0 : options.sort) } : {})), { limits, options: { minimal: ['price'], maximum: ['price'] } }), (options === null || options === void 0 ? void 0 : options.mainGender) || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1266
- .then(({ data, count: total, maximum, minimal }) => {
1267
- var _a, _b, _c, _d, _e, _f, _g, _h;
1268
- return ({
1269
- products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1270
- pages: Math.ceil(total / limits.limit),
1271
- prices: {
1272
- price: { min: +((_b = (_a = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.toFixed(2)), max: +((_d = (_c = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.toFixed(2)) },
1273
- subscriberPrice: {
1274
- min: +((_f = (_e = minimal === null || minimal === void 0 ? void 0 : minimal.price) === null || _e === void 0 ? void 0 : _e.subscriberPrice) === null || _f === void 0 ? void 0 : _f.toFixed(2)),
1275
- max: +((_h = (_g = maximum === null || maximum === void 0 ? void 0 : maximum.price) === null || _g === void 0 ? void 0 : _g.subscriberPrice) === null || _h === void 0 ? void 0 : _h.toFixed(2)),
1276
- },
1277
- },
1278
- });
1279
- });
1280
- });
1281
- }
1282
- }
1283
- CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1284
- CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService });
1285
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService, decorators: [{
1286
- type: Injectable
1287
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1288
- type: Inject,
1289
- args: ['ProductRepository']
1290
- }] }, { type: undefined, decorators: [{
1291
- type: Inject,
1292
- args: [CATEGORY_STRUCTURE]
1293
- }] }, { type: i1$1.Shops, decorators: [{
1294
- type: Inject,
1295
- args: [DEFAULT_SHOP]
1296
- }] }]; } });
1297
-
1298
- class CategoryService {
1299
- constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1300
- this.productRepository = productRepository;
1301
- this.categoryRepository = categoryRepository;
1302
- this.categoryFilterRepository = categoryFilterRepository;
1303
- this.categoryStructureAdapter = categoryStructureAdapter;
1304
- this.shop = shop;
1305
- }
1306
- fetchBrands(category, mainGender) {
1307
- return __awaiter(this, void 0, void 0, function* () {
1308
- const brands = yield this.productRepository
1309
- .findCatalog({
1310
- filters: yield this.categoryStructureAdapter.buildProductFilterByCategory(category),
1311
- fields: ['brand'],
1312
- }, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1313
- .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
1314
- return this.categoryRepository
1315
- .find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
1316
- .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1317
- });
1318
- }
1319
- fetchFilterOptions(category, filters) {
1320
- return __awaiter(this, void 0, void 0, function* () {
1321
- return yield this.categoryFilterRepository
1322
- .find({ filters: { categoryId: +category.id } })
1323
- .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1324
- });
1325
- }
1326
- }
1327
- CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1328
- CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CategoryService });
1329
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CategoryService, decorators: [{
1330
- type: Injectable
1331
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1332
- type: Inject,
1333
- args: ['ProductRepository']
1334
- }] }, { type: undefined, decorators: [{
1335
- type: Inject,
1336
- args: ['CategoryRepository']
1337
- }] }, { type: undefined, decorators: [{
1338
- type: Inject,
1339
- args: ['CategoryFilterRepository']
1340
- }] }, { type: undefined, decorators: [{
1341
- type: Inject,
1342
- args: [CATEGORY_STRUCTURE]
1343
- }] }, { type: i1$1.Shops, decorators: [{
1344
- type: Inject,
1345
- args: [DEFAULT_SHOP]
1346
- }] }]; } });
1347
-
1348
- var ProductSorts;
1349
- (function (ProductSorts) {
1350
- ProductSorts["MOST_RELEVANT"] = "most-relevant";
1351
- ProductSorts["BEST_SELLER"] = "best-sellers";
1352
- ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1353
- ProductSorts["LOWEST_PRICE"] = "lowest-price";
1354
- ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1355
- ProductSorts["BEST_RATING"] = "best-rating";
1356
- ProductSorts["NEWS"] = "news";
1357
- })(ProductSorts || (ProductSorts = {}));
1358
-
1359
- class CategoryWithTree extends Category {
1360
- }
1361
- __decorate([
1362
- Type(() => CategoryWithTree),
1363
- __metadata("design:type", Array)
1364
- ], CategoryWithTree.prototype, "children", void 0);
1365
-
1366
- class CheckoutSubscriptionService {
1367
- constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1368
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1369
- this.subscriptionRepository = subscriptionRepository;
1370
- this.couponService = couponService;
1371
- }
1372
- getCheckoutSubscription(checkoutData) {
1373
- const checkoutId = cookie.get('checkoutSubscriptionId');
1374
- if (!isNil(checkoutId))
1375
- return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
1376
- return from(this.createCheckoutSubscription(checkoutData));
1377
- }
1378
- createCheckoutSubscription(checkoutData) {
1379
- return __awaiter(this, void 0, void 0, function* () {
1380
- const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
1381
- cookie.set('checkoutSubscriptionId', checkout.id);
1382
- return checkout;
1383
- });
1384
- }
1385
- clearCheckoutSubscriptionFromSession() {
1386
- cookie.remove('checkoutSubscriptionId');
1387
- return of();
1388
- }
1389
- checkCoupon(nickname, userEmail) {
1390
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
1391
- .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
1392
- .pipe()));
1393
- }
1394
- calcDiscountSubscription(coupon) {
1395
- return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
1396
- }
1397
- }
1398
- CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
1399
- CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService });
1400
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
1401
- type: Injectable
1402
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1403
- type: Inject,
1404
- args: ['CheckoutSubscriptionRepository']
1405
- }] }, { type: undefined, decorators: [{
1406
- type: Inject,
1407
- args: ['SubscriptionRepository']
1408
- }] }, { type: CouponService }]; } });
1409
-
1410
- class HomeShopService {
1411
- constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
1412
- this.categoryRepository = categoryRepository;
1413
- this.homeRepository = homeRepository;
1414
- this.productRepository = productRepository;
1415
- this.defaultShop = defaultShop;
1416
- this.buildCategoryGroupWithRequiredData = (group) => {
1417
- var _a, _b;
1418
- return ({
1419
- category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
1420
- products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
1421
- 'id',
1422
- 'price',
1423
- 'reviews',
1424
- 'hasVariants',
1425
- 'slug',
1426
- 'sku',
1427
- 'stock',
1428
- 'costPrice',
1429
- 'images',
1430
- 'miniatures',
1431
- 'name',
1432
- 'weight',
1433
- 'rate',
1434
- 'type',
1435
- ])))) || [],
1436
- });
1437
- };
1438
- }
1439
- get homeId() {
1440
- if (this.defaultShop === Shops.GLAMSHOP)
1441
- return 'glamshop';
1442
- if (this.defaultShop === Shops.MENSMARKET)
1443
- return 'mens_market';
1444
- return null;
1445
- }
1446
- getHomeData() {
1447
- return this.getHomeConfiguration().pipe(map((home) => { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), concatMap((home) => home
1448
- ? of(home)
1449
- : forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
1450
- discoverProducts,
1451
- featuredProducts,
1452
- verticalProducts,
1453
- })), concatMap((data) => this.saveHomeData(data)))));
1454
- }
1455
- getBanners(type) {
1456
- return this.getHomeConfiguration().pipe(map((home) => {
1457
- if (type === 'brand')
1458
- return home.brandsCarousel;
1459
- if (type === 'buyToWin')
1460
- return [home.buyToWinBanner];
1461
- if (type === 'block')
1462
- return home.blockBanners;
1463
- if (type === 'blog')
1464
- return [home.blogBanner];
1465
- }));
1466
- }
1467
- getMinValueForFreeShipping() {
1468
- return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
1469
- }
1470
- getDiscoverProducts() {
1471
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
1472
- }
1473
- getFeaturedProducts() {
1474
- return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
1475
- }
1476
- getVerticalProducts() {
1477
- 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({
1478
- filters: { categories: { operator: Where.IN, value: [category.id] } },
1479
- limits: { limit: 12 },
1480
- })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
1481
- }
1482
- getHomeConfiguration() {
1483
- return of(this.homeConfiguration).pipe(concatMap((home) => home
1484
- ? of(home)
1485
- : !this.homeId
1486
- ? throwError(new RequiredArgumentError(['homeId']))
1487
- : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
1488
- }
1489
- saveHomeData(homeData) {
1490
- const data = {
1491
- createdAt: new Date(),
1492
- expiresAt: add(new Date(), { hours: 1 }),
1493
- data: homeData,
1494
- };
1495
- return from(this.homeRepository.update({
1496
- id: this.homeId,
1497
- data,
1498
- })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
1499
- }
1500
- }
1501
- HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1502
- HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService });
1503
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: HomeShopService, decorators: [{
1504
- type: Injectable
1505
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1506
- type: Inject,
1507
- args: ['CategoryRepository']
1508
- }] }, { type: undefined, decorators: [{
1509
- type: Inject,
1510
- args: ['HomeRepository']
1511
- }] }, { type: undefined, decorators: [{
1512
- type: Inject,
1513
- args: ['ProductRepository']
1514
- }] }, { type: i1$1.Shops, decorators: [{
1515
- type: Inject,
1516
- args: [DEFAULT_SHOP]
1517
- }] }]; } });
1518
-
1519
- class OrderService {
1520
- constructor(angularFirestore, orderRepository) {
1521
- this.angularFirestore = angularFirestore;
1522
- this.orderRepository = orderRepository;
1523
- this.orderSubject = new Subject();
1524
- }
1525
- getOrder(id) {
1526
- this.angularFirestore
1527
- .doc(`${this.orderRepository.collectionName}/${id}`)
1528
- .valueChanges()
1529
- .pipe(map((doc) => Order.toInstance(doc)))
1530
- .subscribe((doc) => this.orderSubject.next(doc));
1531
- return this.orderSubject;
1532
- }
1533
- }
1534
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1535
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
1536
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
1537
- type: Injectable
1538
- }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
1539
- type: Inject,
1540
- args: ['OrderRepository']
1541
- }] }]; } });
1542
-
1543
- class ShippingService {
1544
- constructor(http, apiUrl, homeService) {
1545
- this.http = http;
1546
- this.apiUrl = apiUrl;
1547
- this.homeService = homeService;
1548
- }
1549
- getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
1550
- return combineLatest([
1551
- this.homeService.getHomeData(),
1552
- this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
1553
- ]).pipe(map(([datas, shippingMethodsResponse]) => {
1554
- let shippingMethods = shippingMethodsResponse.result;
1555
- if (!shippingMethods.length)
1556
- return [];
1557
- shippingMethods = shippingMethods.map((s) => {
1558
- if (s.ShippingCompanyName == 'Same Day EG')
1559
- s.ShippingCompanyName = 'Same Day';
1560
- else
1561
- return s;
1562
- });
1563
- const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
1564
- if (this.isHolidays(datasSameDayNotAvaliable)) {
1565
- shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
1566
- }
1567
- if (totalPrice >= 200) {
1568
- shippingMethods = shippingMethods.map((s) => {
1569
- if (s.serviceName !== 'Same Day')
1570
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1571
- else
1572
- return s;
1573
- });
1574
- }
1575
- if (shop == Shops.GLAMSHOP)
1576
- return shippingMethods;
1577
- if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
1578
- shippingMethods = shippingMethods.map((s) => {
1579
- if (s.serviceName == 'Same Day')
1580
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1581
- else
1582
- return Object.assign(Object.assign({}, s), { totalPrice: 0 });
1583
- });
1584
- }
1585
- if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
1586
- shippingMethods = shippingMethods.map((s) => {
1587
- return Object.assign(Object.assign({}, s), { totalPrice: s.totalPrice / 2 });
1588
- });
1589
- }
1590
- return shippingMethods;
1591
- }));
1592
- }
1593
- isFreeShippingBySubscription(shop, subscriptionPlan) {
1594
- if (!subscriptionPlan)
1595
- return false;
1596
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT') {
1597
- return true;
1598
- }
1599
- return false;
1600
- }
1601
- isHalfShippingBySubscription(shop, subscriptionPlan) {
1602
- if (!subscriptionPlan)
1603
- return false;
1604
- if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
1605
- return true;
1606
- }
1607
- return false;
1608
- }
1609
- isHolidays(datas) {
1610
- const today = new Date();
1611
- for (const key in datas) {
1612
- let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
1613
- let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
1614
- if (start > end)
1615
- end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
1616
- if (today >= start && today <= end)
1617
- return true;
1618
- }
1619
- return false;
1620
- }
1621
- }
1622
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
1623
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
1624
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
1625
- type: Injectable
1626
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
1627
- type: Inject,
1628
- args: [BACKEND_URL]
1629
- }] }, { type: HomeShopService }]; } });
1630
-
1631
- class NewCategoryStructureAdapter {
1632
- constructor(categoryRepository, categoryCollectionChildrenRepository) {
1633
- this.categoryRepository = categoryRepository;
1634
- this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1635
- }
1636
- buildProductFilterByCategory(category) {
1637
- return __awaiter(this, void 0, void 0, function* () {
1638
- const categoriesIds = (yield this.isCollection(category))
1639
- ? yield this.getAllCategoriesIdFromCollection(category)
1640
- : [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1641
- return { category: { id: { operator: Where.IN, value: categoriesIds } } };
1642
- });
1643
- }
1644
- getAllCategoriesIdFromCategory(category) {
1645
- return __awaiter(this, void 0, void 0, function* () {
1646
- return this.categoryRepository
1647
- .getChildren(+category.id)
1648
- .then((categories) => categories.map((category) => category.id.toString()));
1649
- });
1650
- }
1651
- getAllCategoriesIdFromCollection(category) {
1652
- return __awaiter(this, void 0, void 0, function* () {
1653
- return this.categoryCollectionChildrenRepository
1654
- .find({ filters: { collectionId: +category.id } })
1655
- .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1656
- });
1657
- }
1658
- isCollection(category) {
1659
- return __awaiter(this, void 0, void 0, function* () {
1660
- return !isNil(category.isCollection)
1661
- ? category.isCollection
1662
- : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1663
- });
1664
- }
1665
- }
1666
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1667
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter });
1668
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1669
- type: Injectable
1670
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1671
- type: Inject,
1672
- args: ['CategoryRepository']
1673
- }] }, { type: undefined, decorators: [{
1674
- type: Inject,
1675
- args: ['CategoryCollectionChildrenRepository']
1676
- }] }]; } });
1677
-
1678
- class OldCategoryStructureAdapter {
1679
- constructor(categoryRepository) {
1680
- this.categoryRepository = categoryRepository;
1681
- }
1682
- buildProductFilterByCategory(category) {
1683
- var _a;
1684
- return __awaiter(this, void 0, void 0, function* () {
1685
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1686
- ? category.products
1687
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1688
- return { id: { operator: Where.IN, value: productsIds } };
1689
- });
1690
- }
1691
- }
1692
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1693
- OldCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter });
1694
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1695
- type: Injectable
1696
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1697
- type: Inject,
1698
- args: ['CategoryRepository']
1699
- }] }]; } });
1700
-
1701
- class AngularConnectModule {
1702
- static initializeApp(defaultShop, options, nameOrConfig) {
1703
- return {
1704
- ngModule: AngularConnectModule,
1705
- providers: [
1706
- {
1707
- provide: CATEGORY_STRUCTURE,
1708
- useClass: isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
1709
- ? OldCategoryStructureAdapter
1710
- : NewCategoryStructureAdapter,
1711
- },
1712
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1713
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1714
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1715
- ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1716
- ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1717
- ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
1718
- ],
1719
- };
1720
- }
1721
- }
1722
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1723
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1724
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
1725
- AuthService,
1726
- CartService,
1727
- CatalogService,
1728
- CategoryService,
1729
- CheckoutService,
1730
- CheckoutSubscriptionService,
1731
- CouponService,
1732
- HomeShopService,
1733
- OrderService,
1734
- ShippingService,
1735
- ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1736
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1737
- type: NgModule,
1738
- args: [{
1739
- imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1740
- providers: [
1741
- AuthService,
1742
- CartService,
1743
- CatalogService,
1744
- CategoryService,
1745
- CheckoutService,
1746
- CheckoutSubscriptionService,
1747
- CouponService,
1748
- HomeShopService,
1749
- OrderService,
1750
- ShippingService,
1751
- ],
1752
- }]
1753
- }] });
1754
-
1755
- class AngularFirebaseAuthModule {
1756
- static initializeApp(options, nameOrConfig) {
1757
- return {
1758
- ngModule: AngularFirebaseAuthModule,
1759
- providers: [
1760
- { provide: FIREBASE_OPTIONS, useValue: options },
1761
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
1762
- ],
1763
- };
1764
- }
1765
- }
1766
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1767
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
1768
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
1769
- {
1770
- provide: 'Authentication',
1771
- useFactory: (authenticationService, userRepository) => {
1772
- return new Authentication(authenticationService, userRepository);
1773
- },
1774
- deps: ['AuthenticationService', 'UserRepository'],
1775
- },
1776
- {
1777
- provide: 'AuthenticationService',
1778
- useFactory: (angularFireAuth) => {
1779
- return new AuthenticationFirebaseAuthService(angularFireAuth);
1780
- },
1781
- deps: [AngularFireAuth],
1782
- },
1783
- {
1784
- provide: 'Register',
1785
- useFactory: (registerService, userRepository) => {
1786
- return new Register(registerService, userRepository);
1787
- },
1788
- deps: ['RegisterService', 'UserRepository'],
1789
- },
1790
- {
1791
- provide: 'RegisterService',
1792
- useFactory: (angularFireAuth) => {
1793
- return new RegisterFirebaseAuthService(angularFireAuth);
1794
- },
1795
- deps: [AngularFireAuth],
1796
- },
1797
- {
1798
- provide: 'SignOut',
1799
- useFactory: (authenticationService) => {
1800
- return new SignOut(authenticationService);
1801
- },
1802
- deps: ['AuthenticationService'],
1803
- },
1804
- {
1805
- provide: 'RecoveryPassword',
1806
- useFactory: (authenticationService) => {
1807
- return new RecoveryPassword(authenticationService);
1808
- },
1809
- deps: ['AuthenticationService'],
1810
- },
1811
- ], imports: [[AngularFireModule]] });
1812
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
1813
- type: NgModule,
1814
- args: [{
1815
- imports: [AngularFireModule],
1816
- providers: [
1817
- {
1818
- provide: 'Authentication',
1819
- useFactory: (authenticationService, userRepository) => {
1820
- return new Authentication(authenticationService, userRepository);
1821
- },
1822
- deps: ['AuthenticationService', 'UserRepository'],
1823
- },
1824
- {
1825
- provide: 'AuthenticationService',
1826
- useFactory: (angularFireAuth) => {
1827
- return new AuthenticationFirebaseAuthService(angularFireAuth);
1828
- },
1829
- deps: [AngularFireAuth],
1830
- },
1831
- {
1832
- provide: 'Register',
1833
- useFactory: (registerService, userRepository) => {
1834
- return new Register(registerService, userRepository);
1835
- },
1836
- deps: ['RegisterService', 'UserRepository'],
1837
- },
1838
- {
1839
- provide: 'RegisterService',
1840
- useFactory: (angularFireAuth) => {
1841
- return new RegisterFirebaseAuthService(angularFireAuth);
1842
- },
1843
- deps: [AngularFireAuth],
1844
- },
1845
- {
1846
- provide: 'SignOut',
1847
- useFactory: (authenticationService) => {
1848
- return new SignOut(authenticationService);
1849
- },
1850
- deps: ['AuthenticationService'],
1851
- },
1852
- {
1853
- provide: 'RecoveryPassword',
1854
- useFactory: (authenticationService) => {
1855
- return new RecoveryPassword(authenticationService);
1856
- },
1857
- deps: ['AuthenticationService'],
1858
- },
1859
- ],
1860
- }]
1861
- }] });
1862
-
1863
- /**
1864
- * Generated bundle index. Do not edit.
1865
- */
1866
-
1867
- export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService };
1868
- //# sourceMappingURL=infrab4a-connect-angular.js.map