@daffodil/product 0.94.1-rc.0 → 0.95.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 (46) hide show
  1. package/fesm2022/daffodil-product-driver-in-memory.mjs +200 -227
  2. package/fesm2022/daffodil-product-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs +444 -0
  4. package/fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs.map +1 -0
  5. package/fesm2022/daffodil-product-driver-magento-2.4.7.mjs +704 -0
  6. package/fesm2022/daffodil-product-driver-magento-2.4.7.mjs.map +1 -0
  7. package/fesm2022/daffodil-product-driver-magento-auto-testing.mjs +7 -0
  8. package/fesm2022/daffodil-product-driver-magento-auto-testing.mjs.map +1 -0
  9. package/fesm2022/daffodil-product-driver-magento-auto.mjs +7 -0
  10. package/fesm2022/daffodil-product-driver-magento-auto.mjs.map +1 -0
  11. package/fesm2022/daffodil-product-driver-shopify.mjs +99 -127
  12. package/fesm2022/daffodil-product-driver-shopify.mjs.map +1 -1
  13. package/fesm2022/daffodil-product-driver-testing.mjs +117 -87
  14. package/fesm2022/daffodil-product-driver-testing.mjs.map +1 -1
  15. package/fesm2022/daffodil-product-driver.mjs +22 -45
  16. package/fesm2022/daffodil-product-driver.mjs.map +1 -1
  17. package/fesm2022/daffodil-product-routing.mjs +347 -285
  18. package/fesm2022/daffodil-product-routing.mjs.map +1 -1
  19. package/fesm2022/daffodil-product-state-testing.mjs +189 -106
  20. package/fesm2022/daffodil-product-state-testing.mjs.map +1 -1
  21. package/fesm2022/daffodil-product-state.mjs +566 -659
  22. package/fesm2022/daffodil-product-state.mjs.map +1 -1
  23. package/fesm2022/daffodil-product-testing.mjs +316 -276
  24. package/fesm2022/daffodil-product-testing.mjs.map +1 -1
  25. package/fesm2022/daffodil-product.mjs +8 -29
  26. package/fesm2022/daffodil-product.mjs.map +1 -1
  27. package/package.json +1 -1
  28. package/types/daffodil-product-driver-in-memory.d.ts +65 -75
  29. package/types/daffodil-product-driver-magento-2.4.7-testing.d.ts +105 -0
  30. package/types/daffodil-product-driver-magento-2.4.7.d.ts +337 -0
  31. package/types/daffodil-product-driver-magento-auto-testing.d.ts +1 -0
  32. package/types/daffodil-product-driver-magento-auto.d.ts +1 -0
  33. package/types/daffodil-product-driver-shopify.d.ts +31 -43
  34. package/types/daffodil-product-driver-testing.d.ts +28 -26
  35. package/types/daffodil-product-driver.d.ts +50 -61
  36. package/types/daffodil-product-routing.d.ts +101 -110
  37. package/types/daffodil-product-state-testing.d.ts +45 -43
  38. package/types/daffodil-product-state.d.ts +347 -375
  39. package/types/daffodil-product-testing.d.ts +82 -89
  40. package/types/daffodil-product.d.ts +93 -102
  41. package/fesm2022/daffodil-product-driver-magento-testing.mjs +0 -275
  42. package/fesm2022/daffodil-product-driver-magento-testing.mjs.map +0 -1
  43. package/fesm2022/daffodil-product-driver-magento.mjs +0 -855
  44. package/fesm2022/daffodil-product-driver-magento.mjs.map +0 -1
  45. package/types/daffodil-product-driver-magento-testing.d.ts +0 -114
  46. package/types/daffodil-product-driver-magento.d.ts +0 -396
@@ -1,694 +1,601 @@
1
- import * as i0 from '@angular/core';
2
- import { Inject, Injectable, inject, NgModule } from '@angular/core';
3
- import * as i1 from '@ngrx/effects';
4
- import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
5
- import { of } from 'rxjs';
6
- import { switchMap, map, catchError } from 'rxjs/operators';
7
- import { DaffProductDriver } from '@daffodil/product/driver';
8
- import { createSingleInjectionToken, daffSubtract, createMultiInjectionToken } from '@daffodil/core';
9
- import { daffTransformErrorToStateError, daffOperationStateSelectorFactory, daffOperationInitialState, daffOperationFailed, daffCompleteOperation, daffStartResolution, daffComposeReducers } from '@daffodil/core/state';
10
- import * as i1$1 from '@ngrx/store';
11
- import { defaultMemoize, createFeatureSelector, createSelector, select, combineReducers, StoreModule } from '@ngrx/store';
12
- import { createEntityAdapter } from '@ngrx/entity';
13
-
14
- /**
15
- * Action types for Product Grid Actions.
16
- */
1
+ import * as i0 from "@angular/core";
2
+ import { Inject, Injectable, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
3
+ import * as i1$1 from "@ngrx/effects";
4
+ import { EffectsModule, createEffect, ofType, provideEffects } from "@ngrx/effects";
5
+ import { of } from "rxjs";
6
+ import { catchError, map, switchMap } from "rxjs/operators";
7
+ import { DaffProductDriver } from "@daffodil/product/driver";
8
+ import { createMultiInjectionToken, createSingleInjectionToken, daffSubtract } from "@daffodil/core";
9
+ import { daffCompleteOperation, daffComposeReducers, daffOperationFailed, daffOperationInitialState, daffOperationStateSelectorFactory, daffStartResolution, daffTransformErrorToStateError } from "@daffodil/core/state";
10
+ import * as i1 from "@ngrx/store";
11
+ import { StoreModule, combineReducers, createFeatureSelector, createSelector, defaultMemoize, provideState, select } from "@ngrx/store";
12
+ import { createEntityAdapter } from "@ngrx/entity";
17
13
  var DaffProductGridActionTypes;
18
- (function (DaffProductGridActionTypes) {
19
- DaffProductGridActionTypes["ProductGridLoadAction"] = "[@daffodil/product] ProductGrid Load Action";
20
- DaffProductGridActionTypes["ProductGridLoadSuccessAction"] = "[@daffodil/product] ProductGrid Load Success Action";
21
- DaffProductGridActionTypes["ProductGridLoadFailureAction"] = "[@daffodil/product] ProductGrid Load Failure Action";
22
- DaffProductGridActionTypes["ProductGridResetAction"] = "[@daffodil/product] ProductGrid Reset Action";
14
+ (function(DaffProductGridActionTypes) {
15
+ DaffProductGridActionTypes["ProductGridLoadAction"] = "[@daffodil/product] ProductGrid Load Action";
16
+ DaffProductGridActionTypes["ProductGridLoadSuccessAction"] = "[@daffodil/product] ProductGrid Load Success Action";
17
+ DaffProductGridActionTypes["ProductGridLoadFailureAction"] = "[@daffodil/product] ProductGrid Load Failure Action";
18
+ DaffProductGridActionTypes["ProductGridResetAction"] = "[@daffodil/product] ProductGrid Reset Action";
23
19
  })(DaffProductGridActionTypes || (DaffProductGridActionTypes = {}));
24
- /**
25
- * Triggers a request for an array of products.
26
- */
27
- class DaffProductGridLoad {
28
- constructor() {
29
- this.type = DaffProductGridActionTypes.ProductGridLoadAction;
30
- }
31
- }
32
- /**
33
- * An action called when a request for of an array of products succeeded.
34
- *
35
- * @param payload - An array of Products
36
- */
37
- class DaffProductGridLoadSuccess {
38
- constructor(payload) {
39
- this.payload = payload;
40
- this.type = DaffProductGridActionTypes.ProductGridLoadSuccessAction;
41
- }
42
- }
43
- /**
44
- * An action called when a request for an array of products failed.
45
- *
46
- * @param payload - An error message
47
- */
48
- class DaffProductGridLoadFailure {
49
- constructor(payload) {
50
- this.payload = payload;
51
- this.type = DaffProductGridActionTypes.ProductGridLoadFailureAction;
52
- }
53
- }
54
- /**
55
- * Resets the state of the product grid redux store to its initial state.
56
- */
57
- class DaffProductGridReset {
58
- constructor() {
59
- this.type = DaffProductGridActionTypes.ProductGridResetAction;
60
- }
61
- }
62
-
63
- /**
64
- * Action types for Product Actions.
65
- */
20
+ var DaffProductGridLoad = class {
21
+ constructor() {
22
+ this.type = DaffProductGridActionTypes.ProductGridLoadAction;
23
+ }
24
+ };
25
+ var DaffProductGridLoadSuccess = class {
26
+ constructor(payload) {
27
+ this.payload = payload;
28
+ this.type = DaffProductGridActionTypes.ProductGridLoadSuccessAction;
29
+ }
30
+ };
31
+ var DaffProductGridLoadFailure = class {
32
+ constructor(payload) {
33
+ this.payload = payload;
34
+ this.type = DaffProductGridActionTypes.ProductGridLoadFailureAction;
35
+ }
36
+ };
37
+ var DaffProductGridReset = class {
38
+ constructor() {
39
+ this.type = DaffProductGridActionTypes.ProductGridResetAction;
40
+ }
41
+ };
66
42
  var DaffProductActionTypes;
67
- (function (DaffProductActionTypes) {
68
- DaffProductActionTypes["ProductLoadAction"] = "[@daffodil/product] Product Load Action";
69
- DaffProductActionTypes["ProductLoadSuccessAction"] = "[@daffodil/product] Product Load Success Action";
70
- DaffProductActionTypes["ProductLoadFailureAction"] = "[@daffodil/product] Product Load Failure Action";
43
+ (function(DaffProductActionTypes) {
44
+ DaffProductActionTypes["ProductLoadAction"] = "[@daffodil/product] Product Load Action";
45
+ DaffProductActionTypes["ProductLoadSuccessAction"] = "[@daffodil/product] Product Load Success Action";
46
+ DaffProductActionTypes["ProductLoadFailureAction"] = "[@daffodil/product] Product Load Failure Action";
71
47
  })(DaffProductActionTypes || (DaffProductActionTypes = {}));
72
- /**
73
- * Triggers a request for a Product.
74
- *
75
- * @param payload - Id of requested Product
76
- */
77
- class DaffProductLoad {
78
- constructor(payload) {
79
- this.payload = payload;
80
- this.type = DaffProductActionTypes.ProductLoadAction;
81
- }
82
- }
83
- /**
84
- * An action called when a request for a Product succeeded.
85
- *
86
- * @param payload - A Product
87
- */
88
- class DaffProductLoadSuccess {
89
- constructor(payload) {
90
- this.payload = payload;
91
- this.type = DaffProductActionTypes.ProductLoadSuccessAction;
92
- }
93
- }
94
- /**
95
- * An action called when a request for a Product failed.
96
- *
97
- * @param payload - An error message
98
- */
99
- class DaffProductLoadFailure {
100
- constructor(payload) {
101
- this.payload = payload;
102
- this.type = DaffProductActionTypes.ProductLoadFailureAction;
103
- }
104
- }
105
-
106
- /**
107
- * Action types for Product Page Actions.
108
- */
48
+ var DaffProductLoad = class {
49
+ constructor(payload) {
50
+ this.payload = payload;
51
+ this.type = DaffProductActionTypes.ProductLoadAction;
52
+ }
53
+ };
54
+ var DaffProductLoadSuccess = class {
55
+ constructor(payload) {
56
+ this.payload = payload;
57
+ this.type = DaffProductActionTypes.ProductLoadSuccessAction;
58
+ }
59
+ };
60
+ var DaffProductLoadFailure = class {
61
+ constructor(payload) {
62
+ this.payload = payload;
63
+ this.type = DaffProductActionTypes.ProductLoadFailureAction;
64
+ }
65
+ };
109
66
  var DaffProductPageActionTypes;
110
- (function (DaffProductPageActionTypes) {
111
- DaffProductPageActionTypes["ProductPageLoadByUrlAction"] = "[@daffodil/product] Product Page Load By URL Action";
112
- DaffProductPageActionTypes["ProductPageLoadAction"] = "[@daffodil/product] Product Page Load Action";
113
- DaffProductPageActionTypes["ProductPageLoadSuccessAction"] = "[@daffodil/product] Product Page Load Success Action";
114
- DaffProductPageActionTypes["ProductPageLoadFailureAction"] = "[@daffodil/product] Product Page Load Failure Action";
115
- DaffProductPageActionTypes["UpdateQtyAction"] = "[@daffodil/product] Product Page Update Qty Action";
67
+ (function(DaffProductPageActionTypes) {
68
+ DaffProductPageActionTypes["ProductPageLoadByUrlAction"] = "[@daffodil/product] Product Page Load By URL Action";
69
+ DaffProductPageActionTypes["ProductPageLoadAction"] = "[@daffodil/product] Product Page Load Action";
70
+ DaffProductPageActionTypes["ProductPageLoadSuccessAction"] = "[@daffodil/product] Product Page Load Success Action";
71
+ DaffProductPageActionTypes["ProductPageLoadFailureAction"] = "[@daffodil/product] Product Page Load Failure Action";
72
+ DaffProductPageActionTypes["UpdateQtyAction"] = "[@daffodil/product] Product Page Update Qty Action";
116
73
  })(DaffProductPageActionTypes || (DaffProductPageActionTypes = {}));
117
- /**
118
- * An action triggered to initialize a product page load.
119
- * This is intended to be used for loading a product page rather than only a product.
120
- *
121
- * @param payload - URL of the requested product
122
- */
123
- class DaffProductPageLoadByUrl {
124
- constructor(payload) {
125
- this.payload = payload;
126
- this.type = DaffProductPageActionTypes.ProductPageLoadByUrlAction;
127
- }
128
- }
129
- /**
130
- * An action triggered to initialize a product page load.
131
- * This is intended to be used for loading a product page rather than only a product.
132
- *
133
- * @param payload - Id of the requested product
134
- */
135
- class DaffProductPageLoad {
136
- constructor(payload) {
137
- this.payload = payload;
138
- this.type = DaffProductPageActionTypes.ProductPageLoadAction;
139
- }
140
- }
141
- /**
142
- * An action triggered upon a successful product page request.
143
- *
144
- * @param payload - A DaffProduct
145
- */
146
- class DaffProductPageLoadSuccess {
147
- constructor(payload) {
148
- this.payload = payload;
149
- this.type = DaffProductPageActionTypes.ProductPageLoadSuccessAction;
150
- }
151
- }
152
- /**
153
- * An action triggered upon a failed product page request.
154
- *
155
- * @param payload - an error message
156
- */
157
- class DaffProductPageLoadFailure {
158
- constructor(payload) {
159
- this.payload = payload;
160
- this.type = DaffProductPageActionTypes.ProductPageLoadFailureAction;
161
- }
162
- }
163
- /**
164
- * Update the qty of the current product.
165
- *
166
- * @param payload - The qty of the product.
167
- */
168
- class DaffProductPageUpdateQty {
169
- constructor(payload) {
170
- this.payload = payload;
171
- this.type = DaffProductPageActionTypes.UpdateQtyAction;
172
- }
173
- }
174
-
175
- const {
176
- /**
177
- * Transforms {@link DaffError}s into {@link DaffStateError}s before they are serialized into state.
178
- * Can be used to further refine Daffodil errors into more specific app errors.
179
- */
180
- token: DAFF_PRODUCT_ERROR_MATCHER,
181
- /**
182
- * Provider function for {@link DAFF_PRODUCT_ERROR_MATCHER}.
183
- */
184
- provider: provideDaffProductErrorMatcher, } = createSingleInjectionToken('DAFF_PRODUCT_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
185
-
186
- /**
187
- * Effects for handling product grid actions and for triggering corresponding service requests.
188
- *
189
- * @param action$ - Redux action object
190
- * @param driver - A product service driver
191
- */
192
- class DaffProductGridEffects {
193
- constructor(actions$, driver, errorMatcher) {
194
- this.actions$ = actions$;
195
- this.driver = driver;
196
- this.errorMatcher = errorMatcher;
197
- /**
198
- * Handles ProductGridLoadAction by making a service call for products and returning a success or failure action
199
- * to the action stream.
200
- *
201
- * @returns An Observable of a DaffProductGridAction
202
- */
203
- this.loadAll$ = createEffect(() => this.actions$.pipe(ofType(DaffProductGridActionTypes.ProductGridLoadAction), switchMap((action) => this.driver.getAll()
204
- .pipe(map((resp) => new DaffProductGridLoadSuccess(resp)), catchError((error) => of(new DaffProductGridLoadFailure(this.errorMatcher(error))))))));
205
- }
206
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGridEffects, deps: [{ token: i1.Actions }, { token: DaffProductDriver }, { token: DAFF_PRODUCT_ERROR_MATCHER }], target: i0.ɵɵFactoryTarget.Injectable }); }
207
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGridEffects }); }
208
- }
209
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGridEffects, decorators: [{
210
- type: Injectable
211
- }], ctorParameters: () => [{ type: i1.Actions }, { type: undefined, decorators: [{
212
- type: Inject,
213
- args: [DaffProductDriver]
214
- }] }, { type: undefined, decorators: [{
215
- type: Inject,
216
- args: [DAFF_PRODUCT_ERROR_MATCHER]
217
- }] }] });
218
-
219
- /**
220
- * Effects for handling product actions and for triggering corresponding service requests.
221
- *
222
- * @param action$ - Redux action object
223
- * @param driver - A product service driver
224
- */
225
- class DaffProductEffects {
226
- constructor(actions$, driver, errorMatcher) {
227
- this.actions$ = actions$;
228
- this.driver = driver;
229
- this.errorMatcher = errorMatcher;
230
- /**
231
- * Handles ProductLoadAction by making a service call for a product and returning a success or
232
- * failure action to the action stream.
233
- *
234
- * @returns An Observable of a ProductLoadAction
235
- */
236
- this.load$ = createEffect(() => this.actions$.pipe(ofType(DaffProductActionTypes.ProductLoadAction), switchMap((action) => this.driver.get(action.payload)
237
- .pipe(map((resp) => new DaffProductLoadSuccess(resp)), catchError((error) => of(new DaffProductLoadFailure(this.errorMatcher(error))))))));
238
- }
239
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductEffects, deps: [{ token: i1.Actions }, { token: DaffProductDriver }, { token: DAFF_PRODUCT_ERROR_MATCHER }], target: i0.ɵɵFactoryTarget.Injectable }); }
240
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductEffects }); }
241
- }
242
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductEffects, decorators: [{
243
- type: Injectable
244
- }], ctorParameters: () => [{ type: i1.Actions }, { type: undefined, decorators: [{
245
- type: Inject,
246
- args: [DaffProductDriver]
247
- }] }, { type: undefined, decorators: [{
248
- type: Inject,
249
- args: [DAFF_PRODUCT_ERROR_MATCHER]
250
- }] }] });
251
-
252
- const DAFF_PRODUCT_STORE_FEATURE_KEY = 'daffProduct';
253
-
254
- /**
255
- * A function that returns a selector for the entire product feature state.
256
- */
74
+ var DaffProductPageLoadByUrl = class {
75
+ constructor(payload) {
76
+ this.payload = payload;
77
+ this.type = DaffProductPageActionTypes.ProductPageLoadByUrlAction;
78
+ }
79
+ };
80
+ var DaffProductPageLoad = class {
81
+ constructor(payload) {
82
+ this.payload = payload;
83
+ this.type = DaffProductPageActionTypes.ProductPageLoadAction;
84
+ }
85
+ };
86
+ var DaffProductPageLoadSuccess = class {
87
+ constructor(payload) {
88
+ this.payload = payload;
89
+ this.type = DaffProductPageActionTypes.ProductPageLoadSuccessAction;
90
+ }
91
+ };
92
+ var DaffProductPageLoadFailure = class {
93
+ constructor(payload) {
94
+ this.payload = payload;
95
+ this.type = DaffProductPageActionTypes.ProductPageLoadFailureAction;
96
+ }
97
+ };
98
+ var DaffProductPageUpdateQty = class {
99
+ constructor(payload) {
100
+ this.payload = payload;
101
+ this.type = DaffProductPageActionTypes.UpdateQtyAction;
102
+ }
103
+ };
104
+ const { token: DAFF_PRODUCT_ERROR_MATCHER, provider: provideDaffProductErrorMatcher } = createSingleInjectionToken("DAFF_PRODUCT_ERROR_MATCHER", { factory: () => daffTransformErrorToStateError });
105
+ var DaffProductGridEffects = class DaffProductGridEffects {
106
+ constructor(actions$, driver, errorMatcher) {
107
+ this.actions$ = actions$;
108
+ this.driver = driver;
109
+ this.errorMatcher = errorMatcher;
110
+ this.loadAll$ = createEffect(() => this.actions$.pipe(ofType(DaffProductGridActionTypes.ProductGridLoadAction), switchMap((action) => this.driver.getAll().pipe(map((resp) => new DaffProductGridLoadSuccess(resp)), catchError((error) => of(new DaffProductGridLoadFailure(this.errorMatcher(error))))))));
111
+ }
112
+ static {
113
+ this.ɵfac = i0.ɵɵngDeclareFactory({
114
+ minVersion: "12.0.0",
115
+ version: "22.2.4",
116
+ ngImport: i0,
117
+ type: DaffProductGridEffects,
118
+ deps: [
119
+ { token: i1$1.Actions },
120
+ { token: DaffProductDriver },
121
+ { token: DAFF_PRODUCT_ERROR_MATCHER }
122
+ ],
123
+ target: i0.ɵɵFactoryTarget.Injectable
124
+ });
125
+ }
126
+ static {
127
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
128
+ minVersion: "12.0.0",
129
+ version: "22.2.4",
130
+ ngImport: i0,
131
+ type: DaffProductGridEffects
132
+ });
133
+ }
134
+ };
135
+ i0.ɵɵngDeclareClassMetadata({
136
+ minVersion: "12.0.0",
137
+ version: "22.2.4",
138
+ ngImport: i0,
139
+ type: DaffProductGridEffects,
140
+ decorators: [{ type: Injectable }],
141
+ ctorParameters: () => [
142
+ { type: i1$1.Actions },
143
+ {
144
+ type: void 0,
145
+ decorators: [{
146
+ type: Inject,
147
+ args: [DaffProductDriver]
148
+ }]
149
+ },
150
+ {
151
+ type: void 0,
152
+ decorators: [{
153
+ type: Inject,
154
+ args: [DAFF_PRODUCT_ERROR_MATCHER]
155
+ }]
156
+ }
157
+ ]
158
+ });
159
+ var DaffProductEffects = class DaffProductEffects {
160
+ constructor(actions$, driver, errorMatcher) {
161
+ this.actions$ = actions$;
162
+ this.driver = driver;
163
+ this.errorMatcher = errorMatcher;
164
+ this.load$ = createEffect(() => this.actions$.pipe(ofType(DaffProductActionTypes.ProductLoadAction), switchMap((action) => this.driver.get(action.payload).pipe(map((resp) => new DaffProductLoadSuccess(resp)), catchError((error) => of(new DaffProductLoadFailure(this.errorMatcher(error))))))));
165
+ }
166
+ static {
167
+ this.ɵfac = i0.ɵɵngDeclareFactory({
168
+ minVersion: "12.0.0",
169
+ version: "22.2.4",
170
+ ngImport: i0,
171
+ type: DaffProductEffects,
172
+ deps: [
173
+ { token: i1$1.Actions },
174
+ { token: DaffProductDriver },
175
+ { token: DAFF_PRODUCT_ERROR_MATCHER }
176
+ ],
177
+ target: i0.ɵɵFactoryTarget.Injectable
178
+ });
179
+ }
180
+ static {
181
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
182
+ minVersion: "12.0.0",
183
+ version: "22.2.4",
184
+ ngImport: i0,
185
+ type: DaffProductEffects
186
+ });
187
+ }
188
+ };
189
+ i0.ɵɵngDeclareClassMetadata({
190
+ minVersion: "12.0.0",
191
+ version: "22.2.4",
192
+ ngImport: i0,
193
+ type: DaffProductEffects,
194
+ decorators: [{ type: Injectable }],
195
+ ctorParameters: () => [
196
+ { type: i1$1.Actions },
197
+ {
198
+ type: void 0,
199
+ decorators: [{
200
+ type: Inject,
201
+ args: [DaffProductDriver]
202
+ }]
203
+ },
204
+ {
205
+ type: void 0,
206
+ decorators: [{
207
+ type: Inject,
208
+ args: [DAFF_PRODUCT_ERROR_MATCHER]
209
+ }]
210
+ }
211
+ ]
212
+ });
213
+ const DAFF_PRODUCT_STORE_FEATURE_KEY = "daffProduct";
257
214
  const getDaffProductFeatureSelector = defaultMemoize(() => ({ selectProductState: createFeatureSelector(DAFF_PRODUCT_STORE_FEATURE_KEY) })).memoized;
258
-
259
215
  const createProductPageSelectors = () => {
260
- const { selectProductState, } = getDaffProductFeatureSelector();
261
- const selectCurrentProductState = createSelector(selectProductState, (state) => state.product);
262
- const selectCurrentProductId = createSelector(selectCurrentProductState, (state) => state.currentProductId);
263
- const selectCurrentProduct = createSelector(selectProductState, selectCurrentProductId, (state, id) => state.products.entities[id]);
264
- return {
265
- ...daffOperationStateSelectorFactory(selectCurrentProductState),
266
- selectCurrentProductState,
267
- selectCurrentProductId,
268
- selectCurrentProduct,
269
- };
216
+ const { selectProductState } = getDaffProductFeatureSelector();
217
+ const selectCurrentProductState = createSelector(selectProductState, (state) => state.product);
218
+ const selectCurrentProductId = createSelector(selectCurrentProductState, (state) => state.currentProductId);
219
+ const selectCurrentProduct = createSelector(selectProductState, selectCurrentProductId, (state, id) => state.products.entities[id]);
220
+ return {
221
+ ...daffOperationStateSelectorFactory(selectCurrentProductState),
222
+ selectCurrentProductState,
223
+ selectCurrentProductId,
224
+ selectCurrentProduct
225
+ };
270
226
  };
271
- /**
272
- * A function that returns all selectors related to the product page.
273
- * Returns {@link DaffProductPageMemoizedSelectors}.
274
- */
275
227
  const getDaffProductPageSelectors = defaultMemoize(() => createProductPageSelectors()).memoized;
276
-
277
- /**
278
- * Product Adapter for changing/overwriting entity state.
279
- */
280
228
  const daffProductEntitiesAdapter = (() => {
281
- let cache;
282
- return () => cache = cache || createEntityAdapter();
229
+ let cache;
230
+ return () => cache = cache || createEntityAdapter();
283
231
  })();
284
-
285
232
  const createProductEntitiesSelectors = () => {
286
- const { selectProductState, } = getDaffProductFeatureSelector();
287
- const adapterSelectors = daffProductEntitiesAdapter().getSelectors();
288
- /**
289
- * Product Entities State
290
- */
291
- const selectProductEntitiesState = createSelector(selectProductState, (state) => state.products);
292
- /**
293
- * Adapters created with @ngrx/entity generate
294
- * commonly used selector functions including
295
- * getting all ids in the record set, a dictionary
296
- * of the records by id, an array of records and
297
- * the total number of records. This reduces boilerplate
298
- * in selecting records from the entity state.
299
- */
300
- const selectProductIds = createSelector(selectProductEntitiesState, adapterSelectors.selectIds);
301
- const selectProductEntities = createSelector(selectProductEntitiesState, adapterSelectors.selectEntities);
302
- const selectAllProducts = createSelector(selectProductEntitiesState, adapterSelectors.selectAll);
303
- const selectProductTotal = createSelector(selectProductEntitiesState, adapterSelectors.selectTotal);
304
- const selectProduct = defaultMemoize((productId) => createSelector(selectProductEntities, products => products[productId])).memoized;
305
- const selectProductPrice = defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product?.price || null)).memoized;
306
- const selectProductDiscountAmount = defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product?.discount?.amount || 0)).memoized;
307
- const selectProductDiscountedPrice = defaultMemoize((productId) => createSelector(selectProductPrice(productId), selectProductDiscountAmount(productId), (price, discountAmount) => daffSubtract(price, discountAmount))).memoized;
308
- const selectProductDiscountPercent = defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product.discount?.percent || 0)).memoized;
309
- const selectProductHasDiscount = defaultMemoize((productId) => createSelector(selectProductDiscountAmount(productId), (discountAmount) => !!discountAmount)).memoized;
310
- const selectIsProductOutOfStock = defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product ? !product.in_stock : null)).memoized;
311
- return {
312
- selectProductEntitiesState,
313
- selectProductIds,
314
- selectProductEntities,
315
- selectAllProducts,
316
- selectProductTotal,
317
- selectProduct,
318
- selectProductPrice,
319
- selectProductDiscountAmount,
320
- selectProductDiscountedPrice,
321
- selectProductDiscountPercent,
322
- selectProductHasDiscount,
323
- selectIsProductOutOfStock,
324
- };
233
+ const { selectProductState } = getDaffProductFeatureSelector();
234
+ const adapterSelectors = daffProductEntitiesAdapter().getSelectors();
235
+ const selectProductEntitiesState = createSelector(selectProductState, (state) => state.products);
236
+ const selectProductIds = createSelector(selectProductEntitiesState, adapterSelectors.selectIds);
237
+ const selectProductEntities = createSelector(selectProductEntitiesState, adapterSelectors.selectEntities);
238
+ const selectAllProducts = createSelector(selectProductEntitiesState, adapterSelectors.selectAll);
239
+ const selectProductTotal = createSelector(selectProductEntitiesState, adapterSelectors.selectTotal);
240
+ const selectProduct = defaultMemoize((productId) => createSelector(selectProductEntities, (products) => products[productId])).memoized;
241
+ const selectProductPrice = defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product?.price || null)).memoized;
242
+ const selectProductDiscountAmount = defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product?.discount?.amount || 0)).memoized;
243
+ return {
244
+ selectProductEntitiesState,
245
+ selectProductIds,
246
+ selectProductEntities,
247
+ selectAllProducts,
248
+ selectProductTotal,
249
+ selectProduct,
250
+ selectProductPrice,
251
+ selectProductDiscountAmount,
252
+ selectProductDiscountedPrice: defaultMemoize((productId) => createSelector(selectProductPrice(productId), selectProductDiscountAmount(productId), (price, discountAmount) => daffSubtract(price, discountAmount))).memoized,
253
+ selectProductDiscountPercent: defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product.discount?.percent || 0)).memoized,
254
+ selectProductHasDiscount: defaultMemoize((productId) => createSelector(selectProductDiscountAmount(productId), (discountAmount) => !!discountAmount)).memoized,
255
+ selectIsProductOutOfStock: defaultMemoize((productId) => createSelector(selectProduct(productId), (product) => product ? !product.in_stock : null)).memoized
256
+ };
325
257
  };
326
- /**
327
- * A function that returns all selectors related to product entities and simple product prices.
328
- */
329
258
  const getDaffProductEntitiesSelectors = defaultMemoize(() => createProductEntitiesSelectors()).memoized;
330
-
331
259
  const createProductGridSelectors = () => {
332
- const { selectProductState, } = getDaffProductFeatureSelector();
333
- const selectProductGridState = createSelector(selectProductState, (state) => state.productGrid);
334
- const selectProductGridLoadingState = createSelector(selectProductGridState, (state) => state.loading);
335
- return {
336
- selectProductGridState,
337
- selectProductGridLoadingState,
338
- };
260
+ const { selectProductState } = getDaffProductFeatureSelector();
261
+ const selectProductGridState = createSelector(selectProductState, (state) => state.productGrid);
262
+ return {
263
+ selectProductGridState,
264
+ selectProductGridLoadingState: createSelector(selectProductGridState, (state) => state.loading)
265
+ };
339
266
  };
340
- /**
341
- * A function that returns all selectors related to loading a grid of products.
342
- * Returns {@link DaffProductGridMemoizedSelectors}.
343
- */
344
267
  const getDaffProductGridSelectors = defaultMemoize(() => createProductGridSelectors()).memoized;
345
-
346
- /**
347
- * A function that returns all selectors in the entire product feature area.
348
- * Returns {@link DaffProductAllSelectors}.
349
- */
350
268
  const getDaffProductSelectors = () => ({
351
- ...getDaffProductPageSelectors(),
352
- ...getDaffProductGridSelectors(),
353
- ...getDaffProductEntitiesSelectors(),
354
- ...getDaffProductFeatureSelector(),
269
+ ...getDaffProductPageSelectors(),
270
+ ...getDaffProductGridSelectors(),
271
+ ...getDaffProductEntitiesSelectors(),
272
+ ...getDaffProductFeatureSelector()
273
+ });
274
+ var DaffProductFacade = class DaffProductFacade {
275
+ constructor(store) {
276
+ this.store = store;
277
+ this.selectors = getDaffProductSelectors();
278
+ }
279
+ getProduct(id) {
280
+ return this.store.pipe(select(this.selectors.selectProduct(id)));
281
+ }
282
+ getPrice(id) {
283
+ return this.store.pipe(select(this.selectors.selectProductPrice(id)));
284
+ }
285
+ hasDiscount(id) {
286
+ return this.store.pipe(select(this.selectors.selectProductHasDiscount(id)));
287
+ }
288
+ getDiscountAmount(id) {
289
+ return this.store.pipe(select(this.selectors.selectProductDiscountAmount(id)));
290
+ }
291
+ getDiscountedPrice(id) {
292
+ return this.store.pipe(select(this.selectors.selectProductDiscountedPrice(id)));
293
+ }
294
+ getDiscountPercent(id) {
295
+ return this.store.pipe(select(this.selectors.selectProductDiscountPercent(id)));
296
+ }
297
+ isOutOfStock(id) {
298
+ return this.store.pipe(select(this.selectors.selectIsProductOutOfStock(id)));
299
+ }
300
+ dispatch(action) {
301
+ this.store.dispatch(action);
302
+ }
303
+ static {
304
+ this.ɵfac = i0.ɵɵngDeclareFactory({
305
+ minVersion: "12.0.0",
306
+ version: "22.2.4",
307
+ ngImport: i0,
308
+ type: DaffProductFacade,
309
+ deps: [{ token: i1.Store }],
310
+ target: i0.ɵɵFactoryTarget.Injectable
311
+ });
312
+ }
313
+ static {
314
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
315
+ minVersion: "12.0.0",
316
+ version: "22.2.4",
317
+ ngImport: i0,
318
+ type: DaffProductFacade,
319
+ providedIn: "root"
320
+ });
321
+ }
322
+ };
323
+ i0.ɵɵngDeclareClassMetadata({
324
+ minVersion: "12.0.0",
325
+ version: "22.2.4",
326
+ ngImport: i0,
327
+ type: DaffProductFacade,
328
+ decorators: [{
329
+ type: Injectable,
330
+ args: [{ providedIn: "root" }]
331
+ }],
332
+ ctorParameters: () => [{ type: i1.Store }]
333
+ });
334
+ var DaffProductPageFacade = class DaffProductPageFacade {
335
+ constructor(store) {
336
+ this.store = store;
337
+ this.selectors = getDaffProductSelectors();
338
+ this.loadingState$ = this.store.pipe(select(this.selectors.selectLoadingState));
339
+ this.loading$ = this.store.pipe(select(this.selectors.selectLoading));
340
+ this.mutating$ = this.store.pipe(select(this.selectors.selectMutating));
341
+ this.resolving$ = this.store.pipe(select(this.selectors.selectResolving));
342
+ this.errors$ = this.store.pipe(select(this.selectors.selectErrors));
343
+ this.hasErrors$ = this.store.pipe(select(this.selectors.selectHasErrors));
344
+ this.product$ = this.store.pipe(select(this.selectors.selectCurrentProduct));
345
+ }
346
+ dispatch(action) {
347
+ this.store.dispatch(action);
348
+ }
349
+ static {
350
+ this.ɵfac = i0.ɵɵngDeclareFactory({
351
+ minVersion: "12.0.0",
352
+ version: "22.2.4",
353
+ ngImport: i0,
354
+ type: DaffProductPageFacade,
355
+ deps: [{ token: i1.Store }],
356
+ target: i0.ɵɵFactoryTarget.Injectable
357
+ });
358
+ }
359
+ static {
360
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
361
+ minVersion: "12.0.0",
362
+ version: "22.2.4",
363
+ ngImport: i0,
364
+ type: DaffProductPageFacade,
365
+ providedIn: "root"
366
+ });
367
+ }
368
+ };
369
+ i0.ɵɵngDeclareClassMetadata({
370
+ minVersion: "12.0.0",
371
+ version: "22.2.4",
372
+ ngImport: i0,
373
+ type: DaffProductPageFacade,
374
+ decorators: [{
375
+ type: Injectable,
376
+ args: [{ providedIn: "root" }]
377
+ }],
378
+ ctorParameters: () => [{ type: i1.Store }]
379
+ });
380
+ var DaffProductGridFacade = class DaffProductGridFacade {
381
+ constructor(store) {
382
+ this.store = store;
383
+ const { selectProductGridLoadingState, selectAllProducts } = getDaffProductSelectors();
384
+ this.loading$ = this.store.pipe(select(selectProductGridLoadingState));
385
+ this.products$ = this.store.pipe(select(selectAllProducts));
386
+ }
387
+ dispatch(action) {
388
+ this.store.dispatch(action);
389
+ }
390
+ static {
391
+ this.ɵfac = i0.ɵɵngDeclareFactory({
392
+ minVersion: "12.0.0",
393
+ version: "22.2.4",
394
+ ngImport: i0,
395
+ type: DaffProductGridFacade,
396
+ deps: [{ token: i1.Store }],
397
+ target: i0.ɵɵFactoryTarget.Injectable
398
+ });
399
+ }
400
+ static {
401
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
402
+ minVersion: "12.0.0",
403
+ version: "22.2.4",
404
+ ngImport: i0,
405
+ type: DaffProductGridFacade,
406
+ providedIn: "root"
407
+ });
408
+ }
409
+ };
410
+ i0.ɵɵngDeclareClassMetadata({
411
+ minVersion: "12.0.0",
412
+ version: "22.2.4",
413
+ ngImport: i0,
414
+ type: DaffProductGridFacade,
415
+ decorators: [{
416
+ type: Injectable,
417
+ args: [{ providedIn: "root" }]
418
+ }],
419
+ ctorParameters: () => [{ type: i1.Store }]
355
420
  });
356
-
357
- /**
358
- * A facade for getting state about a particular product.
359
- *
360
- * @inheritdoc
361
- */
362
- class DaffProductFacade {
363
- constructor(store) {
364
- this.store = store;
365
- this.selectors = getDaffProductSelectors();
366
- }
367
- getProduct(id) {
368
- return this.store.pipe(select(this.selectors.selectProduct(id)));
369
- }
370
- getPrice(id) {
371
- return this.store.pipe(select(this.selectors.selectProductPrice(id)));
372
- }
373
- hasDiscount(id) {
374
- return this.store.pipe(select(this.selectors.selectProductHasDiscount(id)));
375
- }
376
- getDiscountAmount(id) {
377
- return this.store.pipe(select(this.selectors.selectProductDiscountAmount(id)));
378
- }
379
- getDiscountedPrice(id) {
380
- return this.store.pipe(select(this.selectors.selectProductDiscountedPrice(id)));
381
- }
382
- getDiscountPercent(id) {
383
- return this.store.pipe(select(this.selectors.selectProductDiscountPercent(id)));
384
- }
385
- isOutOfStock(id) {
386
- return this.store.pipe(select(this.selectors.selectIsProductOutOfStock(id)));
387
- }
388
- dispatch(action) {
389
- this.store.dispatch(action);
390
- }
391
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductFacade, deps: [{ token: i1$1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
392
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductFacade, providedIn: 'root' }); }
393
- }
394
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductFacade, decorators: [{
395
- type: Injectable,
396
- args: [{
397
- providedIn: 'root',
398
- }]
399
- }], ctorParameters: () => [{ type: i1$1.Store }] });
400
-
401
- /**
402
- * A facade for getting state about a particular product.
403
- *
404
- * @inheritdoc
405
- */
406
- class DaffProductPageFacade {
407
- constructor(store) {
408
- this.store = store;
409
- this.selectors = getDaffProductSelectors();
410
- this.loadingState$ = this.store.pipe(select(this.selectors.selectLoadingState));
411
- this.loading$ = this.store.pipe(select(this.selectors.selectLoading));
412
- this.mutating$ = this.store.pipe(select(this.selectors.selectMutating));
413
- this.resolving$ = this.store.pipe(select(this.selectors.selectResolving));
414
- this.errors$ = this.store.pipe(select(this.selectors.selectErrors));
415
- this.hasErrors$ = this.store.pipe(select(this.selectors.selectHasErrors));
416
- this.product$ = this.store.pipe(select(this.selectors.selectCurrentProduct));
417
- }
418
- dispatch(action) {
419
- this.store.dispatch(action);
420
- }
421
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductPageFacade, deps: [{ token: i1$1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
422
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductPageFacade, providedIn: 'root' }); }
423
- }
424
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductPageFacade, decorators: [{
425
- type: Injectable,
426
- args: [{
427
- providedIn: 'root',
428
- }]
429
- }], ctorParameters: () => [{ type: i1$1.Store }] });
430
-
431
- /**
432
- * A facade for accessing state for a list of products from an application component.
433
- *
434
- * @inheritdoc
435
- */
436
- class DaffProductGridFacade {
437
- constructor(store) {
438
- this.store = store;
439
- const { selectProductGridLoadingState, selectAllProducts, } = getDaffProductSelectors();
440
- this.loading$ = this.store.pipe(select(selectProductGridLoadingState));
441
- this.products$ = this.store.pipe(select(selectAllProducts));
442
- }
443
- dispatch(action) {
444
- this.store.dispatch(action);
445
- }
446
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGridFacade, deps: [{ token: i1$1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
447
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGridFacade, providedIn: 'root' }); }
448
- }
449
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGridFacade, decorators: [{
450
- type: Injectable,
451
- args: [{
452
- providedIn: 'root',
453
- }]
454
- }], ctorParameters: () => [{ type: i1$1.Store }] });
455
-
456
- /**
457
- * Initial values of the product state.
458
- */
459
421
  const daffProductReducerInitialState = {
460
- ...daffOperationInitialState,
461
- currentProductId: null,
462
- qty: 1,
422
+ ...daffOperationInitialState,
423
+ currentProductId: null,
424
+ qty: 1
463
425
  };
464
- /**
465
- * Reducer function that catches actions and changes/overwrites product state.
466
- *
467
- * @param state current State of the redux store
468
- * @param action a product action
469
- * @returns product state
470
- */
471
426
  function daffProductReducer(state = daffProductReducerInitialState, action) {
472
- switch (action.type) {
473
- case DaffProductPageActionTypes.ProductPageLoadAction:
474
- case DaffProductPageActionTypes.ProductPageLoadByUrlAction:
475
- return daffStartResolution(state);
476
- case DaffProductPageActionTypes.ProductPageLoadSuccessAction:
477
- return { ...daffCompleteOperation(state), currentProductId: action.payload.id };
478
- case DaffProductPageActionTypes.ProductPageLoadFailureAction:
479
- return daffOperationFailed([action.payload], state);
480
- case DaffProductPageActionTypes.UpdateQtyAction:
481
- return { ...state, qty: action.payload };
482
- default:
483
- return state;
484
- }
427
+ switch (action.type) {
428
+ case DaffProductPageActionTypes.ProductPageLoadAction:
429
+ case DaffProductPageActionTypes.ProductPageLoadByUrlAction: return daffStartResolution(state);
430
+ case DaffProductPageActionTypes.ProductPageLoadSuccessAction: return {
431
+ ...daffCompleteOperation(state),
432
+ currentProductId: action.payload.id
433
+ };
434
+ case DaffProductPageActionTypes.ProductPageLoadFailureAction: return daffOperationFailed([action.payload], state);
435
+ case DaffProductPageActionTypes.UpdateQtyAction: return {
436
+ ...state,
437
+ qty: action.payload
438
+ };
439
+ default: return state;
440
+ }
485
441
  }
486
-
487
- /**
488
- * Reducer function that catches actions and changes/overwrites product entities state.
489
- *
490
- * @param state current State of the redux store
491
- * @param action ProductGrid, BestSellers, or Product actions
492
- * @returns Product entities state
493
- */
494
442
  function daffProductEntitiesReducer(state = daffProductEntitiesAdapter().getInitialState(), action) {
495
- const adapter = daffProductEntitiesAdapter();
496
- switch (action.type) {
497
- case DaffProductGridActionTypes.ProductGridLoadSuccessAction:
498
- return adapter.upsertMany(action.payload, state);
499
- case DaffProductPageActionTypes.ProductPageLoadSuccessAction:
500
- case DaffProductActionTypes.ProductLoadSuccessAction:
501
- return adapter.upsertMany(action.payload.products, state);
502
- case DaffProductGridActionTypes.ProductGridResetAction:
503
- return adapter.removeAll(state);
504
- default:
505
- return state;
506
- }
443
+ const adapter = daffProductEntitiesAdapter();
444
+ switch (action.type) {
445
+ case DaffProductGridActionTypes.ProductGridLoadSuccessAction: return adapter.upsertMany(action.payload, state);
446
+ case DaffProductPageActionTypes.ProductPageLoadSuccessAction:
447
+ case DaffProductActionTypes.ProductLoadSuccessAction: return adapter.upsertMany(action.payload.products, state);
448
+ case DaffProductGridActionTypes.ProductGridResetAction: return adapter.removeAll(state);
449
+ default: return state;
450
+ }
507
451
  }
508
-
509
- /**
510
- * Initial values of the product grid state.
511
- */
512
452
  const initialState = {
513
- products: [],
514
- loading: false,
515
- errors: [],
453
+ products: [],
454
+ loading: false,
455
+ errors: []
516
456
  };
517
- /**
518
- * Reducer function that catches actions and changes/overwrites product grid state.
519
- *
520
- * @param state current State of the redux store
521
- * @param action a product grid action
522
- * @returns Product grid state
523
- */
524
457
  function daffProductGridReducer(state = initialState, action) {
525
- switch (action.type) {
526
- case DaffProductGridActionTypes.ProductGridLoadAction:
527
- return { ...state, loading: true };
528
- case DaffProductGridActionTypes.ProductGridLoadSuccessAction:
529
- return { ...state, loading: false };
530
- case DaffProductGridActionTypes.ProductGridLoadFailureAction:
531
- return { ...state,
532
- loading: false,
533
- errors: state.errors.concat(new Array(action.payload)) };
534
- default:
535
- return state;
536
- }
458
+ switch (action.type) {
459
+ case DaffProductGridActionTypes.ProductGridLoadAction: return {
460
+ ...state,
461
+ loading: true
462
+ };
463
+ case DaffProductGridActionTypes.ProductGridLoadSuccessAction: return {
464
+ ...state,
465
+ loading: false
466
+ };
467
+ case DaffProductGridActionTypes.ProductGridLoadFailureAction: return {
468
+ ...state,
469
+ loading: false,
470
+ errors: state.errors.concat(new Array(action.payload))
471
+ };
472
+ default: return state;
473
+ }
537
474
  }
538
-
539
- /**
540
- * Returns state values from all product related reducers.
541
- */
542
475
  const daffProductReducers = {
543
- products: daffProductEntitiesReducer,
544
- productGrid: daffProductGridReducer,
545
- product: daffProductReducer,
476
+ products: daffProductEntitiesReducer,
477
+ productGrid: daffProductGridReducer,
478
+ product: daffProductReducer
546
479
  };
547
-
548
- const {
549
- /**
550
- * A token to hold the injectable extra meta-reducers.
551
- *
552
- * Prefer using {@link daffProductProvideMetaReducers}.
553
- */
554
- token: DAFF_PRODUCT_META_REDUCERS,
555
- /**
556
- * Provides additional meta-reducers that run after the standard Daffodil cart meta-reducers.
557
- *
558
- * @example
559
- * ```ts
560
- * providers: [
561
- * ...daffProductProvideMetaReducers(
562
- * myMetaReducer1,
563
- * myMetaReducer2
564
- * )
565
- * ]
566
- * ```
567
- */
568
- provider: daffProductProvideMetaReducers, factoryProvider: daffProductProvideMetaReducerFactories, } = createMultiInjectionToken('DAFF_PRODUCT_META_REDUCERS');
569
-
570
- const {
571
- /**
572
- * A token to hold the injectable extra reducers.
573
- *
574
- * Prefer using {@link daffProductProvideExtraReducers}.
575
- */
576
- token: DAFF_PRODUCT_EXTRA_REDUCERS,
577
- /**
578
- * Provides additional reducers that run after the standard Daffodil cart reducers.
579
- *
580
- * @example
581
- * ```ts
582
- * providers: [
583
- * ...daffProductProvideExtraReducers(
584
- * myReducer1,
585
- * myReducer2
586
- * )
587
- * ]
588
- * ```
589
- */
590
- provider: daffProductProvideExtraReducers, } = createMultiInjectionToken('DAFF_PRODUCT_EXTRA_REDUCERS');
591
-
592
- /**
593
- * Effects for handling product actions and for triggering corresponding service requests.
594
- *
595
- * @param action$ - Redux action object
596
- * @param driver - A product service driver
597
- */
598
- class DaffProductPageEffects {
599
- constructor(actions$, driver, errorMatcher) {
600
- this.actions$ = actions$;
601
- this.driver = driver;
602
- this.errorMatcher = errorMatcher;
603
- /**
604
- * Handles ProductPageLoadAction by making a service call for a product and returning a success or
605
- * failure action to the action stream.
606
- *
607
- * @returns An Observable of a ProductLoadAction
608
- */
609
- this.load$ = createEffect(() => this.actions$.pipe(ofType(DaffProductPageActionTypes.ProductPageLoadAction), switchMap((action) => this.driver.get(action.payload)
610
- .pipe(map((resp) => new DaffProductPageLoadSuccess(resp)), catchError((error) => of(new DaffProductPageLoadFailure(this.errorMatcher(error))))))));
611
- this.loadByUrl$ = createEffect(() => this.actions$.pipe(ofType(DaffProductPageActionTypes.ProductPageLoadByUrlAction), switchMap((action) => this.driver.getByUrl(action.payload)
612
- .pipe(map((resp) => new DaffProductPageLoadSuccess(resp)), catchError((error) => of(new DaffProductPageLoadFailure(this.errorMatcher(error))))))));
613
- }
614
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductPageEffects, deps: [{ token: i1.Actions }, { token: DaffProductDriver }, { token: DAFF_PRODUCT_ERROR_MATCHER }], target: i0.ɵɵFactoryTarget.Injectable }); }
615
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductPageEffects }); }
616
- }
617
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductPageEffects, decorators: [{
618
- type: Injectable
619
- }], ctorParameters: () => [{ type: i1.Actions }, { type: undefined, decorators: [{
620
- type: Inject,
621
- args: [DaffProductDriver]
622
- }] }, { type: undefined, decorators: [{
623
- type: Inject,
624
- args: [DAFF_PRODUCT_ERROR_MATCHER]
625
- }] }] });
626
-
627
- const {
628
- /**
629
- * An internal token to hold the Daffodil product feature store config.
630
- *
631
- * @docs-private
632
- */
633
- token: DAFF_PRODUCT_STORE_CONFIG,
634
- /**
635
- * Provider function for {@link DAFF_PRODUCT_STORE_CONFIG}.
636
- */
637
- provider: provideDaffProductStoreConfig, } = createSingleInjectionToken('DAFF_PRODUCT_STORE_CONFIG', {
638
- providedIn: 'any',
639
- factory: () => ({
640
- metaReducers: inject(DAFF_PRODUCT_META_REDUCERS),
641
- }),
480
+ const { token: DAFF_PRODUCT_META_REDUCERS, provider: daffProductProvideMetaReducers, factoryProvider: daffProductProvideMetaReducerFactories } = createMultiInjectionToken("DAFF_PRODUCT_META_REDUCERS");
481
+ const { token: DAFF_PRODUCT_EXTRA_REDUCERS, provider: daffProductProvideExtraReducers } = createMultiInjectionToken("DAFF_PRODUCT_EXTRA_REDUCERS");
482
+ var DaffProductPageEffects = class DaffProductPageEffects {
483
+ constructor(actions$, driver, errorMatcher) {
484
+ this.actions$ = actions$;
485
+ this.driver = driver;
486
+ this.errorMatcher = errorMatcher;
487
+ this.load$ = createEffect(() => this.actions$.pipe(ofType(DaffProductPageActionTypes.ProductPageLoadAction), switchMap((action) => this.driver.get(action.payload).pipe(map((resp) => new DaffProductPageLoadSuccess(resp)), catchError((error) => of(new DaffProductPageLoadFailure(this.errorMatcher(error))))))));
488
+ this.loadByUrl$ = createEffect(() => this.actions$.pipe(ofType(DaffProductPageActionTypes.ProductPageLoadByUrlAction), switchMap((action) => this.driver.getByUrl(action.payload).pipe(map((resp) => new DaffProductPageLoadSuccess(resp)), catchError((error) => of(new DaffProductPageLoadFailure(this.errorMatcher(error))))))));
489
+ }
490
+ static {
491
+ this.ɵfac = i0.ɵɵngDeclareFactory({
492
+ minVersion: "12.0.0",
493
+ version: "22.2.4",
494
+ ngImport: i0,
495
+ type: DaffProductPageEffects,
496
+ deps: [
497
+ { token: i1$1.Actions },
498
+ { token: DaffProductDriver },
499
+ { token: DAFF_PRODUCT_ERROR_MATCHER }
500
+ ],
501
+ target: i0.ɵɵFactoryTarget.Injectable
502
+ });
503
+ }
504
+ static {
505
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
506
+ minVersion: "12.0.0",
507
+ version: "22.2.4",
508
+ ngImport: i0,
509
+ type: DaffProductPageEffects
510
+ });
511
+ }
512
+ };
513
+ i0.ɵɵngDeclareClassMetadata({
514
+ minVersion: "12.0.0",
515
+ version: "22.2.4",
516
+ ngImport: i0,
517
+ type: DaffProductPageEffects,
518
+ decorators: [{ type: Injectable }],
519
+ ctorParameters: () => [
520
+ { type: i1$1.Actions },
521
+ {
522
+ type: void 0,
523
+ decorators: [{
524
+ type: Inject,
525
+ args: [DaffProductDriver]
526
+ }]
527
+ },
528
+ {
529
+ type: void 0,
530
+ decorators: [{
531
+ type: Inject,
532
+ args: [DAFF_PRODUCT_ERROR_MATCHER]
533
+ }]
534
+ }
535
+ ]
642
536
  });
643
-
644
- const {
645
- /**
646
- * An internal token to hold the Daffodil cart reducers.
647
- * Includes the extra and standard reducers.
648
- *
649
- * @docs-private
650
- */
651
- token: DAFF_PRODUCT_REDUCERS,
652
- /**
653
- * Provider function for {@link DAFF_PRODUCT_REDUCERS}.
654
- */
655
- provider: provideDaffProductReducers, } = createSingleInjectionToken('DAFF_PRODUCT_REDUCERS', {
656
- factory: () => daffComposeReducers([
657
- combineReducers(daffProductReducers),
658
- ...inject(DAFF_PRODUCT_EXTRA_REDUCERS),
659
- ]),
537
+ const { token: DAFF_PRODUCT_STORE_CONFIG, provider: provideDaffProductStoreConfig } = createSingleInjectionToken("DAFF_PRODUCT_STORE_CONFIG", {
538
+ providedIn: "any",
539
+ factory: () => ({ metaReducers: inject(DAFF_PRODUCT_META_REDUCERS) })
660
540
  });
541
+ const { token: DAFF_PRODUCT_REDUCERS, provider: provideDaffProductReducers, factoryProvider: provideDaffProductReducersFactory } = createSingleInjectionToken("DAFF_PRODUCT_REDUCERS");
542
+ var DaffProductStateModule = class DaffProductStateModule {
543
+ static {
544
+ this.ɵfac = i0.ɵɵngDeclareFactory({
545
+ minVersion: "12.0.0",
546
+ version: "22.2.4",
547
+ ngImport: i0,
548
+ type: DaffProductStateModule,
549
+ deps: [],
550
+ target: i0.ɵɵFactoryTarget.NgModule
551
+ });
552
+ }
553
+ static {
554
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
555
+ minVersion: "14.0.0",
556
+ version: "22.2.4",
557
+ ngImport: i0,
558
+ type: DaffProductStateModule,
559
+ imports: [i1.StoreFeatureModule, i1$1.EffectsFeatureModule]
560
+ });
561
+ }
562
+ static {
563
+ this.ɵinj = i0.ɵɵngDeclareInjector({
564
+ minVersion: "12.0.0",
565
+ version: "22.2.4",
566
+ ngImport: i0,
567
+ type: DaffProductStateModule,
568
+ providers: [provideDaffProductReducersFactory((() => daffComposeReducers([combineReducers(daffProductReducers), ...inject(DAFF_PRODUCT_EXTRA_REDUCERS)])))],
569
+ imports: [StoreModule.forFeature(DAFF_PRODUCT_STORE_FEATURE_KEY, DAFF_PRODUCT_REDUCERS, DAFF_PRODUCT_STORE_CONFIG), EffectsModule.forFeature([
570
+ DaffProductGridEffects,
571
+ DaffProductEffects,
572
+ DaffProductPageEffects
573
+ ])]
574
+ });
575
+ }
576
+ };
577
+ i0.ɵɵngDeclareClassMetadata({
578
+ minVersion: "12.0.0",
579
+ version: "22.2.4",
580
+ ngImport: i0,
581
+ type: DaffProductStateModule,
582
+ decorators: [{
583
+ type: NgModule,
584
+ args: [{
585
+ imports: [StoreModule.forFeature(DAFF_PRODUCT_STORE_FEATURE_KEY, DAFF_PRODUCT_REDUCERS, DAFF_PRODUCT_STORE_CONFIG), EffectsModule.forFeature([
586
+ DaffProductGridEffects,
587
+ DaffProductEffects,
588
+ DaffProductPageEffects
589
+ ])],
590
+ providers: [provideDaffProductReducersFactory((() => daffComposeReducers([combineReducers(daffProductReducers), ...inject(DAFF_PRODUCT_EXTRA_REDUCERS)])))]
591
+ }]
592
+ }]
593
+ });
594
+ const provideDaffProductState = () => makeEnvironmentProviders([
595
+ provideState(DAFF_PRODUCT_STORE_FEATURE_KEY, DAFF_PRODUCT_REDUCERS, DAFF_PRODUCT_STORE_CONFIG),
596
+ provideEffects(DaffProductGridEffects, DaffProductEffects, DaffProductPageEffects),
597
+ provideDaffProductReducersFactory(() => daffComposeReducers([combineReducers(daffProductReducers), ...inject(DAFF_PRODUCT_EXTRA_REDUCERS)]))
598
+ ]);
599
+ export { DAFF_PRODUCT_ERROR_MATCHER, DAFF_PRODUCT_EXTRA_REDUCERS, DAFF_PRODUCT_META_REDUCERS, DAFF_PRODUCT_STORE_FEATURE_KEY, DaffProductActionTypes, DaffProductEffects, DaffProductFacade, DaffProductGridActionTypes, DaffProductGridEffects, DaffProductGridFacade, DaffProductGridLoad, DaffProductGridLoadFailure, DaffProductGridLoadSuccess, DaffProductGridReset, DaffProductLoad, DaffProductLoadFailure, DaffProductLoadSuccess, DaffProductPageActionTypes, DaffProductPageFacade, DaffProductPageLoad, DaffProductPageLoadByUrl, DaffProductPageLoadFailure, DaffProductPageLoadSuccess, DaffProductPageUpdateQty, DaffProductStateModule, daffProductEntitiesAdapter, daffProductEntitiesReducer, daffProductGridReducer, daffProductProvideExtraReducers, daffProductProvideMetaReducerFactories, daffProductProvideMetaReducers, daffProductReducer, daffProductReducerInitialState, daffProductReducers, getDaffProductEntitiesSelectors, getDaffProductFeatureSelector, getDaffProductGridSelectors, getDaffProductPageSelectors, getDaffProductSelectors, provideDaffProductErrorMatcher, provideDaffProductState };
661
600
 
662
- /**
663
- * A module that provides the default reducers and effects for the product redux state.
664
- */
665
- class DaffProductStateModule {
666
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
667
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffProductStateModule, imports: [i1$1.StoreFeatureModule, i1.EffectsFeatureModule] }); }
668
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductStateModule, imports: [StoreModule.forFeature(DAFF_PRODUCT_STORE_FEATURE_KEY, DAFF_PRODUCT_REDUCERS, DAFF_PRODUCT_STORE_CONFIG),
669
- EffectsModule.forFeature([
670
- DaffProductGridEffects,
671
- DaffProductEffects,
672
- DaffProductPageEffects,
673
- ])] }); }
674
- }
675
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductStateModule, decorators: [{
676
- type: NgModule,
677
- args: [{
678
- imports: [
679
- StoreModule.forFeature(DAFF_PRODUCT_STORE_FEATURE_KEY, DAFF_PRODUCT_REDUCERS, DAFF_PRODUCT_STORE_CONFIG),
680
- EffectsModule.forFeature([
681
- DaffProductGridEffects,
682
- DaffProductEffects,
683
- DaffProductPageEffects,
684
- ]),
685
- ],
686
- }]
687
- }] });
688
-
689
- /**
690
- * Generated bundle index. Do not edit.
691
- */
692
-
693
- export { DAFF_PRODUCT_ERROR_MATCHER, DAFF_PRODUCT_EXTRA_REDUCERS, DAFF_PRODUCT_META_REDUCERS, DAFF_PRODUCT_STORE_FEATURE_KEY, DaffProductActionTypes, DaffProductEffects, DaffProductFacade, DaffProductGridActionTypes, DaffProductGridEffects, DaffProductGridFacade, DaffProductGridLoad, DaffProductGridLoadFailure, DaffProductGridLoadSuccess, DaffProductGridReset, DaffProductLoad, DaffProductLoadFailure, DaffProductLoadSuccess, DaffProductPageActionTypes, DaffProductPageFacade, DaffProductPageLoad, DaffProductPageLoadByUrl, DaffProductPageLoadFailure, DaffProductPageLoadSuccess, DaffProductPageUpdateQty, DaffProductStateModule, daffProductEntitiesAdapter, daffProductEntitiesReducer, daffProductGridReducer, daffProductProvideExtraReducers, daffProductProvideMetaReducerFactories, daffProductProvideMetaReducers, daffProductReducer, daffProductReducerInitialState, daffProductReducers, getDaffProductEntitiesSelectors, getDaffProductFeatureSelector, getDaffProductGridSelectors, getDaffProductPageSelectors, getDaffProductSelectors, provideDaffProductErrorMatcher };
694
- //# sourceMappingURL=daffodil-product-state.mjs.map
601
+ //# sourceMappingURL=daffodil-product-state.mjs.map