@ngrx-traits/common 19.2.3 → 20.0.0-beta.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 (75) hide show
  1. package/README.md +1 -1
  2. package/fesm2022/ngrx-traits-common.mjs +13 -13
  3. package/fesm2022/ngrx-traits-common.mjs.map +1 -1
  4. package/index.d.ts +1023 -12
  5. package/package.json +2 -2
  6. package/async-action/async-action.model.d.ts +0 -19
  7. package/async-action/async-action.trait.d.ts +0 -68
  8. package/async-action/index.d.ts +0 -2
  9. package/crud-entities/crud-entities.model.d.ts +0 -74
  10. package/crud-entities/crud-entities.trait.actions.d.ts +0 -2
  11. package/crud-entities/crud-entities.trait.d.ts +0 -40
  12. package/crud-entities/crud-entities.trait.mutators.d.ts +0 -3
  13. package/crud-entities/crud-entities.trait.reducer.d.ts +0 -7
  14. package/crud-entities/crud-entities.trait.selectors.d.ts +0 -3
  15. package/crud-entities/index.d.ts +0 -2
  16. package/entities-pagination/entities-pagination.model.d.ts +0 -80
  17. package/entities-pagination/entities-pagination.model.internal.d.ts +0 -20
  18. package/entities-pagination/entities-pagination.trait.actions.d.ts +0 -2
  19. package/entities-pagination/entities-pagination.trait.d.ts +0 -69
  20. package/entities-pagination/entities-pagination.trait.effects.d.ts +0 -8
  21. package/entities-pagination/entities-pagination.trait.mutators.d.ts +0 -3
  22. package/entities-pagination/entities-pagination.trait.reducer.d.ts +0 -8
  23. package/entities-pagination/entities-pagination.trait.selectors.d.ts +0 -4
  24. package/entities-pagination/index.d.ts +0 -2
  25. package/entities-sync-to-route-query-params/entities-sync-to-route-query-params.d.ts +0 -30
  26. package/entities-sync-to-route-query-params/index.d.ts +0 -1
  27. package/filter-entities/filter-entities.model.d.ts +0 -57
  28. package/filter-entities/filter-entities.model.internal.d.ts +0 -14
  29. package/filter-entities/filter-entities.trait.actions.d.ts +0 -2
  30. package/filter-entities/filter-entities.trait.d.ts +0 -48
  31. package/filter-entities/filter-entities.trait.effect.d.ts +0 -6
  32. package/filter-entities/filter-entities.trait.mutators.d.ts +0 -2
  33. package/filter-entities/filter-entities.trait.reducer.d.ts +0 -5
  34. package/filter-entities/filter-entities.trait.selectors.d.ts +0 -4
  35. package/filter-entities/index.d.ts +0 -2
  36. package/load-entities/index.d.ts +0 -2
  37. package/load-entities/load-entities.model.d.ts +0 -97
  38. package/load-entities/load-entities.mutators.d.ts +0 -3
  39. package/load-entities/load-entities.trait.actions.d.ts +0 -2
  40. package/load-entities/load-entities.trait.d.ts +0 -44
  41. package/load-entities/load-entities.trait.reducer.d.ts +0 -4
  42. package/load-entities/load-entities.trait.selectors.d.ts +0 -3
  43. package/load-entities/load-entities.utils.d.ts +0 -4
  44. package/load-entity/index.d.ts +0 -2
  45. package/load-entity/load-entity.model.d.ts +0 -9
  46. package/load-entity/load-entity.traits.d.ts +0 -74
  47. package/reset/index.d.ts +0 -1
  48. package/reset/reset.trait.d.ts +0 -30
  49. package/select-entities/index.d.ts +0 -3
  50. package/select-entities/select-entities.model.d.ts +0 -42
  51. package/select-entities/select-entities.trait.actions.d.ts +0 -2
  52. package/select-entities/select-entities.trait.d.ts +0 -39
  53. package/select-entities/select-entities.trait.mutators.d.ts +0 -2
  54. package/select-entities/select-entities.trait.reducer.d.ts +0 -8
  55. package/select-entities/select-entities.trait.selectors.d.ts +0 -3
  56. package/select-entities/select-entities.utils.d.ts +0 -7
  57. package/select-entity/index.d.ts +0 -2
  58. package/select-entity/select-entity.model.d.ts +0 -34
  59. package/select-entity/select-entity.trait.actions.d.ts +0 -2
  60. package/select-entity/select-entity.trait.d.ts +0 -35
  61. package/select-entity/select-entity.trait.mutators.d.ts +0 -2
  62. package/select-entity/select-entity.trait.reducer.d.ts +0 -8
  63. package/select-entity/select-entity.trait.selectors.d.ts +0 -2
  64. package/set-entity/index.d.ts +0 -2
  65. package/set-entity/set-entity.model.d.ts +0 -17
  66. package/set-entity/set-entity.trait.d.ts +0 -46
  67. package/sort-entities/index.d.ts +0 -3
  68. package/sort-entities/sort-entities.model.d.ts +0 -36
  69. package/sort-entities/sort-entities.trait.actions.d.ts +0 -2
  70. package/sort-entities/sort-entities.trait.d.ts +0 -41
  71. package/sort-entities/sort-entities.trait.effect.d.ts +0 -6
  72. package/sort-entities/sort-entities.trait.mutators.d.ts +0 -3
  73. package/sort-entities/sort-entities.trait.reducer.d.ts +0 -4
  74. package/sort-entities/sort-entities.trait.selectors.d.ts +0 -2
  75. package/sort-entities/sort-entities.utils.d.ts +0 -10
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ngrx-traits/common",
3
- "version": "19.2.3",
3
+ "version": "20.0.0-beta.2",
4
4
  "peerDependencies": {
5
5
  "@angular/core": "^19.0.0",
6
6
  "@ngrx/effects": "^19.0.0",
7
7
  "@ngrx/entity": "^19.0.0",
8
8
  "@ngrx/store": "^19.0.0",
9
- "@ngrx-traits/core": "19.2.3"
9
+ "@ngrx-traits/core": "20.0.0-beta.2"
10
10
  },
11
11
  "optionalDependencies": {
12
12
  "@angular/router": "^19.0.0"
@@ -1,19 +0,0 @@
1
- import { PostfixProps, PrefixProps } from '@ngrx-traits/core';
2
- import { ActionCreator, NotAllowedCheck } from '@ngrx/store';
3
- import { Action } from '@ngrx/store/src/models';
4
- import { StatusState } from '../load-entities';
5
- export type ActionCreatorWithOptionalProps<T> = T extends undefined ? ActionCreator<string, () => Action<string>> : ActionCreator<string, (props: T & NotAllowedCheck<T & object>) => T & Action<string>>;
6
- type AsyncActions<Request, Response, Failure> = {
7
- '': ActionCreatorWithOptionalProps<Request>;
8
- Success: ActionCreatorWithOptionalProps<Response>;
9
- Fail: ActionCreatorWithOptionalProps<Failure>;
10
- };
11
- type StatusSelectors<S extends StatusState> = {
12
- isLoading: (state: S) => boolean;
13
- isSuccess: (state: S) => boolean;
14
- isFail: (state: S) => boolean;
15
- };
16
- export type AsyncActionState<J extends string> = PrefixProps<StatusState, J>;
17
- export type AsyncActionSelectors<J extends string, S extends StatusState> = PostfixProps<StatusSelectors<S>, J>;
18
- export type AsyncActionActions<Request, Response, Failure, J extends string> = PrefixProps<AsyncActions<Request, Response, Failure>, J>;
19
- export {};
@@ -1,68 +0,0 @@
1
- import { ActionCreatorProps } from '@ngrx/store/src/models';
2
- import { ActionCreatorWithOptionalProps } from './async-action.model';
3
- /**
4
- * Generates the typical ngrx code need to make a async action with
5
- * a request, success and failure actions, plus a status property to track its progress
6
- * and selectors to query the status. This trait can be added more thant once as long
7
- * as the name prop is different.
8
- *
9
- * @param options - Config object for the trait factory
10
- * @param options.name - Name of the main request action, should be in camel case
11
- * @param options.actionProps - Optional param for the main request action, use the props()
12
- * function for its value, if not present action will have no params,
13
- * @param options.actionSuccessProps - Optional param for the request success action,
14
- * use the props() function for its value, if not present action success will have no params
15
- * @param options.actionFailProps - Optional param for the request fail action,
16
- * use the props() function for its value, if not present action fail will have no params
17
- * @returns the trait factory
18
- *
19
- * @example
20
- *
21
- * export interface TestState
22
- * extends AsyncActionState<'createClient'>{}
23
- *
24
- * // The following trait config
25
- * const traits = createEntityFeatureFactory(
26
- * {entityName: 'Todo'},
27
- * addAsyncActionTrait({
28
- * name: 'createClient',
29
- * actionProps: props<{ name: string }>(),
30
- * actionSuccessProps: props<{ id: string }>(),
31
- * }),
32
- * )({
33
- * actionsGroupKey: 'Client',
34
- * featureSelector: createFeatureSelector<AsyncActionState<'createClient'>>(
35
- * 'client',
36
- * ),
37
- * });
38
- * // adds following props to the state:
39
- * // createClientStatus?: 'loading' | 'success' | 'fail';
40
- *
41
- * // generated actions
42
- * traits.actions.createClient({name:'Pedro'})
43
- * traits.actions.createClientSuccess({id:'123'})
44
- * traits.actions.createClientFail();
45
- * //generated selectors
46
- * traits.selectors.isLoadingCreateClient
47
- * traits.selectors.isSuccessCreateClient
48
- * traits.selectors.isFailCreateClient
49
- */
50
- export declare function addAsyncActionTrait<J extends string, Request extends object | undefined = undefined, Response extends object | undefined = undefined, Failure extends object | undefined = undefined>({ name, actionProps, actionSuccessProps, actionFailProps, }: {
51
- name: J;
52
- actionProps?: ActionCreatorProps<Request>;
53
- actionSuccessProps?: ActionCreatorProps<Response>;
54
- actionFailProps?: ActionCreatorProps<Failure>;
55
- }): import("@ngrx-traits/core").TraitFactory<import("@ngrx-traits/core").PrefixProps<import("@ngrx-traits/common").StatusState, J>, import("@ngrx-traits/core").PrefixProps<{
56
- '': ActionCreatorWithOptionalProps<Request>;
57
- Success: ActionCreatorWithOptionalProps<Response>;
58
- Fail: ActionCreatorWithOptionalProps<Failure>;
59
- }, J>, import("@ngrx-traits/core").PostfixProps<{
60
- isLoading: (state: import("@ngrx-traits/core").PrefixProps<import("@ngrx-traits/common").StatusState, J>) => boolean;
61
- isSuccess: (state: import("@ngrx-traits/core").PrefixProps<import("@ngrx-traits/common").StatusState, J>) => boolean;
62
- isFail: (state: import("@ngrx-traits/core").PrefixProps<import("@ngrx-traits/common").StatusState, J>) => boolean;
63
- }, J>, {}, string, {
64
- name: J;
65
- actionProps: ActionCreatorProps<Request> | undefined;
66
- actionSuccessProps: ActionCreatorProps<Response> | undefined;
67
- actionFailProps: ActionCreatorProps<Failure> | undefined;
68
- }, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -1,2 +0,0 @@
1
- export * from './async-action.model';
2
- export * from './async-action.trait';
@@ -1,74 +0,0 @@
1
- import { Predicate, Update } from '@ngrx/entity/src/models';
2
- import { ActionCreator } from '@ngrx/store';
3
- import { Action } from '@ngrx/store/src/models';
4
- import { LoadEntitiesState } from '../load-entities/load-entities.model';
5
- export declare enum ChangeType {
6
- CREATED = "c",
7
- UPDATED = "u",
8
- DELETED = "d"
9
- }
10
- export interface Change<T> {
11
- id: string | number;
12
- changeType: ChangeType;
13
- entityChanges?: Partial<T>;
14
- }
15
- export interface EntityChange<T> {
16
- entity: T;
17
- changeType: ChangeType;
18
- }
19
- export interface CrudEntitiesState<T> {
20
- changes: Change<T>[];
21
- }
22
- export type CrudEntitiesActions<T> = {
23
- addEntities: ActionCreator<string, (...entities: T[]) => {
24
- entities: T[];
25
- } & Action<string>>;
26
- removeEntities: ActionCreator<string, (...keys: string[] | number[]) => {
27
- keys: string[] | number[];
28
- } & Action<string>>;
29
- updateEntities: ActionCreator<string, (...updates: Update<T>[]) => {
30
- updates: Update<T>[];
31
- } & Action<string>>;
32
- upsertEntities: ActionCreator<string, (...entities: T[]) => {
33
- entities: T[];
34
- } & Action<string>>;
35
- removeAllEntities: ActionCreator<string, (predicate?: Predicate<T>) => {
36
- predicate?: Predicate<T>;
37
- } & Action<string>>;
38
- clearEntitiesChanges: ActionCreator<string, () => Action<string>>;
39
- };
40
- export type CrudEntitiesSelectors<Entity> = {
41
- /**
42
- * Return all changes made to the list plus entities, and can be filtered
43
- * by change type
44
- * @param state
45
- * @param props
46
- */
47
- selectEntitiesChangesList: (state: LoadEntitiesState<Entity> & CrudEntitiesState<Entity>) => EntityChange<Entity>[];
48
- /**
49
- * Returns the entities plus the kind of change,
50
- * filters redundant changes ideal for a batch update
51
- * if you add and remove the same and items this changes are remove from the list
52
- * if you add and then update one or more times, the updates are discarded
53
- * if you update one or more times and then remove, the updates are discarded
54
- * @param state
55
- */
56
- selectFilteredEntitiesChangesList: (state: LoadEntitiesState<Entity> & CrudEntitiesState<Entity>) => EntityChange<Entity>[];
57
- };
58
- export type CrudEntitiesMutators<Entity> = {
59
- addEntities<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(entities: Entity[], state: S): S;
60
- removeEntities<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(keys: string[], state: S): S;
61
- removeEntities<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(keys: number[], state: S): S;
62
- removeEntities<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(predicate: Predicate<Entity>, state: S): S;
63
- removeAllEntities<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(state: S): S;
64
- clearEntitiesChanges<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(state: S): S;
65
- updateEntities<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(updates: Update<Entity>[], state: S): S;
66
- upsertEntities<S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(entities: Entity[], state: S): S;
67
- };
68
- export interface CrudEntitiesConfig {
69
- storeChanges?: boolean;
70
- }
71
- export declare const crudEntitiesTraitKey = "crud";
72
- export interface CrudEntitiesKeyedConfig {
73
- crud?: CrudEntitiesConfig;
74
- }
@@ -1,2 +0,0 @@
1
- import { CrudEntitiesActions } from './crud-entities.model';
2
- export declare function createCrudTraitActions<Entity>(actionsGroupKey: string, entitiesName: string): CrudEntitiesActions<Entity>;
@@ -1,40 +0,0 @@
1
- import { CrudEntitiesActions, CrudEntitiesConfig } from './crud-entities.model';
2
- /**
3
- * Generates ngrx code to add, remove update, upsert entities on a list, it also
4
- * tracks the changes made, helpful for implementing batch updates. The `storeChanges` (false by default),
5
- * will store for add and update the changed entity props in the property `entityChanges` of the `Change` object.
6
- * @param config
7
- * @param config.storeChanges - Will store the changes made, default fals
8
- *
9
- * @example
10
- * // The following trait config
11
- *
12
- * export interface TestState
13
- * extends EntityAndStatusState<Todo>, CrudState<Todo>{}
14
- *
15
- * const traits = createEntityFeatureFactory(
16
- * {entityName: 'Todo'},
17
- * addLoadEntitiesTrait<Todo>(),
18
- * addCrudEntitiesTrait<Todo>()
19
- * )({
20
- * actionsGroupKey: '[Todos]',
21
- * featureSelector: createFeatureSelector<TestState>>(
22
- * 'todos',
23
- * ),
24
- * });
25
- *
26
- * // adds following props to the state:
27
- * // changes: Change<Todo>[];
28
- *
29
- * // generated actions
30
- * traits.actions.addTodos(entity1,entity2...)
31
- * traits.actions.updateTodos({id: id1, changes:{prop1}},{id: id2, changes:{prop2}} ...)
32
- * traits.actions.upsertTodos(entity1,entity2...)
33
- * traits.actions.removeAllTodos()
34
- * traits.actions.clearTodosChanges()
35
- * // generated selectors
36
- * traits.selectors.selectTodosChangesList()
37
- * traits.selectors.selectFilteredTodosChangesList()
38
- * traits.selectors.selectAllFilteredChanges()
39
- */
40
- export declare function addCrudEntitiesTrait<Entity>({ storeChanges, }?: CrudEntitiesConfig): import("@ngrx-traits/core").TraitFactory<import("../load-entities/load-entities.model").LoadEntitiesState<Entity> & import("./crud-entities.model").CrudEntitiesState<Entity>, CrudEntitiesActions<Entity>, import("./crud-entities.model").CrudEntitiesSelectors<Entity>, import("./crud-entities.model").CrudEntitiesMutators<Entity>, "crud", CrudEntitiesConfig, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -1,3 +0,0 @@
1
- import { CrudEntitiesKeyedConfig, CrudEntitiesMutators } from './crud-entities.model';
2
- import { LoadEntitiesKeyedConfig } from '../load-entities/load-entities.model';
3
- export declare function createCrudTraitMutators<Entity>(allConfigs: CrudEntitiesKeyedConfig & LoadEntitiesKeyedConfig<Entity>): CrudEntitiesMutators<Entity>;
@@ -1,7 +0,0 @@
1
- import { FilterEntitiesActions, FilterEntitiesKeyedConfig } from '../filter-entities/filter-entities.model';
2
- import { CrudEntitiesActions, CrudEntitiesKeyedConfig, CrudEntitiesMutators, CrudEntitiesState } from './crud-entities.model';
3
- import { LoadEntitiesActions, LoadEntitiesKeyedConfig, LoadEntitiesState } from '../load-entities';
4
- import { SortEntitiesActions, SortEntitiesKeyedConfig } from '../sort-entities';
5
- import { EntitiesPaginationActions, EntitiesPaginationKeyedConfig } from '../entities-pagination';
6
- export declare function createCrudInitialState<Entity>(previousInitialState: any): LoadEntitiesState<Entity> & CrudEntitiesState<Entity>;
7
- export declare function createCrudTraitReducer<Entity, S extends LoadEntitiesState<Entity> & CrudEntitiesState<Entity>>(initialState: S, allActions: CrudEntitiesActions<Entity> & LoadEntitiesActions<Entity> & SortEntitiesActions<Entity> & FilterEntitiesActions<any> & EntitiesPaginationActions, allMutators: CrudEntitiesMutators<Entity>, allConfigs: CrudEntitiesKeyedConfig & FilterEntitiesKeyedConfig<Entity, unknown> & LoadEntitiesKeyedConfig<Entity> & SortEntitiesKeyedConfig<Entity> & EntitiesPaginationKeyedConfig): import("@ngrx/store").ActionReducer<unknown extends S ? S : S, import("@ngrx/store").Action<string>>;
@@ -1,3 +0,0 @@
1
- import { CrudEntitiesSelectors } from './crud-entities.model';
2
- import { LoadEntitiesSelectors } from '../load-entities/load-entities.model';
3
- export declare function createCrudTraitSelectors<Entity>(previousSelectors: LoadEntitiesSelectors<Entity>): CrudEntitiesSelectors<Entity>;
@@ -1,2 +0,0 @@
1
- export * from './crud-entities.model';
2
- export * from './crud-entities.trait';
@@ -1,80 +0,0 @@
1
- import { Action, ActionCreator } from '@ngrx/store/src/models';
2
- import { LoadEntitiesState } from '../load-entities';
3
- export type CacheType = 'full' | 'partial' | 'grow';
4
- export interface EntitiesPaginationState {
5
- pagination: {
6
- currentPage: number;
7
- requestPage: number;
8
- pageSize: number;
9
- total?: number;
10
- pagesToCache: number;
11
- cache: {
12
- type: CacheType;
13
- start: number;
14
- end: number;
15
- };
16
- };
17
- }
18
- export type EntitiesPaginationActions = {
19
- loadEntitiesPage: ActionCreator<string, (props: {
20
- index: number;
21
- forceLoad?: boolean;
22
- }) => {
23
- index: number;
24
- forceLoad?: boolean;
25
- } & Action<string>>;
26
- loadEntitiesPageSuccess: ActionCreator<string, () => Action<string>>;
27
- loadEntitiesPageFail: ActionCreator<string, () => Action<string>>;
28
- loadEntitiesNextPage: ActionCreator<string, () => Action<string>>;
29
- loadEntitiesPreviousPage: ActionCreator<string, () => Action<string>>;
30
- loadEntitiesFirstPage: ActionCreator<string, (forceLoad?: boolean) => {
31
- forceLoad?: boolean;
32
- } & Action<string>>;
33
- loadEntitiesLastPage: ActionCreator<string, () => Action<string>>;
34
- clearEntitiesPagesCache: ActionCreator<string, () => Action<string>>;
35
- };
36
- export type EntitiesPaginationSelectors<T> = {
37
- selectEntitiesCurrentPageList: (state: LoadEntitiesState<T> & EntitiesPaginationState) => T[];
38
- selectEntitiesCurrentPage: (state: LoadEntitiesState<T> & EntitiesPaginationState) => PageModel<T>;
39
- selectEntitiesPagedRequest: (state: LoadEntitiesState<T> & EntitiesPaginationState) => PagedRequest;
40
- selectEntitiesCurrentPageInfo: (state: LoadEntitiesState<T> & EntitiesPaginationState) => PageInfoModel;
41
- isLoadingEntitiesCurrentPage: (state: LoadEntitiesState<T> & EntitiesPaginationState) => boolean;
42
- };
43
- export type EntitiesPaginationMutators<Entity> = {
44
- mergePaginatedEntities<S extends LoadEntitiesState<Entity> & EntitiesPaginationState>(entities: Entity[], total: number | undefined, state: S): S;
45
- setEntitiesPage<Entity, S extends LoadEntitiesState<Entity> & EntitiesPaginationState>(state: S, index: number): S;
46
- };
47
- export interface PageModel<T> {
48
- entities: T[];
49
- isLoading: boolean;
50
- pageIndex: number;
51
- total: number | undefined;
52
- pageSize: number;
53
- pagesCount: number | undefined;
54
- hasPrevious: boolean;
55
- hasNext: boolean;
56
- }
57
- export interface PageInfoModel {
58
- pageIndex: number;
59
- total: number | undefined;
60
- pageSize: number;
61
- pagesCount: number | undefined;
62
- hasPrevious: boolean;
63
- hasNext: boolean;
64
- cacheType: CacheType;
65
- }
66
- export interface PagedRequest {
67
- startIndex: number;
68
- size: number;
69
- page: number;
70
- }
71
- export declare const entitiesPaginationTraitKey = "pagination";
72
- export interface EntitiesPaginationConfig {
73
- cacheType?: CacheType;
74
- pageSize?: number;
75
- currentPage?: number;
76
- pagesToCache?: number;
77
- }
78
- export interface EntitiesPaginationKeyedConfig {
79
- pagination?: EntitiesPaginationConfig;
80
- }
@@ -1,20 +0,0 @@
1
- import { Action, ActionCreator } from '@ngrx/store/src/models';
2
- import { LoadEntitiesState } from '../load-entities/load-entities.model';
3
- import { EntitiesPaginationActions, EntitiesPaginationSelectors, EntitiesPaginationState } from './entities-pagination.model';
4
- /**
5
- * @internal
6
- */
7
- export type ƟPaginationActions = EntitiesPaginationActions & {
8
- setEntitiesRequestPage: ActionCreator<string, (props: {
9
- index: number;
10
- }) => {
11
- index: number;
12
- } & Action<string>>;
13
- };
14
- /**
15
- * @internal
16
- */
17
- export type ƟEntitiesPaginationSelectors<Entity> = EntitiesPaginationSelectors<Entity> & {
18
- isEntitiesCurrentPageInCache: (state: LoadEntitiesState<Entity> & EntitiesPaginationState) => boolean;
19
- isEntitiesNextPageInCache: (state: LoadEntitiesState<Entity> & EntitiesPaginationState) => boolean;
20
- };
@@ -1,2 +0,0 @@
1
- import { EntitiesPaginationActions } from './entities-pagination.model';
2
- export declare function createPaginationTraitActions(actionsGroupKey: string, entitiesName: string): EntitiesPaginationActions;
@@ -1,69 +0,0 @@
1
- import { EntitiesPaginationConfig, EntitiesPaginationMutators, EntitiesPaginationSelectors } from './entities-pagination.model';
2
- /**
3
- * Generates ngrx code to paginate a list of entities, this has 3 cache `cacheType`
4
- * - 'full': The full result is cache in memory and split in pages to render, useful
5
- * for small result but not so small that requires been render in pages
6
- * - 'partial': Backend returns partial results because is are to big, this has a cache a few pages forward
7
- * to avoid calling the backend on each page, the cache is clean when a new loadEntities is required
8
- * - 'grow': Similar to partial that the backend returns partial result, but in this case the cache grows,
9
- * after each loadEntities the cache is appended to the previous cache, this mode is ideal for infinite scrolls,
10
- * where you will only call loadNextPage.
11
- * To make the pagination experience smoother the loadEntities action is fired when the current page is equal
12
- * to the last cached page, so while the user is reading the page more pages are being loading in the background.
13
- * @param config
14
- * @param config.cacheType - Default to 'partial', change the cache mode
15
- * @param config.pageSize - Default to 10, number of entities on each page
16
- * @param config.currentPage - Default to 0, starting page
17
- * @param config.pagesToCache - Default to 3, used in partial and grow cache mode, is the number of
18
- * extra pages kept in cache to avoid calling the backend on each page
19
- *
20
- * @example
21
- * // The following trait config
22
- *
23
- * export interface TestState
24
- * extends EntityAndStatusState<Todo>,EntitiesPaginationState{}
25
- *
26
- * const traits = createEntityFeatureFactory(
27
- * {entityName: 'Todo'},
28
- * addLoadEntitiesTrait<Todo>(),
29
- * addEntitiesPaginationTrait<Todo>()
30
- * )({
31
- * actionsGroupKey: '[Todos]',
32
- * featureSelector: createFeatureSelector<TestState>>(
33
- * 'todos',
34
- * ),
35
- * });
36
- *
37
- * // adds following props to the state:
38
- * // pagination: {
39
- * // currentPage: number;
40
- * // requestPage: number;
41
- * // pageSize: number;
42
- * // total?: number;
43
- * // pagesToCache: number;
44
- * // cache: {
45
- * // type: 'full' | 'partial' | 'grow';
46
- * // start: number;
47
- * // end: number;
48
- * // }
49
- * // }
50
- *
51
- * // generated actions
52
- * traits.actions.loadTodosPage({index})
53
- * traits.actions.loadTodosPageSuccess()
54
- * traits.actions.loadTodosPageFail()
55
- * traits.actions.loadTodosNextPage()
56
- * traits.actions.loadTodosPreviousPage()
57
- * traits.actions.loadTodosFirstPage()
58
- * traits.actions.loadTodosLastPage()
59
- * traits.actions.clearTodosPagesCache()
60
- * // generated selectors
61
- * traits.selectors.selectTodosCurrentPageList()
62
- * traits.selectors.isLoadingTodosCurrentPage()
63
- * // use isLoadingTodosPage over isLoadingTodos (which will return true even
64
- * // if the page loading is not the current one)
65
- * traits.selectors.selectTodosCurrentPage()
66
- * traits.selectors.selectTodosPagedRequest()// use in effects to get paging parameter
67
- * traits.selectors.selectTodosCurrentPageInfo()
68
- */
69
- export declare function addEntitiesPaginationTrait<Entity>({ cacheType, pageSize, currentPage, pagesToCache, }?: EntitiesPaginationConfig): import("@ngrx-traits/core").TraitFactory<import("../load-entities/load-entities.model").LoadEntitiesState<Entity> & import("./entities-pagination.model").EntitiesPaginationState, import("./entities-pagination.model").EntitiesPaginationActions, EntitiesPaginationSelectors<Entity>, EntitiesPaginationMutators<Entity>, "pagination", EntitiesPaginationConfig, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -1,8 +0,0 @@
1
- import { TraitEffect } from '@ngrx-traits/core';
2
- import { Type } from '@ngrx-traits/core';
3
- import { CrudEntitiesActions } from '../crud-entities/crud-entities.model';
4
- import { FilterEntitiesActions } from '../filter-entities/filter-entities.model';
5
- import { LoadEntitiesActions, LoadEntitiesSelectors } from '../load-entities';
6
- import { EntitiesPaginationSelectors } from './entities-pagination.model';
7
- import { ƟPaginationActions } from './entities-pagination.model.internal';
8
- export declare function createPaginationTraitEffects<Entity>(allActions: ƟPaginationActions & FilterEntitiesActions<Entity> & LoadEntitiesActions<Entity> & CrudEntitiesActions<Entity>, allSelectors: LoadEntitiesSelectors<Entity> & EntitiesPaginationSelectors<Entity>): Type<TraitEffect>[];
@@ -1,3 +0,0 @@
1
- import { EntitiesPaginationMutators, EntitiesPaginationSelectors } from './entities-pagination.model';
2
- import { LoadEntitiesKeyedConfig } from '../load-entities';
3
- export declare function createPaginationTraitMutators<Entity>(allSelectors: EntitiesPaginationSelectors<Entity>, allConfigs: LoadEntitiesKeyedConfig<Entity>): EntitiesPaginationMutators<Entity>;
@@ -1,8 +0,0 @@
1
- import { FilterEntitiesKeyedConfig } from '../filter-entities/filter-entities.model';
2
- import { LoadEntitiesActions, LoadEntitiesKeyedConfig, LoadEntitiesMutators, LoadEntitiesSelectors, LoadEntitiesState } from '../load-entities/load-entities.model';
3
- import { EntitiesPaginationKeyedConfig, EntitiesPaginationMutators, EntitiesPaginationState } from './entities-pagination.model';
4
- import { CrudEntitiesActions } from '../crud-entities';
5
- import { ƟPaginationActions } from './entities-pagination.model.internal';
6
- import { ƟFilterEntitiesActions } from '../filter-entities/filter-entities.model.internal';
7
- export declare function createPaginationInitialState<Entity>(previousInitialState: any, allConfigs: EntitiesPaginationKeyedConfig): LoadEntitiesState<Entity> & EntitiesPaginationState;
8
- export declare function createPaginationTraitReducer<Entity, S extends LoadEntitiesState<Entity> & EntitiesPaginationState>(initialState: S, allActions: ƟPaginationActions & ƟFilterEntitiesActions<Entity> & LoadEntitiesActions<Entity> & CrudEntitiesActions<Entity>, allSelectors: LoadEntitiesSelectors<Entity>, allMutators: EntitiesPaginationMutators<Entity> & LoadEntitiesMutators<Entity>, allConfigs: FilterEntitiesKeyedConfig<Entity, unknown> & LoadEntitiesKeyedConfig<Entity> & EntitiesPaginationKeyedConfig): import("@ngrx/store").ActionReducer<unknown extends S ? S : S, import("@ngrx/store").Action<string>>;
@@ -1,4 +0,0 @@
1
- import { EntitiesPaginationSelectors } from './entities-pagination.model';
2
- import { LoadEntitiesSelectors } from '../load-entities/load-entities.model';
3
- import { FilterEntitiesKeyedConfig } from '../filter-entities/filter-entities.model';
4
- export declare function createPaginationTraitSelectors<Entity>(previousSelectors: LoadEntitiesSelectors<Entity>, allConfigs: FilterEntitiesKeyedConfig<Entity, unknown>): EntitiesPaginationSelectors<Entity>;
@@ -1,2 +0,0 @@
1
- export * from './entities-pagination.model';
2
- export * from './entities-pagination.trait';
@@ -1,30 +0,0 @@
1
- import { Action, ActionCreator } from '@ngrx/store/src/models';
2
- /**
3
- * Generates ngrx code necessary to load and set to the current route query params for the filter, sort and paging traits
4
- *
5
- * @example
6
- *
7
- * const traits = createEntityFeatureFactory(
8
- * {entityName: 'Todo'},
9
- * addLoadEntitiesTrait<Todo>(),
10
- * addFilterEntitiesTrait(),
11
- * addSortEntitiesTrait<Todo>({
12
- * remote: true,
13
- * defaultSort: {active:'id', direction:'asc'}
14
- * })
15
- * addEntitiesPaginationTrait<Todo>(),
16
- * addEntitiesSyncToRouteQueryParams()
17
- * )({
18
- * actionsGroupKey: '[Todos]',
19
- * featureSelector: createFeatureSelector<TestState>>(
20
- * 'todos',
21
- * ),
22
- * });
23
- *
24
- *
25
- * // generated actions
26
- * traits.actions.loadTodosUsingRouteQueryParams()
27
- */
28
- export declare function addEntitiesSyncToRouteQueryParams(): import("@ngrx-traits/core").TraitFactory<{}, {
29
- loadEntitiesUsingRouteQueryParams: ActionCreator<`${string} Load ${string} Using Route Query Params`, () => Action<`${string} Load ${string} Using Route Query Params`>>;
30
- }, {}, {}, "entitiesSyncToRouteQueryParams", unknown, import("@ngrx-traits/core").AllTraitConfigs>;
@@ -1 +0,0 @@
1
- export * from './entities-sync-to-route-query-params';
@@ -1,57 +0,0 @@
1
- import { Action, ActionCreator } from '@ngrx/store/src/models';
2
- import { LoadEntitiesState } from '../load-entities/load-entities.model';
3
- export interface FilterEntitiesState<F> {
4
- filters?: F;
5
- }
6
- type FilterPatchConditionalType<F, P> = P extends true ? Partial<F> : F;
7
- export interface FilterActionOverload<F> {
8
- <P extends boolean>(props?: {
9
- filters: FilterPatchConditionalType<F, P>;
10
- forceLoad?: boolean;
11
- patch: P;
12
- }): {
13
- filters: FilterPatchConditionalType<F, P>;
14
- forceLoad: boolean;
15
- patch: P;
16
- } & Action<string>;
17
- (props?: {
18
- filters: F;
19
- forceLoad?: boolean;
20
- }): {
21
- filters: F;
22
- forceLoad: boolean;
23
- patch: boolean;
24
- } & Action<string>;
25
- }
26
- export type FilterEntitiesActions<F> = {
27
- /**
28
- * Store the filters param (read using selectFilter) and fires the loadEntities action
29
- * if the filters param has changed, this call is also debounce by default, to disable this
30
- * behavior you can use the forceLoad param as true or defaultDebounceTime to 0 in the trait config
31
- * to disable permanently.
32
- * If the `patch` param is set to true (default is false), the filters are merged with the previous value in the store,
33
- * otherwise they are replaced.
34
- */
35
- filterEntities: ActionCreator<string, FilterActionOverload<F>>;
36
- };
37
- export type FilterEntitiesSelectors<T, F> = {
38
- /**
39
- * Returns the stored filters set by the filter action
40
- * @param state
41
- */
42
- selectEntitiesFilter: (state: LoadEntitiesState<T> & FilterEntitiesState<F>) => F | undefined;
43
- };
44
- export type FilterEntitiesMutators<T, F> = {
45
- setEntitiesFilters<S extends LoadEntitiesState<T> & FilterEntitiesState<F>>(filter: F | undefined, state: S): S;
46
- };
47
- export declare const filterEntitiesTraitKey = "filter";
48
- export type FilterEntitiesConfig<T, F> = {
49
- defaultFilter?: F;
50
- filterFn?: (filter: F, entity: T) => boolean;
51
- defaultDebounceTime?: number;
52
- isRemoteFilter?: (previous: F | undefined, current: F | undefined) => boolean;
53
- };
54
- export type FilterEntitiesKeyedConfig<T, F> = {
55
- filter?: FilterEntitiesConfig<T, F>;
56
- };
57
- export {};
@@ -1,14 +0,0 @@
1
- import { Action, ActionCreator } from '@ngrx/store/src/models';
2
- import { FilterEntitiesActions } from './filter-entities.model';
3
- /**
4
- * @internal
5
- */
6
- export type ƟFilterEntitiesActions<F> = FilterEntitiesActions<F> & {
7
- storeEntitiesFilter: ActionCreator<string, (props: {
8
- filters?: F;
9
- patch?: boolean;
10
- }) => {
11
- filters?: F;
12
- patch?: boolean;
13
- } & Action<string>>;
14
- };
@@ -1,2 +0,0 @@
1
- import { FilterEntitiesActions } from './filter-entities.model';
2
- export declare function createFilterTraitActions<F>(actionsGroupKey: string, entitiesName: string): FilterEntitiesActions<F>;
@@ -1,48 +0,0 @@
1
- import { FilterEntitiesConfig, FilterEntitiesSelectors } from './filter-entities.model';
2
- /**
3
- * Generates the ngrx code needed to filter a list of entities locally or remotely, adds a filter
4
- * action and a selectFilter selector, the filter action is debounced and the filter will only
5
- * call the loadEntities action if the params have changed, so there is no need to implement that in
6
- * the components. The filter action has a `forceLoad` param which can
7
- * be use to skip that restriction for one call or setting the `defaultDebounceTime` to 0 for all calls.
8
- * Calling the filter action will also replace the `filters` param in the store, if the `patch` param is set
9
- * the filters are merged with the previous value in the store.
10
- * @param traitConfig - Config object fot the trait factory
11
- * @param traitConfig.defaultFilter - Initial value for the filter
12
- * @param traitConfig.filterFn - Function to filter entities in memory, if not present then its expected
13
- * is filtered by the backend unless isRemoteFilter is defned
14
- * @param traitConfig.defaultDebounceTime - Value in milliseconds. Default to 400ms
15
- * @param traitConfig.isRemoteFilter - Function to when it returns true it fires loadEntities so a remote
16
- * backend filtering can run, otherwise it uses filterFn to do a local filtering
17
- *
18
- * @example
19
- * // The following trait config
20
- *
21
- * export interface TestState
22
- * extends LoadEntitiesState<Todo>, FilterEntitiesState<TodoFilter>{}
23
- *
24
- * const traits = createEntityFeatureFactory(
25
- * {entityName: 'Todo'},
26
- * addLoadEntitiesTrait<Todo>(),
27
- * //addFilterEntitiesTrait<Todo,TodoFilter>() // no params uses remote filtering
28
- * addFilterEntitiesTrait<Todo,TodoFilter>({filterFn: (filter, entity) => // local filtering
29
- * !filter.content || !!entity.content?.includes(filter.content.toLowerCase())
30
- * // or use the following function to switch between remote search and local
31
- * // depending on which properties have changed in the filter
32
- * // isRemoteFilter: (previous, current) => previous?.someRemoteParam !== current?.someRemoteParam,
33
- * )({
34
- * actionsGroupKey: '[Todos]',
35
- * featureSelector: createFeatureSelector<TestState>>(
36
- * 'todos',
37
- * ),
38
- * });
39
- *
40
- * // adds following props to the state:
41
- * // filters?: TodoFilter;
42
- *
43
- * // generated actions
44
- * traits.actions.filterTodos()
45
- * // generated selectors
46
- * traits.selectors.selectTodosFilter()
47
- */
48
- 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,6 +0,0 @@
1
- import { TraitEffect, Type } from '@ngrx-traits/core';
2
- import { EntitiesPaginationActions } from '../entities-pagination';
3
- import { LoadEntitiesActions, LoadEntitiesSelectors } from '../load-entities/load-entities.model';
4
- import { FilterEntitiesKeyedConfig, FilterEntitiesSelectors } from './filter-entities.model';
5
- import { ƟFilterEntitiesActions } from './filter-entities.model.internal';
6
- export declare function createFilterTraitEffects<Entity, F>(allActions: ƟFilterEntitiesActions<F> & LoadEntitiesActions<Entity> & EntitiesPaginationActions, allSelectors: FilterEntitiesSelectors<Entity, F> & LoadEntitiesSelectors<Entity>, allConfigs: FilterEntitiesKeyedConfig<Entity, F>): Type<TraitEffect>[];
@@ -1,2 +0,0 @@
1
- import { FilterEntitiesMutators } from './filter-entities.model';
2
- export declare function createFilterTraitMutators<Entity, F>(): FilterEntitiesMutators<Entity, F>;