@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.
- 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,294 +1,356 @@
|
|
|
1
|
-
import { isPlatformBrowser } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import * as i1 from
|
|
6
|
-
import {
|
|
7
|
-
import { map,
|
|
8
|
-
import {
|
|
9
|
-
import * as i2 from
|
|
10
|
-
import { daffRoutingQueryParamFilterRequestEqualBuilder } from
|
|
11
|
-
import { DaffBase64ServiceToken, createConfigInjectionToken, createMultiInjectionToken, daffArrayToDict, daffFiltersToRequests } from
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
import { isPlatformBrowser } from "@angular/common";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Inject, Injectable, InjectionToken, NgModule, PLATFORM_ID, inject, makeEnvironmentProviders } from "@angular/core";
|
|
4
|
+
import { createEffect, ofType } from "@ngrx/effects";
|
|
5
|
+
import * as i1 from "@ngrx/store";
|
|
6
|
+
import { EMPTY, of } from "rxjs";
|
|
7
|
+
import { map, switchMap, take, tap, withLatestFrom } from "rxjs/operators";
|
|
8
|
+
import { DaffProductPageActionTypes, DaffProductPageLoad, DaffProductPageLoadByUrl } from "@daffodil/product/state";
|
|
9
|
+
import * as i2 from "@daffodil/core/routing";
|
|
10
|
+
import { daffRoutingQueryParamFilterRequestEqualBuilder } from "@daffodil/core/routing";
|
|
11
|
+
import { DaffBase64ServiceToken, createConfigInjectionToken, createMultiInjectionToken, daffArrayToDict, daffFiltersToRequests } from "@daffodil/core";
|
|
12
|
+
var DaffProductPageIdResolver = class DaffProductPageIdResolver {
|
|
13
|
+
constructor(platformId, store, dispatcher) {
|
|
14
|
+
this.platformId = platformId;
|
|
15
|
+
this.store = store;
|
|
16
|
+
this.dispatcher = dispatcher;
|
|
17
|
+
}
|
|
18
|
+
resolve(route) {
|
|
19
|
+
this.store.dispatch(new DaffProductPageLoad(route.paramMap.get("id")));
|
|
20
|
+
return isPlatformBrowser(this.platformId) ? of(true) : this.dispatcher.pipe(ofType(DaffProductPageActionTypes.ProductPageLoadSuccessAction, DaffProductPageActionTypes.ProductPageLoadFailureAction), map(() => true), take(1));
|
|
21
|
+
}
|
|
22
|
+
static {
|
|
23
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
24
|
+
minVersion: "12.0.0",
|
|
25
|
+
version: "22.2.4",
|
|
26
|
+
ngImport: i0,
|
|
27
|
+
type: DaffProductPageIdResolver,
|
|
28
|
+
deps: [
|
|
29
|
+
{ token: PLATFORM_ID },
|
|
30
|
+
{ token: i1.Store },
|
|
31
|
+
{ token: i1.ActionsSubject }
|
|
32
|
+
],
|
|
33
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
static {
|
|
37
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
38
|
+
minVersion: "12.0.0",
|
|
39
|
+
version: "22.2.4",
|
|
40
|
+
ngImport: i0,
|
|
41
|
+
type: DaffProductPageIdResolver,
|
|
42
|
+
providedIn: "root"
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
47
|
+
minVersion: "12.0.0",
|
|
48
|
+
version: "22.2.4",
|
|
49
|
+
ngImport: i0,
|
|
50
|
+
type: DaffProductPageIdResolver,
|
|
51
|
+
decorators: [{
|
|
52
|
+
type: Injectable,
|
|
53
|
+
args: [{ providedIn: "root" }]
|
|
54
|
+
}],
|
|
55
|
+
ctorParameters: () => [
|
|
56
|
+
{
|
|
57
|
+
type: void 0,
|
|
58
|
+
decorators: [{
|
|
59
|
+
type: Inject,
|
|
60
|
+
args: [PLATFORM_ID]
|
|
61
|
+
}]
|
|
62
|
+
},
|
|
63
|
+
{ type: i1.Store },
|
|
64
|
+
{ type: i1.ActionsSubject }
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
var DaffProductPageUrlResolver = class DaffProductPageUrlResolver {
|
|
68
|
+
constructor(platformId, store, dispatcher, urlNormalizer) {
|
|
69
|
+
this.platformId = platformId;
|
|
70
|
+
this.store = store;
|
|
71
|
+
this.dispatcher = dispatcher;
|
|
72
|
+
this.urlNormalizer = urlNormalizer;
|
|
73
|
+
}
|
|
74
|
+
resolve(route, state) {
|
|
75
|
+
this.store.dispatch(new DaffProductPageLoadByUrl(this.urlNormalizer.normalize(state.url)));
|
|
76
|
+
return isPlatformBrowser(this.platformId) ? of(true) : this.dispatcher.pipe(ofType(DaffProductPageActionTypes.ProductPageLoadSuccessAction, DaffProductPageActionTypes.ProductPageLoadFailureAction), map(() => true), take(1));
|
|
77
|
+
}
|
|
78
|
+
static {
|
|
79
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
80
|
+
minVersion: "12.0.0",
|
|
81
|
+
version: "22.2.4",
|
|
82
|
+
ngImport: i0,
|
|
83
|
+
type: DaffProductPageUrlResolver,
|
|
84
|
+
deps: [
|
|
85
|
+
{ token: PLATFORM_ID },
|
|
86
|
+
{ token: i1.Store },
|
|
87
|
+
{ token: i1.ActionsSubject },
|
|
88
|
+
{ token: i2.DaffRoutingUriNormalizer }
|
|
89
|
+
],
|
|
90
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
static {
|
|
94
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
95
|
+
minVersion: "12.0.0",
|
|
96
|
+
version: "22.2.4",
|
|
97
|
+
ngImport: i0,
|
|
98
|
+
type: DaffProductPageUrlResolver,
|
|
99
|
+
providedIn: "root"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
104
|
+
minVersion: "12.0.0",
|
|
105
|
+
version: "22.2.4",
|
|
106
|
+
ngImport: i0,
|
|
107
|
+
type: DaffProductPageUrlResolver,
|
|
108
|
+
decorators: [{
|
|
109
|
+
type: Injectable,
|
|
110
|
+
args: [{ providedIn: "root" }]
|
|
111
|
+
}],
|
|
112
|
+
ctorParameters: () => [
|
|
113
|
+
{
|
|
114
|
+
type: void 0,
|
|
115
|
+
decorators: [{
|
|
116
|
+
type: Inject,
|
|
117
|
+
args: [PLATFORM_ID]
|
|
118
|
+
}]
|
|
119
|
+
},
|
|
120
|
+
{ type: i1.Store },
|
|
121
|
+
{ type: i1.ActionsSubject },
|
|
122
|
+
{ type: i2.DaffRoutingUriNormalizer }
|
|
123
|
+
]
|
|
124
|
+
});
|
|
70
125
|
const DAFF_PRODUCT_ROUTING_QUERY_PARAM_REQUEST_MAP = {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
126
|
+
filterRequests: "filters",
|
|
127
|
+
appliedSortOption: "sortOption",
|
|
128
|
+
appliedSortDirection: "sortDir",
|
|
129
|
+
currentPage: "page",
|
|
130
|
+
pageSize: "size"
|
|
76
131
|
};
|
|
77
|
-
/**
|
|
78
|
-
* The default configuration for the {@link DaffProductRoutingConfig}.
|
|
79
|
-
*/
|
|
80
132
|
const daffProductRoutingConfigDefaultFactory = (base64) => ({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
133
|
+
params: DAFF_PRODUCT_ROUTING_QUERY_PARAM_REQUEST_MAP,
|
|
134
|
+
transforms: {
|
|
135
|
+
pageSize: {
|
|
136
|
+
request: (str) => Number(str),
|
|
137
|
+
queryParam: (pageSize) => String(pageSize)
|
|
138
|
+
},
|
|
139
|
+
currentPage: {
|
|
140
|
+
request: (str) => Number(str),
|
|
141
|
+
queryParam: (currentPage) => String(currentPage)
|
|
142
|
+
},
|
|
143
|
+
filterRequests: {
|
|
144
|
+
request: (base64Str) => JSON.parse(base64.decode(base64Str)),
|
|
145
|
+
queryParam: (filterRequests) => base64.encode(JSON.stringify(filterRequests))
|
|
146
|
+
}
|
|
147
|
+
}
|
|
96
148
|
});
|
|
97
|
-
const DAFF_PRODUCT_ROUTING_CONFIG_DEFAULT = new InjectionToken(
|
|
98
|
-
|
|
99
|
-
const {
|
|
100
|
-
/**
|
|
101
|
-
* The token used to provide @daffodil/product/routing config data.
|
|
102
|
-
*/
|
|
103
|
-
token: DAFF_PRODUCT_ROUTING_CONFIG,
|
|
104
|
-
/**
|
|
105
|
-
* Provides the {@link DAFF_PRODUCT_ROUTING_CONFIG} token.
|
|
106
|
-
*/
|
|
107
|
-
provider: provideDaffProductRoutingConfig, } = createConfigInjectionToken(DAFF_PRODUCT_ROUTING_CONFIG_DEFAULT, 'DAFF_PRODUCT_ROUTING_CONFIG');
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* A list of request fields that can be transformed to and from query params.
|
|
111
|
-
*/
|
|
149
|
+
const DAFF_PRODUCT_ROUTING_CONFIG_DEFAULT = new InjectionToken("DAFF_PRODUCT_ROUTING_CONFIG_DEFAULT", { factory: () => daffProductRoutingConfigDefaultFactory(inject(DaffBase64ServiceToken)) });
|
|
150
|
+
const { token: DAFF_PRODUCT_ROUTING_CONFIG, provider: provideDaffProductRoutingConfig } = createConfigInjectionToken(DAFF_PRODUCT_ROUTING_CONFIG_DEFAULT, "DAFF_PRODUCT_ROUTING_CONFIG");
|
|
112
151
|
const DAFF_PRODUCT_COLLECTION_REQUEST_FIELDS = [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
152
|
+
"filterRequests",
|
|
153
|
+
"appliedSortOption",
|
|
154
|
+
"appliedSortDirection",
|
|
155
|
+
"currentPage",
|
|
156
|
+
"pageSize"
|
|
118
157
|
];
|
|
119
|
-
|
|
120
|
-
const {
|
|
121
|
-
/**
|
|
122
|
-
* A list of product filter requests that are contained directly in query params,
|
|
123
|
-
* with a one-to-one mapping between filters and query params.
|
|
124
|
-
* This is constrasted to {@link DaffCollectionRequestQueryParams#filterRequests}
|
|
125
|
-
* which remains the actual canonical source of truth of the filter requests.
|
|
126
|
-
* The discrete filter params persist in the URL as long as the corresponding filter remains applied.
|
|
127
|
-
*/
|
|
128
|
-
token: DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS, } = createMultiInjectionToken('DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS', { providedIn: 'any' });
|
|
129
|
-
/**
|
|
130
|
-
* A multi-provider for {@link DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS}.
|
|
131
|
-
*
|
|
132
|
-
* @param queryParam Defaults to `filterName`.
|
|
133
|
-
* @param builder Defaults to {@link daffRoutingQueryParamFilterRequestEqualBuilder}.
|
|
134
|
-
*/
|
|
158
|
+
const { token: DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS } = createMultiInjectionToken("DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS", { providedIn: "any" });
|
|
135
159
|
function daffProductRoutingProvideDiscreteFilterParam(filterName, queryParam, builder) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Builds a {@link DaffCollectionRequest} from the query params of the passed route.
|
|
149
|
-
* Its behavior can be configured via the {@link DAFF_PRODUCT_COLLECTION_QUERY_PARAMS} and
|
|
150
|
-
* {@link DAFF_PRODUCT_COLLECTION_QUERY_PARAM_TRANSFORMS} injection tokens.
|
|
151
|
-
*/
|
|
152
|
-
class DaffProductGetCollectionRequestFromRoute {
|
|
153
|
-
constructor(config, discreteFilters) {
|
|
154
|
-
this.config = config;
|
|
155
|
-
this.discreteFilters = discreteFilters;
|
|
156
|
-
}
|
|
157
|
-
getRequest(queryParamMap) {
|
|
158
|
-
const request = DAFF_PRODUCT_COLLECTION_REQUEST_FIELDS.reduce((acc, field) => {
|
|
159
|
-
const qp = this.config.params[field] || field;
|
|
160
|
-
if (queryParamMap.has(qp)) {
|
|
161
|
-
const qpVal = queryParamMap.get(qp);
|
|
162
|
-
// no idea why field needs to be typecasted
|
|
163
|
-
acc[field] = this.config.transforms?.[field]?.request?.(qpVal) || qpVal;
|
|
164
|
-
}
|
|
165
|
-
return acc;
|
|
166
|
-
}, {});
|
|
167
|
-
const filterRequests = this.discreteFilters.reduce((acc, { filterName, builder, queryParam }) => queryParamMap.has(queryParam)
|
|
168
|
-
? [
|
|
169
|
-
...acc,
|
|
170
|
-
builder(filterName, queryParamMap.getAll(queryParam)),
|
|
171
|
-
]
|
|
172
|
-
: acc, request.filterRequests || []);
|
|
173
|
-
// add discrete filter params to the list of requests
|
|
174
|
-
if (filterRequests.length > 0) {
|
|
175
|
-
request.filterRequests = filterRequests;
|
|
176
|
-
}
|
|
177
|
-
return request;
|
|
178
|
-
}
|
|
179
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGetCollectionRequestFromRoute, deps: [{ token: DAFF_PRODUCT_ROUTING_CONFIG }, { token: DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
180
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffProductGetCollectionRequestFromRoute }); }
|
|
160
|
+
return {
|
|
161
|
+
provide: DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS,
|
|
162
|
+
useValue: {
|
|
163
|
+
filterName,
|
|
164
|
+
queryParam: queryParam || filterName,
|
|
165
|
+
builder: builder || daffRoutingQueryParamFilterRequestEqualBuilder
|
|
166
|
+
},
|
|
167
|
+
multi: true
|
|
168
|
+
};
|
|
181
169
|
}
|
|
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
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
170
|
+
var DaffProductGetCollectionRequestFromRoute = class DaffProductGetCollectionRequestFromRoute {
|
|
171
|
+
constructor(config, discreteFilters) {
|
|
172
|
+
this.config = config;
|
|
173
|
+
this.discreteFilters = discreteFilters;
|
|
174
|
+
}
|
|
175
|
+
getRequest(queryParamMap) {
|
|
176
|
+
const request = DAFF_PRODUCT_COLLECTION_REQUEST_FIELDS.reduce((acc, field) => {
|
|
177
|
+
const qp = this.config.params[field] || field;
|
|
178
|
+
if (queryParamMap.has(qp)) {
|
|
179
|
+
const qpVal = queryParamMap.get(qp);
|
|
180
|
+
acc[field] = this.config.transforms?.[field]?.request?.(qpVal) || qpVal;
|
|
181
|
+
}
|
|
182
|
+
return acc;
|
|
183
|
+
}, {});
|
|
184
|
+
const filterRequests = this.discreteFilters.reduce((acc, { filterName, builder, queryParam }) => queryParamMap.has(queryParam) ? [...acc, builder(filterName, queryParamMap.getAll(queryParam))] : acc, request.filterRequests || []);
|
|
185
|
+
if (filterRequests.length > 0) request.filterRequests = filterRequests;
|
|
186
|
+
return request;
|
|
187
|
+
}
|
|
188
|
+
static {
|
|
189
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
190
|
+
minVersion: "12.0.0",
|
|
191
|
+
version: "22.2.4",
|
|
192
|
+
ngImport: i0,
|
|
193
|
+
type: DaffProductGetCollectionRequestFromRoute,
|
|
194
|
+
deps: [{ token: DAFF_PRODUCT_ROUTING_CONFIG }, { token: DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS }],
|
|
195
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
static {
|
|
199
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
200
|
+
minVersion: "12.0.0",
|
|
201
|
+
version: "22.2.4",
|
|
202
|
+
ngImport: i0,
|
|
203
|
+
type: DaffProductGetCollectionRequestFromRoute
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
208
|
+
minVersion: "12.0.0",
|
|
209
|
+
version: "22.2.4",
|
|
210
|
+
ngImport: i0,
|
|
211
|
+
type: DaffProductGetCollectionRequestFromRoute,
|
|
212
|
+
decorators: [{ type: Injectable }],
|
|
213
|
+
ctorParameters: () => [{
|
|
214
|
+
type: void 0,
|
|
215
|
+
decorators: [{
|
|
216
|
+
type: Inject,
|
|
217
|
+
args: [DAFF_PRODUCT_ROUTING_CONFIG]
|
|
218
|
+
}]
|
|
219
|
+
}, {
|
|
220
|
+
type: void 0,
|
|
221
|
+
decorators: [{
|
|
222
|
+
type: Inject,
|
|
223
|
+
args: [DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS]
|
|
224
|
+
}]
|
|
225
|
+
}]
|
|
226
|
+
});
|
|
227
|
+
var DaffProductGetQueryParamsFromRequest = class DaffProductGetQueryParamsFromRequest {
|
|
228
|
+
constructor(config, discreteFilters) {
|
|
229
|
+
this.config = config;
|
|
230
|
+
this.discreteFilters = discreteFilters;
|
|
231
|
+
}
|
|
232
|
+
getQueryParams(request) {
|
|
233
|
+
const filterRequests = daffArrayToDict(request.filterRequests, (fr) => fr.name);
|
|
234
|
+
const trimmedQueryParams = this.discreteFilters.reduce((acc, { filterName, queryParam }) => {
|
|
235
|
+
if (!filterRequests[filterName]) acc[queryParam] = void 0;
|
|
236
|
+
return acc;
|
|
237
|
+
}, {});
|
|
238
|
+
return DAFF_PRODUCT_COLLECTION_REQUEST_FIELDS.reduce((acc, field) => {
|
|
239
|
+
const val = request[field];
|
|
240
|
+
if (val) acc[this.config.params[field] || field] = this.config.transforms?.[field]?.queryParam?.(val) || String(val);
|
|
241
|
+
return acc;
|
|
242
|
+
}, trimmedQueryParams);
|
|
243
|
+
}
|
|
244
|
+
static {
|
|
245
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
246
|
+
minVersion: "12.0.0",
|
|
247
|
+
version: "22.2.4",
|
|
248
|
+
ngImport: i0,
|
|
249
|
+
type: DaffProductGetQueryParamsFromRequest,
|
|
250
|
+
deps: [{ token: DAFF_PRODUCT_ROUTING_CONFIG }, { token: DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS }],
|
|
251
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
static {
|
|
255
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
256
|
+
minVersion: "12.0.0",
|
|
257
|
+
version: "22.2.4",
|
|
258
|
+
ngImport: i0,
|
|
259
|
+
type: DaffProductGetQueryParamsFromRequest
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
264
|
+
minVersion: "12.0.0",
|
|
265
|
+
version: "22.2.4",
|
|
266
|
+
ngImport: i0,
|
|
267
|
+
type: DaffProductGetQueryParamsFromRequest,
|
|
268
|
+
decorators: [{ type: Injectable }],
|
|
269
|
+
ctorParameters: () => [{
|
|
270
|
+
type: void 0,
|
|
271
|
+
decorators: [{
|
|
272
|
+
type: Inject,
|
|
273
|
+
args: [DAFF_PRODUCT_ROUTING_CONFIG]
|
|
274
|
+
}]
|
|
275
|
+
}, {
|
|
276
|
+
type: void 0,
|
|
277
|
+
decorators: [{
|
|
278
|
+
type: Inject,
|
|
279
|
+
args: [DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS]
|
|
280
|
+
}]
|
|
281
|
+
}]
|
|
282
|
+
});
|
|
283
|
+
var DaffProductRoutingCollectionEffects = class {
|
|
284
|
+
constructor(actions$, router, actionTypes, facade, getQueryParams, route) {
|
|
285
|
+
this.actions$ = actions$;
|
|
286
|
+
this.router = router;
|
|
287
|
+
this.actionTypes = actionTypes;
|
|
288
|
+
this.facade = facade;
|
|
289
|
+
this.getQueryParams = getQueryParams;
|
|
290
|
+
this.route = route;
|
|
291
|
+
this.update$ = createEffect(() => this.actions$.pipe(ofType(...this.actionTypes), withLatestFrom(this.facade.metadata$), map(([action, metadata]) => [action, {
|
|
292
|
+
filterRequests: daffFiltersToRequests(metadata.filters),
|
|
293
|
+
appliedSortOption: metadata.appliedSortOption,
|
|
294
|
+
appliedSortDirection: metadata.appliedSortDirection,
|
|
295
|
+
currentPage: metadata.currentPage,
|
|
296
|
+
pageSize: metadata.pageSize
|
|
297
|
+
}]), tap(([action, request]) => this.router.navigate([], {
|
|
298
|
+
relativeTo: this.route,
|
|
299
|
+
queryParams: this.getQueryParams.getQueryParams(request),
|
|
300
|
+
queryParamsHandling: "merge"
|
|
301
|
+
})), switchMap(() => EMPTY)), { dispatch: false });
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
const provideDaffProductRouting = (config) => makeEnvironmentProviders([
|
|
305
|
+
DaffProductGetCollectionRequestFromRoute,
|
|
306
|
+
DaffProductGetQueryParamsFromRequest,
|
|
307
|
+
...config ? [provideDaffProductRoutingConfig(config)] : []
|
|
308
|
+
]);
|
|
309
|
+
var DaffProductRoutingModule = class DaffProductRoutingModule {
|
|
310
|
+
static withConfig(config) {
|
|
311
|
+
return {
|
|
312
|
+
ngModule: DaffProductRoutingModule,
|
|
313
|
+
providers: [provideDaffProductRoutingConfig(config)]
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
static {
|
|
317
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
318
|
+
minVersion: "12.0.0",
|
|
319
|
+
version: "22.2.4",
|
|
320
|
+
ngImport: i0,
|
|
321
|
+
type: DaffProductRoutingModule,
|
|
322
|
+
deps: [],
|
|
323
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
static {
|
|
327
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
328
|
+
minVersion: "14.0.0",
|
|
329
|
+
version: "22.2.4",
|
|
330
|
+
ngImport: i0,
|
|
331
|
+
type: DaffProductRoutingModule
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
static {
|
|
335
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
336
|
+
minVersion: "12.0.0",
|
|
337
|
+
version: "22.2.4",
|
|
338
|
+
ngImport: i0,
|
|
339
|
+
type: DaffProductRoutingModule,
|
|
340
|
+
providers: [provideDaffProductRouting()]
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
345
|
+
minVersion: "12.0.0",
|
|
346
|
+
version: "22.2.4",
|
|
347
|
+
ngImport: i0,
|
|
348
|
+
type: DaffProductRoutingModule,
|
|
349
|
+
decorators: [{
|
|
350
|
+
type: NgModule,
|
|
351
|
+
args: [{ providers: [provideDaffProductRouting()] }]
|
|
352
|
+
}]
|
|
353
|
+
});
|
|
354
|
+
export { DAFF_PRODUCT_COLLECTION_REQUEST_FIELDS, DAFF_PRODUCT_ROUTING_CONFIG, DAFF_PRODUCT_ROUTING_CONFIG_DEFAULT, DAFF_PRODUCT_ROUTING_DISCRETE_FILTER_PARAMS, DAFF_PRODUCT_ROUTING_QUERY_PARAM_REQUEST_MAP, DaffProductGetCollectionRequestFromRoute, DaffProductGetQueryParamsFromRequest, DaffProductPageIdResolver, DaffProductPageUrlResolver, DaffProductRoutingCollectionEffects, DaffProductRoutingModule, daffProductRoutingConfigDefaultFactory, daffProductRoutingProvideDiscreteFilterParam, provideDaffProductRouting, provideDaffProductRoutingConfig };
|
|
292
355
|
|
|
293
|
-
|
|
294
|
-
//# sourceMappingURL=daffodil-product-routing.mjs.map
|
|
356
|
+
//# sourceMappingURL=daffodil-product-routing.mjs.map
|