@angular-architects/ngrx-toolkit 19.2.3 → 20.0.1

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 (47) hide show
  1. package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs +3 -3
  2. package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs.map +1 -1
  3. package/fesm2022/angular-architects-ngrx-toolkit.mjs +36 -34
  4. package/fesm2022/angular-architects-ngrx-toolkit.mjs.map +1 -1
  5. package/index.d.ts +949 -24
  6. package/package.json +5 -5
  7. package/redux-connector/index.d.ts +59 -2
  8. package/lib/assertions/assertions.d.ts +0 -2
  9. package/lib/devtools/features/with-disabled-name-indicies.d.ts +0 -27
  10. package/lib/devtools/features/with-glitch-tracking.d.ts +0 -30
  11. package/lib/devtools/features/with-mapper.d.ts +0 -28
  12. package/lib/devtools/internal/current-action-names.d.ts +0 -1
  13. package/lib/devtools/internal/default-tracker.d.ts +0 -13
  14. package/lib/devtools/internal/devtools-feature.d.ts +0 -24
  15. package/lib/devtools/internal/devtools-syncer.service.d.ts +0 -35
  16. package/lib/devtools/internal/glitch-tracker.service.d.ts +0 -18
  17. package/lib/devtools/internal/models.d.ts +0 -24
  18. package/lib/devtools/provide-devtools-config.d.ts +0 -20
  19. package/lib/devtools/rename-devtools-name.d.ts +0 -7
  20. package/lib/devtools/update-state.d.ts +0 -15
  21. package/lib/devtools/with-dev-tools-stub.d.ts +0 -5
  22. package/lib/devtools/with-devtools.d.ts +0 -24
  23. package/lib/immutable-state/deep-freeze.d.ts +0 -11
  24. package/lib/immutable-state/is-dev-mode.d.ts +0 -1
  25. package/lib/immutable-state/with-immutable-state.d.ts +0 -60
  26. package/lib/shared/signal-store-models.d.ts +0 -26
  27. package/lib/shared/throw-if-null.d.ts +0 -1
  28. package/lib/storage-sync/features/with-indexed-db.d.ts +0 -2
  29. package/lib/storage-sync/features/with-local-storage.d.ts +0 -3
  30. package/lib/storage-sync/internal/indexeddb.service.d.ts +0 -29
  31. package/lib/storage-sync/internal/local-storage.service.d.ts +0 -8
  32. package/lib/storage-sync/internal/models.d.ts +0 -45
  33. package/lib/storage-sync/internal/session-storage.service.d.ts +0 -8
  34. package/lib/storage-sync/with-storage-sync.d.ts +0 -45
  35. package/lib/with-call-state.d.ts +0 -58
  36. package/lib/with-conditional.d.ts +0 -50
  37. package/lib/with-data-service.d.ts +0 -109
  38. package/lib/with-feature-factory.d.ts +0 -28
  39. package/lib/with-pagination.d.ts +0 -98
  40. package/lib/with-redux.d.ts +0 -147
  41. package/lib/with-reset.d.ts +0 -29
  42. package/lib/with-undo-redo.d.ts +0 -31
  43. package/redux-connector/src/lib/create-redux.d.ts +0 -13
  44. package/redux-connector/src/lib/model.d.ts +0 -40
  45. package/redux-connector/src/lib/rxjs-interop/redux-method.d.ts +0 -14
  46. package/redux-connector/src/lib/signal-redux-store.d.ts +0 -11
  47. package/redux-connector/src/lib/util.d.ts +0 -5
@@ -1,58 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
3
- export type CallState = 'init' | 'loading' | 'loaded' | {
4
- error: string;
5
- };
6
- export type CallStateSlice = {
7
- callState: CallState;
8
- };
9
- export type NamedCallStateSlice<Collection extends string> = {
10
- [K in keyof CallStateSlice as Collection extends '' ? `${Collection}${K}` : `${Collection}${Capitalize<K>}`]: CallStateSlice[K];
11
- };
12
- export type CallStateSignals = {
13
- loading: Signal<boolean>;
14
- loaded: Signal<boolean>;
15
- error: Signal<string | null>;
16
- };
17
- export type NamedCallStateSignals<Prop extends string> = {
18
- [K in keyof CallStateSignals as Prop extends '' ? `${Prop}${K}` : `${Prop}${Capitalize<K>}`]: CallStateSignals[K];
19
- };
20
- export type SetCallState<Prop extends string | undefined> = Prop extends string ? NamedCallStateSlice<Prop> : CallStateSlice;
21
- export declare function deriveCallStateKeys<Collection extends string>(collection?: Collection): {
22
- callStateKey: string;
23
- loadingKey: string;
24
- loadedKey: string;
25
- errorKey: string;
26
- };
27
- export declare function getCallStateKeys(config?: {
28
- collection?: string;
29
- }): {
30
- callStateKey: string;
31
- loadingKey: string;
32
- loadedKey: string;
33
- errorKey: string;
34
- };
35
- export declare function getCollectionArray(config: {
36
- collection?: string;
37
- } | {
38
- collections?: string[];
39
- }): string[] | undefined;
40
- export declare function withCallState<Collection extends string>(config: {
41
- collections: Collection[];
42
- }): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult & {
43
- state: NamedCallStateSlice<Collection>;
44
- props: NamedCallStateSignals<Collection>;
45
- }>;
46
- export declare function withCallState<Collection extends string>(config: {
47
- collection: Collection;
48
- }): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult & {
49
- state: NamedCallStateSlice<Collection>;
50
- props: NamedCallStateSignals<Collection>;
51
- }>;
52
- export declare function withCallState(): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult & {
53
- state: CallStateSlice;
54
- props: CallStateSignals;
55
- }>;
56
- export declare function setLoading<Prop extends string | undefined = undefined>(prop?: Prop): SetCallState<Prop>;
57
- export declare function setLoaded<Prop extends string | undefined = undefined>(prop?: Prop): SetCallState<Prop>;
58
- export declare function setError<Prop extends string | undefined = undefined>(error: unknown, prop?: Prop): SetCallState<Prop>;
@@ -1,50 +0,0 @@
1
- import { SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from '@ngrx/signals';
2
- /**
3
- * `withConditional` activates a feature based on a given condition.
4
- *
5
- * **Use Cases**
6
- * - Conditionally activate features based on the **store state** or other criteria.
7
- * - Choose between **two different implementations** of a feature.
8
- *
9
- * **Type Constraints**
10
- * Both features must have **exactly the same state, props, and methods**.
11
- * Otherwise, a type error will occur.
12
- *
13
- *
14
- * **Usage**
15
- *
16
- * ```typescript
17
- * const withUser = signalStoreFeature(
18
- * withState({ id: 1, name: 'Konrad' }),
19
- * withHooks(store => ({
20
- * onInit() {
21
- * // user loading logic
22
- * }
23
- * }))
24
- * );
25
- *
26
- * function withFakeUser() {
27
- * return signalStoreFeature(
28
- * withState({ id: 0, name: 'anonymous' })
29
- * );
30
- * }
31
- *
32
- * signalStore(
33
- * withMethods(() => ({
34
- * useRealUser: () => true
35
- * })),
36
- * withConditional((store) => store.useRealUser(), withUser, withFakeUser)
37
- * )
38
- * ```
39
- *
40
- * @param condition - A function that determines which feature to activate based on the store state.
41
- * @param featureIfTrue - The feature to activate if the condition evaluates to `true`.
42
- * @param featureIfFalse - The feature to activate if the condition evaluates to `false`.
43
- * @returns A `SignalStoreFeature` that applies the selected feature based on the condition.
44
- */
45
- export declare function withConditional<Input extends SignalStoreFeatureResult, Output extends SignalStoreFeatureResult>(condition: (store: StateSignals<Input['state']> & Input['props'] & Input['methods']) => boolean, featureIfTrue: SignalStoreFeature<NoInfer<Input>, Output>, featureIfFalse: SignalStoreFeature<NoInfer<Input>, NoInfer<Output>>): SignalStoreFeature<Input, Output>;
46
- export declare const emptyFeature: SignalStoreFeature<import("@ngrx/signals").EmptyFeatureResult, {
47
- state: {};
48
- props: {};
49
- methods: {};
50
- }>;
@@ -1,109 +0,0 @@
1
- import { ProviderToken, Signal } from '@angular/core';
2
- import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
3
- import { EntityId, NamedEntityState } from '@ngrx/signals/entities';
4
- import { EntityState } from './shared/signal-store-models';
5
- import { CallState, NamedCallStateSlice } from './with-call-state';
6
- export type Filter = Record<string, unknown>;
7
- export type Entity = {
8
- id: EntityId;
9
- };
10
- export interface DataService<E extends Entity, F extends Filter> {
11
- load(filter: F): Promise<E[]>;
12
- loadById(id: EntityId): Promise<E>;
13
- create(entity: E): Promise<E>;
14
- update(entity: E): Promise<E>;
15
- updateAll(entity: E[]): Promise<E[]>;
16
- delete(entity: E): Promise<void>;
17
- }
18
- export declare function capitalize(str: string): string;
19
- export declare function getDataServiceKeys(options: {
20
- collection?: string;
21
- }): {
22
- filterKey: string;
23
- selectedIdsKey: string;
24
- selectedEntitiesKey: string;
25
- updateFilterKey: string;
26
- updateSelectedKey: string;
27
- loadKey: string;
28
- entitiesKey: string;
29
- entityMapKey: string;
30
- idsKey: string;
31
- currentKey: string;
32
- loadByIdKey: string;
33
- setCurrentKey: string;
34
- createKey: string;
35
- updateKey: string;
36
- updateAllKey: string;
37
- deleteKey: string;
38
- };
39
- export type NamedDataServiceState<E extends Entity, F extends Filter, Collection extends string> = {
40
- [K in Collection as `${K}Filter`]: F;
41
- } & {
42
- [K in Collection as `selected${Capitalize<K>}Ids`]: Record<EntityId, boolean>;
43
- } & {
44
- [K in Collection as `current${Capitalize<K>}`]: E;
45
- };
46
- export type DataServiceState<E extends Entity, F extends Filter> = {
47
- filter: F;
48
- selectedIds: Record<EntityId, boolean>;
49
- current: E;
50
- };
51
- export type DataServiceComputed<E extends Entity> = {
52
- selectedEntities: Signal<E[]>;
53
- };
54
- export type NamedDataServiceComputed<E extends Entity, Collection extends string> = {
55
- [K in Collection as `selected${Capitalize<K>}Entities`]: Signal<E[]>;
56
- };
57
- export type NamedDataServiceMethods<E extends Entity, F extends Filter, Collection extends string> = {
58
- [K in Collection as `update${Capitalize<K>}Filter`]: (filter: F) => void;
59
- } & {
60
- [K in Collection as `updateSelected${Capitalize<K>}Entities`]: (id: EntityId, selected: boolean) => void;
61
- } & {
62
- [K in Collection as `load${Capitalize<K>}Entities`]: () => Promise<void>;
63
- } & {
64
- [K in Collection as `setCurrent${Capitalize<K>}`]: (entity: E) => void;
65
- } & {
66
- [K in Collection as `load${Capitalize<K>}ById`]: (id: EntityId) => Promise<void>;
67
- } & {
68
- [K in Collection as `create${Capitalize<K>}`]: (entity: E) => Promise<void>;
69
- } & {
70
- [K in Collection as `update${Capitalize<K>}`]: (entity: E) => Promise<void>;
71
- } & {
72
- [K in Collection as `updateAll${Capitalize<K>}`]: (entity: E[]) => Promise<void>;
73
- } & {
74
- [K in Collection as `delete${Capitalize<K>}`]: (entity: E) => Promise<void>;
75
- };
76
- export type DataServiceMethods<E extends Entity, F extends Filter> = {
77
- updateFilter: (filter: F) => void;
78
- updateSelected: (id: EntityId, selected: boolean) => void;
79
- load: () => Promise<void>;
80
- setCurrent(entity: E): void;
81
- loadById(id: EntityId): Promise<void>;
82
- create(entity: E): Promise<void>;
83
- update(entity: E): Promise<void>;
84
- updateAll(entities: E[]): Promise<void>;
85
- delete(entity: E): Promise<void>;
86
- };
87
- export declare function withDataService<E extends Entity, F extends Filter, Collection extends string>(options: {
88
- dataServiceType: ProviderToken<DataService<E, F>>;
89
- filter: F;
90
- collection: Collection;
91
- }): SignalStoreFeature<EmptyFeatureResult & {
92
- state: NamedCallStateSlice<Collection> & NamedEntityState<E, Collection>;
93
- }, {
94
- state: NamedDataServiceState<E, F, Collection>;
95
- props: NamedDataServiceComputed<E, Collection>;
96
- methods: NamedDataServiceMethods<E, F, Collection>;
97
- }>;
98
- export declare function withDataService<E extends Entity, F extends Filter>(options: {
99
- dataServiceType: ProviderToken<DataService<E, F>>;
100
- filter: F;
101
- }): SignalStoreFeature<EmptyFeatureResult & {
102
- state: {
103
- callState: CallState;
104
- } & EntityState<E>;
105
- }, {
106
- state: DataServiceState<E, F>;
107
- props: DataServiceComputed<E>;
108
- methods: DataServiceMethods<E, F>;
109
- }>;
@@ -1,28 +0,0 @@
1
- import { SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from '@ngrx/signals';
2
- type StoreForFactory<Input extends SignalStoreFeatureResult> = StateSignals<Input['state']> & Input['props'] & Input['methods'];
3
- /**
4
- * @deprecated Use `import { withFeature } from '@ngrx/signals'` instead, starting with `ngrx/signals` 19.1: https://ngrx.io/guide/signals/signal-store/custom-store-features#connecting-a-custom-feature-with-the-store
5
- *
6
- * Allows to pass properties, methods, or signals from a SignalStore
7
- * to a feature.
8
- *
9
- * Typically, a `signalStoreFeature` can have input constraints on
10
- *
11
- * ```typescript
12
- * function withSum(a: Signal<number>, b: Signal<number>) {
13
- * return signalStoreFeature(
14
- * withComputed(() => ({
15
- * sum: computed(() => a() + b())
16
- * }))
17
- * );
18
- * }
19
- *
20
- * signalStore(
21
- * withState({ a: 1, b: 2 }),
22
- * withFeatureFactory((store) => withSum(store.a, store.b))
23
- * );
24
- * ```
25
- * @param factoryFn
26
- */
27
- export declare function withFeatureFactory<Input extends SignalStoreFeatureResult, Output extends SignalStoreFeatureResult>(factoryFn: (store: StoreForFactory<Input>) => SignalStoreFeature<Input, Output>): SignalStoreFeature<Input, Output>;
28
- export {};
@@ -1,98 +0,0 @@
1
- /** With pagination comes in two flavors the first one is local pagination or in memory pagination. For example we have 2000 items which we want
2
- * to display in a table and the response payload is small enough to be stored in the memory. But we can not display all 2000 items at once
3
- * so we need to paginate the data. The second flavor is server side pagination where the response payload is too large to be stored in the memory
4
- * and we need to fetch the data from the server in chunks. In the second case we 'could' also cache the data in the memory but that could lead to
5
- * other problems like memory leaks and stale data. So we will not cache the data in the memory in the second case.
6
- * This feature implements the local pagination.
7
- */
8
- import { Signal } from '@angular/core';
9
- import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
10
- export type Page = {
11
- label: string | number;
12
- value: number;
13
- };
14
- export type NamedPaginationServiceState<E, Collection extends string> = {
15
- [K in Collection as `selectedPage${Capitalize<K>}Entities`]: Array<E>;
16
- } & {
17
- [K in Collection as `${Lowercase<K>}CurrentPage`]: number;
18
- } & {
19
- [K in Collection as `${Lowercase<K>}PageSize`]: number;
20
- } & {
21
- [K in Collection as `${Lowercase<K>}TotalCount`]: number;
22
- } & {
23
- [K in Collection as `${Lowercase<K>}PageCount`]: number;
24
- } & {
25
- [K in Collection as `${Lowercase<K>}PageNavigationArray`]: number;
26
- } & {
27
- [K in Collection as `${Lowercase<K>}PageNavigationArrayMax`]: number;
28
- };
29
- export type NamedPaginationServiceSignals<E, Collection extends string> = {
30
- [K in Collection as `selectedPage${Capitalize<K>}Entities`]: Signal<E[]>;
31
- } & {
32
- [K in Collection as `${Lowercase<K>}CurrentPage`]: Signal<number>;
33
- } & {
34
- [K in Collection as `${Lowercase<K>}PageSize`]: Signal<number>;
35
- } & {
36
- [K in Collection as `${Lowercase<K>}TotalCount`]: Signal<number>;
37
- } & {
38
- [K in Collection as `${Lowercase<K>}PageCount`]: Signal<number>;
39
- } & {
40
- [K in Collection as `${Lowercase<K>}PageNavigationArray`]: Signal<Page[]>;
41
- } & {
42
- [K in Collection as `${Lowercase<K>}PageNavigationArrayMax`]: Signal<number>;
43
- } & {
44
- [K in Collection as `hasNext${Capitalize<K>}Page`]: Signal<boolean>;
45
- } & {
46
- [K in Collection as `hasPrevious${Capitalize<K>}Page`]: Signal<boolean>;
47
- };
48
- export type PaginationServiceState<E> = {
49
- selectedPageEntities: Array<E>;
50
- currentPage: number;
51
- pageSize: number;
52
- totalCount: number;
53
- pageCount: number;
54
- pageNavigationArray: Page[];
55
- pageNavigationArrayMax: number;
56
- };
57
- export type PaginationServiceSignals<E> = {
58
- selectedPageEntities: Signal<E[]>;
59
- currentPage: Signal<number>;
60
- pageSize: Signal<number>;
61
- totalCount: Signal<number>;
62
- pageCount: Signal<number>;
63
- pageNavigationArray: Signal<Page[]>;
64
- pageNavigationArrayMax: Signal<number>;
65
- hasNextPage: Signal<boolean>;
66
- hasPreviousPage: Signal<boolean>;
67
- };
68
- export type SetPaginationState<E, Collection extends string | undefined> = Collection extends string ? NamedPaginationServiceState<E, Collection> : PaginationServiceState<E>;
69
- export declare function withPagination<E, Collection extends string>(options: {
70
- entity: E;
71
- collection: Collection;
72
- }): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult & {
73
- state: NamedPaginationServiceState<E, Collection>;
74
- props: NamedPaginationServiceSignals<E, Collection>;
75
- }>;
76
- export declare function withPagination<E>(): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult & {
77
- state: PaginationServiceState<E>;
78
- props: PaginationServiceSignals<E>;
79
- }>;
80
- export declare function gotoPage<E, Collection extends string>(page: number, options?: {
81
- collection: Collection;
82
- }): Partial<SetPaginationState<E, Collection>>;
83
- export declare function setPageSize<E, Collection extends string>(pageSize: number, options?: {
84
- collection: Collection;
85
- }): Partial<SetPaginationState<E, Collection>>;
86
- export declare function nextPage<E, Collection extends string>(options?: {
87
- collection: Collection;
88
- }): Partial<SetPaginationState<E, Collection>>;
89
- export declare function previousPage<E, Collection extends string>(options?: {
90
- collection: Collection;
91
- }): Partial<SetPaginationState<E, Collection>>;
92
- export declare function firstPage<E, Collection extends string>(options?: {
93
- collection: Collection;
94
- }): Partial<SetPaginationState<E, Collection>>;
95
- export declare function setMaxPageNavigationArrayItems<E, Collection extends string>(maxPageNavigationArrayItems: number, options?: {
96
- collection: Collection;
97
- }): Partial<SetPaginationState<E, Collection>>;
98
- export declare function createPageArray(currentPage: number, itemsPerPage: number, totalItems: number, paginationRange: number): Page[];
@@ -1,147 +0,0 @@
1
- import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult, WritableStateSource } from '@ngrx/signals';
2
- import { Observable } from 'rxjs';
3
- /** Actions **/
4
- type Payload = Record<string, unknown>;
5
- type ActionFn<Type extends string = string, ActionPayload extends Payload = Payload> = ((payload: ActionPayload) => ActionPayload & {
6
- type: Type;
7
- }) & {
8
- type: Type;
9
- };
10
- type ActionFns = Record<string, ActionFn>;
11
- export type ActionsFnSpecs = Record<string, Payload>;
12
- type ActionFnCreator<Spec extends ActionsFnSpecs> = {
13
- [ActionName in keyof Spec]: (Record<never, never> extends Spec[ActionName] ? () => Spec[ActionName] & {
14
- type: ActionName;
15
- } : (payload: Spec[ActionName]) => Spec[ActionName] & {
16
- type: ActionName;
17
- }) & {
18
- type: ActionName & string;
19
- };
20
- };
21
- type ActionFnPayload<Action> = Action extends (payload: infer Payload) => void ? Payload : never;
22
- type ActionFnsCreator<Spec extends ActionsFnSpecs> = Spec extends {
23
- private: Record<string, Payload>;
24
- public: Record<string, Payload>;
25
- } ? ActionFnCreator<Spec['private']> & ActionFnCreator<Spec['public']> : ActionFnCreator<Spec>;
26
- type PublicActionFns<Spec extends ActionsFnSpecs> = Spec extends {
27
- public: Record<string, Payload>;
28
- } ? ActionFnCreator<Spec['public']> : ActionFnCreator<Spec>;
29
- export declare function payload<Type extends Payload>(): Type;
30
- export declare const noPayload: {};
31
- /** Reducer **/
32
- type ReducerFunction<ReducerAction, State> = (state: State, action: ActionFnPayload<ReducerAction>) => void;
33
- type ReducerFactory<StateActionFns extends ActionFns, State> = (actions: StateActionFns, on: <ReducerAction extends {
34
- type: string;
35
- }>(action: ReducerAction, reducerFn: ReducerFunction<ReducerAction, State>) => void) => void;
36
- /**
37
- * Creates a reducer function to separate the reducer logic into another file.
38
- *
39
- * ```typescript
40
- * interface FlightState {
41
- * flights: Flight[];
42
- * effect1: boolean;
43
- * effect2: boolean;
44
- * }
45
- *
46
- * const initialState: FlightState = {
47
- * flights: [],
48
- * effect1: false,
49
- * effect2: false,
50
- * };
51
- *
52
- * const actions = {
53
- * init: noPayload,
54
- * updateEffect1: payload<{ value: boolean }>(),
55
- * updateEffect2: payload<{ value: boolean }>(),
56
- * };
57
- *
58
- * const reducer = createReducer<FlightState, typeof actions>((actions, on) => {
59
- * on(actions.updateEffect1, (state, { value }) => {
60
- * patchState(state, { effect1: value });
61
- * });
62
- *
63
- * on(actions.updateEffect2, (state, { value }) => {
64
- * patchState(state, { effect2: value });
65
- * });
66
- * });
67
- *
68
- * signalStore(
69
- * withState(initialState),
70
- * withRedux({
71
- * actions,
72
- * reducer,
73
- * })
74
- * );
75
- * ```
76
- * @param reducerFactory
77
- */
78
- export declare function createReducer<State extends object, Actions extends ActionsFnSpecs>(reducerFactory: ReducerFactory<ActionFnsCreator<Actions>, WritableStateSource<State>>): ReducerFactory<ActionFnsCreator<Actions>, WritableStateSource<State>>;
79
- /** Effect **/
80
- type EffectsFactory<StateActionFns extends ActionFns> = (actions: StateActionFns, create: <EffectAction extends {
81
- type: string;
82
- }>(action: EffectAction) => Observable<ActionFnPayload<EffectAction>>) => Record<string, Observable<unknown>>;
83
- /**
84
- * @deprecated Use NgRx's `@ngrx/signals/events` starting in 19.2
85
- *
86
- * Creates the effects function to separate the effects logic into another file.
87
- *
88
- * ```typescript
89
- * interface FlightState {
90
- * flights: Flight[];
91
- * effect1: boolean;
92
- * effect2: boolean;
93
- * }
94
- *
95
- * const initialState: FlightState = {
96
- * flights: [],
97
- * effect1: false,
98
- * effect2: false,
99
- * };
100
- *
101
- * const actions = {
102
- * init: noPayload,
103
- * updateEffect1: payload<{ value: boolean }>(),
104
- * updateEffect2: payload<{ value: boolean }>(),
105
- * };
106
- *
107
- * const effects = createEffects(actions, (actions, create) => {
108
- * return {
109
- * init1$: create(actions.init).pipe(
110
- * map(() => actions.updateEffect1({ value: true }))
111
- * ),
112
- * init2$: create(actions.init).pipe(
113
- * map(() => actions.updateEffect2({ value: true }))
114
- * ),
115
- * };
116
- * });
117
- *
118
- * signalStore(
119
- * withState(initialState),
120
- * withRedux({
121
- * actions,
122
- * effects,
123
- * })
124
- * );
125
- * ```
126
- * @param actions
127
- * @param effectsFactory
128
- */
129
- export declare function createEffects<Actions extends ActionsFnSpecs>(actions: Actions, effectsFactory: EffectsFactory<ActionFnsCreator<Actions>>): EffectsFactory<ActionFnsCreator<Actions>>;
130
- /**
131
- * @param redux redux
132
- *
133
- * properties do not start with `with` since they are not extension functions on their own.
134
- *
135
- * no dependency to NgRx
136
- *
137
- * actions are passed to reducer and effects, but it is also possible to use other actions.
138
- * effects provide forAction and do not return anything. that is important because effects should stay inaccessible
139
- */
140
- export declare function withRedux<Spec extends ActionsFnSpecs, Input extends SignalStoreFeatureResult, StateActionFns extends ActionFnsCreator<Spec> = ActionFnsCreator<Spec>, PublicStoreActionFns extends PublicActionFns<Spec> = PublicActionFns<Spec>>(redux: {
141
- actions: Spec;
142
- reducer: ReducerFactory<StateActionFns, WritableStateSource<Input['state']>>;
143
- effects: EffectsFactory<StateActionFns>;
144
- }): SignalStoreFeature<Input, EmptyFeatureResult & {
145
- methods: PublicStoreActionFns;
146
- }>;
147
- export {};
@@ -1,29 +0,0 @@
1
- import { StateSource } from '@ngrx/signals';
2
- export type PublicMethods = {
3
- resetState(): void;
4
- };
5
- /**
6
- * Adds a `resetState` method to the store, which resets the state
7
- * to the initial state.
8
- *
9
- * If you want to set a custom initial state, you can use {@link setResetState}.
10
- */
11
- export declare function withReset(): import("@ngrx/signals").SignalStoreFeature<import("@ngrx/signals").EmptyFeatureResult, {
12
- state: {};
13
- props: {
14
- _resetState: {
15
- value: {};
16
- };
17
- };
18
- methods: {
19
- resetState: () => void;
20
- };
21
- }>;
22
- /**
23
- * Sets the reset state of the store to the given state.
24
- *
25
- * Throws an error if the store is not configured with {@link withReset}.
26
- * @param store the instance of a SignalStore
27
- * @param state the state to set as the reset state
28
- */
29
- export declare function setResetState<State extends object>(store: StateSource<State>, state: State): void;
@@ -1,31 +0,0 @@
1
- import { Signal } from '@angular/core';
2
- import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';
3
- export type StackItem = Record<string, unknown>;
4
- export type NormalizedUndoRedoOptions = {
5
- maxStackSize: number;
6
- collections?: string[];
7
- keys: string[];
8
- skip: number;
9
- };
10
- export declare function getUndoRedoKeys(collections?: string[]): string[];
11
- type NonNever<T> = T extends never ? never : T;
12
- type ExtractEntityCollection<T> = T extends `${infer U}Entities` ? U : never;
13
- type ExtractEntityCollections<Store extends SignalStoreFeatureResult> = NonNever<{
14
- [K in keyof Store['props']]: ExtractEntityCollection<K>;
15
- }[keyof Store['props']]>;
16
- type OptionsForState<Store extends SignalStoreFeatureResult> = Partial<Omit<NormalizedUndoRedoOptions, 'collections' | 'keys'>> & {
17
- collections?: ExtractEntityCollections<Store>[];
18
- keys?: (keyof Store['state'])[];
19
- };
20
- export declare function withUndoRedo<Input extends EmptyFeatureResult>(options?: OptionsForState<Input>): SignalStoreFeature<Input, EmptyFeatureResult & {
21
- props: {
22
- canUndo: Signal<boolean>;
23
- canRedo: Signal<boolean>;
24
- };
25
- methods: {
26
- undo: () => void;
27
- redo: () => void;
28
- clearStack: () => void;
29
- };
30
- }>;
31
- export {};
@@ -1,13 +0,0 @@
1
- import { ActionCreator, ActionType } from '@ngrx/store/src/models';
2
- import { CreateReduxState, MapperTypes, Store } from './model';
3
- export declare function mapAction<Creators extends readonly ActionCreator[]>(...args: [
4
- ...creators: Creators,
5
- storeMethod: (action: ActionType<Creators[number]>) => unknown
6
- ]): MapperTypes<Creators>;
7
- export declare function mapAction<Creators extends readonly ActionCreator[], T>(...args: [
8
- ...creators: Creators,
9
- storeMethod: (action: ActionType<Creators[number]>, resultMethod: (input: T) => unknown) => unknown,
10
- resultMethod: (input: T) => unknown
11
- ]): MapperTypes<Creators>;
12
- export declare function withActionMappers(...mappers: MapperTypes<ActionCreator[]>[]): MapperTypes<ActionCreator[]>[];
13
- export declare function createReduxState<StoreName extends string, STORE extends Store>(storeName: StoreName, signalStore: STORE, withActionMappers: (store: InstanceType<STORE>) => MapperTypes<ActionCreator[]>[]): CreateReduxState<StoreName, STORE>;
@@ -1,40 +0,0 @@
1
- import { EnvironmentProviders, Signal, Type } from '@angular/core';
2
- import { DeepSignal } from '@ngrx/signals/src/deep-signal';
3
- import { SignalStoreFeatureResult, StateSignals } from '@ngrx/signals/src/signal-store-models';
4
- import { Action, ActionCreator, ActionType, Prettify } from '@ngrx/store/src/models';
5
- import { Observable, Unsubscribable } from 'rxjs';
6
- export type IncludePropType<T, V, WithNevers = {
7
- [K in keyof T]: Exclude<T[K], undefined> extends V ? T[K] extends Record<string, unknown> ? IncludePropType<T[K], V> : T[K] : never;
8
- }> = Prettify<Pick<WithNevers, {
9
- [K in keyof WithNevers]: WithNevers[K] extends never ? never : K extends string ? K : never;
10
- }[keyof WithNevers]>>;
11
- export type Store = Type<Record<string, unknown> & StateSignals<SignalStoreFeatureResult['state']>>;
12
- export type CreateReduxState<StoreName extends string, STORE extends Store> = {
13
- [K in StoreName as `provide${Capitalize<K>}Store`]: (connectReduxDevtools?: boolean) => EnvironmentProviders;
14
- } & {
15
- [K in StoreName as `inject${Capitalize<K>}Store`]: () => InjectableReduxSlice<STORE>;
16
- };
17
- export type Selectors<STORE extends Store> = IncludePropType<InstanceType<STORE>, Signal<unknown> | DeepSignal<unknown>>;
18
- export type Dispatch = {
19
- dispatch: (input: Action | Observable<Action> | Signal<Action>) => Unsubscribable;
20
- };
21
- export type InjectableReduxSlice<STORE extends Store> = Selectors<STORE> & Dispatch;
22
- export type ExtractActionTypes<Creators extends readonly ActionCreator[]> = {
23
- [Key in keyof Creators]: Creators[Key] extends ActionCreator<infer T> ? T : never;
24
- };
25
- export interface ActionMethod<T, V extends Action = Action> {
26
- (action: V): T;
27
- }
28
- export interface StoreMethod<Creators extends readonly ActionCreator[], ResultState = unknown> {
29
- (action: ActionType<Creators[number]>): ResultState;
30
- }
31
- export interface MapperTypes<Creators extends readonly ActionCreator[]> {
32
- types: ExtractActionTypes<Creators>;
33
- storeMethod: StoreMethod<Creators>;
34
- resultMethod?: (...args: unknown[]) => unknown;
35
- }
36
- export type ServiceWithDecorator = {
37
- ɵprov?: {
38
- providedIn?: string;
39
- };
40
- };
@@ -1,14 +0,0 @@
1
- import { Injector, Signal } from '@angular/core';
2
- import { Observable } from 'rxjs';
3
- type RxMethodInput<Input> = Input | Observable<Input> | Signal<Input>;
4
- type RxMethodRef = {
5
- destroy: () => void;
6
- };
7
- type RxMethod<Input, MethodInput = Input, MethodResult = unknown> = ((input: RxMethodInput<Input>, resultMethod: (input: MethodInput) => MethodResult) => RxMethodRef) & RxMethodRef;
8
- export declare function reduxMethod<Input, MethodInput = Input>(generator: (source$: Observable<Input>) => Observable<MethodInput>, config?: {
9
- injector?: Injector;
10
- }): RxMethod<Input, MethodInput>;
11
- export declare function reduxMethod<Input, MethodInput = Input, MethodResult = unknown>(generator: (source$: Observable<Input>) => Observable<MethodInput>, resultMethod: (input: MethodInput) => MethodResult, config?: {
12
- injector?: Injector;
13
- }): RxMethod<Input, MethodInput, MethodResult>;
14
- export {};
@@ -1,11 +0,0 @@
1
- import { Action, ActionCreator } from '@ngrx/store';
2
- import { MapperTypes } from './model';
3
- import * as i0 from "@angular/core";
4
- export declare class SignalReduxStore {
5
- private mapperDict;
6
- dispatch: import("@ngrx/signals/rxjs-interop").RxMethod<Action<string>>;
7
- connectFeatureStore(mappers: MapperTypes<ActionCreator<any, any>[]>[]): void;
8
- static ɵfac: i0.ɵɵFactoryDeclaration<SignalReduxStore, never>;
9
- static ɵprov: i0.ɵɵInjectableDeclaration<SignalReduxStore>;
10
- }
11
- export declare function injectReduxDispatch(): import("@ngrx/signals/rxjs-interop").RxMethod<Action<string>>;
@@ -1,5 +0,0 @@
1
- import { ActionCreator } from '@ngrx/store';
2
- import { Unsubscribable } from 'rxjs';
3
- export declare function isUnsubscribable<F extends (...args: unknown[]) => unknown>(fn: F | (F & Unsubscribable)): fn is F & Unsubscribable;
4
- export declare function capitalize(str: string): string;
5
- export declare function isActionCreator(action: unknown): action is ActionCreator;