@nrwl/angular 14.5.0-beta.1 → 14.5.0-beta.4
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/CHANGELOG.md +1 -1
- package/esm2020/src/runtime/nx/data-persistence.mjs +260 -184
- package/esm2020/src/runtime/nx/nx.module.mjs +7 -5
- package/fesm2015/nrwl-angular.mjs +265 -187
- package/fesm2015/nrwl-angular.mjs.map +1 -1
- package/fesm2020/nrwl-angular.mjs +265 -187
- package/fesm2020/nrwl-angular.mjs.map +1 -1
- package/generators.json +2 -2
- package/migrations.json +41 -0
- package/package.json +11 -12
- package/src/executors/file-server/file-server.impl.js +14 -6
- package/src/executors/file-server/file-server.impl.js.map +1 -1
- package/src/executors/file-server/schema.d.ts +1 -0
- package/src/executors/file-server/schema.json +5 -0
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js +19 -1
- package/src/executors/ng-packagr-lite/ng-packagr-adjustments/ng-package/entry-point/write-package.transform.js.map +1 -1
- package/src/executors/package/package.impl.js +1 -1
- package/src/executors/package/package.impl.js.map +1 -1
- package/src/generators/application/schema.json +1 -1
- package/src/generators/convert-to-with-mf/schema.json +1 -1
- package/src/generators/init/init.js +7 -7
- package/src/generators/init/init.js.map +1 -1
- package/src/generators/karma/karma.js +10 -9
- package/src/generators/karma/karma.js.map +1 -1
- package/src/generators/ngrx/schema.d.ts +9 -1
- package/src/generators/ngrx/schema.json +4 -2
- package/src/generators/utils/dependencies.js +3 -3
- package/src/generators/utils/dependencies.js.map +1 -1
- package/src/runtime/nx/data-persistence.d.ts +256 -192
- package/src/runtime/nx/data-persistence.js +256 -180
- package/src/runtime/nx/data-persistence.js.map +1 -1
- package/src/runtime/nx/nx.module.d.ts +2 -0
- package/src/runtime/nx/nx.module.js +2 -0
- package/src/runtime/nx/nx.module.js.map +1 -1
- package/src/utils/mf/with-module-federation.js +4 -1
- package/src/utils/mf/with-module-federation.js.map +1 -1
- package/src/utils/test-runners.d.ts +4 -0
- package/src/utils/versions.d.ts +21 -5
- package/src/utils/versions.js +22 -6
- package/src/utils/versions.js.map +1 -1
|
@@ -7,16 +7,209 @@ import { isObservable, of } from 'rxjs';
|
|
|
7
7
|
import { map, concatMap, catchError, groupBy, mergeMap, switchMap, filter, withLatestFrom } from 'rxjs/operators';
|
|
8
8
|
import * as i1 from '@ngrx/store';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @whatItDoes Handles pessimistic updates (updating the server first).
|
|
13
|
+
*
|
|
14
|
+
* Updating the server, when implemented naively, suffers from race conditions and poor error handling.
|
|
15
|
+
*
|
|
16
|
+
* `pessimisticUpdate` addresses these problems. It runs all fetches in order, which removes race conditions
|
|
17
|
+
* and forces the developer to handle errors.
|
|
18
|
+
*
|
|
19
|
+
* ## Example:
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* @Injectable()
|
|
23
|
+
* class TodoEffects {
|
|
24
|
+
* updateTodo$ = createEffect(() =>
|
|
25
|
+
* this.actions$.pipe(
|
|
26
|
+
* ofType('UPDATE_TODO'),
|
|
27
|
+
* pessimisticUpdate({
|
|
28
|
+
* // provides an action
|
|
29
|
+
* run: (action: UpdateTodo) => {
|
|
30
|
+
* // update the backend first, and then dispatch an action that will
|
|
31
|
+
* // update the client side
|
|
32
|
+
* return this.backend.updateTodo(action.todo.id, action.todo).pipe(
|
|
33
|
+
* map((updated) => ({
|
|
34
|
+
* type: 'UPDATE_TODO_SUCCESS',
|
|
35
|
+
* todo: updated,
|
|
36
|
+
* }))
|
|
37
|
+
* );
|
|
38
|
+
* },
|
|
39
|
+
* onError: (action: UpdateTodo, error: any) => {
|
|
40
|
+
* // we don't need to undo the changes on the client side.
|
|
41
|
+
* // we can dispatch an error, or simply log the error here and return `null`
|
|
42
|
+
* return null;
|
|
43
|
+
* },
|
|
44
|
+
* })
|
|
45
|
+
* )
|
|
46
|
+
* );
|
|
47
|
+
*
|
|
48
|
+
* constructor(private actions$: Actions, private backend: Backend) {}
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* Note that if you don't return a new action from the run callback, you must set the dispatch property
|
|
53
|
+
* of the effect to false, like this:
|
|
54
|
+
*
|
|
55
|
+
* ```typescript
|
|
56
|
+
* class TodoEffects {
|
|
57
|
+
* updateTodo$ = createEffect(() =>
|
|
58
|
+
* this.actions$.pipe(
|
|
59
|
+
* //...
|
|
60
|
+
* ), { dispatch: false }
|
|
61
|
+
* );
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* @param opts
|
|
66
|
+
*/
|
|
10
67
|
function pessimisticUpdate(opts) {
|
|
11
68
|
return (source) => {
|
|
12
69
|
return source.pipe(mapActionAndState(), concatMap(runWithErrorHandling(opts.run, opts.onError)));
|
|
13
70
|
};
|
|
14
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
*
|
|
74
|
+
* @whatItDoes Handles optimistic updates (updating the client first).
|
|
75
|
+
*
|
|
76
|
+
* It runs all fetches in order, which removes race conditions and forces the developer to handle errors.
|
|
77
|
+
*
|
|
78
|
+
* When using `optimisticUpdate`, in case of a failure, the developer has already updated the state locally,
|
|
79
|
+
* so the developer must provide an undo action.
|
|
80
|
+
*
|
|
81
|
+
* The error handling must be done in the callback, or by means of the undo action.
|
|
82
|
+
*
|
|
83
|
+
* ## Example:
|
|
84
|
+
*
|
|
85
|
+
* ```typescript
|
|
86
|
+
* @Injectable()
|
|
87
|
+
* class TodoEffects {
|
|
88
|
+
* updateTodo$ = createEffect(() =>
|
|
89
|
+
* this.actions$.pipe(
|
|
90
|
+
* ofType('UPDATE_TODO'),
|
|
91
|
+
* optimisticUpdate({
|
|
92
|
+
* // provides an action
|
|
93
|
+
* run: (action: UpdateTodo) => {
|
|
94
|
+
* return this.backend.updateTodo(action.todo.id, action.todo).pipe(
|
|
95
|
+
* mapTo({
|
|
96
|
+
* type: 'UPDATE_TODO_SUCCESS',
|
|
97
|
+
* })
|
|
98
|
+
* );
|
|
99
|
+
* },
|
|
100
|
+
* undoAction: (action: UpdateTodo, error: any) => {
|
|
101
|
+
* // dispatch an undo action to undo the changes in the client state
|
|
102
|
+
* return {
|
|
103
|
+
* type: 'UNDO_TODO_UPDATE',
|
|
104
|
+
* todo: action.todo,
|
|
105
|
+
* };
|
|
106
|
+
* },
|
|
107
|
+
* })
|
|
108
|
+
* )
|
|
109
|
+
* );
|
|
110
|
+
*
|
|
111
|
+
* constructor(private actions$: Actions, private backend: Backend) {}
|
|
112
|
+
* }
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* Note that if you don't return a new action from the run callback, you must set the dispatch property
|
|
116
|
+
* of the effect to false, like this:
|
|
117
|
+
*
|
|
118
|
+
* ```typescript
|
|
119
|
+
* class TodoEffects {
|
|
120
|
+
* updateTodo$ = createEffect(() =>
|
|
121
|
+
* this.actions$.pipe(
|
|
122
|
+
* //...
|
|
123
|
+
* ), { dispatch: false }
|
|
124
|
+
* );
|
|
125
|
+
* }
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @param opts
|
|
129
|
+
*/
|
|
15
130
|
function optimisticUpdate(opts) {
|
|
16
131
|
return (source) => {
|
|
17
132
|
return source.pipe(mapActionAndState(), concatMap(runWithErrorHandling(opts.run, opts.undoAction)));
|
|
18
133
|
};
|
|
19
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
*
|
|
137
|
+
* @whatItDoes Handles data fetching.
|
|
138
|
+
*
|
|
139
|
+
* Data fetching implemented naively suffers from race conditions and poor error handling.
|
|
140
|
+
*
|
|
141
|
+
* `fetch` addresses these problems. It runs all fetches in order, which removes race conditions
|
|
142
|
+
* and forces the developer to handle errors.
|
|
143
|
+
*
|
|
144
|
+
* ## Example:
|
|
145
|
+
*
|
|
146
|
+
* ```typescript
|
|
147
|
+
* @Injectable()
|
|
148
|
+
* class TodoEffects {
|
|
149
|
+
* loadTodos$ = createEffect(() =>
|
|
150
|
+
* this.actions$.pipe(
|
|
151
|
+
* ofType('GET_TODOS'),
|
|
152
|
+
* fetch({
|
|
153
|
+
* // provides an action
|
|
154
|
+
* run: (a: GetTodos) => {
|
|
155
|
+
* return this.backend.getAll().pipe(
|
|
156
|
+
* map((response) => ({
|
|
157
|
+
* type: 'TODOS',
|
|
158
|
+
* todos: response.todos,
|
|
159
|
+
* }))
|
|
160
|
+
* );
|
|
161
|
+
* },
|
|
162
|
+
* onError: (action: GetTodos, error: any) => {
|
|
163
|
+
* // dispatch an undo action to undo the changes in the client state
|
|
164
|
+
* return null;
|
|
165
|
+
* },
|
|
166
|
+
* })
|
|
167
|
+
* )
|
|
168
|
+
* );
|
|
169
|
+
*
|
|
170
|
+
* constructor(private actions$: Actions, private backend: Backend) {}
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*
|
|
174
|
+
* This is correct, but because it set the concurrency to 1, it may not be performant.
|
|
175
|
+
*
|
|
176
|
+
* To fix that, you can provide the `id` function, like this:
|
|
177
|
+
*
|
|
178
|
+
* ```typescript
|
|
179
|
+
* @Injectable()
|
|
180
|
+
* class TodoEffects {
|
|
181
|
+
* loadTodo$ = createEffect(() =>
|
|
182
|
+
* this.actions$.pipe(
|
|
183
|
+
* ofType('GET_TODO'),
|
|
184
|
+
* fetch({
|
|
185
|
+
* id: (todo: GetTodo) => {
|
|
186
|
+
* return todo.id;
|
|
187
|
+
* },
|
|
188
|
+
* // provides an action
|
|
189
|
+
* run: (todo: GetTodo) => {
|
|
190
|
+
* return this.backend.getTodo(todo.id).map((response) => ({
|
|
191
|
+
* type: 'LOAD_TODO_SUCCESS',
|
|
192
|
+
* todo: response.todo,
|
|
193
|
+
* }));
|
|
194
|
+
* },
|
|
195
|
+
* onError: (action: GetTodo, error: any) => {
|
|
196
|
+
* // dispatch an undo action to undo the changes in the client state
|
|
197
|
+
* return null;
|
|
198
|
+
* },
|
|
199
|
+
* })
|
|
200
|
+
* )
|
|
201
|
+
* );
|
|
202
|
+
*
|
|
203
|
+
* constructor(private actions$: Actions, private backend: Backend) {}
|
|
204
|
+
* }
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.
|
|
208
|
+
*
|
|
209
|
+
* In addition, if there are multiple requests for Todo 1 scheduled, it will only run the last one.
|
|
210
|
+
*
|
|
211
|
+
* @param opts
|
|
212
|
+
*/
|
|
20
213
|
function fetch(opts) {
|
|
21
214
|
return (source) => {
|
|
22
215
|
if (opts.id) {
|
|
@@ -28,6 +221,55 @@ function fetch(opts) {
|
|
|
28
221
|
return source.pipe(mapActionAndState(), concatMap(runWithErrorHandling(opts.run, opts.onError)));
|
|
29
222
|
};
|
|
30
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* @whatItDoes Handles data fetching as part of router navigation.
|
|
226
|
+
*
|
|
227
|
+
* Data fetching implemented naively suffers from race conditions and poor error handling.
|
|
228
|
+
*
|
|
229
|
+
* `navigation` addresses these problems.
|
|
230
|
+
*
|
|
231
|
+
* It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`
|
|
232
|
+
* callback. It provides the activated snapshot associated with the component and the current state. And it only runs
|
|
233
|
+
* the last request.
|
|
234
|
+
*
|
|
235
|
+
* ## Example:
|
|
236
|
+
*
|
|
237
|
+
* ```typescript
|
|
238
|
+
* @Injectable()
|
|
239
|
+
* class TodoEffects {
|
|
240
|
+
* loadTodo$ = createEffect(() =>
|
|
241
|
+
* this.actions$.pipe(
|
|
242
|
+
* // listens for the routerNavigation action from @ngrx/router-store
|
|
243
|
+
* navigation(TodoComponent, {
|
|
244
|
+
* run: (activatedRouteSnapshot: ActivatedRouteSnapshot) => {
|
|
245
|
+
* return this.backend
|
|
246
|
+
* .fetchTodo(activatedRouteSnapshot.params['id'])
|
|
247
|
+
* .pipe(
|
|
248
|
+
* map((todo) => ({
|
|
249
|
+
* type: 'LOAD_TODO_SUCCESS',
|
|
250
|
+
* todo: todo,
|
|
251
|
+
* }))
|
|
252
|
+
* );
|
|
253
|
+
* },
|
|
254
|
+
* onError: (
|
|
255
|
+
* activatedRouteSnapshot: ActivatedRouteSnapshot,
|
|
256
|
+
* error: any
|
|
257
|
+
* ) => {
|
|
258
|
+
* // we can log and error here and return null
|
|
259
|
+
* // we can also navigate back
|
|
260
|
+
* return null;
|
|
261
|
+
* },
|
|
262
|
+
* })
|
|
263
|
+
* )
|
|
264
|
+
* );
|
|
265
|
+
*
|
|
266
|
+
* constructor(private actions$: Actions, private backend: Backend) {}
|
|
267
|
+
* }
|
|
268
|
+
* ```
|
|
269
|
+
*
|
|
270
|
+
* @param component
|
|
271
|
+
* @param opts
|
|
272
|
+
*/
|
|
31
273
|
function navigation(component, opts) {
|
|
32
274
|
return (source) => {
|
|
33
275
|
const nav = source.pipe(mapActionAndState(), filter(([action]) => isStateSnapshot(action)), map(([action, ...slices]) => {
|
|
@@ -84,6 +326,8 @@ function normalizeActionAndState(args) {
|
|
|
84
326
|
}
|
|
85
327
|
/**
|
|
86
328
|
* @whatItDoes Provides convenience methods for implementing common operations of persisting data.
|
|
329
|
+
*
|
|
330
|
+
* @deprecated Use the individual operators instead. Will be removed in v15.
|
|
87
331
|
*/
|
|
88
332
|
class DataPersistence {
|
|
89
333
|
constructor(store, actions) {
|
|
@@ -91,213 +335,45 @@ class DataPersistence {
|
|
|
91
335
|
this.actions = actions;
|
|
92
336
|
}
|
|
93
337
|
/**
|
|
338
|
+
* See {@link pessimisticUpdate} operator for more information.
|
|
94
339
|
*
|
|
95
|
-
* @
|
|
96
|
-
*
|
|
97
|
-
* Update the server implemented naively suffers from race conditions and poor error handling.
|
|
98
|
-
*
|
|
99
|
-
* `pessimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions
|
|
100
|
-
* and forces the developer to handle errors.
|
|
101
|
-
*
|
|
102
|
-
* ## Example:
|
|
103
|
-
*
|
|
104
|
-
* ```typescript
|
|
105
|
-
* @Injectable()
|
|
106
|
-
* class TodoEffects {
|
|
107
|
-
* @Effect() updateTodo = this.s.pessimisticUpdate<UpdateTodo>('UPDATE_TODO', {
|
|
108
|
-
* // provides an action and the current state of the store
|
|
109
|
-
* run(a, state) {
|
|
110
|
-
* // update the backend first, and then dispatch an action that will
|
|
111
|
-
* // update the client side
|
|
112
|
-
* return this.backend(state.user, a.payload).map(updated => ({
|
|
113
|
-
* type: 'TODO_UPDATED',
|
|
114
|
-
* payload: updated
|
|
115
|
-
* }));
|
|
116
|
-
* },
|
|
117
|
-
*
|
|
118
|
-
* onError(a, e: any) {
|
|
119
|
-
* // we don't need to undo the changes on the client side.
|
|
120
|
-
* // we can dispatch an error, or simply log the error here and return `null`
|
|
121
|
-
* return null;
|
|
122
|
-
* }
|
|
123
|
-
* });
|
|
124
|
-
*
|
|
125
|
-
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
|
|
126
|
-
* }
|
|
127
|
-
* ```
|
|
128
|
-
*
|
|
129
|
-
* Note that if you don't return a new action from the run callback, you must set the dispatch property
|
|
130
|
-
* of the effect to false, like this:
|
|
131
|
-
*
|
|
132
|
-
* ```
|
|
133
|
-
* class TodoEffects {
|
|
134
|
-
* @Effect({dispatch: false})
|
|
135
|
-
* updateTodo; //...
|
|
136
|
-
* }
|
|
137
|
-
* ```
|
|
340
|
+
* @deprecated Use the {@link pessimisticUpdate} operator instead.
|
|
341
|
+
* The {@link DataPersistence} class will be removed in v15.
|
|
138
342
|
*/
|
|
139
343
|
pessimisticUpdate(actionType, opts) {
|
|
140
344
|
return this.actions.pipe(ofType(actionType), withLatestFrom(this.store), pessimisticUpdate(opts));
|
|
141
345
|
}
|
|
142
346
|
/**
|
|
347
|
+
* See {@link optimisticUpdate} operator for more information.
|
|
143
348
|
*
|
|
144
|
-
* @
|
|
145
|
-
*
|
|
146
|
-
* `optimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions
|
|
147
|
-
* and forces the developer to handle errors.
|
|
148
|
-
*
|
|
149
|
-
* `optimisticUpdate` is different from `pessimisticUpdate`. In case of a failure, when using `optimisticUpdate`,
|
|
150
|
-
* the developer already updated the state locally, so the developer must provide an undo action.
|
|
151
|
-
*
|
|
152
|
-
* The error handling must be done in the callback, or by means of the undo action.
|
|
153
|
-
*
|
|
154
|
-
* ## Example:
|
|
155
|
-
*
|
|
156
|
-
* ```typescript
|
|
157
|
-
* @Injectable()
|
|
158
|
-
* class TodoEffects {
|
|
159
|
-
* @Effect() updateTodo = this.s.optimisticUpdate<UpdateTodo>('UPDATE_TODO', {
|
|
160
|
-
* // provides an action and the current state of the store
|
|
161
|
-
* run: (a, state) => {
|
|
162
|
-
* return this.backend(state.user, a.payload);
|
|
163
|
-
* },
|
|
164
|
-
*
|
|
165
|
-
* undoAction: (a, e: any) => {
|
|
166
|
-
* // dispatch an undo action to undo the changes in the client state
|
|
167
|
-
* return ({
|
|
168
|
-
* type: 'UNDO_UPDATE_TODO',
|
|
169
|
-
* payload: a
|
|
170
|
-
* });
|
|
171
|
-
* }
|
|
172
|
-
* });
|
|
173
|
-
*
|
|
174
|
-
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
|
|
175
|
-
* }
|
|
176
|
-
* ```
|
|
177
|
-
*
|
|
178
|
-
* Note that if you don't return a new action from the run callback, you must set the dispatch property
|
|
179
|
-
* of the effect to false, like this:
|
|
180
|
-
*
|
|
181
|
-
* ```
|
|
182
|
-
* class TodoEffects {
|
|
183
|
-
* @Effect({dispatch: false})
|
|
184
|
-
* updateTodo; //...
|
|
185
|
-
* }
|
|
186
|
-
* ```
|
|
349
|
+
* @deprecated Use the {@link optimisticUpdate} operator instead.
|
|
350
|
+
* The {@link DataPersistence} class will be removed in v15.
|
|
187
351
|
*/
|
|
188
352
|
optimisticUpdate(actionType, opts) {
|
|
189
353
|
return this.actions.pipe(ofType(actionType), withLatestFrom(this.store), optimisticUpdate(opts));
|
|
190
354
|
}
|
|
191
355
|
/**
|
|
356
|
+
* See {@link fetch} operator for more information.
|
|
192
357
|
*
|
|
193
|
-
* @
|
|
194
|
-
*
|
|
195
|
-
* Data fetching implemented naively suffers from race conditions and poor error handling.
|
|
196
|
-
*
|
|
197
|
-
* `fetch` addresses these problems--it runs all fetches in order, which removes race conditions
|
|
198
|
-
* and forces the developer to handle errors.
|
|
199
|
-
*
|
|
200
|
-
* ## Example:
|
|
201
|
-
*
|
|
202
|
-
* ```typescript
|
|
203
|
-
* @Injectable()
|
|
204
|
-
* class TodoEffects {
|
|
205
|
-
* @Effect() loadTodos = this.s.fetch<GetTodos>('GET_TODOS', {
|
|
206
|
-
* // provides an action and the current state of the store
|
|
207
|
-
* run: (a, state) => {
|
|
208
|
-
* return this.backend(state.user, a.payload).map(r => ({
|
|
209
|
-
* type: 'TODOS',
|
|
210
|
-
* payload: r
|
|
211
|
-
* });
|
|
212
|
-
* },
|
|
213
|
-
*
|
|
214
|
-
* onError: (a, e: any) => {
|
|
215
|
-
* // dispatch an undo action to undo the changes in the client state
|
|
216
|
-
* }
|
|
217
|
-
* });
|
|
218
|
-
*
|
|
219
|
-
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
|
|
220
|
-
* }
|
|
221
|
-
* ```
|
|
222
|
-
*
|
|
223
|
-
* This is correct, but because it set the concurrency to 1, it may not be performant.
|
|
224
|
-
*
|
|
225
|
-
* To fix that, you can provide the `id` function, like this:
|
|
226
|
-
*
|
|
227
|
-
* ```typescript
|
|
228
|
-
* @Injectable()
|
|
229
|
-
* class TodoEffects {
|
|
230
|
-
* @Effect() loadTodo = this.s.fetch<GetTodo>('GET_TODO', {
|
|
231
|
-
* id: (a, state) => {
|
|
232
|
-
* return a.payload.id;
|
|
233
|
-
* }
|
|
234
|
-
*
|
|
235
|
-
* // provides an action and the current state of the store
|
|
236
|
-
* run: (a, state) => {
|
|
237
|
-
* return this.backend(state.user, a.payload).map(r => ({
|
|
238
|
-
* type: 'TODO',
|
|
239
|
-
* payload: r
|
|
240
|
-
* });
|
|
241
|
-
* },
|
|
242
|
-
*
|
|
243
|
-
* onError: (a, e: any) => {
|
|
244
|
-
* // dispatch an undo action to undo the changes in the client state
|
|
245
|
-
* return null;
|
|
246
|
-
* }
|
|
247
|
-
* });
|
|
248
|
-
*
|
|
249
|
-
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
|
|
250
|
-
* }
|
|
251
|
-
* ```
|
|
252
|
-
*
|
|
253
|
-
* With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.
|
|
254
|
-
*
|
|
255
|
-
* In addition, if DataPersistence notices that there are multiple requests for Todo 1 scheduled,
|
|
256
|
-
* it will only run the last one.
|
|
358
|
+
* @deprecated Use the {@link fetch} operator instead.
|
|
359
|
+
* The {@link DataPersistence} class will be removed in v15.
|
|
257
360
|
*/
|
|
258
361
|
fetch(actionType, opts) {
|
|
259
362
|
return this.actions.pipe(ofType(actionType), withLatestFrom(this.store), fetch(opts));
|
|
260
363
|
}
|
|
261
364
|
/**
|
|
262
|
-
* @
|
|
365
|
+
* See {@link navigation} operator for more information.
|
|
263
366
|
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
* `navigation` addresses these problems.
|
|
267
|
-
*
|
|
268
|
-
* It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`
|
|
269
|
-
* callback. It provides the activated snapshot associated with the component and the current state. And it only runs
|
|
270
|
-
* the last request.
|
|
271
|
-
*
|
|
272
|
-
* ## Example:
|
|
273
|
-
*
|
|
274
|
-
* ```typescript
|
|
275
|
-
* @Injectable()
|
|
276
|
-
* class TodoEffects {
|
|
277
|
-
* @Effect() loadTodo = this.s.navigation(TodoComponent, {
|
|
278
|
-
* run: (a, state) => {
|
|
279
|
-
* return this.backend.fetchTodo(a.params['id']).map(todo => ({
|
|
280
|
-
* type: 'TODO_LOADED',
|
|
281
|
-
* payload: todo
|
|
282
|
-
* }));
|
|
283
|
-
* },
|
|
284
|
-
* onError: (a, e: any) => {
|
|
285
|
-
* // we can log and error here and return null
|
|
286
|
-
* // we can also navigate back
|
|
287
|
-
* return null;
|
|
288
|
-
* }
|
|
289
|
-
* });
|
|
290
|
-
* constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}
|
|
291
|
-
* }
|
|
292
|
-
* ```
|
|
367
|
+
* @deprecated Use the {@link navigation} operator instead.
|
|
368
|
+
* The {@link DataPersistence} class will be removed in v15.
|
|
293
369
|
*/
|
|
294
370
|
navigation(component, opts) {
|
|
295
371
|
return this.actions.pipe(withLatestFrom(this.store), navigation(component, opts));
|
|
296
372
|
}
|
|
297
373
|
}
|
|
298
|
-
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
299
|
-
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.
|
|
300
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
374
|
+
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: DataPersistence, deps: [{ token: i1.Store }, { token: i2.Actions }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
375
|
+
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: DataPersistence });
|
|
376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: DataPersistence, decorators: [{
|
|
301
377
|
type: Injectable
|
|
302
378
|
}], ctorParameters: function () { return [{ type: i1.Store }, { type: i2.Actions }]; } });
|
|
303
379
|
function findSnapshot(component, s) {
|
|
@@ -328,16 +404,18 @@ function wrapIntoObservable(obj) {
|
|
|
328
404
|
* @whatItDoes Provides services for enterprise Angular applications.
|
|
329
405
|
*
|
|
330
406
|
* See {@link DataPersistence} for more information.
|
|
407
|
+
*
|
|
408
|
+
* @deprecated Use the individual operators instead. Will be removed in v15.
|
|
331
409
|
*/
|
|
332
410
|
class NxModule {
|
|
333
411
|
static forRoot() {
|
|
334
412
|
return { ngModule: NxModule, providers: [DataPersistence] };
|
|
335
413
|
}
|
|
336
414
|
}
|
|
337
|
-
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.
|
|
338
|
-
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.
|
|
339
|
-
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.
|
|
340
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.
|
|
415
|
+
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
416
|
+
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.0", ngImport: i0, type: NxModule });
|
|
417
|
+
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NxModule });
|
|
418
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NxModule, decorators: [{
|
|
341
419
|
type: NgModule,
|
|
342
420
|
args: [{}]
|
|
343
421
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nrwl-angular.mjs","sources":["../../src/runtime/nx/data-persistence.ts","../../src/runtime/nx/nx.module.ts","../../nrwl-angular.ts"],"sourcesContent":["import { Injectable, Type } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { Actions, ofType } from '@ngrx/effects';\nimport { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';\nimport { Action, Store, ActionCreator } from '@ngrx/store';\nimport { isObservable, Observable, of } from 'rxjs';\nimport {\n catchError,\n concatMap,\n filter,\n groupBy,\n map,\n mergeMap,\n switchMap,\n withLatestFrom,\n} from 'rxjs/operators';\n\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface PessimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError(a: A, e: any): Observable<any> | any;\n}\n/**\n * See {@link DataPersistence.pessimisticUpdate} for more information.\n */\nexport interface OptimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n undoAction(a: A, e: any): Observable<Action> | Action;\n}\n\n/**\n * See {@link DataPersistence.fetch} for more information.\n */\nexport interface FetchOpts<T extends Array<unknown>, A> {\n id?(a: A, ...slices: [...T]): any;\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError?(a: A, e: any): Observable<any> | any;\n}\n\n/**\n * See {@link DataPersistence.navigation} for more information.\n */\nexport interface HandleNavigationOpts<T extends Array<unknown>> {\n run(\n a: ActivatedRouteSnapshot,\n ...slices: [...T]\n ): Observable<Action> | Action | void;\n onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;\n}\n\nexport type ActionOrActionWithStates<T extends Array<unknown>, A> =\n | A\n | [A, ...T];\nexport type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;\nexport type ActionStatesStream<T extends Array<unknown>, A> = Observable<\n ActionOrActionWithStates<T, A>\n>;\nexport type ActionStateStream<T, A> = Observable<\n ActionOrActionWithStates<[T], A>\n>;\n\nexport function pessimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: PessimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function optimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: OptimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.undoAction))\n );\n };\n}\n\nexport function fetch<T extends Array<unknown>, A extends Action>(\n opts: FetchOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n if (opts.id) {\n const groupedFetches = source.pipe(\n mapActionAndState(),\n groupBy(([action, ...store]) => {\n return opts.id(action, ...store);\n })\n );\n\n return groupedFetches.pipe(\n mergeMap((pairs) =>\n pairs.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)))\n )\n );\n }\n\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\nexport function navigation<T extends Array<unknown>, A extends Action>(\n component: Type<any>,\n opts: HandleNavigationOpts<T>\n) {\n return (source: ActionStatesStream<T, A>) => {\n const nav = source.pipe(\n mapActionAndState(),\n filter(([action]) => isStateSnapshot(action)),\n map(([action, ...slices]) => {\n if (!isStateSnapshot(action)) {\n // Because of the above filter we'll never get here,\n // but this properly type narrows `action`\n return;\n }\n\n return [\n findSnapshot(component, action.payload.routerState.root),\n ...slices,\n ] as [ActivatedRouteSnapshot, ...T];\n }),\n filter(([snapshot]) => !!snapshot)\n );\n\n return nav.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)));\n };\n}\n\nfunction isStateSnapshot(\n action: any\n): action is RouterNavigationAction<RouterStateSnapshot> {\n return action.type === ROUTER_NAVIGATION;\n}\n\nfunction runWithErrorHandling<T extends Array<unknown>, A, R>(\n run: (a: A, ...slices: [...T]) => Observable<R> | R | void,\n onError: any\n) {\n return ([action, ...slices]: [A, ...T]): Observable<R> => {\n try {\n const r = wrapIntoObservable(run(action, ...slices));\n return r.pipe(catchError((e) => wrapIntoObservable(onError(action, e))));\n } catch (e) {\n return wrapIntoObservable(onError(action, e));\n }\n };\n}\n\n/**\n * @whatItDoes maps Observable<Action | [Action, State]> to\n * Observable<[Action, State]>\n */\nfunction mapActionAndState<T extends Array<unknown>, A>() {\n return (source: Observable<ActionOrActionWithStates<T, A>>) => {\n return source.pipe(\n map((value) => normalizeActionAndState(value) as [A, ...T])\n );\n };\n}\n\n/**\n * @whatItDoes Normalizes either a bare action or an array of action and slices\n * into an array of action and slices (or undefined)\n */\nfunction normalizeActionAndState<T extends Array<unknown>, A>(\n args: ActionOrActionWithStates<T, A>\n): [A, ...T] {\n let action: A, slices: T;\n\n if (args instanceof Array) {\n [action, ...slices] = args;\n } else {\n slices = [] as T;\n action = args;\n }\n\n return [action, ...slices];\n}\n\n/**\n * @whatItDoes Provides convenience methods for implementing common operations of persisting data.\n */\n@Injectable()\nexport class DataPersistence<T> {\n constructor(public store: Store<T>, public actions: Actions) {}\n\n /**\n *\n * @whatItDoes Handles pessimistic updates (updating the server first).\n *\n * Update the server implemented naively suffers from race conditions and poor error handling.\n *\n * `pessimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.pessimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run(a, state) {\n * // update the backend first, and then dispatch an action that will\n * // update the client side\n * return this.backend(state.user, a.payload).map(updated => ({\n * type: 'TODO_UPDATED',\n * payload: updated\n * }));\n * },\n *\n * onError(a, e: any) {\n * // we don't need to undo the changes on the client side.\n * // we can dispatch an error, or simply log the error here and return `null`\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n pessimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: PessimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n pessimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles optimistic updates (updating the client first).\n *\n * `optimisticUpdate` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * `optimisticUpdate` is different from `pessimisticUpdate`. In case of a failure, when using `optimisticUpdate`,\n * the developer already updated the state locally, so the developer must provide an undo action.\n *\n * The error handling must be done in the callback, or by means of the undo action.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() updateTodo = this.s.optimisticUpdate<UpdateTodo>('UPDATE_TODO', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload);\n * },\n *\n * undoAction: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return ({\n * type: 'UNDO_UPDATE_TODO',\n * payload: a\n * });\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```\n * class TodoEffects {\n * @Effect({dispatch: false})\n * updateTodo; //...\n * }\n * ```\n */\n optimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: OptimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n optimisticUpdate(opts)\n );\n }\n\n /**\n *\n * @whatItDoes Handles data fetching.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `fetch` addresses these problems--it runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodos = this.s.fetch<GetTodos>('GET_TODOS', {\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODOS',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * This is correct, but because it set the concurrency to 1, it may not be performant.\n *\n * To fix that, you can provide the `id` function, like this:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.fetch<GetTodo>('GET_TODO', {\n * id: (a, state) => {\n * return a.payload.id;\n * }\n *\n * // provides an action and the current state of the store\n * run: (a, state) => {\n * return this.backend(state.user, a.payload).map(r => ({\n * type: 'TODO',\n * payload: r\n * });\n * },\n *\n * onError: (a, e: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return null;\n * }\n * });\n *\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n *\n * With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.\n *\n * In addition, if DataPersistence notices that there are multiple requests for Todo 1 scheduled,\n * it will only run the last one.\n */\n fetch<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: FetchOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n fetch(opts)\n );\n }\n\n /**\n * @whatItDoes Handles data fetching as part of router navigation.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `navigation` addresses these problems.\n *\n * It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`\n * callback. It provides the activated snapshot associated with the component and the current state. And it only runs\n * the last request.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * @Effect() loadTodo = this.s.navigation(TodoComponent, {\n * run: (a, state) => {\n * return this.backend.fetchTodo(a.params['id']).map(todo => ({\n * type: 'TODO_LOADED',\n * payload: todo\n * }));\n * },\n * onError: (a, e: any) => {\n * // we can log and error here and return null\n * // we can also navigate back\n * return null;\n * }\n * });\n * constructor(private s: DataPersistence<TodosState>, private backend: Backend) {}\n * }\n * ```\n */\n navigation(\n component: Type<any>,\n opts: HandleNavigationOpts<[T]>\n ): Observable<any> {\n return this.actions.pipe(\n withLatestFrom(this.store),\n navigation(component, opts)\n );\n }\n}\n\nfunction findSnapshot(\n component: Type<any>,\n s: ActivatedRouteSnapshot\n): ActivatedRouteSnapshot {\n if (s.routeConfig && s.routeConfig.component === component) {\n return s;\n }\n for (const c of s.children) {\n const ss = findSnapshot(component, c);\n if (ss) {\n return ss;\n }\n }\n return null;\n}\n\nfunction wrapIntoObservable<O>(obj: Observable<O> | O | void): Observable<O> {\n if (isObservable(obj)) {\n return obj;\n } else if (!obj) {\n return of();\n } else {\n return of(obj as O);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { DataPersistence } from './data-persistence';\n\n/**\n * @whatItDoes Provides services for enterprise Angular applications.\n *\n * See {@link DataPersistence} for more information.\n */\n@NgModule({})\nexport class NxModule {\n static forRoot(): ModuleWithProviders<NxModule> {\n return { ngModule: NxModule, providers: [DataPersistence] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AA+DM,SAAU,iBAAiB,CAC/B,IAAiC,EAAA;IAEjC,OAAO,CAAC,MAAgC,KAAwB;QAC9D,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CACxD,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC;AAEK,SAAU,gBAAgB,CAC9B,IAAgC,EAAA;IAEhC,OAAO,CAAC,MAAgC,KAAwB;QAC9D,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAC3D,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC;AAEK,SAAU,KAAK,CACnB,IAAqB,EAAA;IAErB,OAAO,CAAC,MAAgC,KAAwB;QAC9D,IAAI,IAAI,CAAC,EAAE,EAAE;AACX,YAAA,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAChC,iBAA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CAAC,eAAe,CAAC,EAAE,CAAC;KAC7D;;qGAHU,QAAQ,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;sGAAR,QAAQ,EAAA,CAAA,CAAA;sGAAR,QAAQ,EAAA,CAAA,CAAA;2FAAR,QAAQ,EAAA,UAAA,EAAA,CAAA;kBADpB,QAAQ;mBAAC,EAAE,CAAA;;;ACRZ;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"nrwl-angular.mjs","sources":["../../src/runtime/nx/data-persistence.ts","../../src/runtime/nx/nx.module.ts","../../nrwl-angular.ts"],"sourcesContent":["import { Injectable, Type } from '@angular/core';\nimport { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';\nimport { Actions, ofType } from '@ngrx/effects';\nimport { ROUTER_NAVIGATION, RouterNavigationAction } from '@ngrx/router-store';\nimport { Action, Store, ActionCreator } from '@ngrx/store';\nimport { isObservable, Observable, of } from 'rxjs';\nimport {\n catchError,\n concatMap,\n filter,\n groupBy,\n map,\n mergeMap,\n switchMap,\n withLatestFrom,\n} from 'rxjs/operators';\n\nexport interface PessimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError(a: A, e: any): Observable<any> | any;\n}\n\nexport interface OptimisticUpdateOpts<T extends Array<unknown>, A> {\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n undoAction(a: A, e: any): Observable<Action> | Action;\n}\n\nexport interface FetchOpts<T extends Array<unknown>, A> {\n id?(a: A, ...slices: [...T]): any;\n run(a: A, ...slices: [...T]): Observable<Action> | Action | void;\n onError?(a: A, e: any): Observable<any> | any;\n}\n\nexport interface HandleNavigationOpts<T extends Array<unknown>> {\n run(\n a: ActivatedRouteSnapshot,\n ...slices: [...T]\n ): Observable<Action> | Action | void;\n onError?(a: ActivatedRouteSnapshot, e: any): Observable<any> | any;\n}\n\nexport type ActionOrActionWithStates<T extends Array<unknown>, A> =\n | A\n | [A, ...T];\nexport type ActionOrActionWithState<T, A> = ActionOrActionWithStates<[T], A>;\nexport type ActionStatesStream<T extends Array<unknown>, A> = Observable<\n ActionOrActionWithStates<T, A>\n>;\nexport type ActionStateStream<T, A> = Observable<\n ActionOrActionWithStates<[T], A>\n>;\n\n/**\n *\n * @whatItDoes Handles pessimistic updates (updating the server first).\n *\n * Updating the server, when implemented naively, suffers from race conditions and poor error handling.\n *\n * `pessimisticUpdate` addresses these problems. It runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * updateTodo$ = createEffect(() =>\n * this.actions$.pipe(\n * ofType('UPDATE_TODO'),\n * pessimisticUpdate({\n * // provides an action\n * run: (action: UpdateTodo) => {\n * // update the backend first, and then dispatch an action that will\n * // update the client side\n * return this.backend.updateTodo(action.todo.id, action.todo).pipe(\n * map((updated) => ({\n * type: 'UPDATE_TODO_SUCCESS',\n * todo: updated,\n * }))\n * );\n * },\n * onError: (action: UpdateTodo, error: any) => {\n * // we don't need to undo the changes on the client side.\n * // we can dispatch an error, or simply log the error here and return `null`\n * return null;\n * },\n * })\n * )\n * );\n *\n * constructor(private actions$: Actions, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```typescript\n * class TodoEffects {\n * updateTodo$ = createEffect(() =>\n * this.actions$.pipe(\n * //...\n * ), { dispatch: false }\n * );\n * }\n * ```\n *\n * @param opts\n */\nexport function pessimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: PessimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\n/**\n *\n * @whatItDoes Handles optimistic updates (updating the client first).\n *\n * It runs all fetches in order, which removes race conditions and forces the developer to handle errors.\n *\n * When using `optimisticUpdate`, in case of a failure, the developer has already updated the state locally,\n * so the developer must provide an undo action.\n *\n * The error handling must be done in the callback, or by means of the undo action.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * updateTodo$ = createEffect(() =>\n * this.actions$.pipe(\n * ofType('UPDATE_TODO'),\n * optimisticUpdate({\n * // provides an action\n * run: (action: UpdateTodo) => {\n * return this.backend.updateTodo(action.todo.id, action.todo).pipe(\n * mapTo({\n * type: 'UPDATE_TODO_SUCCESS',\n * })\n * );\n * },\n * undoAction: (action: UpdateTodo, error: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return {\n * type: 'UNDO_TODO_UPDATE',\n * todo: action.todo,\n * };\n * },\n * })\n * )\n * );\n *\n * constructor(private actions$: Actions, private backend: Backend) {}\n * }\n * ```\n *\n * Note that if you don't return a new action from the run callback, you must set the dispatch property\n * of the effect to false, like this:\n *\n * ```typescript\n * class TodoEffects {\n * updateTodo$ = createEffect(() =>\n * this.actions$.pipe(\n * //...\n * ), { dispatch: false }\n * );\n * }\n * ```\n *\n * @param opts\n */\nexport function optimisticUpdate<T extends Array<unknown>, A extends Action>(\n opts: OptimisticUpdateOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.undoAction))\n );\n };\n}\n\n/**\n *\n * @whatItDoes Handles data fetching.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `fetch` addresses these problems. It runs all fetches in order, which removes race conditions\n * and forces the developer to handle errors.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * loadTodos$ = createEffect(() =>\n * this.actions$.pipe(\n * ofType('GET_TODOS'),\n * fetch({\n * // provides an action\n * run: (a: GetTodos) => {\n * return this.backend.getAll().pipe(\n * map((response) => ({\n * type: 'TODOS',\n * todos: response.todos,\n * }))\n * );\n * },\n * onError: (action: GetTodos, error: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return null;\n * },\n * })\n * )\n * );\n *\n * constructor(private actions$: Actions, private backend: Backend) {}\n * }\n * ```\n *\n * This is correct, but because it set the concurrency to 1, it may not be performant.\n *\n * To fix that, you can provide the `id` function, like this:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * loadTodo$ = createEffect(() =>\n * this.actions$.pipe(\n * ofType('GET_TODO'),\n * fetch({\n * id: (todo: GetTodo) => {\n * return todo.id;\n * },\n * // provides an action\n * run: (todo: GetTodo) => {\n * return this.backend.getTodo(todo.id).map((response) => ({\n * type: 'LOAD_TODO_SUCCESS',\n * todo: response.todo,\n * }));\n * },\n * onError: (action: GetTodo, error: any) => {\n * // dispatch an undo action to undo the changes in the client state\n * return null;\n * },\n * })\n * )\n * );\n *\n * constructor(private actions$: Actions, private backend: Backend) {}\n * }\n * ```\n *\n * With this setup, the requests for Todo 1 will run concurrently with the requests for Todo 2.\n *\n * In addition, if there are multiple requests for Todo 1 scheduled, it will only run the last one.\n *\n * @param opts\n */\nexport function fetch<T extends Array<unknown>, A extends Action>(\n opts: FetchOpts<T, A>\n) {\n return (source: ActionStatesStream<T, A>): Observable<Action> => {\n if (opts.id) {\n const groupedFetches = source.pipe(\n mapActionAndState(),\n groupBy(([action, ...store]) => {\n return opts.id(action, ...store);\n })\n );\n\n return groupedFetches.pipe(\n mergeMap((pairs) =>\n pairs.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)))\n )\n );\n }\n\n return source.pipe(\n mapActionAndState(),\n concatMap(runWithErrorHandling(opts.run, opts.onError))\n );\n };\n}\n\n/**\n * @whatItDoes Handles data fetching as part of router navigation.\n *\n * Data fetching implemented naively suffers from race conditions and poor error handling.\n *\n * `navigation` addresses these problems.\n *\n * It checks if an activated router state contains the passed in component type, and, if it does, runs the `run`\n * callback. It provides the activated snapshot associated with the component and the current state. And it only runs\n * the last request.\n *\n * ## Example:\n *\n * ```typescript\n * @Injectable()\n * class TodoEffects {\n * loadTodo$ = createEffect(() =>\n * this.actions$.pipe(\n * // listens for the routerNavigation action from @ngrx/router-store\n * navigation(TodoComponent, {\n * run: (activatedRouteSnapshot: ActivatedRouteSnapshot) => {\n * return this.backend\n * .fetchTodo(activatedRouteSnapshot.params['id'])\n * .pipe(\n * map((todo) => ({\n * type: 'LOAD_TODO_SUCCESS',\n * todo: todo,\n * }))\n * );\n * },\n * onError: (\n * activatedRouteSnapshot: ActivatedRouteSnapshot,\n * error: any\n * ) => {\n * // we can log and error here and return null\n * // we can also navigate back\n * return null;\n * },\n * })\n * )\n * );\n *\n * constructor(private actions$: Actions, private backend: Backend) {}\n * }\n * ```\n *\n * @param component\n * @param opts\n */\nexport function navigation<T extends Array<unknown>, A extends Action>(\n component: Type<any>,\n opts: HandleNavigationOpts<T>\n) {\n return (source: ActionStatesStream<T, A>) => {\n const nav = source.pipe(\n mapActionAndState(),\n filter(([action]) => isStateSnapshot(action)),\n map(([action, ...slices]) => {\n if (!isStateSnapshot(action)) {\n // Because of the above filter we'll never get here,\n // but this properly type narrows `action`\n return;\n }\n\n return [\n findSnapshot(component, action.payload.routerState.root),\n ...slices,\n ] as [ActivatedRouteSnapshot, ...T];\n }),\n filter(([snapshot]) => !!snapshot)\n );\n\n return nav.pipe(switchMap(runWithErrorHandling(opts.run, opts.onError)));\n };\n}\n\nfunction isStateSnapshot(\n action: any\n): action is RouterNavigationAction<RouterStateSnapshot> {\n return action.type === ROUTER_NAVIGATION;\n}\n\nfunction runWithErrorHandling<T extends Array<unknown>, A, R>(\n run: (a: A, ...slices: [...T]) => Observable<R> | R | void,\n onError: any\n) {\n return ([action, ...slices]: [A, ...T]): Observable<R> => {\n try {\n const r = wrapIntoObservable(run(action, ...slices));\n return r.pipe(catchError((e) => wrapIntoObservable(onError(action, e))));\n } catch (e) {\n return wrapIntoObservable(onError(action, e));\n }\n };\n}\n\n/**\n * @whatItDoes maps Observable<Action | [Action, State]> to\n * Observable<[Action, State]>\n */\nfunction mapActionAndState<T extends Array<unknown>, A>() {\n return (source: Observable<ActionOrActionWithStates<T, A>>) => {\n return source.pipe(\n map((value) => normalizeActionAndState(value) as [A, ...T])\n );\n };\n}\n\n/**\n * @whatItDoes Normalizes either a bare action or an array of action and slices\n * into an array of action and slices (or undefined)\n */\nfunction normalizeActionAndState<T extends Array<unknown>, A>(\n args: ActionOrActionWithStates<T, A>\n): [A, ...T] {\n let action: A, slices: T;\n\n if (args instanceof Array) {\n [action, ...slices] = args;\n } else {\n slices = [] as T;\n action = args;\n }\n\n return [action, ...slices];\n}\n\n/**\n * @whatItDoes Provides convenience methods for implementing common operations of persisting data.\n *\n * @deprecated Use the individual operators instead. Will be removed in v15.\n */\n@Injectable()\nexport class DataPersistence<T> {\n constructor(public store: Store<T>, public actions: Actions) {}\n\n /**\n * See {@link pessimisticUpdate} operator for more information.\n *\n * @deprecated Use the {@link pessimisticUpdate} operator instead.\n * The {@link DataPersistence} class will be removed in v15.\n */\n pessimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: PessimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n pessimisticUpdate(opts)\n );\n }\n\n /**\n * See {@link optimisticUpdate} operator for more information.\n *\n * @deprecated Use the {@link optimisticUpdate} operator instead.\n * The {@link DataPersistence} class will be removed in v15.\n */\n optimisticUpdate<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: OptimisticUpdateOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n optimisticUpdate(opts)\n );\n }\n\n /**\n * See {@link fetch} operator for more information.\n *\n * @deprecated Use the {@link fetch} operator instead.\n * The {@link DataPersistence} class will be removed in v15.\n */\n fetch<A extends Action = Action>(\n actionType: string | ActionCreator,\n opts: FetchOpts<[T], A>\n ): Observable<any> {\n return this.actions.pipe(\n ofType<A>(actionType),\n withLatestFrom(this.store),\n fetch(opts)\n );\n }\n\n /**\n * See {@link navigation} operator for more information.\n *\n * @deprecated Use the {@link navigation} operator instead.\n * The {@link DataPersistence} class will be removed in v15.\n */\n navigation(\n component: Type<any>,\n opts: HandleNavigationOpts<[T]>\n ): Observable<any> {\n return this.actions.pipe(\n withLatestFrom(this.store),\n navigation(component, opts)\n );\n }\n}\n\nfunction findSnapshot(\n component: Type<any>,\n s: ActivatedRouteSnapshot\n): ActivatedRouteSnapshot {\n if (s.routeConfig && s.routeConfig.component === component) {\n return s;\n }\n for (const c of s.children) {\n const ss = findSnapshot(component, c);\n if (ss) {\n return ss;\n }\n }\n return null;\n}\n\nfunction wrapIntoObservable<O>(obj: Observable<O> | O | void): Observable<O> {\n if (isObservable(obj)) {\n return obj;\n } else if (!obj) {\n return of();\n } else {\n return of(obj as O);\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { DataPersistence } from './data-persistence';\n\n/**\n * @whatItDoes Provides services for enterprise Angular applications.\n *\n * See {@link DataPersistence} for more information.\n *\n * @deprecated Use the individual operators instead. Will be removed in v15.\n */\n@NgModule({})\nexport class NxModule {\n static forRoot(): ModuleWithProviders<NxModule> {\n return { ngModule: NxModule, providers: [DataPersistence] };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;AAoDA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDG;AACG,SAAU,iBAAiB,CAC/B,IAAiC,EAAA;IAEjC,OAAO,CAAC,MAAgC,KAAwB;QAC9D,OAAO,MAAM,CAAC,IAAI,CAChB,iBAAiB,EAAE,EACnB,SAAS,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CACxD,CAAC;AACJ,KAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A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