@daffodil/product 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.
- package/fesm2022/daffodil-product-driver-in-memory.mjs +200 -227
- package/fesm2022/daffodil-product-driver-in-memory.mjs.map +1 -1
- package/fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs +444 -0
- package/fesm2022/daffodil-product-driver-magento-2.4.7-testing.mjs.map +1 -0
- package/fesm2022/daffodil-product-driver-magento-2.4.7.mjs +704 -0
- package/fesm2022/daffodil-product-driver-magento-2.4.7.mjs.map +1 -0
- package/fesm2022/daffodil-product-driver-magento-auto-testing.mjs +7 -0
- package/fesm2022/daffodil-product-driver-magento-auto-testing.mjs.map +1 -0
- package/fesm2022/daffodil-product-driver-magento-auto.mjs +7 -0
- package/fesm2022/daffodil-product-driver-magento-auto.mjs.map +1 -0
- package/fesm2022/daffodil-product-driver-shopify.mjs +99 -127
- package/fesm2022/daffodil-product-driver-shopify.mjs.map +1 -1
- package/fesm2022/daffodil-product-driver-testing.mjs +117 -87
- package/fesm2022/daffodil-product-driver-testing.mjs.map +1 -1
- package/fesm2022/daffodil-product-driver.mjs +22 -45
- package/fesm2022/daffodil-product-driver.mjs.map +1 -1
- package/fesm2022/daffodil-product-routing.mjs +347 -285
- package/fesm2022/daffodil-product-routing.mjs.map +1 -1
- package/fesm2022/daffodil-product-state-testing.mjs +189 -106
- package/fesm2022/daffodil-product-state-testing.mjs.map +1 -1
- package/fesm2022/daffodil-product-state.mjs +566 -659
- package/fesm2022/daffodil-product-state.mjs.map +1 -1
- package/fesm2022/daffodil-product-testing.mjs +316 -276
- package/fesm2022/daffodil-product-testing.mjs.map +1 -1
- package/fesm2022/daffodil-product.mjs +8 -29
- package/fesm2022/daffodil-product.mjs.map +1 -1
- package/package.json +1 -1
- package/types/daffodil-product-driver-in-memory.d.ts +65 -75
- package/types/daffodil-product-driver-magento-2.4.7-testing.d.ts +105 -0
- package/types/daffodil-product-driver-magento-2.4.7.d.ts +337 -0
- package/types/daffodil-product-driver-magento-auto-testing.d.ts +1 -0
- package/types/daffodil-product-driver-magento-auto.d.ts +1 -0
- package/types/daffodil-product-driver-shopify.d.ts +31 -43
- package/types/daffodil-product-driver-testing.d.ts +28 -26
- package/types/daffodil-product-driver.d.ts +50 -61
- package/types/daffodil-product-routing.d.ts +101 -110
- package/types/daffodil-product-state-testing.d.ts +45 -43
- package/types/daffodil-product-state.d.ts +347 -375
- package/types/daffodil-product-testing.d.ts +82 -89
- package/types/daffodil-product.d.ts +93 -102
- package/fesm2022/daffodil-product-driver-magento-testing.mjs +0 -275
- package/fesm2022/daffodil-product-driver-magento-testing.mjs.map +0 -1
- package/fesm2022/daffodil-product-driver-magento.mjs +0 -855
- package/fesm2022/daffodil-product-driver-magento.mjs.map +0 -1
- package/types/daffodil-product-driver-magento-testing.d.ts +0 -114
- package/types/daffodil-product-driver-magento.d.ts +0 -396
|
@@ -1,694 +1,601 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import { Inject, Injectable, inject,
|
|
3
|
-
import * as i1 from
|
|
4
|
-
import { createEffect, ofType,
|
|
5
|
-
import { of } from
|
|
6
|
-
import {
|
|
7
|
-
import { DaffProductDriver } from
|
|
8
|
-
import { createSingleInjectionToken, daffSubtract
|
|
9
|
-
import {
|
|
10
|
-
import * as i1
|
|
11
|
-
import {
|
|
12
|
-
import { createEntityAdapter } from
|
|
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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
class
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
class
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
282
|
-
|
|
229
|
+
let cache;
|
|
230
|
+
return () => cache = cache || createEntityAdapter();
|
|
283
231
|
})();
|
|
284
|
-
|
|
285
232
|
const createProductEntitiesSelectors = () => {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
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
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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
|
-
|
|
461
|
-
|
|
462
|
-
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
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
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
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
|
-
|
|
514
|
-
|
|
515
|
-
|
|
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
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
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
|
-
|
|
544
|
-
|
|
545
|
-
|
|
476
|
+
products: daffProductEntitiesReducer,
|
|
477
|
+
productGrid: daffProductGridReducer,
|
|
478
|
+
product: daffProductReducer
|
|
546
479
|
};
|
|
547
|
-
|
|
548
|
-
const {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
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
|
-
|
|
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
|