@ngrx-traits/common 12.1.1 → 12.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/async-action/async-action.trait.d.ts +7 -2
  2. package/bundles/ngrx-traits-common.umd.js +155 -87
  3. package/bundles/ngrx-traits-common.umd.js.map +1 -1
  4. package/crud-entities/crud-entities.trait.d.ts +6 -2
  5. package/entities-pagination/entities-pagination.trait.d.ts +25 -11
  6. package/entities-pagination/entities-pagination.trait.reducer.d.ts +3 -2
  7. package/esm2015/async-action/async-action.trait.js +7 -2
  8. package/esm2015/async-action/async-action.trait.js.map +1 -1
  9. package/esm2015/crud-entities/crud-entities.trait.js +6 -2
  10. package/esm2015/crud-entities/crud-entities.trait.js.map +1 -1
  11. package/esm2015/entities-pagination/entities-pagination.trait.effects.js +3 -3
  12. package/esm2015/entities-pagination/entities-pagination.trait.effects.js.map +1 -1
  13. package/esm2015/entities-pagination/entities-pagination.trait.js +25 -11
  14. package/esm2015/entities-pagination/entities-pagination.trait.js.map +1 -1
  15. package/esm2015/entities-pagination/entities-pagination.trait.reducer.js +1 -1
  16. package/esm2015/entities-pagination/entities-pagination.trait.reducer.js.map +1 -1
  17. package/esm2015/filter-entities/filter-entities.trait.effect.js +3 -3
  18. package/esm2015/filter-entities/filter-entities.trait.effect.js.map +1 -1
  19. package/esm2015/filter-entities/filter-entities.trait.js +7 -2
  20. package/esm2015/filter-entities/filter-entities.trait.js.map +1 -1
  21. package/esm2015/load-entities/load-entities.trait.js +15 -10
  22. package/esm2015/load-entities/load-entities.trait.js.map +1 -1
  23. package/esm2015/load-entity/load-entity.traits.js +12 -6
  24. package/esm2015/load-entity/load-entity.traits.js.map +1 -1
  25. package/esm2015/reset/reset.trait.js +24 -21
  26. package/esm2015/reset/reset.trait.js.map +1 -1
  27. package/esm2015/select-entities/select-entities.trait.js +6 -2
  28. package/esm2015/select-entities/select-entities.trait.js.map +1 -1
  29. package/esm2015/select-entity/select-entity.trait.js +6 -2
  30. package/esm2015/select-entity/select-entity.trait.js.map +1 -1
  31. package/esm2015/set-entity/set-entity.trait.js +6 -3
  32. package/esm2015/set-entity/set-entity.trait.js.map +1 -1
  33. package/esm2015/sort-entities/sort-entities.trait.effect.js +3 -3
  34. package/esm2015/sort-entities/sort-entities.trait.effect.js.map +1 -1
  35. package/esm2015/sort-entities/sort-entities.trait.js +8 -2
  36. package/esm2015/sort-entities/sort-entities.trait.js.map +1 -1
  37. package/esm2015/sort-entities/sort-entities.utils.js +2 -0
  38. package/esm2015/sort-entities/sort-entities.utils.js.map +1 -1
  39. package/fesm2015/ngrx-traits-common.js +135 -74
  40. package/fesm2015/ngrx-traits-common.js.map +1 -1
  41. package/filter-entities/filter-entities.trait.d.ts +7 -2
  42. package/load-entities/load-entities.trait.d.ts +15 -10
  43. package/load-entity/load-entity.traits.d.ts +12 -6
  44. package/package.json +2 -2
  45. package/reset/reset.trait.d.ts +3 -2
  46. package/select-entities/select-entities.trait.d.ts +6 -2
  47. package/select-entity/select-entity.trait.d.ts +6 -2
  48. package/set-entity/set-entity.trait.d.ts +6 -3
  49. package/sort-entities/sort-entities.trait.d.ts +8 -2
  50. package/sort-entities/sort-entities.utils.d.ts +2 -0
@@ -19,7 +19,7 @@ import { FilterEntitiesConfig, FilterEntitiesSelectors } from './filter-entities
19
19
  * // The following trait config
20
20
  *
21
21
  * export interface TestState
22
- * extends EntityAndStatusState<Todo>,FilterState<TodoFilter>{}
22
+ * extends LoadEntitiesState<Todo>, FilterEntitiesState<TodoFilter>{}
23
23
  *
24
24
  * const traits = createEntityFeatureFactory(
25
25
  * addLoadEntitiesTrait<Todo>(),
@@ -35,8 +35,13 @@ import { FilterEntitiesConfig, FilterEntitiesSelectors } from './filter-entities
35
35
  * 'todos',
36
36
  * ),
37
37
  * });
38
- * // will generate the following actions and selectors, plus the ones generated by other traits
38
+ *
39
+ * // adds following props to the state:
40
+ * // filters?: TodoFilter;
41
+ *
42
+ * // generated actions
39
43
  * traits.actions.filterTodos()
44
+ * // generated selectors
40
45
  * traits.selectors.selectTodosFilter()
41
46
  */
42
47
  export declare function addFilterEntitiesTrait<Entity, F>({ defaultDebounceTime, defaultFilter, filterFn, isRemoteFilter, }?: FilterEntitiesConfig<Entity, F>): import("@ngrx-traits/core").TraitFactory<import("../load-entities/load-entities.model").LoadEntitiesState<Entity> & import("./filter-entities.model").FilterEntitiesState<F>, import("./filter-entities.model").FilterEntitiesActions<F>, FilterEntitiesSelectors<Entity, F>, import("./filter-entities.model").FilterEntitiesMutators<Entity, F>, "filter", FilterEntitiesConfig<Entity, F>, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -1,11 +1,9 @@
1
1
  import { LoadEntitiesState, LoadEntitiesConfig } from './load-entities.model';
2
2
  /**
3
- * Generates the ngrx code needed to load a list of entities from the backend
4
- * with a load[EntitiesName], load[EntitiesName]Success, load[EntitiesName]Fail actions, and selectors to query the
5
- * entities like selectEntity[EntitiesName]List, selectEntity[EntitiesName]Ids, selectEntity[EntitiesName]Map, and its progress loading
6
- * with isLoading[EntitiesName],isLoading[EntitiesName]Success, isLoading[EntitiesName]Fail. This trait is the base for all other traits related
7
- * to a list of entities, the other will call loadEntities when needing data.
8
- * @param traitConfig - Config object fot the trait factory
3
+ * Generates the ngrx code needed to load a list of entities from the backend. This trait is the base for all other traits related
4
+ * to a list of entities, the other will call loadEntities when needing data. See the example for the list of actions and selectors this generates
5
+ *
6
+ * @param traitConfig - Config object for the trait factory
9
7
  * @param traitConfig.selectId - Function that returns the id of an entity
10
8
  * @param traitConfig.sortComparer - Default sort function for to @ngrx/entity EntityAdapter
11
9
  *
@@ -24,16 +22,23 @@ import { LoadEntitiesState, LoadEntitiesConfig } from './load-entities.model';
24
22
  * 'todos',
25
23
  * ),
26
24
  * });
27
- * // will generate the actions and selectors
25
+ *
26
+ * // adds following props to the state:
27
+ * // ids: string[] | number[];
28
+ * // entities: Dictionary<Todo>;
29
+ * // status?: 'loading' | 'success' | 'fail';
30
+ *
31
+ * // generated actions
28
32
  * traits.actions.loadTodos()
29
33
  * traits.actions.loadTodosSuccess({entities: todos})
30
34
  * traits.actions.loadTodosFail();
35
+ * // generated selectors
31
36
  * traits.selectors.selectTodosList
32
37
  * traits.selectors.selectTodosMap
33
38
  * traits.selectors.selectTodosIds
34
39
  * traits.selectors.selectTodosTotal
35
- * traits.selectors.isLoadingTodos
36
- * traits.selectors.isSuccessTodosSuccess
37
- * traits.selectors.isFailTodosFail
40
+ * traits.selectors.isTodosLoading
41
+ * traits.selectors.isTodosLoadingSuccess
42
+ * traits.selectors.isTodosLoadingFail
38
43
  */
39
44
  export declare function addLoadEntitiesTrait<Entity>(traitConfig?: Omit<LoadEntitiesConfig<Entity>, 'adapter'>): import("@ngrx-traits/core").TraitFactory<LoadEntitiesState<Entity>, import("./load-entities.model").LoadEntitiesActions<Entity>, import("./load-entities.model").LoadEntitiesSelectors<Entity>, import("./load-entities.model").LoadEntitiesMutators<Entity>, "loadEntities", LoadEntitiesConfig<Entity>, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -2,7 +2,8 @@ import { ActionCreatorProps } from '@ngrx/store/src/models';
2
2
  import { LoadEntityState } from './load-entity.model';
3
3
  declare type RecordEntity<T> = T extends Record<string, infer J> ? J : never;
4
4
  /**
5
- * Generates ngrx code needed to load and entity and store it in a state
5
+ * Generates ngrx code needed to load and entity and store it in a state. This action can be added
6
+ * more than once as long as the entityName para is different
6
7
  * @param entityName - Entity name, should be in camel case
7
8
  * @param options.actionProps - Optional param for the main request action,
8
9
  * use the props() function for its value, if not present action will have no params,
@@ -26,14 +27,19 @@ declare type RecordEntity<T> = T extends Record<string, infer J> ? J : never;
26
27
  * >('client'),
27
28
  * });
28
29
  *
29
- * // will generate
30
+ * // adds following props to the state:
31
+ * // loadClientStatus?: 'loading' | 'success' | 'fail';
32
+ * // client?: Client;
33
+ *
34
+ * // generated actions
30
35
  * traits.actions.loadClient({id:123});
31
36
  * traits.actions.loadClientSuccess({client: {id: '123', name: 'gabs'}});
32
37
  * traits.actions.loadClientFail();
33
- * traits.selectors.selectClient
34
- * traits.selectors.isLoadingLoadClient
35
- * traits.selectors.isSuccessLoadClient
36
- * traits.selectors.isFailLoadClient
38
+ * // generated selectors
39
+ * traits.selectors.selectClient()
40
+ * traits.selectors.isLoadingLoadClient()
41
+ * traits.selectors.isSuccessLoadClient()
42
+ * traits.selectors.isFailLoadClient()
37
43
  */
38
44
  export declare function addLoadEntityTraits<J extends string, Request extends object | undefined = undefined, Response extends Record<J, any> | undefined = undefined, Failure extends object | undefined = undefined, Entity = RecordEntity<Response>, State = LoadEntityState<Entity, J>>({ entityName, actionProps, actionSuccessProps, actionFailProps, }: {
39
45
  entityName: J;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrx-traits/common",
3
- "version": "12.1.1",
3
+ "version": "12.1.2",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^12.0.0",
6
6
  "@angular/compiler": "^12.0.0",
@@ -8,7 +8,7 @@
8
8
  "@ngrx/effects": "^12.2.0",
9
9
  "@ngrx/entity": "^12.2.0",
10
10
  "@ngrx/store": "^12.2.0",
11
- "@ngrx-traits/core": "12.1.1",
11
+ "@ngrx-traits/core": "12.1.2",
12
12
  "rxjs": "~6.6.0"
13
13
  },
14
14
  "repository": {
@@ -1,4 +1,5 @@
1
1
  import { GenericActionCreator } from '../load-entities';
2
+ import { ActionCreator, TypedAction } from '@ngrx/store/src/models';
2
3
  /**
3
4
  * Generates the ngrx code needed to reset the current state to the initial state.
4
5
  * @param traitConfig - Config object fot the trait factory
@@ -20,13 +21,13 @@ import { GenericActionCreator } from '../load-entities';
20
21
  * 'todos',
21
22
  * ),
22
23
  * });
23
- * // will generate the following actions, plus the ones generated by other traits
24
+ * // generated actions
24
25
  * traits.actions.resetTodosState()
25
26
  */
26
27
  export declare function addResetEntitiesStateTrait(traitConfig?: {
27
28
  resetOn?: GenericActionCreator[];
28
29
  }): import("@ngrx-traits/core").TraitFactory<{}, {
29
- resetEntitiesState: import("@ngrx/store").ActionCreator<string, () => import("@ngrx/store/src/models").TypedAction<string>>;
30
+ resetEntitiesState: ActionCreator<string, () => TypedAction<string>>;
30
31
  }, {}, {}, "reset", {
31
32
  resetOn?: GenericActionCreator[] | undefined;
32
33
  }, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -17,13 +17,17 @@ import { SelectEntitiesSelectors, SelectEntitiesActions } from './select-entitie
17
17
  * 'todos',
18
18
  * ),
19
19
  * });
20
- * // will generate the following actions and selectors, plus the ones generated by other traits
20
+ *
21
+ * // adds following props to the state:
22
+ * // selectedIds: Dictionary<boolean>;
23
+ *
24
+ * // generated actions
21
25
  * traits.actions.selectTodos({id})
22
26
  * traits.actions.deselectTodos({id})
23
27
  * traits.actions.toggleSectTodos({id})
24
28
  * traits.actions.toggleSelectAllTodos()
25
29
  * traits.actions.clearTodosSelection()
26
- *
30
+ * //generated selectors
27
31
  * traits.selectors.isAllTodosSelected()
28
32
  * traits.selectors.selectTodosIdsSelectedMap()
29
33
  * traits.selectors.selectTodosIdsSelectedList()
@@ -19,11 +19,15 @@ import { SelectEntityActions, SelectEntityConfig } from './select-entity.model';
19
19
  * 'todos',
20
20
  * ),
21
21
  * });
22
- * // will generate the following actions and selectors, plus the ones generated by other traits
22
+ *
23
+ * // adds following props to the state:
24
+ * // selectedId?: number | string;
25
+ *
26
+ * // generated actions
23
27
  * traits.actions.selectTodo({id})
24
28
  * traits.actions.deselectTodo()
25
29
  * traits.actions.toggleSelectTodo({id})
26
- *
30
+ * //generated selectors
27
31
  * traits.selectors.selectTodoIdSelected()
28
32
  * traits.selectors.selectTodoSelected()
29
33
  */
@@ -12,7 +12,7 @@ declare type RecordEntity<T> = T extends Record<string, infer J> ? J : never;
12
12
  * const traits = createEntityFeatureFactory(
13
13
  * addSetEntityTraits({
14
14
  * entityName: 'client',
15
- * actionProps: props<{ client: { id: number; name: string } }
15
+ * actionProps: props<{ client: Client }
16
16
  * }),
17
17
  * )({
18
18
  * actionsGroupKey: 'Client',
@@ -20,10 +20,13 @@ declare type RecordEntity<T> = T extends Record<string, infer J> ? J : never;
20
20
  * SetEntityState<Client, 'client'>
21
21
  * >('client'),
22
22
  * });
23
+ * // adds following props to the state:
24
+ * // client?: Client;
23
25
  *
24
- * // will generate
26
+ * // generated actions
25
27
  * traits.actions.setClient({client: {id:123, name: 'gabs'}});
26
- * traits.selectors.selectClient
28
+ * //generated selectors
29
+ * traits.selectors.selectClient()
27
30
  */
28
31
  export declare function addSetEntityTrait<J extends string, Payload extends Record<J, any> | undefined = undefined, Entity = RecordEntity<Payload>, State = SetEntityState<Entity, J>>({ entityName, actionProps, }: {
29
32
  entityName: J;
@@ -24,10 +24,16 @@ import { SortEntitiesActions, SortEntitiesConfig, SortEntitiesSelectors } from '
24
24
  * 'todos',
25
25
  * ),
26
26
  * });
27
- * // will generate the following actions and selectors, plus the ones generated by other traits
27
+ * // adds following props to the state:
28
+ * // sort: {
29
+ * // current: Sort<Todo>;
30
+ * // default: Sort<Todo>;
31
+ * // }
32
+ *
33
+ * // generated actions
28
34
  * traits.actions.sortTodos({active:'id', direction:'desc'})
29
35
  * traits.actions.resetTodosSort()
30
- *
36
+ * //generated selectors
31
37
  * traits.selectors.selectTodosSort()
32
38
  */
33
39
  export declare function addSortEntitiesTrait<Entity>({ remote, defaultSort, }: SortEntitiesConfig<Entity>): import("@ngrx-traits/core").TraitFactory<import("../load-entities/load-entities.model").LoadEntitiesState<Entity> & import("./sort-entities.model").SortEntitiesState<Entity>, SortEntitiesActions<Entity>, SortEntitiesSelectors<Entity>, import("./sort-entities.model").SortEntitiesMutators<Entity>, "sort", SortEntitiesConfig<Entity>, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -1,6 +1,8 @@
1
1
  import { Sort } from './sort-entities.model';
2
2
  export declare function _isNumberValue(value: any): boolean;
3
3
  /**
4
+ * @internal
5
+ * @ignore
4
6
  * Gets a sorted copy of the data array based on the state of the Sort.
5
7
  * @param data The array of data that should be sorted.
6
8
  * @param sort The connected MatSort that holds the current sort state.