@ngdux/form 0.1.9 → 1.1.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.
@@ -3,7 +3,10 @@ export { RequestState } from '@ngdux/data-model-common';
3
3
  import { createEffect, ofType } from '@ngrx/effects';
4
4
  import { of } from 'rxjs';
5
5
  import { switchMap, map, catchError, exhaustMap, tap } from 'rxjs/operators';
6
- import { createAction, props, createReducer, on, createSelector, createFeatureSelector } from '@ngrx/store';
6
+ import * as i0 from '@angular/core';
7
+ import { InjectionToken, Injectable, Inject } from '@angular/core';
8
+ import * as i1 from '@ngrx/store';
9
+ import { createAction, props, createReducer, on, createSelector, createFeatureSelector, select } from '@ngrx/store';
7
10
  import { createRequestStateActionHandlers, createLoadingStateActionHandlers } from '@ngdux/store-common';
8
11
 
9
12
  class AbstractFormEffects {
@@ -14,15 +17,32 @@ class AbstractFormEffects {
14
17
  this.formActions = formActions;
15
18
  this.notificationService = notificationService;
16
19
  this.load$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.load), switchMap(({ id }) => this.service.loadResource(id).pipe(map(resource => this.formActions.loadSuccess({ resource })), catchError((errors) => of(this.formActions.loadFailure({ errors })))))));
17
- this.create$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.create), switchMap(action => this.service.createResource(action.resource).pipe(map(resource => this.formActions.createSuccess({ resource })), catchError((errors) => of(this.formActions.createFailure({ errors })))))));
18
- this.update$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.save), switchMap(({ resource }) => this.service.saveResource(resource).pipe(map(response => this.formActions.saveSuccess({ resource: response })), catchError((errors) => of(this.formActions.saveFailure({ errors })))))));
19
- this.delete$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.delete), exhaustMap(action => this.service.deleteResource(action.id).pipe(map(() => this.formActions.deleteSuccess({ id: action.id })), catchError((errors) => of(this.formActions.deleteFailure({ errors })))))));
20
+ this.create$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.create), switchMap(action => {
21
+ if (!this.service.createResource) {
22
+ throw new Error('createResource not implement in the ListService');
23
+ }
24
+ return this.service.createResource(action.resource).pipe(map(resource => this.formActions.createSuccess({ resource })), catchError((errors) => of(this.formActions.createFailure({ errors }))));
25
+ })));
26
+ this.update$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.save), switchMap(({ resource }) => {
27
+ if (!this.service.saveResource) {
28
+ throw new Error('saveResource not implement in the ListService');
29
+ }
30
+ return this.service.saveResource(resource).pipe(map(response => this.formActions.saveSuccess({ resource: response })), catchError((errors) => of(this.formActions.saveFailure({ errors }))));
31
+ })));
32
+ this.delete$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.delete), exhaustMap(action => {
33
+ if (!this.service.deleteResource) {
34
+ throw new Error('deleteResource not implement in the ListService');
35
+ }
36
+ return this.service.deleteResource(action.id).pipe(map(() => this.formActions.deleteSuccess({ id: action.id })), catchError((errors) => of(this.formActions.deleteFailure({ errors }))));
37
+ })));
20
38
  this.errorsHandler$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.saveFailure, this.formActions.loadFailure, this.formActions.deleteFailure, this.formActions.createFailure), tap(({ errors }) => {
21
39
  this.notificationService.onFormErrors(errors);
22
40
  })), { dispatch: false });
23
41
  }
24
42
  }
25
43
 
44
+ const FORM_FEATURE_KEY = new InjectionToken('FORM_FEATURE_KEY');
45
+
26
46
  function createFormActions(featureName) {
27
47
  const load = createAction(`[${featureName} API] Load ${featureName}`, props());
28
48
  const loadSuccess = createAction(`[${featureName} API] Load ${featureName} Success`, props());
@@ -93,6 +113,67 @@ function createFormSelectors(getFormState) {
93
113
  };
94
114
  }
95
115
 
116
+ class AbstractFormReducerManager {
117
+ constructor(reducerManager, featureKey) {
118
+ this.reducerManager = reducerManager;
119
+ this.featureKey = featureKey;
120
+ this.actions = this.getActions();
121
+ this.addReducer();
122
+ this.selectors = this.getSelectors();
123
+ }
124
+ getActions() {
125
+ return createFormActions(this.featureKey);
126
+ }
127
+ addReducer() {
128
+ if (!this.reducerManager.currentReducers[this.featureKey]) {
129
+ const reducer = createFormReducer(this.actions);
130
+ this.reducerManager.addReducer(this.featureKey, reducer);
131
+ }
132
+ }
133
+ getSelectors() {
134
+ const getState = createFeatureSelector(this.featureKey);
135
+ return createFormSelectors(getState);
136
+ }
137
+ }
138
+ AbstractFormReducerManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AbstractFormReducerManager, deps: [{ token: i1.ReducerManager }, { token: FORM_FEATURE_KEY }], target: i0.ɵɵFactoryTarget.Injectable });
139
+ AbstractFormReducerManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AbstractFormReducerManager });
140
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AbstractFormReducerManager, decorators: [{
141
+ type: Injectable
142
+ }], ctorParameters: function () {
143
+ return [{ type: i1.ReducerManager }, { type: undefined, decorators: [{
144
+ type: Inject,
145
+ args: [FORM_FEATURE_KEY]
146
+ }] }];
147
+ } });
148
+
149
+ class AbstractFormFacade {
150
+ constructor(store, formActions, formSelectors) {
151
+ this.store = store;
152
+ this.formActions = formActions;
153
+ this.formSelectors = formSelectors;
154
+ this.resource$ = this.store.pipe(select(this.formSelectors.getResource));
155
+ this.loadingState$ = this.store.pipe(select(this.formSelectors.getLoadingState));
156
+ this.requestState$ = this.store.pipe(select(this.formSelectors.getRequestState));
157
+ this.errors$ = this.store.pipe(select(this.formSelectors.getErrors));
158
+ this.isReady$ = this.store.pipe(select(this.formSelectors.isReady));
159
+ }
160
+ create(props) {
161
+ this.store.dispatch(this.formActions.create(props));
162
+ }
163
+ load(props) {
164
+ this.store.dispatch(this.formActions.load(props));
165
+ }
166
+ save(props) {
167
+ this.store.dispatch(this.formActions.save(props));
168
+ }
169
+ delete(props) {
170
+ this.store.dispatch(this.formActions.delete(props));
171
+ }
172
+ reset() {
173
+ this.store.dispatch(this.formActions.reset());
174
+ }
175
+ }
176
+
96
177
  function createFormState(featureName) {
97
178
  const actions = createFormActions(featureName);
98
179
  const reducer = createFormReducer(actions);
@@ -109,5 +190,5 @@ function createFormState(featureName) {
109
190
  * Generated bundle index. Do not edit.
110
191
  */
111
192
 
112
- export { AbstractFormEffects, createFormActions, createFormReducer, createFormSelectors, createFormState };
193
+ export { AbstractFormEffects, AbstractFormFacade, AbstractFormReducerManager, FORM_FEATURE_KEY, createFormActions, createFormReducer, createFormSelectors, createFormState };
113
194
  //# sourceMappingURL=ngdux-form.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngdux-form.mjs","sources":["../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form-effects.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-actions.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-reducer.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-selectors.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-state.ts","../../../../../../../libs/ngdux/util/store/form/src/ngdux-form.ts"],"sourcesContent":["import { FormNotificationService, FormService } from '@ngdux/data-model-common';\nimport { Actions, createEffect, ofType } from '@ngrx/effects';\nimport { Store } from '@ngrx/store';\nimport { of } from 'rxjs';\nimport { catchError, exhaustMap, map, switchMap, tap } from 'rxjs/operators';\nimport { FormActions } from '../models/form.model';\n\nexport abstract class AbstractFormEffects<T, E> {\n load$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.load),\n switchMap(({ id }) =>\n this.service.loadResource(id).pipe(\n map(resource => this.formActions.loadSuccess({ resource })),\n catchError((errors: E) => of(this.formActions.loadFailure({ errors })))\n )\n )\n )\n );\n\n create$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.create),\n switchMap(action =>\n this.service.createResource(action.resource).pipe(\n map(resource => this.formActions.createSuccess({ resource })),\n catchError((errors: E) => of(this.formActions.createFailure({ errors })))\n )\n )\n )\n );\n\n update$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.save),\n switchMap(({ resource }) =>\n this.service.saveResource(resource).pipe(\n map(response => this.formActions.saveSuccess({ resource: response })),\n catchError((errors: E) => of(this.formActions.saveFailure({ errors })))\n )\n )\n )\n );\n\n delete$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.delete),\n exhaustMap(action =>\n this.service.deleteResource(action.id).pipe(\n map(() => this.formActions.deleteSuccess({ id: action.id })),\n catchError((errors: E) => of(this.formActions.deleteFailure({ errors })))\n )\n )\n )\n );\n\n errorsHandler$ = createEffect(\n () =>\n this.actions$.pipe(\n ofType(\n this.formActions.saveFailure,\n this.formActions.loadFailure,\n this.formActions.deleteFailure,\n this.formActions.createFailure\n ),\n tap(({ errors }) => {\n this.notificationService.onFormErrors(errors);\n })\n ),\n { dispatch: false }\n );\n\n protected constructor(\n protected readonly actions$: Actions,\n protected readonly store: Store,\n private readonly service: FormService<T>,\n private readonly formActions: FormActions<T, E>,\n private readonly notificationService: FormNotificationService<E>\n ) {}\n}\n","import { createAction, props } from '@ngrx/store';\nimport { FormActions } from '../models/form.model';\n\nexport function createFormActions<T, E>(featureName: string): FormActions<T, E> {\n const load = createAction(`[${featureName} API] Load ${featureName}`, props<{ id: string }>());\n const loadSuccess = createAction(`[${featureName} API] Load ${featureName} Success`, props<{ resource: T }>());\n const loadFailure = createAction(`[${featureName} API] Load ${featureName} Failure`, props<{ errors: E }>());\n\n const save = createAction(`[${featureName} API] Save ${featureName}`, props<{ resource: T }>());\n const saveSuccess = createAction(`[${featureName} API] Save ${featureName} Success`, props<{ resource: T }>());\n const saveFailure = createAction(`[${featureName} API] Save ${featureName} Failure`, props<{ errors: E }>());\n\n const deleteAction = createAction(`[${featureName} API] Delete ${featureName}`, props<{ id: string }>());\n const deleteSuccess = createAction(`[${featureName} API] Delete ${featureName} Success`, props<{ id: string }>());\n const deleteFailure = createAction(`[${featureName} API] Delete ${featureName} Failure`, props<{ errors: E }>());\n\n const create = createAction(`[${featureName} API] Create ${featureName}`, props<{ resource: T }>());\n const createSuccess = createAction(`[${featureName} API] Create ${featureName} Success`, props<{ resource: T }>());\n const createFailure = createAction(`[${featureName} API] Create ${featureName} Failure`, props<{ errors: E }>());\n\n const reset = createAction(`[${featureName} API] Reset ${featureName}`);\n\n return {\n load,\n loadSuccess,\n loadFailure,\n save,\n saveSuccess,\n saveFailure,\n delete: deleteAction,\n deleteSuccess,\n deleteFailure,\n create,\n createSuccess,\n createFailure,\n reset\n };\n}\n","import { RequestState } from '@ngdux/data-model-common';\nimport { createLoadingStateActionHandlers, createRequestStateActionHandlers } from '@ngdux/store-common';\nimport { ActionCreator, ActionReducer, createReducer, Creator, on, ReducerTypes } from '@ngrx/store';\nimport { FormActions, FormState } from '../models/form.model';\n\nexport function createFormReducer<T, E>(\n actions: FormActions<T, E>,\n actionHandlers?: ReducerTypes<FormState<T, E>, ActionCreator[]>[],\n initialFormState?: object\n): ActionReducer<FormState<T, E>> {\n const initialState: FormState<T, E> = { ...createInitialFormState<T, E>(), ...initialFormState };\n return createReducer<FormState<T, E>>(\n initialState,\n ...createFormActionHandlers<T, E>(initialState, actions),\n ...(actionHandlers || [])\n );\n}\n\nfunction createInitialFormState<T, E>(): FormState<T, E> {\n return {\n resource: undefined,\n loadingState: RequestState.IDLE,\n requestState: RequestState.IDLE,\n errors: undefined\n };\n}\n\nfunction createFormActionHandlers<T, E>(\n initialFormState: FormState<T, E>,\n actions: FormActions<T, E>\n): ReducerTypes<FormState<T, E>, ActionCreator<string, Creator<any[], object>>[]>[] {\n return [\n on(actions.reset, (): FormState<T, E> => initialFormState),\n on(\n actions.loadSuccess,\n actions.createSuccess,\n actions.saveSuccess,\n (state: FormState<T, E>, { resource }): FormState<T, E> => ({ ...state, resource })\n ),\n on(\n actions.deleteSuccess,\n (state: FormState<T, E>): FormState<T, E> => ({\n ...state,\n resource: undefined\n })\n ),\n ...createRequestStateActionHandlers<FormState<T, E>, E>(\n actions.load,\n actions.save,\n actions.saveSuccess,\n actions.saveFailure\n ),\n ...createRequestStateActionHandlers<FormState<T, E>, E>(\n undefined,\n actions.create,\n actions.createSuccess,\n actions.createFailure\n ),\n ...createRequestStateActionHandlers<FormState<T, E>, E>(\n undefined,\n actions.delete,\n actions.deleteSuccess,\n actions.deleteFailure\n ),\n ...createLoadingStateActionHandlers<FormState<T, E>>(actions.load, actions.loadSuccess, actions.loadFailure)\n ];\n}\n","import { RequestState } from '@ngdux/data-model-common';\nimport { createSelector, DefaultProjectorFn, MemoizedSelector } from '@ngrx/store';\nimport { FormSelectors, FormState } from '../models/form.model';\n\nexport function createFormSelectors<T, E>(\n getFormState: MemoizedSelector<object, FormState<T, E>, DefaultProjectorFn<FormState<T, E>>>\n): FormSelectors<T, E> {\n const getRequestState = createSelector(getFormState, state => state.requestState);\n const getLoadingState = createSelector(getFormState, state => state.loadingState);\n const getErrors = createSelector(getFormState, state => state.errors);\n const getResource = createSelector(getFormState, state => state.resource);\n\n const isReady = createSelector(\n getResource,\n getLoadingState,\n (resource, loadingState) => !!resource && loadingState === RequestState.SUCCESS\n );\n\n return {\n getRequestState,\n getLoadingState,\n getErrors,\n getResource,\n isReady\n };\n}\n","import { Action, createFeatureSelector } from '@ngrx/store';\nimport { FormState } from '../models/form.model';\nimport { createFormActions } from './form-actions';\nimport { createFormReducer } from './form-reducer';\nimport { createFormSelectors } from './form-selectors';\n\nexport function createFormState<T, E>(featureName: string) {\n const actions = createFormActions<T, E>(featureName);\n const reducer = createFormReducer(actions);\n const getState = createFeatureSelector<FormState<T, E>>(featureName);\n const selectors = createFormSelectors(getState);\n\n return {\n actions,\n reducer: (state: FormState<T, E>, action: Action): FormState<T, E> => reducer(state, action),\n selectors\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;MAOsB,mBAAmB,CAAA;IAiEvC,WACqB,CAAA,QAAiB,EACjB,KAAY,EACd,OAAuB,EACvB,WAA8B,EAC9B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version":3,"file":"ngdux-form.mjs","sources":["../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form-effects.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/models/form.model.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-actions.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-reducer.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-selectors.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form-state.service.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form.facade.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-state.ts","../../../../../../../libs/ngdux/util/store/form/src/ngdux-form.ts"],"sourcesContent":["import { FormNotificationService, FormService } from '@ngdux/data-model-common';\r\nimport { Actions, createEffect, ofType } from '@ngrx/effects';\r\nimport { Store } from '@ngrx/store';\r\nimport { of } from 'rxjs';\r\nimport { catchError, exhaustMap, map, switchMap, tap } from 'rxjs/operators';\r\nimport { FormActions } from '../models/form.model';\r\n\r\nexport abstract class AbstractFormEffects<DTO, ERROR, CREATE_DTO = DTO> {\r\n load$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.load),\r\n switchMap(({ id }) =>\r\n this.service.loadResource(id).pipe(\r\n map(resource => this.formActions.loadSuccess({ resource })),\r\n catchError((errors: ERROR) => of(this.formActions.loadFailure({ errors })))\r\n )\r\n )\r\n )\r\n );\r\n\r\n create$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.create),\r\n switchMap(action => {\r\n if (!this.service.createResource) {\r\n throw new Error('createResource not implement in the ListService');\r\n }\r\n\r\n return this.service.createResource(action.resource).pipe(\r\n map(resource => this.formActions.createSuccess({ resource })),\r\n catchError((errors: ERROR) => of(this.formActions.createFailure({ errors })))\r\n );\r\n })\r\n )\r\n );\r\n\r\n update$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.save),\r\n switchMap(({ resource }) => {\r\n if (!this.service.saveResource) {\r\n throw new Error('saveResource not implement in the ListService');\r\n }\r\n\r\n return this.service.saveResource(resource).pipe(\r\n map(response => this.formActions.saveSuccess({ resource: response })),\r\n catchError((errors: ERROR) => of(this.formActions.saveFailure({ errors })))\r\n );\r\n })\r\n )\r\n );\r\n\r\n delete$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.delete),\r\n exhaustMap(action => {\r\n if (!this.service.deleteResource) {\r\n throw new Error('deleteResource not implement in the ListService');\r\n }\r\n\r\n return this.service.deleteResource(action.id).pipe(\r\n map(() => this.formActions.deleteSuccess({ id: action.id })),\r\n catchError((errors: ERROR) => of(this.formActions.deleteFailure({ errors })))\r\n );\r\n })\r\n )\r\n );\r\n\r\n errorsHandler$ = createEffect(\r\n () =>\r\n this.actions$.pipe(\r\n ofType(\r\n this.formActions.saveFailure,\r\n this.formActions.loadFailure,\r\n this.formActions.deleteFailure,\r\n this.formActions.createFailure\r\n ),\r\n tap(({ errors }) => {\r\n this.notificationService.onFormErrors(errors);\r\n })\r\n ),\r\n { dispatch: false }\r\n );\r\n\r\n protected constructor(\r\n protected readonly actions$: Actions,\r\n protected readonly store: Store,\r\n private readonly service: FormService<DTO, CREATE_DTO>,\r\n private readonly formActions: FormActions<DTO, ERROR, CREATE_DTO>,\r\n private readonly notificationService: FormNotificationService<ERROR>\r\n ) {}\r\n}\r\n","import { InjectionToken } from '@angular/core';\r\nimport { RequestState } from '@ngdux/data-model-common';\r\nimport { ApiRequestState, LoadingState } from '@ngdux/store-common';\r\nimport { ActionCreator, MemoizedSelector } from '@ngrx/store';\r\nimport { TypedAction } from '@ngrx/store/src/models';\r\n\r\nexport const FORM_FEATURE_KEY = new InjectionToken<string>('FORM_FEATURE_KEY');\r\n\r\nexport interface FormState<T, E> extends ApiRequestState<E>, LoadingState {\r\n resource?: T;\r\n}\r\n\r\nexport interface FormSelectors<T, E> {\r\n getRequestState: MemoizedSelector<object, RequestState>;\r\n getLoadingState: MemoizedSelector<object, RequestState>;\r\n getErrors: MemoizedSelector<object, E | undefined>;\r\n getResource: MemoizedSelector<object, T | undefined>;\r\n isReady: MemoizedSelector<object, boolean>;\r\n}\r\n\r\nexport interface FormActions<DTO, ERROR, CREATE_DTO = DTO> {\r\n load: ActionCreator<string, (props: { id: string }) => { id: string } & TypedAction<string>>;\r\n loadSuccess: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n loadFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n save: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n saveSuccess: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n saveFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n delete: ActionCreator<string, (props: { id: string }) => { id: string } & TypedAction<string>>;\r\n deleteSuccess: ActionCreator<string, (props: { id: string }) => { id: string } & TypedAction<string>>;\r\n deleteFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n create: ActionCreator<string, (props: { resource: CREATE_DTO }) => { resource: CREATE_DTO } & TypedAction<string>>;\r\n createSuccess: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n createFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n reset: ActionCreator<string, () => TypedAction<string>>;\r\n}\r\n","import { createAction, props } from '@ngrx/store';\r\nimport { FormActions } from '../models/form.model';\r\n\r\nexport function createFormActions<DTO, ERROR, CREATE_DTO = DTO>(\r\n featureName: string\r\n): FormActions<DTO, ERROR, CREATE_DTO> {\r\n const load = createAction(`[${featureName} API] Load ${featureName}`, props<{ id: string }>());\r\n const loadSuccess = createAction(`[${featureName} API] Load ${featureName} Success`, props<{ resource: DTO }>());\r\n const loadFailure = createAction(`[${featureName} API] Load ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const save = createAction(`[${featureName} API] Save ${featureName}`, props<{ resource: DTO }>());\r\n const saveSuccess = createAction(`[${featureName} API] Save ${featureName} Success`, props<{ resource: DTO }>());\r\n const saveFailure = createAction(`[${featureName} API] Save ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const deleteAction = createAction(`[${featureName} API] Delete ${featureName}`, props<{ id: string }>());\r\n const deleteSuccess = createAction(`[${featureName} API] Delete ${featureName} Success`, props<{ id: string }>());\r\n const deleteFailure = createAction(`[${featureName} API] Delete ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const create = createAction(`[${featureName} API] Create ${featureName}`, props<{ resource: CREATE_DTO }>());\r\n const createSuccess = createAction(`[${featureName} API] Create ${featureName} Success`, props<{ resource: DTO }>());\r\n const createFailure = createAction(`[${featureName} API] Create ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const reset = createAction(`[${featureName} API] Reset ${featureName}`);\r\n\r\n return {\r\n load,\r\n loadSuccess,\r\n loadFailure,\r\n save,\r\n saveSuccess,\r\n saveFailure,\r\n delete: deleteAction,\r\n deleteSuccess,\r\n deleteFailure,\r\n create,\r\n createSuccess,\r\n createFailure,\r\n reset\r\n };\r\n}\r\n","import { RequestState } from '@ngdux/data-model-common';\r\nimport { createLoadingStateActionHandlers, createRequestStateActionHandlers } from '@ngdux/store-common';\r\nimport { ActionCreator, ActionReducer, Creator, ReducerTypes, createReducer, on } from '@ngrx/store';\r\nimport { FormActions, FormState } from '../models/form.model';\r\n\r\nexport function createFormReducer<DTO, ERROR, CREATE_DTO = DTO>(\r\n actions: FormActions<DTO, ERROR, CREATE_DTO>,\r\n actionHandlers?: ReducerTypes<FormState<DTO, ERROR>, ActionCreator[]>[],\r\n initialFormState?: Record<string, any>\r\n): ActionReducer<FormState<DTO, ERROR>> {\r\n const initialState: FormState<DTO, ERROR> = { ...createInitialFormState<DTO, ERROR>(), ...initialFormState };\r\n return createReducer<FormState<DTO, ERROR>>(\r\n initialState,\r\n ...createFormActionHandlers<DTO, ERROR, CREATE_DTO>(initialState, actions),\r\n ...(actionHandlers || [])\r\n );\r\n}\r\n\r\nfunction createInitialFormState<DTO, ERROR>(): FormState<DTO, ERROR> {\r\n return {\r\n resource: undefined,\r\n loadingState: RequestState.IDLE,\r\n requestState: RequestState.IDLE,\r\n errors: undefined\r\n };\r\n}\r\n\r\nfunction createFormActionHandlers<DTO, ERROR, CREATE_DTO = DTO>(\r\n initialFormState: FormState<DTO, ERROR>,\r\n actions: FormActions<DTO, ERROR, CREATE_DTO>\r\n): ReducerTypes<FormState<DTO, ERROR>, ActionCreator<string, Creator<any[], object>>[]>[] {\r\n return [\r\n on(actions.reset, (): FormState<DTO, ERROR> => initialFormState),\r\n on(\r\n actions.loadSuccess,\r\n actions.createSuccess,\r\n actions.saveSuccess,\r\n (state: FormState<DTO, ERROR>, { resource }): FormState<DTO, ERROR> => ({ ...state, resource })\r\n ),\r\n on(\r\n actions.deleteSuccess,\r\n (state: FormState<DTO, ERROR>): FormState<DTO, ERROR> => ({\r\n ...state,\r\n resource: undefined\r\n })\r\n ),\r\n ...createRequestStateActionHandlers<FormState<DTO, ERROR>, ERROR>(\r\n actions.load,\r\n actions.save,\r\n actions.saveSuccess,\r\n actions.saveFailure\r\n ),\r\n ...createRequestStateActionHandlers<FormState<DTO, ERROR>, ERROR>(\r\n undefined,\r\n actions.create,\r\n actions.createSuccess,\r\n actions.createFailure\r\n ),\r\n ...createRequestStateActionHandlers<FormState<DTO, ERROR>, ERROR>(\r\n undefined,\r\n actions.delete,\r\n actions.deleteSuccess,\r\n actions.deleteFailure\r\n ),\r\n ...createLoadingStateActionHandlers<FormState<DTO, ERROR>>(actions.load, actions.loadSuccess, actions.loadFailure)\r\n ];\r\n}\r\n","import { RequestState } from '@ngdux/data-model-common';\r\nimport { createSelector, DefaultProjectorFn, MemoizedSelector } from '@ngrx/store';\r\nimport { FormSelectors, FormState } from '../models/form.model';\r\n\r\nexport function createFormSelectors<T, E>(\r\n getFormState: MemoizedSelector<object, FormState<T, E>, DefaultProjectorFn<FormState<T, E>>>\r\n): FormSelectors<T, E> {\r\n const getRequestState = createSelector(getFormState, state => state.requestState);\r\n const getLoadingState = createSelector(getFormState, state => state.loadingState);\r\n const getErrors = createSelector(getFormState, state => state.errors);\r\n const getResource = createSelector(getFormState, state => state.resource);\r\n\r\n const isReady = createSelector(\r\n getResource,\r\n getLoadingState,\r\n (resource, loadingState) => !!resource && loadingState === RequestState.SUCCESS\r\n );\r\n\r\n return {\r\n getRequestState,\r\n getLoadingState,\r\n getErrors,\r\n getResource,\r\n isReady\r\n };\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { ReducerManager, createFeatureSelector } from '@ngrx/store';\r\nimport { FORM_FEATURE_KEY, FormActions, FormSelectors, FormState } from '../models/form.model';\r\nimport { createFormActions } from './form-actions';\r\nimport { createFormReducer } from './form-reducer';\r\nimport { createFormSelectors } from './form-selectors';\r\n\r\n@Injectable()\r\nexport abstract class AbstractFormReducerManager<DTO, ERROR, CREATE_DTO = DTO> {\r\n actions: FormActions<DTO, ERROR, CREATE_DTO>;\r\n selectors: FormSelectors<DTO, ERROR>;\r\n\r\n constructor(\r\n private readonly reducerManager: ReducerManager,\r\n @Inject(FORM_FEATURE_KEY) private readonly featureKey: string\r\n ) {\r\n this.actions = this.getActions();\r\n this.addReducer();\r\n this.selectors = this.getSelectors();\r\n }\r\n\r\n protected getActions() {\r\n return createFormActions<DTO, ERROR, CREATE_DTO>(this.featureKey);\r\n }\r\n\r\n protected addReducer() {\r\n if (!this.reducerManager.currentReducers[this.featureKey]) {\r\n const reducer = createFormReducer(this.actions);\r\n this.reducerManager.addReducer(this.featureKey, reducer);\r\n }\r\n }\r\n\r\n protected getSelectors() {\r\n const getState = createFeatureSelector<FormState<DTO, ERROR>>(this.featureKey);\r\n return createFormSelectors(getState);\r\n }\r\n}\r\n","import { ActionPayload } from '@ngdux/store-common';\r\nimport { select, Store } from '@ngrx/store';\r\nimport { FormActions, FormSelectors } from '../models/form.model';\r\n\r\nexport abstract class AbstractFormFacade<DTO, E, CREATE_DTO = DTO> {\r\n readonly resource$ = this.store.pipe(select(this.formSelectors.getResource));\r\n readonly loadingState$ = this.store.pipe(select(this.formSelectors.getLoadingState));\r\n readonly requestState$ = this.store.pipe(select(this.formSelectors.getRequestState));\r\n readonly errors$ = this.store.pipe(select(this.formSelectors.getErrors));\r\n readonly isReady$ = this.store.pipe(select(this.formSelectors.isReady));\r\n\r\n constructor(\r\n protected readonly store: Store,\r\n private readonly formActions: FormActions<DTO, E, CREATE_DTO>,\r\n private readonly formSelectors: FormSelectors<DTO, E>\r\n ) {}\r\n\r\n create(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['create']>): void {\r\n this.store.dispatch(this.formActions.create(props));\r\n }\r\n\r\n load(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['load']>): void {\r\n this.store.dispatch(this.formActions.load(props));\r\n }\r\n\r\n save(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['save']>): void {\r\n this.store.dispatch(this.formActions.save(props));\r\n }\r\n\r\n delete(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['delete']>): void {\r\n this.store.dispatch(this.formActions.delete(props));\r\n }\r\n\r\n reset(): void {\r\n this.store.dispatch(this.formActions.reset());\r\n }\r\n}\r\n","import { Action, createFeatureSelector } from '@ngrx/store';\r\nimport { FormState } from '../models/form.model';\r\nimport { createFormActions } from './form-actions';\r\nimport { createFormReducer } from './form-reducer';\r\nimport { createFormSelectors } from './form-selectors';\r\n\r\nexport function createFormState<DTO, ERROR, CREATE_DTO = DTO>(featureName: string) {\r\n const actions = createFormActions<DTO, ERROR, CREATE_DTO>(featureName);\r\n const reducer = createFormReducer(actions);\r\n const getState = createFeatureSelector<FormState<DTO, ERROR>>(featureName);\r\n const selectors = createFormSelectors(getState);\r\n\r\n return {\r\n actions,\r\n reducer: (state: FormState<DTO, ERROR>, action: Action): FormState<DTO, ERROR> => reducer(state, action),\r\n selectors\r\n };\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAOsB,mBAAmB,CAAA;IA6EvC,WACqB,CAAA,QAAiB,EACjB,KAAY,EACd,OAAqC,EACrC,WAAgD,EAChD,mBAAmD,EAAA;AAJjD,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAS;AACjB,QAAA,IAAK,CAAA,KAAA,GAAL,KAAK,CAAO;AACd,QAAA,IAAO,CAAA,OAAA,GAAP,OAAO,CAA8B;AACrC,QAAA,IAAW,CAAA,WAAA,GAAX,WAAW,CAAqC;AAChD,QAAA,IAAmB,CAAA,mBAAA,GAAnB,mBAAmB,CAAgC;AAjFtE,QAAA,IAAA,CAAA,KAAK,GAAG,YAAY,CAAC,MACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAChB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAC7B,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,KACf,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,IAAI,CAChC,GAAG,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAC3D,UAAU,CAAC,CAAC,MAAa,KAAK,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAC5E,CACF,CACF,CACF,CAAC;QAEF,IAAO,CAAA,OAAA,GAAG,YAAY,CAAC,MACrB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAChB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAC/B,SAAS,CAAC,MAAM,IAAG;AACjB,YAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;AAChC,gBAAA,MAAM,IAAI,KAAK,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,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACrD;AAED,IAAA,IAAI,CAAC,KAA6D,EAAA;AAChE,QAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACnD;AAED,IAAA,IAAI,CAAC,KAA6D,EAAA;AAChE,QAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACnD;AAED,IAAA,MAAM,CAAC,KAA+D,EAAA;AACpE,QAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;KACrD;IAED,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;KAC/C;AACF;;AC9BK,SAAU,eAAe,CAA+B,WAAmB,EAAA;AAC/E,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAyB,WAAW,CAAC,CAAC;AACvE,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC3C,IAAA,MAAM,QAAQ,GAAG,qBAAqB,CAAwB,WAAW,CAAC,CAAC;AAC3E,IAAA,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO;QACL,OAAO;AACP,QAAA,OAAO,EAAE,CAAC,KAA4B,EAAE,MAAc,KAA4B,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;QACxG,SAAS;KACV,CAAC;AACJ;;ACjBA;;AAEG;;;;"}
@@ -3,7 +3,10 @@ export { RequestState } from '@ngdux/data-model-common';
3
3
  import { createEffect, ofType } from '@ngrx/effects';
4
4
  import { of } from 'rxjs';
5
5
  import { switchMap, map, catchError, exhaustMap, tap } from 'rxjs/operators';
6
- import { createAction, props, createReducer, on, createSelector, createFeatureSelector } from '@ngrx/store';
6
+ import * as i0 from '@angular/core';
7
+ import { InjectionToken, Injectable, Inject } from '@angular/core';
8
+ import * as i1 from '@ngrx/store';
9
+ import { createAction, props, createReducer, on, createSelector, createFeatureSelector, select } from '@ngrx/store';
7
10
  import { createRequestStateActionHandlers, createLoadingStateActionHandlers } from '@ngdux/store-common';
8
11
 
9
12
  class AbstractFormEffects {
@@ -14,15 +17,32 @@ class AbstractFormEffects {
14
17
  this.formActions = formActions;
15
18
  this.notificationService = notificationService;
16
19
  this.load$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.load), switchMap(({ id }) => this.service.loadResource(id).pipe(map(resource => this.formActions.loadSuccess({ resource })), catchError((errors) => of(this.formActions.loadFailure({ errors })))))));
17
- this.create$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.create), switchMap(action => this.service.createResource(action.resource).pipe(map(resource => this.formActions.createSuccess({ resource })), catchError((errors) => of(this.formActions.createFailure({ errors })))))));
18
- this.update$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.save), switchMap(({ resource }) => this.service.saveResource(resource).pipe(map(response => this.formActions.saveSuccess({ resource: response })), catchError((errors) => of(this.formActions.saveFailure({ errors })))))));
19
- this.delete$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.delete), exhaustMap(action => this.service.deleteResource(action.id).pipe(map(() => this.formActions.deleteSuccess({ id: action.id })), catchError((errors) => of(this.formActions.deleteFailure({ errors })))))));
20
+ this.create$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.create), switchMap(action => {
21
+ if (!this.service.createResource) {
22
+ throw new Error('createResource not implement in the ListService');
23
+ }
24
+ return this.service.createResource(action.resource).pipe(map(resource => this.formActions.createSuccess({ resource })), catchError((errors) => of(this.formActions.createFailure({ errors }))));
25
+ })));
26
+ this.update$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.save), switchMap(({ resource }) => {
27
+ if (!this.service.saveResource) {
28
+ throw new Error('saveResource not implement in the ListService');
29
+ }
30
+ return this.service.saveResource(resource).pipe(map(response => this.formActions.saveSuccess({ resource: response })), catchError((errors) => of(this.formActions.saveFailure({ errors }))));
31
+ })));
32
+ this.delete$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.delete), exhaustMap(action => {
33
+ if (!this.service.deleteResource) {
34
+ throw new Error('deleteResource not implement in the ListService');
35
+ }
36
+ return this.service.deleteResource(action.id).pipe(map(() => this.formActions.deleteSuccess({ id: action.id })), catchError((errors) => of(this.formActions.deleteFailure({ errors }))));
37
+ })));
20
38
  this.errorsHandler$ = createEffect(() => this.actions$.pipe(ofType(this.formActions.saveFailure, this.formActions.loadFailure, this.formActions.deleteFailure, this.formActions.createFailure), tap(({ errors }) => {
21
39
  this.notificationService.onFormErrors(errors);
22
40
  })), { dispatch: false });
23
41
  }
24
42
  }
25
43
 
44
+ const FORM_FEATURE_KEY = new InjectionToken('FORM_FEATURE_KEY');
45
+
26
46
  function createFormActions(featureName) {
27
47
  const load = createAction(`[${featureName} API] Load ${featureName}`, props());
28
48
  const loadSuccess = createAction(`[${featureName} API] Load ${featureName} Success`, props());
@@ -96,6 +116,65 @@ function createFormSelectors(getFormState) {
96
116
  };
97
117
  }
98
118
 
119
+ class AbstractFormReducerManager {
120
+ constructor(reducerManager, featureKey) {
121
+ this.reducerManager = reducerManager;
122
+ this.featureKey = featureKey;
123
+ this.actions = this.getActions();
124
+ this.addReducer();
125
+ this.selectors = this.getSelectors();
126
+ }
127
+ getActions() {
128
+ return createFormActions(this.featureKey);
129
+ }
130
+ addReducer() {
131
+ if (!this.reducerManager.currentReducers[this.featureKey]) {
132
+ const reducer = createFormReducer(this.actions);
133
+ this.reducerManager.addReducer(this.featureKey, reducer);
134
+ }
135
+ }
136
+ getSelectors() {
137
+ const getState = createFeatureSelector(this.featureKey);
138
+ return createFormSelectors(getState);
139
+ }
140
+ }
141
+ AbstractFormReducerManager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AbstractFormReducerManager, deps: [{ token: i1.ReducerManager }, { token: FORM_FEATURE_KEY }], target: i0.ɵɵFactoryTarget.Injectable });
142
+ AbstractFormReducerManager.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AbstractFormReducerManager });
143
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: AbstractFormReducerManager, decorators: [{
144
+ type: Injectable
145
+ }], ctorParameters: function () { return [{ type: i1.ReducerManager }, { type: undefined, decorators: [{
146
+ type: Inject,
147
+ args: [FORM_FEATURE_KEY]
148
+ }] }]; } });
149
+
150
+ class AbstractFormFacade {
151
+ constructor(store, formActions, formSelectors) {
152
+ this.store = store;
153
+ this.formActions = formActions;
154
+ this.formSelectors = formSelectors;
155
+ this.resource$ = this.store.pipe(select(this.formSelectors.getResource));
156
+ this.loadingState$ = this.store.pipe(select(this.formSelectors.getLoadingState));
157
+ this.requestState$ = this.store.pipe(select(this.formSelectors.getRequestState));
158
+ this.errors$ = this.store.pipe(select(this.formSelectors.getErrors));
159
+ this.isReady$ = this.store.pipe(select(this.formSelectors.isReady));
160
+ }
161
+ create(props) {
162
+ this.store.dispatch(this.formActions.create(props));
163
+ }
164
+ load(props) {
165
+ this.store.dispatch(this.formActions.load(props));
166
+ }
167
+ save(props) {
168
+ this.store.dispatch(this.formActions.save(props));
169
+ }
170
+ delete(props) {
171
+ this.store.dispatch(this.formActions.delete(props));
172
+ }
173
+ reset() {
174
+ this.store.dispatch(this.formActions.reset());
175
+ }
176
+ }
177
+
99
178
  function createFormState(featureName) {
100
179
  const actions = createFormActions(featureName);
101
180
  const reducer = createFormReducer(actions);
@@ -112,5 +191,5 @@ function createFormState(featureName) {
112
191
  * Generated bundle index. Do not edit.
113
192
  */
114
193
 
115
- export { AbstractFormEffects, createFormActions, createFormReducer, createFormSelectors, createFormState };
194
+ export { AbstractFormEffects, AbstractFormFacade, AbstractFormReducerManager, FORM_FEATURE_KEY, createFormActions, createFormReducer, createFormSelectors, createFormState };
116
195
  //# sourceMappingURL=ngdux-form.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ngdux-form.mjs","sources":["../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form-effects.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-actions.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-reducer.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-selectors.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-state.ts","../../../../../../../libs/ngdux/util/store/form/src/ngdux-form.ts"],"sourcesContent":["import { FormNotificationService, FormService } from '@ngdux/data-model-common';\nimport { Actions, createEffect, ofType } from '@ngrx/effects';\nimport { Store } from '@ngrx/store';\nimport { of } from 'rxjs';\nimport { catchError, exhaustMap, map, switchMap, tap } from 'rxjs/operators';\nimport { FormActions } from '../models/form.model';\n\nexport abstract class AbstractFormEffects<T, E> {\n load$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.load),\n switchMap(({ id }) =>\n this.service.loadResource(id).pipe(\n map(resource => this.formActions.loadSuccess({ resource })),\n catchError((errors: E) => of(this.formActions.loadFailure({ errors })))\n )\n )\n )\n );\n\n create$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.create),\n switchMap(action =>\n this.service.createResource(action.resource).pipe(\n map(resource => this.formActions.createSuccess({ resource })),\n catchError((errors: E) => of(this.formActions.createFailure({ errors })))\n )\n )\n )\n );\n\n update$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.save),\n switchMap(({ resource }) =>\n this.service.saveResource(resource).pipe(\n map(response => this.formActions.saveSuccess({ resource: response })),\n catchError((errors: E) => of(this.formActions.saveFailure({ errors })))\n )\n )\n )\n );\n\n delete$ = createEffect(() =>\n this.actions$.pipe(\n ofType(this.formActions.delete),\n exhaustMap(action =>\n this.service.deleteResource(action.id).pipe(\n map(() => this.formActions.deleteSuccess({ id: action.id })),\n catchError((errors: E) => of(this.formActions.deleteFailure({ errors })))\n )\n )\n )\n );\n\n errorsHandler$ = createEffect(\n () =>\n this.actions$.pipe(\n ofType(\n this.formActions.saveFailure,\n this.formActions.loadFailure,\n this.formActions.deleteFailure,\n this.formActions.createFailure\n ),\n tap(({ errors }) => {\n this.notificationService.onFormErrors(errors);\n })\n ),\n { dispatch: false }\n );\n\n protected constructor(\n protected readonly actions$: Actions,\n protected readonly store: Store,\n private readonly service: FormService<T>,\n private readonly formActions: FormActions<T, E>,\n private readonly notificationService: FormNotificationService<E>\n ) {}\n}\n","import { createAction, props } from '@ngrx/store';\nimport { FormActions } from '../models/form.model';\n\nexport function createFormActions<T, E>(featureName: string): FormActions<T, E> {\n const load = createAction(`[${featureName} API] Load ${featureName}`, props<{ id: string }>());\n const loadSuccess = createAction(`[${featureName} API] Load ${featureName} Success`, props<{ resource: T }>());\n const loadFailure = createAction(`[${featureName} API] Load ${featureName} Failure`, props<{ errors: E }>());\n\n const save = createAction(`[${featureName} API] Save ${featureName}`, props<{ resource: T }>());\n const saveSuccess = createAction(`[${featureName} API] Save ${featureName} Success`, props<{ resource: T }>());\n const saveFailure = createAction(`[${featureName} API] Save ${featureName} Failure`, props<{ errors: E }>());\n\n const deleteAction = createAction(`[${featureName} API] Delete ${featureName}`, props<{ id: string }>());\n const deleteSuccess = createAction(`[${featureName} API] Delete ${featureName} Success`, props<{ id: string }>());\n const deleteFailure = createAction(`[${featureName} API] Delete ${featureName} Failure`, props<{ errors: E }>());\n\n const create = createAction(`[${featureName} API] Create ${featureName}`, props<{ resource: T }>());\n const createSuccess = createAction(`[${featureName} API] Create ${featureName} Success`, props<{ resource: T }>());\n const createFailure = createAction(`[${featureName} API] Create ${featureName} Failure`, props<{ errors: E }>());\n\n const reset = createAction(`[${featureName} API] Reset ${featureName}`);\n\n return {\n load,\n loadSuccess,\n loadFailure,\n save,\n saveSuccess,\n saveFailure,\n delete: deleteAction,\n deleteSuccess,\n deleteFailure,\n create,\n createSuccess,\n createFailure,\n reset\n };\n}\n","import { RequestState } from '@ngdux/data-model-common';\nimport { createLoadingStateActionHandlers, createRequestStateActionHandlers } from '@ngdux/store-common';\nimport { ActionCreator, ActionReducer, createReducer, Creator, on, ReducerTypes } from '@ngrx/store';\nimport { FormActions, FormState } from '../models/form.model';\n\nexport function createFormReducer<T, E>(\n actions: FormActions<T, E>,\n actionHandlers?: ReducerTypes<FormState<T, E>, ActionCreator[]>[],\n initialFormState?: object\n): ActionReducer<FormState<T, E>> {\n const initialState: FormState<T, E> = { ...createInitialFormState<T, E>(), ...initialFormState };\n return createReducer<FormState<T, E>>(\n initialState,\n ...createFormActionHandlers<T, E>(initialState, actions),\n ...(actionHandlers || [])\n );\n}\n\nfunction createInitialFormState<T, E>(): FormState<T, E> {\n return {\n resource: undefined,\n loadingState: RequestState.IDLE,\n requestState: RequestState.IDLE,\n errors: undefined\n };\n}\n\nfunction createFormActionHandlers<T, E>(\n initialFormState: FormState<T, E>,\n actions: FormActions<T, E>\n): ReducerTypes<FormState<T, E>, ActionCreator<string, Creator<any[], object>>[]>[] {\n return [\n on(actions.reset, (): FormState<T, E> => initialFormState),\n on(\n actions.loadSuccess,\n actions.createSuccess,\n actions.saveSuccess,\n (state: FormState<T, E>, { resource }): FormState<T, E> => ({ ...state, resource })\n ),\n on(\n actions.deleteSuccess,\n (state: FormState<T, E>): FormState<T, E> => ({\n ...state,\n resource: undefined\n })\n ),\n ...createRequestStateActionHandlers<FormState<T, E>, E>(\n actions.load,\n actions.save,\n actions.saveSuccess,\n actions.saveFailure\n ),\n ...createRequestStateActionHandlers<FormState<T, E>, E>(\n undefined,\n actions.create,\n actions.createSuccess,\n actions.createFailure\n ),\n ...createRequestStateActionHandlers<FormState<T, E>, E>(\n undefined,\n actions.delete,\n actions.deleteSuccess,\n actions.deleteFailure\n ),\n ...createLoadingStateActionHandlers<FormState<T, E>>(actions.load, actions.loadSuccess, actions.loadFailure)\n ];\n}\n","import { RequestState } from '@ngdux/data-model-common';\nimport { createSelector, DefaultProjectorFn, MemoizedSelector } from '@ngrx/store';\nimport { FormSelectors, FormState } from '../models/form.model';\n\nexport function createFormSelectors<T, E>(\n getFormState: MemoizedSelector<object, FormState<T, E>, DefaultProjectorFn<FormState<T, E>>>\n): FormSelectors<T, E> {\n const getRequestState = createSelector(getFormState, state => state.requestState);\n const getLoadingState = createSelector(getFormState, state => state.loadingState);\n const getErrors = createSelector(getFormState, state => state.errors);\n const getResource = createSelector(getFormState, state => state.resource);\n\n const isReady = createSelector(\n getResource,\n getLoadingState,\n (resource, loadingState) => !!resource && loadingState === RequestState.SUCCESS\n );\n\n return {\n getRequestState,\n getLoadingState,\n getErrors,\n getResource,\n isReady\n };\n}\n","import { Action, createFeatureSelector } from '@ngrx/store';\nimport { FormState } from '../models/form.model';\nimport { createFormActions } from './form-actions';\nimport { createFormReducer } from './form-reducer';\nimport { createFormSelectors } from './form-selectors';\n\nexport function createFormState<T, E>(featureName: string) {\n const actions = createFormActions<T, E>(featureName);\n const reducer = createFormReducer(actions);\n const getState = createFeatureSelector<FormState<T, E>>(featureName);\n const selectors = createFormSelectors(getState);\n\n return {\n actions,\n reducer: (state: FormState<T, E>, action: Action): FormState<T, E> => reducer(state, action),\n selectors\n };\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;MAOsB,mBAAmB,CAAA;IAiEvC,WACqB,CAAA,QAAiB,EACjB,KAAY,EACd,OAAuB,EACvB,WAA8B,EAC9B,mBAA+C,EAAA;QAJ7C,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAS;QACjB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAO;QACd,IAAO,CAAA,OAAA,GAAP,OAAO,CAAgB;QACvB,IAAW,CAAA,WAAA,GAAX,WAAW,CAAmB;QAC9B,IAAmB,CAAA,mBAAA,GAAnB,mBAAmB,CAA4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AAC,YAAY,EAAE,KAAK,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACtE,IAAA,MAAM,WAAW,GAAG,cAAc,CAAC,YAAY,EAAE,KAAK,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC;IAE1E,MAAM,OAAO,GAAG,cAAc,CAC5B,WAAW,EACX,eAAe,EACf,CAAC,QAAQ,EAAE,YAAY,KAAK,CAAC,CAAC,QAAQ,IAAI,YAAY,KAAK,YAAY,CAAC,OAAO,CAChF,CAAC;IAEF,OAAO;QACL,eAAe;QACf,eAAe;QACf,SAAS;QACT,WAAW;QACX,OAAO;KACR,CAAC;AACJ;;ACnBM,SAAU,eAAe,CAAO,WAAmB,EAAA;AACvD,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAO,WAAW,CAAC,CAAC;AACrD,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC3C,IAAA,MAAM,QAAQ,GAAG,qBAAqB,CAAkB,WAAW,CAAC,CAAC;AACrE,IAAA,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO;QACL,OAAO;AACP,QAAA,OAAO,EAAE,CAAC,KAAsB,EAAE,MAAc,KAAsB,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;QAC5F,SAAS;KACV,CAAC;AACJ;;ACjBA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngdux-form.mjs","sources":["../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form-effects.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/models/form.model.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-actions.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-reducer.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-selectors.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form-state.service.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/abstract-form.facade.ts","../../../../../../../libs/ngdux/util/store/form/src/lib/+state/form-state.ts","../../../../../../../libs/ngdux/util/store/form/src/ngdux-form.ts"],"sourcesContent":["import { FormNotificationService, FormService } from '@ngdux/data-model-common';\r\nimport { Actions, createEffect, ofType } from '@ngrx/effects';\r\nimport { Store } from '@ngrx/store';\r\nimport { of } from 'rxjs';\r\nimport { catchError, exhaustMap, map, switchMap, tap } from 'rxjs/operators';\r\nimport { FormActions } from '../models/form.model';\r\n\r\nexport abstract class AbstractFormEffects<DTO, ERROR, CREATE_DTO = DTO> {\r\n load$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.load),\r\n switchMap(({ id }) =>\r\n this.service.loadResource(id).pipe(\r\n map(resource => this.formActions.loadSuccess({ resource })),\r\n catchError((errors: ERROR) => of(this.formActions.loadFailure({ errors })))\r\n )\r\n )\r\n )\r\n );\r\n\r\n create$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.create),\r\n switchMap(action => {\r\n if (!this.service.createResource) {\r\n throw new Error('createResource not implement in the ListService');\r\n }\r\n\r\n return this.service.createResource(action.resource).pipe(\r\n map(resource => this.formActions.createSuccess({ resource })),\r\n catchError((errors: ERROR) => of(this.formActions.createFailure({ errors })))\r\n );\r\n })\r\n )\r\n );\r\n\r\n update$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.save),\r\n switchMap(({ resource }) => {\r\n if (!this.service.saveResource) {\r\n throw new Error('saveResource not implement in the ListService');\r\n }\r\n\r\n return this.service.saveResource(resource).pipe(\r\n map(response => this.formActions.saveSuccess({ resource: response })),\r\n catchError((errors: ERROR) => of(this.formActions.saveFailure({ errors })))\r\n );\r\n })\r\n )\r\n );\r\n\r\n delete$ = createEffect(() =>\r\n this.actions$.pipe(\r\n ofType(this.formActions.delete),\r\n exhaustMap(action => {\r\n if (!this.service.deleteResource) {\r\n throw new Error('deleteResource not implement in the ListService');\r\n }\r\n\r\n return this.service.deleteResource(action.id).pipe(\r\n map(() => this.formActions.deleteSuccess({ id: action.id })),\r\n catchError((errors: ERROR) => of(this.formActions.deleteFailure({ errors })))\r\n );\r\n })\r\n )\r\n );\r\n\r\n errorsHandler$ = createEffect(\r\n () =>\r\n this.actions$.pipe(\r\n ofType(\r\n this.formActions.saveFailure,\r\n this.formActions.loadFailure,\r\n this.formActions.deleteFailure,\r\n this.formActions.createFailure\r\n ),\r\n tap(({ errors }) => {\r\n this.notificationService.onFormErrors(errors);\r\n })\r\n ),\r\n { dispatch: false }\r\n );\r\n\r\n protected constructor(\r\n protected readonly actions$: Actions,\r\n protected readonly store: Store,\r\n private readonly service: FormService<DTO, CREATE_DTO>,\r\n private readonly formActions: FormActions<DTO, ERROR, CREATE_DTO>,\r\n private readonly notificationService: FormNotificationService<ERROR>\r\n ) {}\r\n}\r\n","import { InjectionToken } from '@angular/core';\r\nimport { RequestState } from '@ngdux/data-model-common';\r\nimport { ApiRequestState, LoadingState } from '@ngdux/store-common';\r\nimport { ActionCreator, MemoizedSelector } from '@ngrx/store';\r\nimport { TypedAction } from '@ngrx/store/src/models';\r\n\r\nexport const FORM_FEATURE_KEY = new InjectionToken<string>('FORM_FEATURE_KEY');\r\n\r\nexport interface FormState<T, E> extends ApiRequestState<E>, LoadingState {\r\n resource?: T;\r\n}\r\n\r\nexport interface FormSelectors<T, E> {\r\n getRequestState: MemoizedSelector<object, RequestState>;\r\n getLoadingState: MemoizedSelector<object, RequestState>;\r\n getErrors: MemoizedSelector<object, E | undefined>;\r\n getResource: MemoizedSelector<object, T | undefined>;\r\n isReady: MemoizedSelector<object, boolean>;\r\n}\r\n\r\nexport interface FormActions<DTO, ERROR, CREATE_DTO = DTO> {\r\n load: ActionCreator<string, (props: { id: string }) => { id: string } & TypedAction<string>>;\r\n loadSuccess: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n loadFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n save: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n saveSuccess: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n saveFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n delete: ActionCreator<string, (props: { id: string }) => { id: string } & TypedAction<string>>;\r\n deleteSuccess: ActionCreator<string, (props: { id: string }) => { id: string } & TypedAction<string>>;\r\n deleteFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n create: ActionCreator<string, (props: { resource: CREATE_DTO }) => { resource: CREATE_DTO } & TypedAction<string>>;\r\n createSuccess: ActionCreator<string, (props: { resource: DTO }) => { resource: DTO } & TypedAction<string>>;\r\n createFailure: ActionCreator<string, (props: { errors: ERROR }) => { errors: ERROR } & TypedAction<string>>;\r\n\r\n reset: ActionCreator<string, () => TypedAction<string>>;\r\n}\r\n","import { createAction, props } from '@ngrx/store';\r\nimport { FormActions } from '../models/form.model';\r\n\r\nexport function createFormActions<DTO, ERROR, CREATE_DTO = DTO>(\r\n featureName: string\r\n): FormActions<DTO, ERROR, CREATE_DTO> {\r\n const load = createAction(`[${featureName} API] Load ${featureName}`, props<{ id: string }>());\r\n const loadSuccess = createAction(`[${featureName} API] Load ${featureName} Success`, props<{ resource: DTO }>());\r\n const loadFailure = createAction(`[${featureName} API] Load ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const save = createAction(`[${featureName} API] Save ${featureName}`, props<{ resource: DTO }>());\r\n const saveSuccess = createAction(`[${featureName} API] Save ${featureName} Success`, props<{ resource: DTO }>());\r\n const saveFailure = createAction(`[${featureName} API] Save ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const deleteAction = createAction(`[${featureName} API] Delete ${featureName}`, props<{ id: string }>());\r\n const deleteSuccess = createAction(`[${featureName} API] Delete ${featureName} Success`, props<{ id: string }>());\r\n const deleteFailure = createAction(`[${featureName} API] Delete ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const create = createAction(`[${featureName} API] Create ${featureName}`, props<{ resource: CREATE_DTO }>());\r\n const createSuccess = createAction(`[${featureName} API] Create ${featureName} Success`, props<{ resource: DTO }>());\r\n const createFailure = createAction(`[${featureName} API] Create ${featureName} Failure`, props<{ errors: ERROR }>());\r\n\r\n const reset = createAction(`[${featureName} API] Reset ${featureName}`);\r\n\r\n return {\r\n load,\r\n loadSuccess,\r\n loadFailure,\r\n save,\r\n saveSuccess,\r\n saveFailure,\r\n delete: deleteAction,\r\n deleteSuccess,\r\n deleteFailure,\r\n create,\r\n createSuccess,\r\n createFailure,\r\n reset\r\n };\r\n}\r\n","import { RequestState } from '@ngdux/data-model-common';\r\nimport { createLoadingStateActionHandlers, createRequestStateActionHandlers } from '@ngdux/store-common';\r\nimport { ActionCreator, ActionReducer, Creator, ReducerTypes, createReducer, on } from '@ngrx/store';\r\nimport { FormActions, FormState } from '../models/form.model';\r\n\r\nexport function createFormReducer<DTO, ERROR, CREATE_DTO = DTO>(\r\n actions: FormActions<DTO, ERROR, CREATE_DTO>,\r\n actionHandlers?: ReducerTypes<FormState<DTO, ERROR>, ActionCreator[]>[],\r\n initialFormState?: Record<string, any>\r\n): ActionReducer<FormState<DTO, ERROR>> {\r\n const initialState: FormState<DTO, ERROR> = { ...createInitialFormState<DTO, ERROR>(), ...initialFormState };\r\n return createReducer<FormState<DTO, ERROR>>(\r\n initialState,\r\n ...createFormActionHandlers<DTO, ERROR, CREATE_DTO>(initialState, actions),\r\n ...(actionHandlers || [])\r\n );\r\n}\r\n\r\nfunction createInitialFormState<DTO, ERROR>(): FormState<DTO, ERROR> {\r\n return {\r\n resource: undefined,\r\n loadingState: RequestState.IDLE,\r\n requestState: RequestState.IDLE,\r\n errors: undefined\r\n };\r\n}\r\n\r\nfunction createFormActionHandlers<DTO, ERROR, CREATE_DTO = DTO>(\r\n initialFormState: FormState<DTO, ERROR>,\r\n actions: FormActions<DTO, ERROR, CREATE_DTO>\r\n): ReducerTypes<FormState<DTO, ERROR>, ActionCreator<string, Creator<any[], object>>[]>[] {\r\n return [\r\n on(actions.reset, (): FormState<DTO, ERROR> => initialFormState),\r\n on(\r\n actions.loadSuccess,\r\n actions.createSuccess,\r\n actions.saveSuccess,\r\n (state: FormState<DTO, ERROR>, { resource }): FormState<DTO, ERROR> => ({ ...state, resource })\r\n ),\r\n on(\r\n actions.deleteSuccess,\r\n (state: FormState<DTO, ERROR>): FormState<DTO, ERROR> => ({\r\n ...state,\r\n resource: undefined\r\n })\r\n ),\r\n ...createRequestStateActionHandlers<FormState<DTO, ERROR>, ERROR>(\r\n actions.load,\r\n actions.save,\r\n actions.saveSuccess,\r\n actions.saveFailure\r\n ),\r\n ...createRequestStateActionHandlers<FormState<DTO, ERROR>, ERROR>(\r\n undefined,\r\n actions.create,\r\n actions.createSuccess,\r\n actions.createFailure\r\n ),\r\n ...createRequestStateActionHandlers<FormState<DTO, ERROR>, ERROR>(\r\n undefined,\r\n actions.delete,\r\n actions.deleteSuccess,\r\n actions.deleteFailure\r\n ),\r\n ...createLoadingStateActionHandlers<FormState<DTO, ERROR>>(actions.load, actions.loadSuccess, actions.loadFailure)\r\n ];\r\n}\r\n","import { RequestState } from '@ngdux/data-model-common';\r\nimport { createSelector, DefaultProjectorFn, MemoizedSelector } from '@ngrx/store';\r\nimport { FormSelectors, FormState } from '../models/form.model';\r\n\r\nexport function createFormSelectors<T, E>(\r\n getFormState: MemoizedSelector<object, FormState<T, E>, DefaultProjectorFn<FormState<T, E>>>\r\n): FormSelectors<T, E> {\r\n const getRequestState = createSelector(getFormState, state => state.requestState);\r\n const getLoadingState = createSelector(getFormState, state => state.loadingState);\r\n const getErrors = createSelector(getFormState, state => state.errors);\r\n const getResource = createSelector(getFormState, state => state.resource);\r\n\r\n const isReady = createSelector(\r\n getResource,\r\n getLoadingState,\r\n (resource, loadingState) => !!resource && loadingState === RequestState.SUCCESS\r\n );\r\n\r\n return {\r\n getRequestState,\r\n getLoadingState,\r\n getErrors,\r\n getResource,\r\n isReady\r\n };\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { ReducerManager, createFeatureSelector } from '@ngrx/store';\r\nimport { FORM_FEATURE_KEY, FormActions, FormSelectors, FormState } from '../models/form.model';\r\nimport { createFormActions } from './form-actions';\r\nimport { createFormReducer } from './form-reducer';\r\nimport { createFormSelectors } from './form-selectors';\r\n\r\n@Injectable()\r\nexport abstract class AbstractFormReducerManager<DTO, ERROR, CREATE_DTO = DTO> {\r\n actions: FormActions<DTO, ERROR, CREATE_DTO>;\r\n selectors: FormSelectors<DTO, ERROR>;\r\n\r\n constructor(\r\n private readonly reducerManager: ReducerManager,\r\n @Inject(FORM_FEATURE_KEY) private readonly featureKey: string\r\n ) {\r\n this.actions = this.getActions();\r\n this.addReducer();\r\n this.selectors = this.getSelectors();\r\n }\r\n\r\n protected getActions() {\r\n return createFormActions<DTO, ERROR, CREATE_DTO>(this.featureKey);\r\n }\r\n\r\n protected addReducer() {\r\n if (!this.reducerManager.currentReducers[this.featureKey]) {\r\n const reducer = createFormReducer(this.actions);\r\n this.reducerManager.addReducer(this.featureKey, reducer);\r\n }\r\n }\r\n\r\n protected getSelectors() {\r\n const getState = createFeatureSelector<FormState<DTO, ERROR>>(this.featureKey);\r\n return createFormSelectors(getState);\r\n }\r\n}\r\n","import { ActionPayload } from '@ngdux/store-common';\r\nimport { select, Store } from '@ngrx/store';\r\nimport { FormActions, FormSelectors } from '../models/form.model';\r\n\r\nexport abstract class AbstractFormFacade<DTO, E, CREATE_DTO = DTO> {\r\n readonly resource$ = this.store.pipe(select(this.formSelectors.getResource));\r\n readonly loadingState$ = this.store.pipe(select(this.formSelectors.getLoadingState));\r\n readonly requestState$ = this.store.pipe(select(this.formSelectors.getRequestState));\r\n readonly errors$ = this.store.pipe(select(this.formSelectors.getErrors));\r\n readonly isReady$ = this.store.pipe(select(this.formSelectors.isReady));\r\n\r\n constructor(\r\n protected readonly store: Store,\r\n private readonly formActions: FormActions<DTO, E, CREATE_DTO>,\r\n private readonly formSelectors: FormSelectors<DTO, E>\r\n ) {}\r\n\r\n create(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['create']>): void {\r\n this.store.dispatch(this.formActions.create(props));\r\n }\r\n\r\n load(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['load']>): void {\r\n this.store.dispatch(this.formActions.load(props));\r\n }\r\n\r\n save(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['save']>): void {\r\n this.store.dispatch(this.formActions.save(props));\r\n }\r\n\r\n delete(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['delete']>): void {\r\n this.store.dispatch(this.formActions.delete(props));\r\n }\r\n\r\n reset(): void {\r\n this.store.dispatch(this.formActions.reset());\r\n }\r\n}\r\n","import { Action, createFeatureSelector } from '@ngrx/store';\r\nimport { FormState } from '../models/form.model';\r\nimport { createFormActions } from './form-actions';\r\nimport { createFormReducer } from './form-reducer';\r\nimport { createFormSelectors } from './form-selectors';\r\n\r\nexport function createFormState<DTO, ERROR, CREATE_DTO = DTO>(featureName: string) {\r\n const actions = createFormActions<DTO, ERROR, CREATE_DTO>(featureName);\r\n const reducer = createFormReducer(actions);\r\n const getState = createFeatureSelector<FormState<DTO, ERROR>>(featureName);\r\n const selectors = createFormSelectors(getState);\r\n\r\n return {\r\n actions,\r\n reducer: (state: FormState<DTO, ERROR>, action: Action): FormState<DTO, ERROR> => reducer(state, action),\r\n selectors\r\n };\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;MAOsB,mBAAmB,CAAA;IA6EvC,WACqB,CAAA,QAAiB,EACjB,KAAY,EACd,OAAqC,EACrC,WAAgD,EAChD,mBAAmD,EAAA;QAJjD,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAS;QACjB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAO;QACd,IAAO,CAAA,OAAA,GAAP,OAAO,CAA8B;QACrC,IA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IAED,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,CAAC;KAC/C;AACF;;AC9BK,SAAU,eAAe,CAA+B,WAAmB,EAAA;AAC/E,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAyB,WAAW,CAAC,CAAC;AACvE,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;AAC3C,IAAA,MAAM,QAAQ,GAAG,qBAAqB,CAAwB,WAAW,CAAC,CAAC;AAC3E,IAAA,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAEhD,OAAO;QACL,OAAO;AACP,QAAA,OAAO,EAAE,CAAC,KAA4B,EAAE,MAAc,KAA4B,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC;QACxG,SAAS;KACV,CAAC;AACJ;;ACjBA;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { FormNotificationService, FormService, RequestState } from '@ngdux/data-model-common';
2
2
  export * from './lib/+state/abstract-form-effects';
3
+ export * from './lib/+state/abstract-form-state.service';
4
+ export * from './lib/+state/abstract-form.facade';
3
5
  export * from './lib/+state/form-actions';
4
6
  export * from './lib/+state/form-reducer';
5
7
  export * from './lib/+state/form-selectors';
@@ -2,40 +2,40 @@ import { FormNotificationService, FormService } from '@ngdux/data-model-common';
2
2
  import { Actions } from '@ngrx/effects';
3
3
  import { Store } from '@ngrx/store';
4
4
  import { FormActions } from '../models/form.model';
5
- export declare abstract class AbstractFormEffects<T, E> {
5
+ export declare abstract class AbstractFormEffects<DTO, ERROR, CREATE_DTO = DTO> {
6
6
  protected readonly actions$: Actions;
7
7
  protected readonly store: Store;
8
8
  private readonly service;
9
9
  private readonly formActions;
10
10
  private readonly notificationService;
11
11
  load$: import("rxjs").Observable<({
12
- resource: T;
12
+ resource: DTO;
13
13
  } & import("@ngrx/store/src/models").TypedAction<string>) | ({
14
- errors: E;
14
+ errors: ERROR;
15
15
  } & import("@ngrx/store/src/models").TypedAction<string>)> & import("@ngrx/effects").CreateEffectMetadata;
16
16
  create$: import("rxjs").Observable<({
17
- resource: T;
17
+ resource: DTO;
18
18
  } & import("@ngrx/store/src/models").TypedAction<string>) | ({
19
- errors: E;
19
+ errors: ERROR;
20
20
  } & import("@ngrx/store/src/models").TypedAction<string>)> & import("@ngrx/effects").CreateEffectMetadata;
21
21
  update$: import("rxjs").Observable<({
22
- resource: T;
22
+ resource: DTO;
23
23
  } & import("@ngrx/store/src/models").TypedAction<string>) | ({
24
- errors: E;
24
+ errors: ERROR;
25
25
  } & import("@ngrx/store/src/models").TypedAction<string>)> & import("@ngrx/effects").CreateEffectMetadata;
26
26
  delete$: import("rxjs").Observable<({
27
27
  id: string;
28
28
  } & import("@ngrx/store/src/models").TypedAction<string>) | ({
29
- errors: E;
29
+ errors: ERROR;
30
30
  } & import("@ngrx/store/src/models").TypedAction<string>)> & import("@ngrx/effects").CreateEffectMetadata;
31
31
  errorsHandler$: import("rxjs").Observable<({
32
- errors: E;
32
+ errors: ERROR;
33
33
  } & import("@ngrx/store/src/models").TypedAction<string>) | ({
34
- errors: E;
34
+ errors: ERROR;
35
35
  } & import("@ngrx/store/src/models").TypedAction<string>) | ({
36
- errors: E;
36
+ errors: ERROR;
37
37
  } & import("@ngrx/store/src/models").TypedAction<string>) | ({
38
- errors: E;
38
+ errors: ERROR;
39
39
  } & import("@ngrx/store/src/models").TypedAction<string>)> & import("@ngrx/effects").CreateEffectMetadata;
40
- protected constructor(actions$: Actions, store: Store, service: FormService<T>, formActions: FormActions<T, E>, notificationService: FormNotificationService<E>);
40
+ protected constructor(actions$: Actions, store: Store, service: FormService<DTO, CREATE_DTO>, formActions: FormActions<DTO, ERROR, CREATE_DTO>, notificationService: FormNotificationService<ERROR>);
41
41
  }
@@ -0,0 +1,15 @@
1
+ import { ReducerManager } from '@ngrx/store';
2
+ import { FormActions, FormSelectors } from '../models/form.model';
3
+ import * as i0 from "@angular/core";
4
+ export declare abstract class AbstractFormReducerManager<DTO, ERROR, CREATE_DTO = DTO> {
5
+ private readonly reducerManager;
6
+ private readonly featureKey;
7
+ actions: FormActions<DTO, ERROR, CREATE_DTO>;
8
+ selectors: FormSelectors<DTO, ERROR>;
9
+ constructor(reducerManager: ReducerManager, featureKey: string);
10
+ protected getActions(): FormActions<DTO, ERROR, CREATE_DTO>;
11
+ protected addReducer(): void;
12
+ protected getSelectors(): FormSelectors<DTO, ERROR>;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<AbstractFormReducerManager<any, any, any>, never>;
14
+ static ɵprov: i0.ɵɵInjectableDeclaration<AbstractFormReducerManager<any, any, any>>;
15
+ }
@@ -0,0 +1,19 @@
1
+ import { ActionPayload } from '@ngdux/store-common';
2
+ import { Store } from '@ngrx/store';
3
+ import { FormActions, FormSelectors } from '../models/form.model';
4
+ export declare abstract class AbstractFormFacade<DTO, E, CREATE_DTO = DTO> {
5
+ protected readonly store: Store;
6
+ private readonly formActions;
7
+ private readonly formSelectors;
8
+ readonly resource$: import("rxjs").Observable<DTO | undefined>;
9
+ readonly loadingState$: import("rxjs").Observable<import("@ngdux/data-model-common").RequestState>;
10
+ readonly requestState$: import("rxjs").Observable<import("@ngdux/data-model-common").RequestState>;
11
+ readonly errors$: import("rxjs").Observable<E | undefined>;
12
+ readonly isReady$: import("rxjs").Observable<boolean>;
13
+ constructor(store: Store, formActions: FormActions<DTO, E, CREATE_DTO>, formSelectors: FormSelectors<DTO, E>);
14
+ create(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['create']>): void;
15
+ load(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['load']>): void;
16
+ save(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['save']>): void;
17
+ delete(props: ActionPayload<FormActions<DTO, E, CREATE_DTO>['delete']>): void;
18
+ reset(): void;
19
+ }
@@ -1,2 +1,2 @@
1
1
  import { FormActions } from '../models/form.model';
2
- export declare function createFormActions<T, E>(featureName: string): FormActions<T, E>;
2
+ export declare function createFormActions<DTO, ERROR, CREATE_DTO = DTO>(featureName: string): FormActions<DTO, ERROR, CREATE_DTO>;
@@ -1,3 +1,3 @@
1
1
  import { ActionCreator, ActionReducer, ReducerTypes } from '@ngrx/store';
2
2
  import { FormActions, FormState } from '../models/form.model';
3
- export declare function createFormReducer<T, E>(actions: FormActions<T, E>, actionHandlers?: ReducerTypes<FormState<T, E>, ActionCreator[]>[], initialFormState?: object): ActionReducer<FormState<T, E>>;
3
+ export declare function createFormReducer<DTO, ERROR, CREATE_DTO = DTO>(actions: FormActions<DTO, ERROR, CREATE_DTO>, actionHandlers?: ReducerTypes<FormState<DTO, ERROR>, ActionCreator[]>[], initialFormState?: Record<string, any>): ActionReducer<FormState<DTO, ERROR>>;
@@ -1,7 +1,7 @@
1
1
  import { Action } from '@ngrx/store';
2
2
  import { FormState } from '../models/form.model';
3
- export declare function createFormState<T, E>(featureName: string): {
4
- actions: import("../models/form.model").FormActions<T, E>;
5
- reducer: (state: FormState<T, E>, action: Action) => FormState<T, E>;
6
- selectors: import("../models/form.model").FormSelectors<T, E>;
3
+ export declare function createFormState<DTO, ERROR, CREATE_DTO = DTO>(featureName: string): {
4
+ actions: import("../models/form.model").FormActions<DTO, ERROR, CREATE_DTO>;
5
+ reducer: (state: FormState<DTO, ERROR>, action: Action) => FormState<DTO, ERROR>;
6
+ selectors: import("../models/form.model").FormSelectors<DTO, ERROR>;
7
7
  };