@daffodil/geography 0.94.1 → 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 (31) hide show
  1. package/fesm2022/daffodil-geography-driver-in-memory.mjs +161 -121
  2. package/fesm2022/daffodil-geography-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-geography-driver-magento-2.4.7.mjs +246 -0
  4. package/fesm2022/daffodil-geography-driver-magento-2.4.7.mjs.map +1 -0
  5. package/fesm2022/daffodil-geography-driver-magento-auto.mjs +7 -0
  6. package/fesm2022/daffodil-geography-driver-magento-auto.mjs.map +1 -0
  7. package/fesm2022/daffodil-geography-driver-testing.mjs +100 -61
  8. package/fesm2022/daffodil-geography-driver-testing.mjs.map +1 -1
  9. package/fesm2022/daffodil-geography-driver.mjs +18 -29
  10. package/fesm2022/daffodil-geography-driver.mjs.map +1 -1
  11. package/fesm2022/daffodil-geography-state-testing.mjs +98 -57
  12. package/fesm2022/daffodil-geography-state-testing.mjs.map +1 -1
  13. package/fesm2022/daffodil-geography-state.mjs +275 -275
  14. package/fesm2022/daffodil-geography-state.mjs.map +1 -1
  15. package/fesm2022/daffodil-geography-testing.mjs +190 -107
  16. package/fesm2022/daffodil-geography-testing.mjs.map +1 -1
  17. package/fesm2022/daffodil-geography.mjs +21 -43
  18. package/fesm2022/daffodil-geography.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/types/daffodil-geography-driver-in-memory.d.ts +51 -49
  21. package/types/daffodil-geography-driver-magento-2.4.7.d.ts +86 -0
  22. package/types/daffodil-geography-driver-magento-auto.d.ts +1 -0
  23. package/types/daffodil-geography-driver-testing.d.ts +28 -25
  24. package/types/daffodil-geography-driver.d.ts +22 -30
  25. package/types/daffodil-geography-state-testing.d.ts +33 -29
  26. package/types/daffodil-geography-state.d.ts +124 -139
  27. package/types/daffodil-geography-testing.d.ts +56 -63
  28. package/types/daffodil-geography.d.ts +37 -46
  29. package/fesm2022/daffodil-geography-driver-magento.mjs +0 -196
  30. package/fesm2022/daffodil-geography-driver-magento.mjs.map +0 -1
  31. package/types/daffodil-geography-driver-magento.d.ts +0 -95
@@ -1,297 +1,297 @@
1
- import * as i1 from '@ngrx/store';
2
- import { defaultMemoize, createFeatureSelector, createSelector, select, StoreModule } from '@ngrx/store';
3
- import { createEntityAdapter } from '@ngrx/entity';
4
- import { createSingleInjectionToken } from '@daffodil/core';
5
- import { daffTransformErrorToStateError } from '@daffodil/core/state';
6
- import * as i0 from '@angular/core';
7
- import { Injectable, Inject, NgModule } from '@angular/core';
8
- import * as i1$1 from '@ngrx/effects';
9
- import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
10
- import { of } from 'rxjs';
11
- import { switchMap, map, catchError } from 'rxjs/operators';
12
- import { DaffGeographyDriver } from '@daffodil/geography/driver';
13
-
14
- /**
15
- * Country Adapter for changing/overwriting entity state.
16
- */
1
+ import * as i1$1 from "@ngrx/store";
2
+ import { StoreModule, createFeatureSelector, createSelector, defaultMemoize, provideState, select } from "@ngrx/store";
3
+ import { createEntityAdapter } from "@ngrx/entity";
4
+ import { createSingleInjectionToken } from "@daffodil/core";
5
+ import { daffTransformErrorToStateError } from "@daffodil/core/state";
6
+ import * as i0 from "@angular/core";
7
+ import { Inject, Injectable, NgModule, makeEnvironmentProviders } from "@angular/core";
8
+ import * as i1 from "@ngrx/effects";
9
+ import { EffectsModule, createEffect, ofType, provideEffects } from "@ngrx/effects";
10
+ import { of } from "rxjs";
11
+ import { catchError, map, switchMap } from "rxjs/operators";
12
+ import { DaffGeographyDriver } from "@daffodil/geography/driver";
17
13
  const getCountryAdapter = (() => {
18
- let cache;
19
- return () => cache = cache || createEntityAdapter();
14
+ let cache;
15
+ return () => cache = cache || createEntityAdapter();
20
16
  })();
21
-
22
- /**
23
- * Initial state for country entity state.
24
- */
25
17
  const daffCountryEntitiesInitialState = getCountryAdapter().getInitialState();
26
-
27
18
  var DaffGeographyActionTypes;
28
- (function (DaffGeographyActionTypes) {
29
- DaffGeographyActionTypes["CountryLoadAction"] = "[@daffodil/geography] Country Load Action";
30
- DaffGeographyActionTypes["CountryLoadSuccessAction"] = "[@daffodil/geography] Country Load Success Action";
31
- DaffGeographyActionTypes["CountryLoadFailureAction"] = "[@daffodil/geography] Country Load Failure Action";
32
- DaffGeographyActionTypes["CountryListAction"] = "[@daffodil/geography] Country List Action";
33
- DaffGeographyActionTypes["CountryListSuccessAction"] = "[@daffodil/geography] Country List Success Action";
34
- DaffGeographyActionTypes["CountryListFailureAction"] = "[@daffodil/geography] Country List Failure Action";
19
+ (function(DaffGeographyActionTypes) {
20
+ DaffGeographyActionTypes["CountryLoadAction"] = "[@daffodil/geography] Country Load Action";
21
+ DaffGeographyActionTypes["CountryLoadSuccessAction"] = "[@daffodil/geography] Country Load Success Action";
22
+ DaffGeographyActionTypes["CountryLoadFailureAction"] = "[@daffodil/geography] Country Load Failure Action";
23
+ DaffGeographyActionTypes["CountryListAction"] = "[@daffodil/geography] Country List Action";
24
+ DaffGeographyActionTypes["CountryListSuccessAction"] = "[@daffodil/geography] Country List Success Action";
25
+ DaffGeographyActionTypes["CountryListFailureAction"] = "[@daffodil/geography] Country List Failure Action";
35
26
  })(DaffGeographyActionTypes || (DaffGeographyActionTypes = {}));
36
- class DaffCountryLoad {
37
- constructor(payload) {
38
- this.payload = payload;
39
- this.type = DaffGeographyActionTypes.CountryLoadAction;
40
- }
41
- }
42
- class DaffCountryLoadSuccess {
43
- constructor(payload) {
44
- this.payload = payload;
45
- this.type = DaffGeographyActionTypes.CountryLoadSuccessAction;
46
- }
47
- }
48
- class DaffCountryLoadFailure {
49
- constructor(payload) {
50
- this.payload = payload;
51
- this.type = DaffGeographyActionTypes.CountryLoadFailureAction;
52
- }
53
- }
54
- class DaffCountryList {
55
- constructor() {
56
- this.type = DaffGeographyActionTypes.CountryListAction;
57
- }
58
- }
59
- class DaffCountryListSuccess {
60
- constructor(payload) {
61
- this.payload = payload;
62
- this.type = DaffGeographyActionTypes.CountryListSuccessAction;
63
- }
64
- }
65
- class DaffCountryListFailure {
66
- constructor(payload) {
67
- this.payload = payload;
68
- this.type = DaffGeographyActionTypes.CountryListFailureAction;
69
- }
70
- }
71
-
72
- /**
73
- * Reducer function that catches actions and changes/overwrites country entities state.
74
- */
27
+ var DaffCountryLoad = class {
28
+ constructor(payload) {
29
+ this.payload = payload;
30
+ this.type = DaffGeographyActionTypes.CountryLoadAction;
31
+ }
32
+ };
33
+ var DaffCountryLoadSuccess = class {
34
+ constructor(payload) {
35
+ this.payload = payload;
36
+ this.type = DaffGeographyActionTypes.CountryLoadSuccessAction;
37
+ }
38
+ };
39
+ var DaffCountryLoadFailure = class {
40
+ constructor(payload) {
41
+ this.payload = payload;
42
+ this.type = DaffGeographyActionTypes.CountryLoadFailureAction;
43
+ }
44
+ };
45
+ var DaffCountryList = class {
46
+ constructor() {
47
+ this.type = DaffGeographyActionTypes.CountryListAction;
48
+ }
49
+ };
50
+ var DaffCountryListSuccess = class {
51
+ constructor(payload) {
52
+ this.payload = payload;
53
+ this.type = DaffGeographyActionTypes.CountryListSuccessAction;
54
+ }
55
+ };
56
+ var DaffCountryListFailure = class {
57
+ constructor(payload) {
58
+ this.payload = payload;
59
+ this.type = DaffGeographyActionTypes.CountryListFailureAction;
60
+ }
61
+ };
75
62
  function daffCountryEntitiesReducer(state = daffCountryEntitiesInitialState, action) {
76
- const adapter = getCountryAdapter();
77
- switch (action.type) {
78
- case DaffGeographyActionTypes.CountryLoadSuccessAction:
79
- return adapter.upsertOne({
80
- ...action.payload,
81
- loaded: true,
82
- }, state);
83
- case DaffGeographyActionTypes.CountryListSuccessAction:
84
- return adapter.upsertMany(action.payload.map(country => ({
85
- ...country,
86
- // defer to the loaded state of the country already in state (if it exists) but init field to false if it does not
87
- loaded: (state.entities[country.id] && state.entities[country.id].loaded) || false,
88
- // if the country coming in has no subdivisions and the same country in state does, use the subdivisions in state
89
- subdivisions: country.subdivisions.length === 0 && state.entities[country.id] && state.entities[country.id].subdivisions.length > 0
90
- ? state.entities[country.id].subdivisions
91
- : country.subdivisions,
92
- })), state);
93
- default:
94
- return state;
95
- }
63
+ const adapter = getCountryAdapter();
64
+ switch (action.type) {
65
+ case DaffGeographyActionTypes.CountryLoadSuccessAction: return adapter.upsertOne({
66
+ ...action.payload,
67
+ loaded: true
68
+ }, state);
69
+ case DaffGeographyActionTypes.CountryListSuccessAction: return adapter.upsertMany(action.payload.map((country) => ({
70
+ ...country,
71
+ loaded: state.entities[country.id] && state.entities[country.id].loaded || false,
72
+ subdivisions: country.subdivisions.length === 0 && state.entities[country.id] && state.entities[country.id].subdivisions.length > 0 ? state.entities[country.id].subdivisions : country.subdivisions
73
+ })), state);
74
+ default: return state;
75
+ }
96
76
  }
97
-
98
77
  const daffGeographyInitialState = {
99
- loading: false,
100
- errors: [],
78
+ loading: false,
79
+ errors: []
101
80
  };
102
-
103
81
  function daffGeographyReducer(state = daffGeographyInitialState, action) {
104
- switch (action.type) {
105
- case DaffGeographyActionTypes.CountryLoadAction:
106
- case DaffGeographyActionTypes.CountryListAction:
107
- return { ...state, loading: true };
108
- case DaffGeographyActionTypes.CountryLoadSuccessAction:
109
- case DaffGeographyActionTypes.CountryListSuccessAction:
110
- return {
111
- ...state,
112
- errors: [],
113
- loading: false,
114
- };
115
- case DaffGeographyActionTypes.CountryLoadFailureAction:
116
- case DaffGeographyActionTypes.CountryListFailureAction:
117
- return {
118
- ...state,
119
- errors: [
120
- ...state.errors,
121
- action.payload,
122
- ],
123
- loading: false,
124
- };
125
- default:
126
- return state;
127
- }
82
+ switch (action.type) {
83
+ case DaffGeographyActionTypes.CountryLoadAction:
84
+ case DaffGeographyActionTypes.CountryListAction: return {
85
+ ...state,
86
+ loading: true
87
+ };
88
+ case DaffGeographyActionTypes.CountryLoadSuccessAction:
89
+ case DaffGeographyActionTypes.CountryListSuccessAction: return {
90
+ ...state,
91
+ errors: [],
92
+ loading: false
93
+ };
94
+ case DaffGeographyActionTypes.CountryLoadFailureAction:
95
+ case DaffGeographyActionTypes.CountryListFailureAction: return {
96
+ ...state,
97
+ errors: [...state.errors, action.payload],
98
+ loading: false
99
+ };
100
+ default: return state;
101
+ }
128
102
  }
129
-
130
103
  const daffGeographyReducers = {
131
- geography: daffGeographyReducer,
132
- countries: daffCountryEntitiesReducer,
104
+ geography: daffGeographyReducer,
105
+ countries: daffCountryEntitiesReducer
133
106
  };
134
-
135
- const DAFF_GEOGRAPHY_STORE_FEATURE_KEY = 'daffGeography';
136
-
137
- const getDaffGeographyFeatureStateSelector = defaultMemoize(() => ({
138
- selectGeographyFeatureState: createFeatureSelector(DAFF_GEOGRAPHY_STORE_FEATURE_KEY),
139
- })).memoized;
140
-
107
+ const DAFF_GEOGRAPHY_STORE_FEATURE_KEY = "daffGeography";
108
+ const getDaffGeographyFeatureStateSelector = defaultMemoize(() => ({ selectGeographyFeatureState: createFeatureSelector(DAFF_GEOGRAPHY_STORE_FEATURE_KEY) })).memoized;
141
109
  const createCountryEntitySelectors = () => {
142
- const { selectGeographyFeatureState } = getDaffGeographyFeatureStateSelector();
143
- const selectCountryEntitiesState = createSelector(selectGeographyFeatureState, state => state.countries);
144
- const { selectIds, selectEntities, selectAll, selectTotal } = getCountryAdapter().getSelectors(selectCountryEntitiesState);
145
- const selectCountry = defaultMemoize((countryId) => createSelector(selectEntities, (countries) => countries[countryId])).memoized;
146
- const selectCountrySubdivisions = defaultMemoize((countryId) => createSelector(selectCountry(countryId), (country) => country?.subdivisions || [])).memoized;
147
- const selectIsCountryFullyLoaded = defaultMemoize((countryId) => createSelector(selectCountry(countryId), (country) => country?.loaded)).memoized;
148
- return {
149
- selectCountryEntitiesState,
150
- /**
151
- * Selector for country IDs.
152
- */
153
- selectCountryIds: selectIds,
154
- /**
155
- * Selector for country entities.
156
- */
157
- selectCountryEntities: selectEntities,
158
- /**
159
- * Selector for all countries.
160
- */
161
- selectAllCountries: selectAll,
162
- /**
163
- * Selector for total number of countries.
164
- */
165
- selectCountryTotal: selectTotal,
166
- /**
167
- * Selector for a specific country.
168
- */
169
- selectCountry,
170
- /**
171
- * Selector for a specific country's subdivisions.
172
- */
173
- selectCountrySubdivisions,
174
- /**
175
- * Selector for checking if a country has been fully loaded.
176
- * If true, then a country's subdivisions will be populated if any exist.
177
- */
178
- selectIsCountryFullyLoaded,
179
- };
110
+ const { selectGeographyFeatureState } = getDaffGeographyFeatureStateSelector();
111
+ const selectCountryEntitiesState = createSelector(selectGeographyFeatureState, (state) => state.countries);
112
+ const { selectIds, selectEntities, selectAll, selectTotal } = getCountryAdapter().getSelectors(selectCountryEntitiesState);
113
+ const selectCountry = defaultMemoize((countryId) => createSelector(selectEntities, (countries) => countries[countryId])).memoized;
114
+ return {
115
+ selectCountryEntitiesState,
116
+ selectCountryIds: selectIds,
117
+ selectCountryEntities: selectEntities,
118
+ selectAllCountries: selectAll,
119
+ selectCountryTotal: selectTotal,
120
+ selectCountry,
121
+ selectCountrySubdivisions: defaultMemoize((countryId) => createSelector(selectCountry(countryId), (country) => country?.subdivisions || [])).memoized,
122
+ selectIsCountryFullyLoaded: defaultMemoize((countryId) => createSelector(selectCountry(countryId), (country) => country?.loaded)).memoized
123
+ };
180
124
  };
181
125
  const getDaffCountryEntitySelectors = defaultMemoize(() => createCountryEntitySelectors()).memoized;
182
-
183
126
  const createGeographySelectors = () => {
184
- const { selectGeographyFeatureState } = getDaffGeographyFeatureStateSelector();
185
- const selectGeographyState = createSelector(selectGeographyFeatureState, state => state.geography);
186
- const selectGeographyLoading = createSelector(selectGeographyState, state => state.loading);
187
- const selectGeographyErrors = createSelector(selectGeographyState, state => state.errors);
188
- return {
189
- selectGeographyState,
190
- selectGeographyLoading,
191
- selectGeographyErrors,
192
- };
127
+ const { selectGeographyFeatureState } = getDaffGeographyFeatureStateSelector();
128
+ const selectGeographyState = createSelector(selectGeographyFeatureState, (state) => state.geography);
129
+ return {
130
+ selectGeographyState,
131
+ selectGeographyLoading: createSelector(selectGeographyState, (state) => state.loading),
132
+ selectGeographyErrors: createSelector(selectGeographyState, (state) => state.errors)
133
+ };
193
134
  };
194
135
  const getGeographySelectors = defaultMemoize(() => createGeographySelectors()).memoized;
195
-
196
136
  const getDaffGeographySelectors = defaultMemoize(() => ({
197
- ...getGeographySelectors(),
198
- ...getDaffCountryEntitySelectors(),
199
- ...getDaffGeographyFeatureStateSelector(),
137
+ ...getGeographySelectors(),
138
+ ...getDaffCountryEntitySelectors(),
139
+ ...getDaffGeographyFeatureStateSelector()
200
140
  })).memoized;
141
+ const { token: DAFF_GEOGRAPHY_ERROR_MATCHER, provider: provideDaffGeographyErrorMatcher } = createSingleInjectionToken("DAFF_GEOGRAPHY_ERROR_MATCHER", { factory: () => daffTransformErrorToStateError });
142
+ var DaffGeographyFacade = class DaffGeographyFacade {
143
+ constructor(store) {
144
+ this.store = store;
145
+ const { selectCountryIds, selectCountryEntities, selectAllCountries, selectCountryTotal, selectGeographyLoading, selectGeographyErrors, selectCountry, selectCountrySubdivisions, selectIsCountryFullyLoaded } = getDaffGeographySelectors();
146
+ this._selectCountry = selectCountry;
147
+ this._selectCountrySubdivisions = selectCountrySubdivisions;
148
+ this._selectIsCountryFullyLoaded = selectIsCountryFullyLoaded;
149
+ this.loading$ = this.store.pipe(select(selectGeographyLoading));
150
+ this.errors$ = this.store.pipe(select(selectGeographyErrors));
151
+ this.countries$ = this.store.pipe(select(selectAllCountries));
152
+ this.countryIds$ = this.store.pipe(select(selectCountryIds));
153
+ this.countryCount$ = this.store.pipe(select(selectCountryTotal));
154
+ this.countryEntities$ = this.store.pipe(select(selectCountryEntities));
155
+ }
156
+ getCountry(id) {
157
+ return this.store.pipe(select(this._selectCountry(id)));
158
+ }
159
+ getCountrySubdivisions(id) {
160
+ return this.store.pipe(select(this._selectCountrySubdivisions(id)));
161
+ }
162
+ isCountryFullyLoaded(id) {
163
+ return this.store.pipe(select(this._selectIsCountryFullyLoaded(id)));
164
+ }
165
+ dispatch(action) {
166
+ this.store.dispatch(action);
167
+ }
168
+ static {
169
+ this.ɵfac = i0.ɵɵngDeclareFactory({
170
+ minVersion: "12.0.0",
171
+ version: "22.2.4",
172
+ ngImport: i0,
173
+ type: DaffGeographyFacade,
174
+ deps: [{ token: i1$1.Store }],
175
+ target: i0.ɵɵFactoryTarget.Injectable
176
+ });
177
+ }
178
+ static {
179
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
180
+ minVersion: "12.0.0",
181
+ version: "22.2.4",
182
+ ngImport: i0,
183
+ type: DaffGeographyFacade,
184
+ providedIn: "root"
185
+ });
186
+ }
187
+ };
188
+ i0.ɵɵngDeclareClassMetadata({
189
+ minVersion: "12.0.0",
190
+ version: "22.2.4",
191
+ ngImport: i0,
192
+ type: DaffGeographyFacade,
193
+ decorators: [{
194
+ type: Injectable,
195
+ args: [{ providedIn: "root" }]
196
+ }],
197
+ ctorParameters: () => [{ type: i1$1.Store }]
198
+ });
199
+ var DaffGeographyEffects = class DaffGeographyEffects {
200
+ constructor(actions$, driver, errorMatcher) {
201
+ this.actions$ = actions$;
202
+ this.driver = driver;
203
+ this.errorMatcher = errorMatcher;
204
+ this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffGeographyActionTypes.CountryLoadAction), switchMap((action) => this.driver.get(action.payload).pipe(map((resp) => new DaffCountryLoadSuccess(resp)), catchError((error) => of(new DaffCountryLoadFailure(this.errorMatcher(error))))))));
205
+ this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffGeographyActionTypes.CountryListAction), switchMap((action) => this.driver.list().pipe(map((resp) => new DaffCountryListSuccess(resp)), catchError((error) => of(new DaffCountryListFailure(this.errorMatcher(error))))))));
206
+ }
207
+ static {
208
+ this.ɵfac = i0.ɵɵngDeclareFactory({
209
+ minVersion: "12.0.0",
210
+ version: "22.2.4",
211
+ ngImport: i0,
212
+ type: DaffGeographyEffects,
213
+ deps: [
214
+ { token: i1.Actions },
215
+ { token: DaffGeographyDriver },
216
+ { token: DAFF_GEOGRAPHY_ERROR_MATCHER }
217
+ ],
218
+ target: i0.ɵɵFactoryTarget.Injectable
219
+ });
220
+ }
221
+ static {
222
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
223
+ minVersion: "12.0.0",
224
+ version: "22.2.4",
225
+ ngImport: i0,
226
+ type: DaffGeographyEffects
227
+ });
228
+ }
229
+ };
230
+ i0.ɵɵngDeclareClassMetadata({
231
+ minVersion: "12.0.0",
232
+ version: "22.2.4",
233
+ ngImport: i0,
234
+ type: DaffGeographyEffects,
235
+ decorators: [{ type: Injectable }],
236
+ ctorParameters: () => [
237
+ { type: i1.Actions },
238
+ {
239
+ type: void 0,
240
+ decorators: [{
241
+ type: Inject,
242
+ args: [DaffGeographyDriver]
243
+ }]
244
+ },
245
+ {
246
+ type: void 0,
247
+ decorators: [{
248
+ type: Inject,
249
+ args: [DAFF_GEOGRAPHY_ERROR_MATCHER]
250
+ }]
251
+ }
252
+ ]
253
+ });
254
+ var DaffGeographyStateModule = class DaffGeographyStateModule {
255
+ static {
256
+ this.ɵfac = i0.ɵɵngDeclareFactory({
257
+ minVersion: "12.0.0",
258
+ version: "22.2.4",
259
+ ngImport: i0,
260
+ type: DaffGeographyStateModule,
261
+ deps: [],
262
+ target: i0.ɵɵFactoryTarget.NgModule
263
+ });
264
+ }
265
+ static {
266
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
267
+ minVersion: "14.0.0",
268
+ version: "22.2.4",
269
+ ngImport: i0,
270
+ type: DaffGeographyStateModule,
271
+ imports: [i1$1.StoreFeatureModule, i1.EffectsFeatureModule]
272
+ });
273
+ }
274
+ static {
275
+ this.ɵinj = i0.ɵɵngDeclareInjector({
276
+ minVersion: "12.0.0",
277
+ version: "22.2.4",
278
+ ngImport: i0,
279
+ type: DaffGeographyStateModule,
280
+ imports: [StoreModule.forFeature(DAFF_GEOGRAPHY_STORE_FEATURE_KEY, daffGeographyReducers), EffectsModule.forFeature([DaffGeographyEffects])]
281
+ });
282
+ }
283
+ };
284
+ i0.ɵɵngDeclareClassMetadata({
285
+ minVersion: "12.0.0",
286
+ version: "22.2.4",
287
+ ngImport: i0,
288
+ type: DaffGeographyStateModule,
289
+ decorators: [{
290
+ type: NgModule,
291
+ args: [{ imports: [StoreModule.forFeature(DAFF_GEOGRAPHY_STORE_FEATURE_KEY, daffGeographyReducers), EffectsModule.forFeature([DaffGeographyEffects])] }]
292
+ }]
293
+ });
294
+ const provideDaffGeographyState = () => makeEnvironmentProviders([provideState(DAFF_GEOGRAPHY_STORE_FEATURE_KEY, daffGeographyReducers), provideEffects(DaffGeographyEffects)]);
295
+ export { DAFF_GEOGRAPHY_ERROR_MATCHER, DAFF_GEOGRAPHY_STORE_FEATURE_KEY, DaffCountryList, DaffCountryListFailure, DaffCountryListSuccess, DaffCountryLoad, DaffCountryLoadFailure, DaffCountryLoadSuccess, DaffGeographyActionTypes, DaffGeographyFacade, DaffGeographyStateModule, daffCountryEntitiesInitialState, daffCountryEntitiesReducer, daffGeographyInitialState, daffGeographyReducer, daffGeographyReducers, getCountryAdapter, getDaffGeographySelectors, provideDaffGeographyErrorMatcher, provideDaffGeographyState };
201
296
 
202
- /**
203
- * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
204
- * Can be used to further refine Daffodil errors into more specific app errors.
205
- */
206
- const { token: DAFF_GEOGRAPHY_ERROR_MATCHER,
207
- /**
208
- * Provider function for {@link DAFF_GEOGRAPHY_ERROR_MATCHER}.
209
- */
210
- provider: provideDaffGeographyErrorMatcher, } = createSingleInjectionToken('DAFF_GEOGRAPHY_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
211
-
212
- /**
213
- * @inheritdoc
214
- */
215
- class DaffGeographyFacade {
216
- constructor(store) {
217
- this.store = store;
218
- const { selectCountryIds, selectCountryEntities, selectAllCountries, selectCountryTotal, selectGeographyLoading, selectGeographyErrors, selectCountry, selectCountrySubdivisions, selectIsCountryFullyLoaded, } = getDaffGeographySelectors();
219
- this._selectCountry = selectCountry;
220
- this._selectCountrySubdivisions = selectCountrySubdivisions;
221
- this._selectIsCountryFullyLoaded = selectIsCountryFullyLoaded;
222
- this.loading$ = this.store.pipe(select(selectGeographyLoading));
223
- this.errors$ = this.store.pipe(select(selectGeographyErrors));
224
- this.countries$ = this.store.pipe(select(selectAllCountries));
225
- this.countryIds$ = this.store.pipe(select(selectCountryIds));
226
- this.countryCount$ = this.store.pipe(select(selectCountryTotal));
227
- this.countryEntities$ = this.store.pipe(select(selectCountryEntities));
228
- }
229
- getCountry(id) {
230
- return this.store.pipe(select(this._selectCountry(id)));
231
- }
232
- getCountrySubdivisions(id) {
233
- return this.store.pipe(select(this._selectCountrySubdivisions(id)));
234
- }
235
- isCountryFullyLoaded(id) {
236
- return this.store.pipe(select(this._selectIsCountryFullyLoaded(id)));
237
- }
238
- dispatch(action) {
239
- this.store.dispatch(action);
240
- }
241
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
242
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyFacade, providedIn: 'root' }); }
243
- }
244
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyFacade, decorators: [{
245
- type: Injectable,
246
- args: [{
247
- providedIn: 'root',
248
- }]
249
- }], ctorParameters: () => [{ type: i1.Store }] });
250
-
251
- class DaffGeographyEffects {
252
- constructor(actions$, driver, errorMatcher) {
253
- this.actions$ = actions$;
254
- this.driver = driver;
255
- this.errorMatcher = errorMatcher;
256
- this.get$ = createEffect(() => this.actions$.pipe(ofType(DaffGeographyActionTypes.CountryLoadAction), switchMap((action) => this.driver.get(action.payload).pipe(map(resp => new DaffCountryLoadSuccess(resp)), catchError((error) => of(new DaffCountryLoadFailure(this.errorMatcher(error))))))));
257
- this.list$ = createEffect(() => this.actions$.pipe(ofType(DaffGeographyActionTypes.CountryListAction), switchMap((action) => this.driver.list().pipe(map(resp => new DaffCountryListSuccess(resp)), catchError((error) => of(new DaffCountryListFailure(this.errorMatcher(error))))))));
258
- }
259
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyEffects, deps: [{ token: i1$1.Actions }, { token: DaffGeographyDriver }, { token: DAFF_GEOGRAPHY_ERROR_MATCHER }], target: i0.ɵɵFactoryTarget.Injectable }); }
260
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyEffects }); }
261
- }
262
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyEffects, decorators: [{
263
- type: Injectable
264
- }], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
265
- type: Inject,
266
- args: [DaffGeographyDriver]
267
- }] }, { type: undefined, decorators: [{
268
- type: Inject,
269
- args: [DAFF_GEOGRAPHY_ERROR_MATCHER]
270
- }] }] });
271
-
272
- class DaffGeographyStateModule {
273
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
274
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyStateModule, imports: [i1.StoreFeatureModule, i1$1.EffectsFeatureModule] }); }
275
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyStateModule, imports: [StoreModule.forFeature(DAFF_GEOGRAPHY_STORE_FEATURE_KEY, daffGeographyReducers),
276
- EffectsModule.forFeature([
277
- DaffGeographyEffects,
278
- ])] }); }
279
- }
280
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffGeographyStateModule, decorators: [{
281
- type: NgModule,
282
- args: [{
283
- imports: [
284
- StoreModule.forFeature(DAFF_GEOGRAPHY_STORE_FEATURE_KEY, daffGeographyReducers),
285
- EffectsModule.forFeature([
286
- DaffGeographyEffects,
287
- ]),
288
- ],
289
- }]
290
- }] });
291
-
292
- /**
293
- * Generated bundle index. Do not edit.
294
- */
295
-
296
- export { DAFF_GEOGRAPHY_ERROR_MATCHER, DAFF_GEOGRAPHY_STORE_FEATURE_KEY, DaffCountryList, DaffCountryListFailure, DaffCountryListSuccess, DaffCountryLoad, DaffCountryLoadFailure, DaffCountryLoadSuccess, DaffGeographyActionTypes, DaffGeographyFacade, DaffGeographyStateModule, daffCountryEntitiesInitialState, daffCountryEntitiesReducer, daffGeographyInitialState, daffGeographyReducer, daffGeographyReducers, getCountryAdapter, getDaffGeographySelectors, provideDaffGeographyErrorMatcher };
297
- //# sourceMappingURL=daffodil-geography-state.mjs.map
297
+ //# sourceMappingURL=daffodil-geography-state.mjs.map