@daffodil/cart 0.94.1 → 0.95.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/fesm2022/daffodil-cart-driver-in-memory.mjs +1618 -1198
  2. package/fesm2022/daffodil-cart-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-cart-driver-magento-2.4.7-testing.mjs +546 -0
  4. package/fesm2022/daffodil-cart-driver-magento-2.4.7-testing.mjs.map +1 -0
  5. package/fesm2022/daffodil-cart-driver-magento-2.4.7.mjs +2607 -0
  6. package/fesm2022/daffodil-cart-driver-magento-2.4.7.mjs.map +1 -0
  7. package/fesm2022/daffodil-cart-driver-magento-auto-testing.mjs +7 -0
  8. package/fesm2022/daffodil-cart-driver-magento-auto-testing.mjs.map +1 -0
  9. package/fesm2022/daffodil-cart-driver-magento-auto.mjs +7 -0
  10. package/fesm2022/daffodil-cart-driver-magento-auto.mjs.map +1 -0
  11. package/fesm2022/daffodil-cart-driver-testing.mjs +553 -335
  12. package/fesm2022/daffodil-cart-driver-testing.mjs.map +1 -1
  13. package/fesm2022/daffodil-cart-driver.mjs +167 -292
  14. package/fesm2022/daffodil-cart-driver.mjs.map +1 -1
  15. package/fesm2022/daffodil-cart-routing.mjs +741 -542
  16. package/fesm2022/daffodil-cart-routing.mjs.map +1 -1
  17. package/fesm2022/daffodil-cart-state-testing.mjs +288 -193
  18. package/fesm2022/daffodil-cart-state-testing.mjs.map +1 -1
  19. package/fesm2022/daffodil-cart-state.mjs +2571 -2800
  20. package/fesm2022/daffodil-cart-state.mjs.map +1 -1
  21. package/fesm2022/daffodil-cart-testing.mjs +542 -357
  22. package/fesm2022/daffodil-cart-testing.mjs.map +1 -1
  23. package/fesm2022/daffodil-cart.mjs +131 -200
  24. package/fesm2022/daffodil-cart.mjs.map +1 -1
  25. package/package.json +1 -1
  26. package/types/daffodil-cart-driver-in-memory.d.ts +273 -292
  27. package/types/daffodil-cart-driver-magento-2.4.7-testing.d.ts +176 -0
  28. package/types/daffodil-cart-driver-magento-2.4.7.d.ts +860 -0
  29. package/types/daffodil-cart-driver-magento-auto-testing.d.ts +1 -0
  30. package/types/daffodil-cart-driver-magento-auto.d.ts +1 -0
  31. package/types/daffodil-cart-driver-testing.d.ts +111 -118
  32. package/types/daffodil-cart-driver.d.ts +219 -262
  33. package/types/daffodil-cart-routing.d.ts +130 -149
  34. package/types/daffodil-cart-state-testing.d.ts +115 -114
  35. package/types/daffodil-cart-state.d.ts +1126 -1173
  36. package/types/daffodil-cart-testing.d.ts +146 -158
  37. package/types/daffodil-cart.d.ts +302 -321
  38. package/fesm2022/daffodil-cart-driver-magento-testing.mjs +0 -332
  39. package/fesm2022/daffodil-cart-driver-magento-testing.mjs.map +0 -1
  40. package/fesm2022/daffodil-cart-driver-magento.mjs +0 -2273
  41. package/fesm2022/daffodil-cart-driver-magento.mjs.map +0 -1
  42. package/types/daffodil-cart-driver-magento-testing.d.ts +0 -188
  43. package/types/daffodil-cart-driver-magento.d.ts +0 -999
@@ -1,547 +1,746 @@
1
- import * as i0 from '@angular/core';
2
- import { Inject, Injectable, NgModule } from '@angular/core';
3
- import * as i2 from '@angular/router';
4
- import { take, tap, filter, map, switchMap, skipUntil } from 'rxjs/operators';
5
- import * as i1 from '@daffodil/cart/state';
6
- import { DaffCartResolveState, DaffResolveCart, DaffCartActionTypes } from '@daffodil/cart/state';
7
- import { createSingleInjectionToken, createConfigInjectionToken } from '@daffodil/core';
8
- import { iif } from 'rxjs';
9
- import * as i3 from '@daffodil/cart';
10
- import * as i1$1 from '@ngrx/store';
11
-
12
- const { token: DaffCartBillingAddressGuardRedirectUrl,
13
- /**
14
- * Provider function for {@link DaffCartBillingAddressGuardRedirectUrl}.
15
- */
16
- provider: provideDaffCartBillingAddressGuardRedirectUrl, } = createSingleInjectionToken('DaffCartBillingAddressGuardRedirectUrl', { factory: () => '/' });
17
-
18
- /**
19
- * A routing guard that will redirect to a given url if the billing address on the cart is not defined.
20
- * The url is `/` by default, but can be overridden with the DaffCartBillingAddressGuardRedirectUrl injection token.
21
- * The guard will not wait until the cart has been resolved before performing the check and emitting.
22
- * Ensure that the cart is resolved prior to running this guard with the {@link DaffResolvedCartGuard}.
23
- */
24
- class DaffBillingAddressGuard {
25
- constructor(facade, router, redirectUrl) {
26
- this.facade = facade;
27
- this.router = router;
28
- this.redirectUrl = redirectUrl;
29
- }
30
- canActivate() {
31
- return this.facade.hasBillingAddress$.pipe(take(1), tap(hasBillingAddress => {
32
- if (!hasBillingAddress) {
33
- this.router.navigateByUrl(this.redirectUrl);
34
- }
35
- }));
36
- }
37
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffBillingAddressGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffCartBillingAddressGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
38
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffBillingAddressGuard, providedIn: 'root' }); }
39
- }
40
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffBillingAddressGuard, decorators: [{
41
- type: Injectable,
42
- args: [{
43
- providedIn: 'root',
44
- }]
45
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
46
- type: Inject,
47
- args: [DaffCartBillingAddressGuardRedirectUrl]
48
- }] }] });
49
-
50
- ;
51
- /**
52
- * The default values of the resolution slice of the cart state configuration.
53
- */
54
- const daffCartRoutingResolutionConfigurationDefault = {
55
- failedResolutionPath: null,
1
+ import * as i0 from "@angular/core";
2
+ import { Inject, Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
3
+ import * as i2 from "@angular/router";
4
+ import { filter, map, skipUntil, switchMap, take, tap } from "rxjs/operators";
5
+ import * as i1$1 from "@daffodil/cart/state";
6
+ import { DaffCartActionTypes, DaffCartResolveState, DaffResolveCart } from "@daffodil/cart/state";
7
+ import { createConfigInjectionToken, createSingleInjectionToken } from "@daffodil/core";
8
+ import { iif } from "rxjs";
9
+ import * as i3 from "@daffodil/cart";
10
+ import * as i1 from "@ngrx/store";
11
+ const { token: DaffCartBillingAddressGuardRedirectUrl, provider: provideDaffCartBillingAddressGuardRedirectUrl } = createSingleInjectionToken("DaffCartBillingAddressGuardRedirectUrl", { factory: () => "/" });
12
+ var DaffBillingAddressGuard = class DaffBillingAddressGuard {
13
+ constructor(facade, router, redirectUrl) {
14
+ this.facade = facade;
15
+ this.router = router;
16
+ this.redirectUrl = redirectUrl;
17
+ }
18
+ canActivate() {
19
+ return this.facade.hasBillingAddress$.pipe(take(1), tap((hasBillingAddress) => {
20
+ if (!hasBillingAddress) this.router.navigateByUrl(this.redirectUrl);
21
+ }));
22
+ }
23
+ static {
24
+ this.ɵfac = i0.ɵɵngDeclareFactory({
25
+ minVersion: "12.0.0",
26
+ version: "22.2.4",
27
+ ngImport: i0,
28
+ type: DaffBillingAddressGuard,
29
+ deps: [
30
+ { token: i1$1.DaffCartFacade },
31
+ { token: i2.Router },
32
+ { token: DaffCartBillingAddressGuardRedirectUrl }
33
+ ],
34
+ target: i0.ɵɵFactoryTarget.Injectable
35
+ });
36
+ }
37
+ static {
38
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
39
+ minVersion: "12.0.0",
40
+ version: "22.2.4",
41
+ ngImport: i0,
42
+ type: DaffBillingAddressGuard,
43
+ providedIn: "root"
44
+ });
45
+ }
56
46
  };
57
-
58
- /**
59
- * The default values of the `@daffodil/cart/state` state configuration.
60
- */
61
- const daffCartRoutingConfigurationDefault = {
62
- resolution: {
63
- ...daffCartRoutingResolutionConfigurationDefault,
64
- },
47
+ i0.ɵɵngDeclareClassMetadata({
48
+ minVersion: "12.0.0",
49
+ version: "22.2.4",
50
+ ngImport: i0,
51
+ type: DaffBillingAddressGuard,
52
+ decorators: [{
53
+ type: Injectable,
54
+ args: [{ providedIn: "root" }]
55
+ }],
56
+ ctorParameters: () => [
57
+ { type: i1$1.DaffCartFacade },
58
+ { type: i2.Router },
59
+ {
60
+ type: void 0,
61
+ decorators: [{
62
+ type: Inject,
63
+ args: [DaffCartBillingAddressGuardRedirectUrl]
64
+ }]
65
+ }
66
+ ]
67
+ });
68
+ const { token: DAFF_CART_ROUTING_CONFIG, provider: provideDaffCartRoutingConfig } = createConfigInjectionToken({ resolution: { failedResolutionPath: null } }, "DAFF_CART_ROUTING_CONFIG");
69
+ var DaffResolvedCartGuard = class DaffResolvedCartGuard {
70
+ constructor(facade, router, config) {
71
+ this.facade = facade;
72
+ this.router = router;
73
+ this.config = config;
74
+ }
75
+ canActivate() {
76
+ return this.facade.resolved$.pipe(filter((resolvedState) => resolvedState === DaffCartResolveState.Succeeded || resolvedState === DaffCartResolveState.ServerSide || resolvedState === DaffCartResolveState.Failed), map((resolvedState) => resolvedState === DaffCartResolveState.Succeeded || resolvedState === DaffCartResolveState.ServerSide), take(1), map((success) => !success && this.config.resolution.failedResolutionPath ? this.router.parseUrl(this.config.resolution.failedResolutionPath) : success));
77
+ }
78
+ static {
79
+ this.ɵfac = i0.ɵɵngDeclareFactory({
80
+ minVersion: "12.0.0",
81
+ version: "22.2.4",
82
+ ngImport: i0,
83
+ type: DaffResolvedCartGuard,
84
+ deps: [
85
+ { token: i1$1.DaffCartFacade },
86
+ { token: i2.Router },
87
+ { token: DAFF_CART_ROUTING_CONFIG }
88
+ ],
89
+ target: i0.ɵɵFactoryTarget.Injectable
90
+ });
91
+ }
92
+ static {
93
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
94
+ minVersion: "12.0.0",
95
+ version: "22.2.4",
96
+ ngImport: i0,
97
+ type: DaffResolvedCartGuard,
98
+ providedIn: "root"
99
+ });
100
+ }
65
101
  };
66
- /**
67
- * The token holding the runtime configuration for the behavior of the
68
- * `@daffodil/cart/state` package.
69
- */
70
- const { token: DAFF_CART_ROUTING_CONFIG,
71
- /**
72
- * Provider function for {@link DAFF_CART_ROUTING_CONFIG}.
73
- */
74
- provider: provideDaffCartRoutingConfig, } = createConfigInjectionToken(daffCartRoutingConfigurationDefault, 'DAFF_CART_ROUTING_CONFIG');
75
-
76
- /**
77
- * A routing guard that will optionally redirect to a given url if the cart is not properly resolved.
78
- * It will initiate cart resolution.
79
- * The url has no default and the guard will not redirect if no value is specified.
80
- * Specify a redirect path with the {@link DaffResolvedCartGuardRedirectUrl} injection token.
81
- * The guard will wait until the cart has been resolved before performing the check and emitting.
82
- */
83
- class DaffResolvedCartGuard {
84
- constructor(facade, router, config) {
85
- this.facade = facade;
86
- this.router = router;
87
- this.config = config;
88
- }
89
- canActivate() {
90
- return this.facade.resolved$.pipe(filter(resolvedState => resolvedState === DaffCartResolveState.Succeeded ||
91
- resolvedState === DaffCartResolveState.ServerSide ||
92
- resolvedState === DaffCartResolveState.Failed), map(resolvedState => resolvedState === DaffCartResolveState.Succeeded ||
93
- resolvedState === DaffCartResolveState.ServerSide), take(1), map(success => !success && this.config.resolution.failedResolutionPath
94
- ? this.router.parseUrl(this.config.resolution.failedResolutionPath)
95
- : success));
96
- }
97
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffResolvedCartGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DAFF_CART_ROUTING_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
98
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffResolvedCartGuard, providedIn: 'root' }); }
99
- }
100
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffResolvedCartGuard, decorators: [{
101
- type: Injectable,
102
- args: [{
103
- providedIn: 'root',
104
- }]
105
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
106
- type: Inject,
107
- args: [DAFF_CART_ROUTING_CONFIG]
108
- }] }] });
109
-
110
- const { token: DaffResolveCartGuardRedirectUrl,
111
- /**
112
- * Provider function for {@link DaffResolveCartGuardRedirectUrl}.
113
- */
114
- provider: provideDaffResolveCartGuardRedirectUrl, } = createSingleInjectionToken('DaffResolveCartGuardRedirectUrl', { factory: () => '/' });
115
-
116
- const shouldAttemptResolution = (resolvedState, hasIDInStorage) => (hasIDInStorage && resolvedState === DaffCartResolveState.Default) || resolvedState === DaffCartResolveState.Failed;
102
+ i0.ɵɵngDeclareClassMetadata({
103
+ minVersion: "12.0.0",
104
+ version: "22.2.4",
105
+ ngImport: i0,
106
+ type: DaffResolvedCartGuard,
107
+ decorators: [{
108
+ type: Injectable,
109
+ args: [{ providedIn: "root" }]
110
+ }],
111
+ ctorParameters: () => [
112
+ { type: i1$1.DaffCartFacade },
113
+ { type: i2.Router },
114
+ {
115
+ type: void 0,
116
+ decorators: [{
117
+ type: Inject,
118
+ args: [DAFF_CART_ROUTING_CONFIG]
119
+ }]
120
+ }
121
+ ]
122
+ });
123
+ const { token: DaffResolveCartGuardRedirectUrl, provider: provideDaffResolveCartGuardRedirectUrl } = createSingleInjectionToken("DaffResolveCartGuardRedirectUrl", { factory: () => "/" });
124
+ const shouldAttemptResolution = (resolvedState, hasIDInStorage) => hasIDInStorage && resolvedState === DaffCartResolveState.Default || resolvedState === DaffCartResolveState.Failed;
117
125
  const canActivate = (resolved) => {
118
- switch (resolved) {
119
- // proceed with navigation
120
- case DaffCartResolveState.Succeeded:
121
- return true;
122
- // we should wait for resolution to finish
123
- case DaffCartResolveState.Resolving:
124
- return null;
125
- // navigation cannot proceed, redirect
126
- case DaffCartResolveState.Default:
127
- case DaffCartResolveState.Failed:
128
- case DaffCartResolveState.ServerSide:
129
- default:
130
- return false;
131
- }
126
+ switch (resolved) {
127
+ case DaffCartResolveState.Succeeded: return true;
128
+ case DaffCartResolveState.Resolving: return null;
129
+ case DaffCartResolveState.Default:
130
+ case DaffCartResolveState.Failed:
131
+ case DaffCartResolveState.ServerSide:
132
+ default: return false;
133
+ }
132
134
  };
133
- /**
134
- * A routing guard that will optionally redirect to a given url if the cart is not properly resolved.
135
- * It will initiate cart resolution.
136
- * The url has no default and the guard will not redirect if no value is specified.
137
- * Specify a redirect path with the {@link DaffResolvedCartGuardRedirectUrl} injection token.
138
- * The guard will wait until the cart has been resolved before performing the check and emitting.
139
- */
140
- class DaffResolveCartGuard {
141
- constructor(facade, router, redirectUrl, storage) {
142
- this.facade = facade;
143
- this.router = router;
144
- this.redirectUrl = redirectUrl;
145
- this.storage = storage;
146
- }
147
- canActivate() {
148
- return this.facade.resolved$.pipe(take(1),
149
- // first step: decide if we should resolve a cart
150
- map((resolved) => shouldAttemptResolution(resolved, !!this.storage.getCartId())), tap((shouldAttempt) => {
151
- if (shouldAttempt) {
152
- this.facade.dispatch(new DaffResolveCart());
153
- }
154
- }),
155
- // If we dispatch above, we can't immediately proceed with the next step
156
- // as the resolved state is not guaranteed to be updated in time.
157
- // This ensures that the above dispatched DaffResolveCart is processed
158
- // by the reducers before this guard proceeds to the next step
159
- switchMap((shouldAttempt) => iif(() => shouldAttempt, this.facade.resolved$.pipe(skipUntil(this.facade.resolved$.pipe(filter((innerResolved) => innerResolved === DaffCartResolveState.Resolving)))), this.facade.resolved$)),
160
- // second step: decide if navigation should proceed
161
- map((resolved) => canActivate(resolved)),
162
- // ensure that the pipe does not emit before resolution has been completed
163
- filter((response) => response !== null && response !== undefined),
164
- // finally we can resolve, but to where do we resolve
165
- map((resolved) => resolved ? resolved : this.router.parseUrl(this.redirectUrl)));
166
- }
167
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffResolveCartGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffResolveCartGuardRedirectUrl }, { token: i3.DaffCartStorageService }], target: i0.ɵɵFactoryTarget.Injectable }); }
168
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffResolveCartGuard, providedIn: 'root' }); }
169
- }
170
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffResolveCartGuard, decorators: [{
171
- type: Injectable,
172
- args: [{
173
- providedIn: 'root',
174
- }]
175
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
176
- type: Inject,
177
- args: [DaffResolveCartGuardRedirectUrl]
178
- }] }, { type: i3.DaffCartStorageService }] });
179
-
180
- const {
181
- /**
182
- * The path to which the user should be redirected if the cart has no items when {@link DaffCartItemsGuard} is invoked.
183
- */
184
- token: DaffCartItemsGuardRedirectUrl,
185
- /**
186
- * Provider function for {@link DaffCartItemsGuardRedirectUrl}.
187
- */
188
- provider: provideDaffCartItemsGuardRedirectUrl, } = createSingleInjectionToken('DaffCartItemsGuardRedirectUrl', { factory: () => '/' });
189
-
190
- /**
191
- * A routing guard that will ensure that the cart is not empty before allowing activation of a route.
192
- * If the cart has items in it, then `canActivate` will emit true. If not, it will emit false and redirect to a specific path.
193
- * The url is `/` by default but can be overridden with the {@link DaffCartItemsGuardRedirectUrl} injection token.
194
- * The guard will not wait until the cart has been resolved before performing the check and emitting.
195
- * Ensure that the cart is resolved prior to running this guard with the {@link DaffResolvedCartGuard}.
196
- */
197
- class DaffCartItemsGuard {
198
- constructor(facade, router, redirectUrl) {
199
- this.facade = facade;
200
- this.router = router;
201
- this.redirectUrl = redirectUrl;
202
- }
203
- canActivate() {
204
- return this.facade.isCartEmpty$.pipe(map(isCartEmpty => !isCartEmpty), take(1), tap(hasNonEmptyCart => {
205
- if (!hasNonEmptyCart) {
206
- this.router.navigateByUrl(this.redirectUrl);
207
- }
208
- }));
209
- }
210
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartItemsGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffCartItemsGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
211
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartItemsGuard, providedIn: 'root' }); }
212
- }
213
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartItemsGuard, decorators: [{
214
- type: Injectable,
215
- args: [{
216
- providedIn: 'root',
217
- }]
218
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
219
- type: Inject,
220
- args: [DaffCartItemsGuardRedirectUrl]
221
- }] }] });
222
-
223
- const {
224
- /**
225
- * The path to which the user should be redirected if the cart has no items when {@link DaffCartInStockItemsGuard} is invoked.
226
- */
227
- token: DaffCartInStockItemsGuardRedirectUrl,
228
- /**
229
- * Provider function for {@link DaffCartInStockItemsGuardRedirectUrl}.
230
- */
231
- provider: provideDaffCartInStockItemsGuardRedirectUrl, } = createSingleInjectionToken('DaffCartInStockItemsGuardRedirectUrl', { factory: () => '/' });
232
-
233
- /**
234
- * A routing guard that will ensure that the cart has only in-stock items before allowing activation of a route.
235
- * If the cart has any out of stock items in it, then `canActivate` will emit `false` and redirect to a specific path.
236
- * The url is `/` by default but can be overridden with the {@link DaffCartInStockItemsGuardRedirectUrl} injection token.
237
- * The guard will not wait until the cart has been resolved before performing the check and emitting.
238
- * Ensure that the cart is resolved prior to running this guard with the {@link DaffResolvedCartGuard}.
239
- */
240
- class DaffCartInStockItemsGuard {
241
- constructor(facade, router, redirectUrl) {
242
- this.facade = facade;
243
- this.router = router;
244
- this.redirectUrl = redirectUrl;
245
- }
246
- canActivateChild() {
247
- return this.canActivate();
248
- }
249
- canActivate() {
250
- return this.facade.hasOutOfStockItems$.pipe(map(hasOutOfStockItems => !hasOutOfStockItems), take(1), tap(hasNoOutOfStockItems => {
251
- if (!hasNoOutOfStockItems) {
252
- this.router.navigateByUrl(this.redirectUrl);
253
- }
254
- }));
255
- }
256
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartInStockItemsGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffCartInStockItemsGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
257
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartInStockItemsGuard, providedIn: 'root' }); }
258
- }
259
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartInStockItemsGuard, decorators: [{
260
- type: Injectable,
261
- args: [{
262
- providedIn: 'root',
263
- }]
264
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
265
- type: Inject,
266
- args: [DaffCartInStockItemsGuardRedirectUrl]
267
- }] }] });
268
-
269
- const { token: DaffCartPaymentMethodGuardRedirectUrl,
270
- /**
271
- * Provider function for {@link DaffCartPaymentMethodGuardRedirectUrl}.
272
- */
273
- provider: provideDaffCartPaymentMethodGuardRedirectUrl, } = createSingleInjectionToken('DaffCartPaymentMethodGuardRedirectUrl', { factory: () => '/' });
274
-
275
- /**
276
- * A routing guard that will redirect to a given url if the payment method on the cart is not defined.
277
- * The url is `/` by default, but can be overridden with the DaffCartPaymentMethodGuardRedirectUrl injection token.
278
- * The guard will not wait until the cart has been resolved before performing the check and emitting.
279
- * Ensure that the cart is resolved prior to running this guard with the {@link DaffResolvedCartGuard}.
280
- */
281
- class DaffPaymentMethodGuard {
282
- constructor(facade, router, redirectUrl) {
283
- this.facade = facade;
284
- this.router = router;
285
- this.redirectUrl = redirectUrl;
286
- }
287
- canActivate() {
288
- return this.facade.hasPaymentMethod$.pipe(take(1), tap(hasPaymentMethod => {
289
- if (!hasPaymentMethod) {
290
- this.router.navigateByUrl(this.redirectUrl);
291
- }
292
- }));
293
- }
294
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentMethodGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffCartPaymentMethodGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
295
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentMethodGuard, providedIn: 'root' }); }
296
- }
297
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffPaymentMethodGuard, decorators: [{
298
- type: Injectable,
299
- args: [{
300
- providedIn: 'root',
301
- }]
302
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
303
- type: Inject,
304
- args: [DaffCartPaymentMethodGuardRedirectUrl]
305
- }] }] });
306
-
307
- const { token: DaffCartShippingAddressGuardRedirectUrl,
308
- /**
309
- * Provider function for {@link DaffCartShippingAddressGuardRedirectUrl}.
310
- */
311
- provider: provideDaffCartShippingAddressGuardRedirectUrl, } = createSingleInjectionToken('DaffCartShippingAddressGuardRedirectUrl', { factory: () => '/' });
312
-
313
- /**
314
- * A routing guard that will redirect to a given url if the shipping address on the cart is not defined.
315
- * The url is `/` by default, but can be overridden with the DaffCartShippingAddressGuardRedirectUrl injection token.
316
- * The guard will not wait until the cart has been resolved before performing the check and emitting.
317
- * Ensure that the cart is resolved prior to running this guard with the {@link DaffResolvedCartGuard}.
318
- */
319
- class DaffShippingAddressGuard {
320
- constructor(facade, router, redirectUrl) {
321
- this.facade = facade;
322
- this.router = router;
323
- this.redirectUrl = redirectUrl;
324
- }
325
- canActivate() {
326
- return this.facade.hasShippingAddress$.pipe(take(1), tap(hasShippingAddress => {
327
- if (!hasShippingAddress) {
328
- this.router.navigateByUrl(this.redirectUrl);
329
- }
330
- }));
331
- }
332
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShippingAddressGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffCartShippingAddressGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
333
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShippingAddressGuard, providedIn: 'root' }); }
334
- }
335
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShippingAddressGuard, decorators: [{
336
- type: Injectable,
337
- args: [{
338
- providedIn: 'root',
339
- }]
340
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
341
- type: Inject,
342
- args: [DaffCartShippingAddressGuardRedirectUrl]
343
- }] }] });
344
-
345
- const { token: DaffCartShippingMethodGuardRedirectUrl,
346
- /**
347
- * Provider function for {@link DaffCartShippingMethodGuardRedirectUrl}.
348
- */
349
- provider: provideDaffCartShippingMethodGuardRedirectUrl, } = createSingleInjectionToken('DaffCartShippingMethodGuardRedirectUrl', { factory: () => '/' });
350
-
351
- /**
352
- * A routing guard that will redirect to a given url if the shipping method on the cart is not defined.
353
- * The url is `/` by default, but can be overridden with the DaffCartShippingMethodGuardRedirectUrl injection token.
354
- * The guard will not wait until the cart has been resolved before performing the check and emitting.
355
- * Ensure that the cart is resolved prior to running this guard with the {@link DaffResolvedCartGuard}.
356
- */
357
- class DaffShippingMethodGuard {
358
- constructor(facade, router, redirectUrl) {
359
- this.facade = facade;
360
- this.router = router;
361
- this.redirectUrl = redirectUrl;
362
- }
363
- canActivate() {
364
- return this.facade.hasShippingMethod$.pipe(take(1), tap(hasShippingMethod => {
365
- if (!hasShippingMethod) {
366
- this.router.navigateByUrl(this.redirectUrl);
367
- }
368
- }));
369
- }
370
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShippingMethodGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffCartShippingMethodGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
371
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShippingMethodGuard, providedIn: 'root' }); }
372
- }
373
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffShippingMethodGuard, decorators: [{
374
- type: Injectable,
375
- args: [{
376
- providedIn: 'root',
377
- }]
378
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
379
- type: Inject,
380
- args: [DaffCartShippingMethodGuardRedirectUrl]
381
- }] }] });
382
-
383
- const { token: DaffCartOrderResultGuardRedirectUrl,
384
- /**
385
- * Provider function for {@link DaffCartOrderResultGuardRedirectUrl}.
386
- */
387
- provider: provideDaffCartOrderResultGuardRedirectUrl, } = createSingleInjectionToken('DaffCartOrderResultGuardRedirectUrl', { factory: () => '/' });
388
-
389
- /**
390
- * A routing guard that will redirect to a given url if the cart order result is not defined.
391
- * The url is `/` by default, but can be overridden with the DaffCartOrderResultGuardRedirectUrl injection token.
392
- */
393
- class DaffOrderResultGuard {
394
- constructor(facade, router, redirectUrl) {
395
- this.facade = facade;
396
- this.router = router;
397
- this.redirectUrl = redirectUrl;
398
- }
399
- canActivate() {
400
- return this.facade.hasOrderResult$.pipe(tap(hasOrderResult => {
401
- if (!hasOrderResult) {
402
- this.router.navigateByUrl(this.redirectUrl);
403
- }
404
- }));
405
- }
406
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffOrderResultGuard, deps: [{ token: i1.DaffCartFacade }, { token: i2.Router }, { token: DaffCartOrderResultGuardRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
407
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffOrderResultGuard, providedIn: 'root' }); }
408
- }
409
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffOrderResultGuard, decorators: [{
410
- type: Injectable,
411
- args: [{
412
- providedIn: 'root',
413
- }]
414
- }], ctorParameters: () => [{ type: i1.DaffCartFacade }, { type: i2.Router }, { type: undefined, decorators: [{
415
- type: Inject,
416
- args: [DaffCartOrderResultGuardRedirectUrl]
417
- }] }] });
418
-
419
- const { token: DaffCartResolverRedirectUrl,
420
- /**
421
- * Provider function for {@link DaffCartResolverRedirectUrl}.
422
- */
423
- provider: provideDaffCartResolverRedirectUrl, } = createSingleInjectionToken('DaffCartResolverRedirectUrl', { factory: () => '/' });
424
-
425
- /**
426
- * Resolves the cart before navigation. Redirects to a given url when a failure occurs during Cart Load.
427
- * This url is `/` by default but can be overridden with the DaffCartResolverRedirectUrl injection token.
428
- */
429
- class DaffCartResolver {
430
- constructor(store, dispatcher, router, redirectUrl) {
431
- this.store = store;
432
- this.dispatcher = dispatcher;
433
- this.router = router;
434
- this.redirectUrl = redirectUrl;
435
- }
436
- resolve() {
437
- this.store.dispatch(new DaffResolveCart());
438
- return this.dispatcher.pipe(filter(action => action.type === DaffCartActionTypes.ResolveCartServerSideAction
439
- || action.type === DaffCartActionTypes.ResolveCartFailureAction
440
- || action.type === DaffCartActionTypes.ResolveCartSuccessAction
441
- || action.type === DaffCartActionTypes.ResolveCartPartialSuccessAction), map((action) => {
442
- if (action.type === DaffCartActionTypes.ResolveCartSuccessAction
443
- || action.type === DaffCartActionTypes.ResolveCartPartialSuccessAction) {
444
- return action.payload;
445
- }
446
- this.router.navigateByUrl(this.redirectUrl);
447
- return null;
448
- }), take(1));
449
- }
450
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartResolver, deps: [{ token: i1$1.Store }, { token: i1$1.ActionsSubject }, { token: i2.Router }, { token: DaffCartResolverRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
451
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartResolver, providedIn: 'root' }); }
452
- }
453
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartResolver, decorators: [{
454
- type: Injectable,
455
- args: [{
456
- providedIn: 'root',
457
- }]
458
- }], ctorParameters: () => [{ type: i1$1.Store }, { type: i1$1.ActionsSubject }, { type: i2.Router }, { type: undefined, decorators: [{
459
- type: Inject,
460
- args: [DaffCartResolverRedirectUrl]
461
- }] }] });
462
-
463
- const { token: DaffEmptyCartResolverRedirectUrl,
464
- /**
465
- * Provider function for {@link DaffEmptyCartResolverRedirectUrl}.
466
- */
467
- provider: provideDaffEmptyCartResolverRedirectUrl, } = createSingleInjectionToken('DaffEmptyCartResolverRedirectUrl', { factory: () => '/' });
468
-
469
- /**
470
- * Resolves the cart before navigation. Redirects to a given url when a failure occurs during Cart Load.
471
- * This url is `/` by default but can be overridden with the DaffCartResolverRedirectUrl injection token.
472
- * This resolver also redirects to a different url when the cart is empty after successfully loading.
473
- * This url is also `/` by default, but can be overridden with the DaffEmptyCartResolverRedirectUrl
474
- */
475
- class DaffEmptyCartResolver {
476
- constructor(cartResolver, router, redirectUrl) {
477
- this.cartResolver = cartResolver;
478
- this.router = router;
479
- this.redirectUrl = redirectUrl;
480
- }
481
- resolve() {
482
- return this.cartResolver.resolve().pipe(map((cart) => {
483
- if (cart.items.length === 0) {
484
- this.router.navigateByUrl(this.redirectUrl);
485
- }
486
- return cart;
487
- }));
488
- }
489
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffEmptyCartResolver, deps: [{ token: DaffCartResolver }, { token: i2.Router }, { token: DaffEmptyCartResolverRedirectUrl }], target: i0.ɵɵFactoryTarget.Injectable }); }
490
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffEmptyCartResolver, providedIn: 'root' }); }
491
- }
492
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffEmptyCartResolver, decorators: [{
493
- type: Injectable,
494
- args: [{
495
- providedIn: 'root',
496
- }]
497
- }], ctorParameters: () => [{ type: DaffCartResolver }, { type: i2.Router }, { type: undefined, decorators: [{
498
- type: Inject,
499
- args: [DaffEmptyCartResolverRedirectUrl]
500
- }] }] });
501
-
502
- class DaffCartRoutingModule {
503
- static forRoot(config = {}) {
504
- return {
505
- ngModule: DaffCartRoutingModule,
506
- providers: [
507
- provideDaffCartRoutingConfig(config),
508
- ],
509
- };
510
- }
511
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
512
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffCartRoutingModule }); }
513
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartRoutingModule, providers: [
514
- { provide: DaffCartBillingAddressGuardRedirectUrl, useValue: '/' },
515
- { provide: DaffCartItemsGuardRedirectUrl, useValue: '/' },
516
- { provide: DaffCartShippingAddressGuardRedirectUrl, useValue: '/' },
517
- { provide: DaffCartShippingMethodGuardRedirectUrl, useValue: '/' },
518
- { provide: DaffCartPaymentMethodGuardRedirectUrl, useValue: '/' },
519
- { provide: DaffCartOrderResultGuardRedirectUrl, useValue: '/' },
520
- { provide: DaffEmptyCartResolverRedirectUrl, useValue: '/' },
521
- { provide: DaffCartResolverRedirectUrl, useValue: '/' },
522
- { provide: DaffResolveCartGuardRedirectUrl, useValue: '/' },
523
- ] }); }
524
- }
525
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffCartRoutingModule, decorators: [{
526
- type: NgModule,
527
- args: [{
528
- providers: [
529
- { provide: DaffCartBillingAddressGuardRedirectUrl, useValue: '/' },
530
- { provide: DaffCartItemsGuardRedirectUrl, useValue: '/' },
531
- { provide: DaffCartShippingAddressGuardRedirectUrl, useValue: '/' },
532
- { provide: DaffCartShippingMethodGuardRedirectUrl, useValue: '/' },
533
- { provide: DaffCartPaymentMethodGuardRedirectUrl, useValue: '/' },
534
- { provide: DaffCartOrderResultGuardRedirectUrl, useValue: '/' },
535
- { provide: DaffEmptyCartResolverRedirectUrl, useValue: '/' },
536
- { provide: DaffCartResolverRedirectUrl, useValue: '/' },
537
- { provide: DaffResolveCartGuardRedirectUrl, useValue: '/' },
538
- ],
539
- }]
540
- }] });
541
-
542
- /**
543
- * Generated bundle index. Do not edit.
544
- */
135
+ var DaffResolveCartGuard = class DaffResolveCartGuard {
136
+ constructor(facade, router, redirectUrl, storage) {
137
+ this.facade = facade;
138
+ this.router = router;
139
+ this.redirectUrl = redirectUrl;
140
+ this.storage = storage;
141
+ }
142
+ canActivate() {
143
+ return this.facade.resolved$.pipe(take(1), map((resolved) => shouldAttemptResolution(resolved, !!this.storage.getCartId())), tap((shouldAttempt) => {
144
+ if (shouldAttempt) this.facade.dispatch(new DaffResolveCart());
145
+ }), switchMap((shouldAttempt) => iif(() => shouldAttempt, this.facade.resolved$.pipe(skipUntil(this.facade.resolved$.pipe(filter((innerResolved) => innerResolved === DaffCartResolveState.Resolving)))), this.facade.resolved$)), map((resolved) => canActivate(resolved)), filter((response) => response !== null && response !== void 0), map((resolved) => resolved ? resolved : this.router.parseUrl(this.redirectUrl)));
146
+ }
147
+ static {
148
+ this.ɵfac = i0.ɵɵngDeclareFactory({
149
+ minVersion: "12.0.0",
150
+ version: "22.2.4",
151
+ ngImport: i0,
152
+ type: DaffResolveCartGuard,
153
+ deps: [
154
+ { token: i1$1.DaffCartFacade },
155
+ { token: i2.Router },
156
+ { token: DaffResolveCartGuardRedirectUrl },
157
+ { token: i3.DaffCartStorageService }
158
+ ],
159
+ target: i0.ɵɵFactoryTarget.Injectable
160
+ });
161
+ }
162
+ static {
163
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
164
+ minVersion: "12.0.0",
165
+ version: "22.2.4",
166
+ ngImport: i0,
167
+ type: DaffResolveCartGuard,
168
+ providedIn: "root"
169
+ });
170
+ }
171
+ };
172
+ i0.ɵɵngDeclareClassMetadata({
173
+ minVersion: "12.0.0",
174
+ version: "22.2.4",
175
+ ngImport: i0,
176
+ type: DaffResolveCartGuard,
177
+ decorators: [{
178
+ type: Injectable,
179
+ args: [{ providedIn: "root" }]
180
+ }],
181
+ ctorParameters: () => [
182
+ { type: i1$1.DaffCartFacade },
183
+ { type: i2.Router },
184
+ {
185
+ type: void 0,
186
+ decorators: [{
187
+ type: Inject,
188
+ args: [DaffResolveCartGuardRedirectUrl]
189
+ }]
190
+ },
191
+ { type: i3.DaffCartStorageService }
192
+ ]
193
+ });
194
+ const { token: DaffCartItemsGuardRedirectUrl, provider: provideDaffCartItemsGuardRedirectUrl } = createSingleInjectionToken("DaffCartItemsGuardRedirectUrl", { factory: () => "/" });
195
+ var DaffCartItemsGuard = class DaffCartItemsGuard {
196
+ constructor(facade, router, redirectUrl) {
197
+ this.facade = facade;
198
+ this.router = router;
199
+ this.redirectUrl = redirectUrl;
200
+ }
201
+ canActivate() {
202
+ return this.facade.isCartEmpty$.pipe(map((isCartEmpty) => !isCartEmpty), take(1), tap((hasNonEmptyCart) => {
203
+ if (!hasNonEmptyCart) this.router.navigateByUrl(this.redirectUrl);
204
+ }));
205
+ }
206
+ static {
207
+ this.ɵfac = i0.ɵɵngDeclareFactory({
208
+ minVersion: "12.0.0",
209
+ version: "22.2.4",
210
+ ngImport: i0,
211
+ type: DaffCartItemsGuard,
212
+ deps: [
213
+ { token: i1$1.DaffCartFacade },
214
+ { token: i2.Router },
215
+ { token: DaffCartItemsGuardRedirectUrl }
216
+ ],
217
+ target: i0.ɵɵFactoryTarget.Injectable
218
+ });
219
+ }
220
+ static {
221
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
222
+ minVersion: "12.0.0",
223
+ version: "22.2.4",
224
+ ngImport: i0,
225
+ type: DaffCartItemsGuard,
226
+ providedIn: "root"
227
+ });
228
+ }
229
+ };
230
+ i0.ɵɵngDeclareClassMetadata({
231
+ minVersion: "12.0.0",
232
+ version: "22.2.4",
233
+ ngImport: i0,
234
+ type: DaffCartItemsGuard,
235
+ decorators: [{
236
+ type: Injectable,
237
+ args: [{ providedIn: "root" }]
238
+ }],
239
+ ctorParameters: () => [
240
+ { type: i1$1.DaffCartFacade },
241
+ { type: i2.Router },
242
+ {
243
+ type: void 0,
244
+ decorators: [{
245
+ type: Inject,
246
+ args: [DaffCartItemsGuardRedirectUrl]
247
+ }]
248
+ }
249
+ ]
250
+ });
251
+ const { token: DaffCartInStockItemsGuardRedirectUrl, provider: provideDaffCartInStockItemsGuardRedirectUrl } = createSingleInjectionToken("DaffCartInStockItemsGuardRedirectUrl", { factory: () => "/" });
252
+ var DaffCartInStockItemsGuard = class DaffCartInStockItemsGuard {
253
+ constructor(facade, router, redirectUrl) {
254
+ this.facade = facade;
255
+ this.router = router;
256
+ this.redirectUrl = redirectUrl;
257
+ }
258
+ canActivateChild() {
259
+ return this.canActivate();
260
+ }
261
+ canActivate() {
262
+ return this.facade.hasOutOfStockItems$.pipe(map((hasOutOfStockItems) => !hasOutOfStockItems), take(1), tap((hasNoOutOfStockItems) => {
263
+ if (!hasNoOutOfStockItems) this.router.navigateByUrl(this.redirectUrl);
264
+ }));
265
+ }
266
+ static {
267
+ this.ɵfac = i0.ɵɵngDeclareFactory({
268
+ minVersion: "12.0.0",
269
+ version: "22.2.4",
270
+ ngImport: i0,
271
+ type: DaffCartInStockItemsGuard,
272
+ deps: [
273
+ { token: i1$1.DaffCartFacade },
274
+ { token: i2.Router },
275
+ { token: DaffCartInStockItemsGuardRedirectUrl }
276
+ ],
277
+ target: i0.ɵɵFactoryTarget.Injectable
278
+ });
279
+ }
280
+ static {
281
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
282
+ minVersion: "12.0.0",
283
+ version: "22.2.4",
284
+ ngImport: i0,
285
+ type: DaffCartInStockItemsGuard,
286
+ providedIn: "root"
287
+ });
288
+ }
289
+ };
290
+ i0.ɵɵngDeclareClassMetadata({
291
+ minVersion: "12.0.0",
292
+ version: "22.2.4",
293
+ ngImport: i0,
294
+ type: DaffCartInStockItemsGuard,
295
+ decorators: [{
296
+ type: Injectable,
297
+ args: [{ providedIn: "root" }]
298
+ }],
299
+ ctorParameters: () => [
300
+ { type: i1$1.DaffCartFacade },
301
+ { type: i2.Router },
302
+ {
303
+ type: void 0,
304
+ decorators: [{
305
+ type: Inject,
306
+ args: [DaffCartInStockItemsGuardRedirectUrl]
307
+ }]
308
+ }
309
+ ]
310
+ });
311
+ const { token: DaffCartPaymentMethodGuardRedirectUrl, provider: provideDaffCartPaymentMethodGuardRedirectUrl } = createSingleInjectionToken("DaffCartPaymentMethodGuardRedirectUrl", { factory: () => "/" });
312
+ var DaffPaymentMethodGuard = class DaffPaymentMethodGuard {
313
+ constructor(facade, router, redirectUrl) {
314
+ this.facade = facade;
315
+ this.router = router;
316
+ this.redirectUrl = redirectUrl;
317
+ }
318
+ canActivate() {
319
+ return this.facade.hasPaymentMethod$.pipe(take(1), tap((hasPaymentMethod) => {
320
+ if (!hasPaymentMethod) this.router.navigateByUrl(this.redirectUrl);
321
+ }));
322
+ }
323
+ static {
324
+ this.ɵfac = i0.ɵɵngDeclareFactory({
325
+ minVersion: "12.0.0",
326
+ version: "22.2.4",
327
+ ngImport: i0,
328
+ type: DaffPaymentMethodGuard,
329
+ deps: [
330
+ { token: i1$1.DaffCartFacade },
331
+ { token: i2.Router },
332
+ { token: DaffCartPaymentMethodGuardRedirectUrl }
333
+ ],
334
+ target: i0.ɵɵFactoryTarget.Injectable
335
+ });
336
+ }
337
+ static {
338
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
339
+ minVersion: "12.0.0",
340
+ version: "22.2.4",
341
+ ngImport: i0,
342
+ type: DaffPaymentMethodGuard,
343
+ providedIn: "root"
344
+ });
345
+ }
346
+ };
347
+ i0.ɵɵngDeclareClassMetadata({
348
+ minVersion: "12.0.0",
349
+ version: "22.2.4",
350
+ ngImport: i0,
351
+ type: DaffPaymentMethodGuard,
352
+ decorators: [{
353
+ type: Injectable,
354
+ args: [{ providedIn: "root" }]
355
+ }],
356
+ ctorParameters: () => [
357
+ { type: i1$1.DaffCartFacade },
358
+ { type: i2.Router },
359
+ {
360
+ type: void 0,
361
+ decorators: [{
362
+ type: Inject,
363
+ args: [DaffCartPaymentMethodGuardRedirectUrl]
364
+ }]
365
+ }
366
+ ]
367
+ });
368
+ const { token: DaffCartShippingAddressGuardRedirectUrl, provider: provideDaffCartShippingAddressGuardRedirectUrl } = createSingleInjectionToken("DaffCartShippingAddressGuardRedirectUrl", { factory: () => "/" });
369
+ var DaffShippingAddressGuard = class DaffShippingAddressGuard {
370
+ constructor(facade, router, redirectUrl) {
371
+ this.facade = facade;
372
+ this.router = router;
373
+ this.redirectUrl = redirectUrl;
374
+ }
375
+ canActivate() {
376
+ return this.facade.hasShippingAddress$.pipe(take(1), tap((hasShippingAddress) => {
377
+ if (!hasShippingAddress) this.router.navigateByUrl(this.redirectUrl);
378
+ }));
379
+ }
380
+ static {
381
+ this.ɵfac = i0.ɵɵngDeclareFactory({
382
+ minVersion: "12.0.0",
383
+ version: "22.2.4",
384
+ ngImport: i0,
385
+ type: DaffShippingAddressGuard,
386
+ deps: [
387
+ { token: i1$1.DaffCartFacade },
388
+ { token: i2.Router },
389
+ { token: DaffCartShippingAddressGuardRedirectUrl }
390
+ ],
391
+ target: i0.ɵɵFactoryTarget.Injectable
392
+ });
393
+ }
394
+ static {
395
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
396
+ minVersion: "12.0.0",
397
+ version: "22.2.4",
398
+ ngImport: i0,
399
+ type: DaffShippingAddressGuard,
400
+ providedIn: "root"
401
+ });
402
+ }
403
+ };
404
+ i0.ɵɵngDeclareClassMetadata({
405
+ minVersion: "12.0.0",
406
+ version: "22.2.4",
407
+ ngImport: i0,
408
+ type: DaffShippingAddressGuard,
409
+ decorators: [{
410
+ type: Injectable,
411
+ args: [{ providedIn: "root" }]
412
+ }],
413
+ ctorParameters: () => [
414
+ { type: i1$1.DaffCartFacade },
415
+ { type: i2.Router },
416
+ {
417
+ type: void 0,
418
+ decorators: [{
419
+ type: Inject,
420
+ args: [DaffCartShippingAddressGuardRedirectUrl]
421
+ }]
422
+ }
423
+ ]
424
+ });
425
+ const { token: DaffCartShippingMethodGuardRedirectUrl, provider: provideDaffCartShippingMethodGuardRedirectUrl } = createSingleInjectionToken("DaffCartShippingMethodGuardRedirectUrl", { factory: () => "/" });
426
+ var DaffShippingMethodGuard = class DaffShippingMethodGuard {
427
+ constructor(facade, router, redirectUrl) {
428
+ this.facade = facade;
429
+ this.router = router;
430
+ this.redirectUrl = redirectUrl;
431
+ }
432
+ canActivate() {
433
+ return this.facade.hasShippingMethod$.pipe(take(1), tap((hasShippingMethod) => {
434
+ if (!hasShippingMethod) this.router.navigateByUrl(this.redirectUrl);
435
+ }));
436
+ }
437
+ static {
438
+ this.ɵfac = i0.ɵɵngDeclareFactory({
439
+ minVersion: "12.0.0",
440
+ version: "22.2.4",
441
+ ngImport: i0,
442
+ type: DaffShippingMethodGuard,
443
+ deps: [
444
+ { token: i1$1.DaffCartFacade },
445
+ { token: i2.Router },
446
+ { token: DaffCartShippingMethodGuardRedirectUrl }
447
+ ],
448
+ target: i0.ɵɵFactoryTarget.Injectable
449
+ });
450
+ }
451
+ static {
452
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
453
+ minVersion: "12.0.0",
454
+ version: "22.2.4",
455
+ ngImport: i0,
456
+ type: DaffShippingMethodGuard,
457
+ providedIn: "root"
458
+ });
459
+ }
460
+ };
461
+ i0.ɵɵngDeclareClassMetadata({
462
+ minVersion: "12.0.0",
463
+ version: "22.2.4",
464
+ ngImport: i0,
465
+ type: DaffShippingMethodGuard,
466
+ decorators: [{
467
+ type: Injectable,
468
+ args: [{ providedIn: "root" }]
469
+ }],
470
+ ctorParameters: () => [
471
+ { type: i1$1.DaffCartFacade },
472
+ { type: i2.Router },
473
+ {
474
+ type: void 0,
475
+ decorators: [{
476
+ type: Inject,
477
+ args: [DaffCartShippingMethodGuardRedirectUrl]
478
+ }]
479
+ }
480
+ ]
481
+ });
482
+ const { token: DaffCartOrderResultGuardRedirectUrl, provider: provideDaffCartOrderResultGuardRedirectUrl } = createSingleInjectionToken("DaffCartOrderResultGuardRedirectUrl", { factory: () => "/" });
483
+ var DaffOrderResultGuard = class DaffOrderResultGuard {
484
+ constructor(facade, router, redirectUrl) {
485
+ this.facade = facade;
486
+ this.router = router;
487
+ this.redirectUrl = redirectUrl;
488
+ }
489
+ canActivate() {
490
+ return this.facade.hasOrderResult$.pipe(tap((hasOrderResult) => {
491
+ if (!hasOrderResult) this.router.navigateByUrl(this.redirectUrl);
492
+ }));
493
+ }
494
+ static {
495
+ this.ɵfac = i0.ɵɵngDeclareFactory({
496
+ minVersion: "12.0.0",
497
+ version: "22.2.4",
498
+ ngImport: i0,
499
+ type: DaffOrderResultGuard,
500
+ deps: [
501
+ { token: i1$1.DaffCartFacade },
502
+ { token: i2.Router },
503
+ { token: DaffCartOrderResultGuardRedirectUrl }
504
+ ],
505
+ target: i0.ɵɵFactoryTarget.Injectable
506
+ });
507
+ }
508
+ static {
509
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
510
+ minVersion: "12.0.0",
511
+ version: "22.2.4",
512
+ ngImport: i0,
513
+ type: DaffOrderResultGuard,
514
+ providedIn: "root"
515
+ });
516
+ }
517
+ };
518
+ i0.ɵɵngDeclareClassMetadata({
519
+ minVersion: "12.0.0",
520
+ version: "22.2.4",
521
+ ngImport: i0,
522
+ type: DaffOrderResultGuard,
523
+ decorators: [{
524
+ type: Injectable,
525
+ args: [{ providedIn: "root" }]
526
+ }],
527
+ ctorParameters: () => [
528
+ { type: i1$1.DaffCartFacade },
529
+ { type: i2.Router },
530
+ {
531
+ type: void 0,
532
+ decorators: [{
533
+ type: Inject,
534
+ args: [DaffCartOrderResultGuardRedirectUrl]
535
+ }]
536
+ }
537
+ ]
538
+ });
539
+ const { token: DaffCartResolverRedirectUrl, provider: provideDaffCartResolverRedirectUrl } = createSingleInjectionToken("DaffCartResolverRedirectUrl", { factory: () => "/" });
540
+ var DaffCartResolver = class DaffCartResolver {
541
+ constructor(store, dispatcher, router, redirectUrl) {
542
+ this.store = store;
543
+ this.dispatcher = dispatcher;
544
+ this.router = router;
545
+ this.redirectUrl = redirectUrl;
546
+ }
547
+ resolve() {
548
+ this.store.dispatch(new DaffResolveCart());
549
+ return this.dispatcher.pipe(filter((action) => action.type === DaffCartActionTypes.ResolveCartServerSideAction || action.type === DaffCartActionTypes.ResolveCartFailureAction || action.type === DaffCartActionTypes.ResolveCartSuccessAction || action.type === DaffCartActionTypes.ResolveCartPartialSuccessAction), map((action) => {
550
+ if (action.type === DaffCartActionTypes.ResolveCartSuccessAction || action.type === DaffCartActionTypes.ResolveCartPartialSuccessAction) return action.payload;
551
+ this.router.navigateByUrl(this.redirectUrl);
552
+ return null;
553
+ }), take(1));
554
+ }
555
+ static {
556
+ this.ɵfac = i0.ɵɵngDeclareFactory({
557
+ minVersion: "12.0.0",
558
+ version: "22.2.4",
559
+ ngImport: i0,
560
+ type: DaffCartResolver,
561
+ deps: [
562
+ { token: i1.Store },
563
+ { token: i1.ActionsSubject },
564
+ { token: i2.Router },
565
+ { token: DaffCartResolverRedirectUrl }
566
+ ],
567
+ target: i0.ɵɵFactoryTarget.Injectable
568
+ });
569
+ }
570
+ static {
571
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
572
+ minVersion: "12.0.0",
573
+ version: "22.2.4",
574
+ ngImport: i0,
575
+ type: DaffCartResolver,
576
+ providedIn: "root"
577
+ });
578
+ }
579
+ };
580
+ i0.ɵɵngDeclareClassMetadata({
581
+ minVersion: "12.0.0",
582
+ version: "22.2.4",
583
+ ngImport: i0,
584
+ type: DaffCartResolver,
585
+ decorators: [{
586
+ type: Injectable,
587
+ args: [{ providedIn: "root" }]
588
+ }],
589
+ ctorParameters: () => [
590
+ { type: i1.Store },
591
+ { type: i1.ActionsSubject },
592
+ { type: i2.Router },
593
+ {
594
+ type: void 0,
595
+ decorators: [{
596
+ type: Inject,
597
+ args: [DaffCartResolverRedirectUrl]
598
+ }]
599
+ }
600
+ ]
601
+ });
602
+ const { token: DaffEmptyCartResolverRedirectUrl, provider: provideDaffEmptyCartResolverRedirectUrl } = createSingleInjectionToken("DaffEmptyCartResolverRedirectUrl", { factory: () => "/" });
603
+ var DaffEmptyCartResolver = class DaffEmptyCartResolver {
604
+ constructor(cartResolver, router, redirectUrl) {
605
+ this.cartResolver = cartResolver;
606
+ this.router = router;
607
+ this.redirectUrl = redirectUrl;
608
+ }
609
+ resolve() {
610
+ return this.cartResolver.resolve().pipe(map((cart) => {
611
+ if (cart.items.length === 0) this.router.navigateByUrl(this.redirectUrl);
612
+ return cart;
613
+ }));
614
+ }
615
+ static {
616
+ this.ɵfac = i0.ɵɵngDeclareFactory({
617
+ minVersion: "12.0.0",
618
+ version: "22.2.4",
619
+ ngImport: i0,
620
+ type: DaffEmptyCartResolver,
621
+ deps: [
622
+ { token: DaffCartResolver },
623
+ { token: i2.Router },
624
+ { token: DaffEmptyCartResolverRedirectUrl }
625
+ ],
626
+ target: i0.ɵɵFactoryTarget.Injectable
627
+ });
628
+ }
629
+ static {
630
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
631
+ minVersion: "12.0.0",
632
+ version: "22.2.4",
633
+ ngImport: i0,
634
+ type: DaffEmptyCartResolver,
635
+ providedIn: "root"
636
+ });
637
+ }
638
+ };
639
+ i0.ɵɵngDeclareClassMetadata({
640
+ minVersion: "12.0.0",
641
+ version: "22.2.4",
642
+ ngImport: i0,
643
+ type: DaffEmptyCartResolver,
644
+ decorators: [{
645
+ type: Injectable,
646
+ args: [{ providedIn: "root" }]
647
+ }],
648
+ ctorParameters: () => [
649
+ { type: DaffCartResolver },
650
+ { type: i2.Router },
651
+ {
652
+ type: void 0,
653
+ decorators: [{
654
+ type: Inject,
655
+ args: [DaffEmptyCartResolverRedirectUrl]
656
+ }]
657
+ }
658
+ ]
659
+ });
660
+ const provideDaffCartRouting = (config = {}) => makeEnvironmentProviders([
661
+ {
662
+ provide: DaffCartBillingAddressGuardRedirectUrl,
663
+ useValue: "/"
664
+ },
665
+ {
666
+ provide: DaffCartItemsGuardRedirectUrl,
667
+ useValue: "/"
668
+ },
669
+ {
670
+ provide: DaffCartShippingAddressGuardRedirectUrl,
671
+ useValue: "/"
672
+ },
673
+ {
674
+ provide: DaffCartShippingMethodGuardRedirectUrl,
675
+ useValue: "/"
676
+ },
677
+ {
678
+ provide: DaffCartPaymentMethodGuardRedirectUrl,
679
+ useValue: "/"
680
+ },
681
+ {
682
+ provide: DaffCartOrderResultGuardRedirectUrl,
683
+ useValue: "/"
684
+ },
685
+ {
686
+ provide: DaffEmptyCartResolverRedirectUrl,
687
+ useValue: "/"
688
+ },
689
+ {
690
+ provide: DaffCartResolverRedirectUrl,
691
+ useValue: "/"
692
+ },
693
+ {
694
+ provide: DaffResolveCartGuardRedirectUrl,
695
+ useValue: "/"
696
+ },
697
+ provideDaffCartRoutingConfig(config)
698
+ ]);
699
+ var DaffCartRoutingModule = class DaffCartRoutingModule {
700
+ static forRoot(config = {}) {
701
+ return {
702
+ ngModule: DaffCartRoutingModule,
703
+ providers: [provideDaffCartRoutingConfig(config)]
704
+ };
705
+ }
706
+ static {
707
+ this.ɵfac = i0.ɵɵngDeclareFactory({
708
+ minVersion: "12.0.0",
709
+ version: "22.2.4",
710
+ ngImport: i0,
711
+ type: DaffCartRoutingModule,
712
+ deps: [],
713
+ target: i0.ɵɵFactoryTarget.NgModule
714
+ });
715
+ }
716
+ static {
717
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
718
+ minVersion: "14.0.0",
719
+ version: "22.2.4",
720
+ ngImport: i0,
721
+ type: DaffCartRoutingModule
722
+ });
723
+ }
724
+ static {
725
+ this.ɵinj = i0.ɵɵngDeclareInjector({
726
+ minVersion: "12.0.0",
727
+ version: "22.2.4",
728
+ ngImport: i0,
729
+ type: DaffCartRoutingModule,
730
+ providers: [provideDaffCartRouting()]
731
+ });
732
+ }
733
+ };
734
+ i0.ɵɵngDeclareClassMetadata({
735
+ minVersion: "12.0.0",
736
+ version: "22.2.4",
737
+ ngImport: i0,
738
+ type: DaffCartRoutingModule,
739
+ decorators: [{
740
+ type: NgModule,
741
+ args: [{ providers: [provideDaffCartRouting()] }]
742
+ }]
743
+ });
744
+ export { DAFF_CART_ROUTING_CONFIG, DaffBillingAddressGuard, DaffCartBillingAddressGuardRedirectUrl, DaffCartInStockItemsGuard, DaffCartInStockItemsGuardRedirectUrl, DaffCartItemsGuard, DaffCartItemsGuardRedirectUrl, DaffCartOrderResultGuardRedirectUrl, DaffCartPaymentMethodGuardRedirectUrl, DaffCartResolver, DaffCartResolverRedirectUrl, DaffCartRoutingModule, DaffCartShippingAddressGuardRedirectUrl, DaffCartShippingMethodGuardRedirectUrl, DaffEmptyCartResolver, DaffEmptyCartResolverRedirectUrl, DaffOrderResultGuard, DaffPaymentMethodGuard, DaffResolveCartGuard, DaffResolveCartGuardRedirectUrl, DaffResolvedCartGuard, DaffShippingAddressGuard, DaffShippingMethodGuard, provideDaffCartRouting };
545
745
 
546
- export { DAFF_CART_ROUTING_CONFIG, DaffBillingAddressGuard, DaffCartBillingAddressGuardRedirectUrl, DaffCartInStockItemsGuard, DaffCartInStockItemsGuardRedirectUrl, DaffCartItemsGuard, DaffCartItemsGuardRedirectUrl, DaffCartOrderResultGuardRedirectUrl, DaffCartPaymentMethodGuardRedirectUrl, DaffCartResolver, DaffCartResolverRedirectUrl, DaffCartRoutingModule, DaffCartShippingAddressGuardRedirectUrl, DaffCartShippingMethodGuardRedirectUrl, DaffEmptyCartResolver, DaffEmptyCartResolverRedirectUrl, DaffOrderResultGuard, DaffPaymentMethodGuard, DaffResolveCartGuard, DaffResolveCartGuardRedirectUrl, DaffResolvedCartGuard, DaffShippingAddressGuard, DaffShippingMethodGuard };
547
- //# sourceMappingURL=daffodil-cart-routing.mjs.map
746
+ //# sourceMappingURL=daffodil-cart-routing.mjs.map