@angular-architects/ngrx-toolkit 19.0.2 → 19.2.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.
Files changed (31) hide show
  1. package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs +8 -8
  2. package/fesm2022/angular-architects-ngrx-toolkit-redux-connector.mjs.map +1 -1
  3. package/fesm2022/angular-architects-ngrx-toolkit.mjs +951 -504
  4. package/fesm2022/angular-architects-ngrx-toolkit.mjs.map +1 -1
  5. package/index.d.ts +18 -8
  6. package/lib/devtools/internal/glitch-tracker.service.d.ts +1 -1
  7. package/lib/devtools/internal/models.d.ts +2 -3
  8. package/lib/devtools/provide-devtools-config.d.ts +20 -0
  9. package/lib/devtools/update-state.d.ts +1 -2
  10. package/lib/devtools/with-devtools.d.ts +2 -8
  11. package/lib/immutable-state/deep-freeze.d.ts +11 -0
  12. package/lib/immutable-state/is-dev-mode.d.ts +1 -0
  13. package/lib/immutable-state/with-immutable-state.d.ts +60 -0
  14. package/lib/storage-sync/features/with-indexed-db.d.ts +2 -0
  15. package/lib/storage-sync/features/with-local-storage.d.ts +3 -0
  16. package/lib/storage-sync/internal/indexeddb.service.d.ts +29 -0
  17. package/lib/storage-sync/internal/local-storage.service.d.ts +8 -0
  18. package/lib/storage-sync/internal/models.d.ts +34 -0
  19. package/lib/storage-sync/internal/session-storage.service.d.ts +8 -0
  20. package/lib/storage-sync/with-storage-sync.d.ts +45 -0
  21. package/lib/with-call-state.d.ts +19 -2
  22. package/lib/with-conditional.d.ts +50 -0
  23. package/lib/with-data-service.d.ts +5 -5
  24. package/lib/with-feature-factory.d.ts +28 -0
  25. package/lib/with-pagination.d.ts +6 -32
  26. package/lib/with-redux.d.ts +3 -1
  27. package/lib/with-undo-redo.d.ts +1 -1
  28. package/package.json +3 -3
  29. package/redux-connector/src/lib/rxjs-interop/redux-method.d.ts +2 -2
  30. package/redux-connector/src/lib/signal-redux-store.d.ts +4 -16
  31. package/lib/with-storage-sync.d.ts +0 -52
package/index.d.ts CHANGED
@@ -1,14 +1,24 @@
1
- export { withDevToolsStub } from './lib/devtools/with-dev-tools-stub';
2
- export { withDevtools } from './lib/devtools/with-devtools';
3
1
  export { withDisabledNameIndices } from './lib/devtools/features/with-disabled-name-indicies';
4
- export { withMapper } from './lib/devtools/features/with-mapper';
5
2
  export { withGlitchTracking } from './lib/devtools/features/with-glitch-tracking';
6
- export { patchState, updateState } from './lib/devtools/update-state';
3
+ export { withMapper } from './lib/devtools/features/with-mapper';
4
+ export { ReduxDevtoolsConfig, provideDevtoolsConfig, } from './lib/devtools/provide-devtools-config';
7
5
  export { renameDevtoolsName } from './lib/devtools/rename-devtools-name';
8
- export { withRedux, payload, noPayload, createReducer, createEffects, } from './lib/with-redux';
6
+ export { patchState, updateState } from './lib/devtools/update-state';
7
+ export { withDevToolsStub } from './lib/devtools/with-dev-tools-stub';
8
+ export { withDevtools } from './lib/devtools/with-devtools';
9
+ export { createEffects, createReducer, noPayload, payload, withRedux, } from './lib/with-redux';
9
10
  export * from './lib/with-call-state';
10
- export * from './lib/with-undo-redo';
11
11
  export * from './lib/with-data-service';
12
- export { withStorageSync, SyncConfig } from './lib/with-storage-sync';
13
12
  export * from './lib/with-pagination';
14
- export { withReset, setResetState } from './lib/with-reset';
13
+ export { setResetState, withReset } from './lib/with-reset';
14
+ export * from './lib/with-undo-redo';
15
+ export { withImmutableState } from './lib/immutable-state/with-immutable-state';
16
+ export { withIndexedDB } from './lib/storage-sync/features/with-indexed-db';
17
+ /**
18
+ * @deprecated Use {@link withIndexedDB} instead.
19
+ */
20
+ export { withIndexedDB as withIndexeddb } from './lib/storage-sync/features/with-indexed-db';
21
+ export { withLocalStorage, withSessionStorage, } from './lib/storage-sync/features/with-local-storage';
22
+ export { SyncConfig, withStorageSync, } from './lib/storage-sync/with-storage-sync';
23
+ export { emptyFeature, withConditional } from './lib/with-conditional';
24
+ export { withFeatureFactory } from './lib/with-feature-factory';
@@ -1,5 +1,5 @@
1
- import { Tracker, TrackerStores } from './models';
2
1
  import { StateSource } from '@ngrx/signals';
2
+ import { Tracker, TrackerStores } from './models';
3
3
  import * as i0 from "@angular/core";
4
4
  /**
5
5
  * Internal Service used by {@link withGlitchTracking}. It does not rely
@@ -1,4 +1,5 @@
1
1
  import { StateSource } from '@ngrx/signals';
2
+ import { ReduxDevtoolsConfig } from '../provide-devtools-config';
2
3
  import { DevtoolsInnerOptions } from './devtools-feature';
3
4
  export type Action = {
4
5
  type: string;
@@ -7,9 +8,7 @@ export type Connection = {
7
8
  send: (action: Action, state: Record<string, unknown>) => void;
8
9
  };
9
10
  export type ReduxDevtoolsExtension = {
10
- connect: (options: {
11
- name: string;
12
- }) => Connection;
11
+ connect: (options: ReduxDevtoolsConfig) => Connection;
13
12
  };
14
13
  export type StoreRegistry = Record<string, {
15
14
  options: DevtoolsInnerOptions;
@@ -0,0 +1,20 @@
1
+ import { InjectionToken, ValueProvider } from '@angular/core';
2
+ /**
3
+ * Provides the configuration options for connecting to the Redux DevTools Extension.
4
+ */
5
+ export declare function provideDevtoolsConfig(config: ReduxDevtoolsConfig): ValueProvider;
6
+ /**
7
+ * Injection token for the configuration options for connecting to the Redux DevTools Extension.
8
+ */
9
+ export declare const REDUX_DEVTOOLS_CONFIG: InjectionToken<ReduxDevtoolsConfig>;
10
+ /**
11
+ * Options for connecting to the Redux DevTools Extension.
12
+ * @example
13
+ * const devToolsOptions: ReduxDevtoolsConfig = {
14
+ * name: 'My App',
15
+ * };
16
+ */
17
+ export type ReduxDevtoolsConfig = {
18
+ /** Optional name for the devtools instance. If empty, "NgRx SignalStore" will be used. */
19
+ name?: string;
20
+ };
@@ -1,5 +1,4 @@
1
- import { patchState as originalPatchState } from '@ngrx/signals';
2
- import { PartialStateUpdater, WritableStateSource } from '@ngrx/signals';
1
+ import { patchState as originalPatchState, PartialStateUpdater, WritableStateSource } from '@ngrx/signals';
3
2
  import { Prettify } from '../shared/prettify';
4
3
  type PatchFn = typeof originalPatchState extends (arg1: infer First, ...args: infer Rest) => infer Returner ? (state: First, action: string, ...rest: Rest) => Returner : never;
5
4
  /**
@@ -1,3 +1,4 @@
1
+ import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
1
2
  import { DevtoolsFeature } from './internal/devtools-feature';
2
3
  import { ReduxDevtoolsExtension } from './internal/models';
3
4
  declare global {
@@ -5,7 +6,6 @@ declare global {
5
6
  __REDUX_DEVTOOLS_EXTENSION__: ReduxDevtoolsExtension | undefined;
6
7
  }
7
8
  }
8
- export declare const existingNames: Map<string, unknown>;
9
9
  export declare const renameDevtoolsMethodName = "___renameDevtoolsName";
10
10
  export declare const uniqueDevtoolsId = "___uniqueDevtoolsId";
11
11
  /**
@@ -21,10 +21,4 @@ export declare const uniqueDevtoolsId = "___uniqueDevtoolsId";
21
21
  * @param name name of the store as it should appear in the DevTools
22
22
  * @param features features to extend or modify the behavior of the Devtools
23
23
  */
24
- export declare function withDevtools(name: string, ...features: DevtoolsFeature[]): import("@ngrx/signals").SignalStoreFeature<import("@ngrx/signals").EmptyFeatureResult, {
25
- state: {};
26
- props: {};
27
- methods: {
28
- [x: string]: (newName?: unknown) => unknown;
29
- };
30
- }>;
24
+ export declare function withDevtools(name: string, ...features: DevtoolsFeature[]): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Deep freezes a state object along its properties with primitive values
3
+ * on the first level.
4
+ *
5
+ * The reason for this is that the final state is a merge of all
6
+ * root properties of all states, i.e. `withState`,....
7
+ *
8
+ * Since the root object will not be part of the state (shadow clone),
9
+ * we are not freezing it.
10
+ */
11
+ export declare function deepFreeze<T extends Record<string | symbol, unknown>>(target: T, propertyNamesToBeFrozen: (string | symbol)[], isRoot?: boolean): void;
@@ -0,0 +1 @@
1
+ export declare function isDevMode(): boolean;
@@ -0,0 +1,60 @@
1
+ import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';
2
+ /**
3
+ * The implementation of this feature is a little bit tricky.
4
+ *
5
+ * `signalStore` does a shallow clone in the initial phase, in order to
6
+ * merge all different states together.
7
+ *
8
+ * Shallow cloning also happens in `patchState`.
9
+ *
10
+ * With shallow cloning, the root state object is replaced, which means,
11
+ * the freezing only stays for its nested properties but not for
12
+ * the primitive and immediate properties.
13
+ *
14
+ * For example:
15
+ *
16
+ * ```ts
17
+ * const state = {
18
+ * id: 1,
19
+ * address: {
20
+ * street: 'Main St',
21
+ * city: 'Springfield',
22
+ * }
23
+ * }
24
+ * ```
25
+ *
26
+ * Running `Object.freeze` on `state` will freeze the `address` object, and
27
+ * the `id`. But since `state` is shallow cloned, the "frozing" state of the
28
+ * `id` is lost. `address`, being an object, is still frozen.
29
+ *
30
+ * To overcome that, we run `watchState` and run `deepFreeze`
31
+ * on every change.
32
+ */
33
+ /**
34
+ * Prevents mutation of the state.
35
+ *
36
+ * This is done by deeply applying `Object.freeze`. Any mutable change within
37
+ * or outside the `SignalStore` will throw an error.
38
+ *
39
+ * @param state the state object
40
+ * @param options enable protection in production (default: false)
41
+ */
42
+ export declare function withImmutableState<State extends object>(state: State, options?: {
43
+ enableInProduction?: boolean;
44
+ }): SignalStoreFeature<SignalStoreFeatureResult, EmptyFeatureResult & {
45
+ state: State;
46
+ }>;
47
+ /**
48
+ * Prevents mutation of the state.
49
+ *
50
+ * This is done by deeply applying `Object.freeze`. Any mutable change within
51
+ * or outside the `SignalStore` will throw an error.
52
+ *
53
+ * @param stateFactory a function returning the state object
54
+ * @param options enable protection in production (default: false)
55
+ */
56
+ export declare function withImmutableState<State extends object>(stateFactory: () => State, options?: {
57
+ enableInProduction?: boolean;
58
+ }): SignalStoreFeature<SignalStoreFeatureResult, EmptyFeatureResult & {
59
+ state: State;
60
+ }>;
@@ -0,0 +1,2 @@
1
+ import { AsyncStorageStrategy } from '../internal/models';
2
+ export declare function withIndexedDB<State extends object>(): AsyncStorageStrategy<State>;
@@ -0,0 +1,3 @@
1
+ import { SyncStorageStrategy } from '../internal/models';
2
+ export declare function withLocalStorage<State extends object>(): SyncStorageStrategy<State>;
3
+ export declare function withSessionStorage<State extends object>(): SyncStorageStrategy<State>;
@@ -0,0 +1,29 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare const keyPath = "ngrxToolkitKeyPath";
3
+ export declare const dbName = "ngrxToolkitDb";
4
+ export declare const storeName = "ngrxToolkitStore";
5
+ export declare const VERSION: number;
6
+ export declare class IndexedDBService {
7
+ /**
8
+ * write to indexedDB
9
+ * @param key
10
+ * @param data
11
+ */
12
+ setItem(key: string, data: string): Promise<void>;
13
+ /**
14
+ * read from indexedDB
15
+ * @param key
16
+ */
17
+ getItem(key: string): Promise<string | null>;
18
+ /**
19
+ * delete indexedDB
20
+ * @param key
21
+ */
22
+ clear(key: string): Promise<void>;
23
+ /**
24
+ * open indexedDB
25
+ */
26
+ private openDB;
27
+ static ɵfac: i0.ɵɵFactoryDeclaration<IndexedDBService, never>;
28
+ static ɵprov: i0.ɵɵInjectableDeclaration<IndexedDBService>;
29
+ }
@@ -0,0 +1,8 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class LocalStorageService {
3
+ getItem(key: string): string | null;
4
+ setItem(key: string, data: string): void;
5
+ clear(key: string): void;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<LocalStorageService, never>;
7
+ static ɵprov: i0.ɵɵInjectableDeclaration<LocalStorageService>;
8
+ }
@@ -0,0 +1,34 @@
1
+ import { Signal, WritableSignal } from '@angular/core';
2
+ import { EmptyFeatureResult, WritableStateSource } from '@ngrx/signals';
3
+ import { SyncConfig } from '../with-storage-sync';
4
+ export type SyncMethods = {
5
+ clearStorage(): void;
6
+ readFromStorage(): void;
7
+ writeToStorage(): void;
8
+ };
9
+ export type SyncFeatureResult = EmptyFeatureResult & {
10
+ methods: SyncMethods;
11
+ };
12
+ export type SyncStoreForFactory<State extends object> = WritableStateSource<State>;
13
+ export type SyncStorageStrategy<State extends object> = ((config: Required<SyncConfig<State>>, store: SyncStoreForFactory<State>, useStubs: boolean) => SyncMethods) & {
14
+ type: 'sync';
15
+ };
16
+ export type AsyncMethods = {
17
+ clearStorage(): Promise<void>;
18
+ readFromStorage(): Promise<void>;
19
+ writeToStorage(): Promise<void>;
20
+ };
21
+ export declare const SYNC_STATUS: unique symbol;
22
+ export type SyncStatus = 'idle' | 'syncing' | 'synced';
23
+ export type AsyncFeatureResult = EmptyFeatureResult & {
24
+ methods: AsyncMethods;
25
+ props: {
26
+ isSynced: Signal<boolean>;
27
+ whenSynced: () => Promise<void>;
28
+ [SYNC_STATUS]: WritableSignal<SyncStatus>;
29
+ };
30
+ };
31
+ export type AsyncStoreForFactory<State extends object> = WritableStateSource<State> & AsyncFeatureResult['props'];
32
+ export type AsyncStorageStrategy<State extends object> = ((config: Required<SyncConfig<State>>, store: AsyncStoreForFactory<State>, useStubs: boolean) => AsyncMethods) & {
33
+ type: 'async';
34
+ };
@@ -0,0 +1,8 @@
1
+ import * as i0 from "@angular/core";
2
+ export declare class SessionStorageService {
3
+ getItem(key: string): string | null;
4
+ setItem(key: string, data: string): void;
5
+ clear(key: string): void;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<SessionStorageService, never>;
7
+ static ɵprov: i0.ɵɵInjectableDeclaration<SessionStorageService>;
8
+ }
@@ -0,0 +1,45 @@
1
+ import { SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';
2
+ import { AsyncFeatureResult, AsyncStorageStrategy, SyncFeatureResult, SyncStorageStrategy } from './internal/models';
3
+ export type SyncConfig<State> = {
4
+ /**
5
+ * The key which is used to access the storage.
6
+ */
7
+ key: string;
8
+ /**
9
+ * Flag indicating if the store should read from storage on init and write to storage on every state change.
10
+ *
11
+ * `true` by default
12
+ */
13
+ autoSync?: boolean;
14
+ /**
15
+ * Function to select that portion of the state which should be stored.
16
+ *
17
+ * Returns the whole state object by default
18
+ */
19
+ select?: (state: State) => unknown;
20
+ /**
21
+ * Function used to parse the state coming from storage.
22
+ *
23
+ * `JSON.parse()` by default
24
+ */
25
+ parse?: (stateString: string) => State;
26
+ /**
27
+ * Function used to transform the state into a string representation.
28
+ *
29
+ * `JSON.stringify()` by default
30
+ */
31
+ stringify?: (state: State) => string;
32
+ /**
33
+ * @deprecated Use {@link withSessionStorage} instead.
34
+ * Factory function used to switch to sessionStorage.
35
+ *
36
+ * `localStorage` by default
37
+ */
38
+ storage?: () => Storage;
39
+ };
40
+ export declare function withStorageSync<Input extends SignalStoreFeatureResult>(key: string): SignalStoreFeature<Input, SyncFeatureResult>;
41
+ export declare function withStorageSync<Input extends SignalStoreFeatureResult>(key: string, storageStrategy: AsyncStorageStrategy<Input['state']>): SignalStoreFeature<Input, AsyncFeatureResult>;
42
+ export declare function withStorageSync<Input extends SignalStoreFeatureResult>(key: string, storageStrategy: SyncStorageStrategy<Input['state']>): SignalStoreFeature<Input, SyncFeatureResult>;
43
+ export declare function withStorageSync<Input extends SignalStoreFeatureResult>(config: SyncConfig<Input['state']>): SignalStoreFeature<Input, SyncFeatureResult>;
44
+ export declare function withStorageSync<Input extends SignalStoreFeatureResult>(config: SyncConfig<Input['state']>, storageStrategy: AsyncStorageStrategy<Input['state']>): SignalStoreFeature<Input, AsyncFeatureResult>;
45
+ export declare function withStorageSync<Input extends SignalStoreFeatureResult>(config: SyncConfig<Input['state']>, storageStrategy: SyncStorageStrategy<Input['state']>): SignalStoreFeature<Input, SyncFeatureResult>;
@@ -7,7 +7,7 @@ export type CallStateSlice = {
7
7
  callState: CallState;
8
8
  };
9
9
  export type NamedCallStateSlice<Collection extends string> = {
10
- [K in keyof CallStateSlice as `${Collection}${Capitalize<K>}`]: CallStateSlice[K];
10
+ [K in keyof CallStateSlice as Collection extends '' ? `${Collection}${K}` : `${Collection}${Capitalize<K>}`]: CallStateSlice[K];
11
11
  };
12
12
  export type CallStateSignals = {
13
13
  loading: Signal<boolean>;
@@ -15,9 +15,15 @@ export type CallStateSignals = {
15
15
  error: Signal<string | null>;
16
16
  };
17
17
  export type NamedCallStateSignals<Prop extends string> = {
18
- [K in keyof CallStateSignals as `${Prop}${Capitalize<K>}`]: CallStateSignals[K];
18
+ [K in keyof CallStateSignals as Prop extends '' ? `${Prop}${K}` : `${Prop}${Capitalize<K>}`]: CallStateSignals[K];
19
19
  };
20
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
+ };
21
27
  export declare function getCallStateKeys(config?: {
22
28
  collection?: string;
23
29
  }): {
@@ -26,6 +32,17 @@ export declare function getCallStateKeys(config?: {
26
32
  loadedKey: string;
27
33
  errorKey: string;
28
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
+ }>;
29
46
  export declare function withCallState<Collection extends string>(config: {
30
47
  collection: Collection;
31
48
  }): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult & {
@@ -0,0 +1,50 @@
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,8 +1,8 @@
1
1
  import { ProviderToken, Signal } from '@angular/core';
2
- import { SignalStoreFeature, EmptyFeatureResult } from '@ngrx/signals';
3
- import { CallState } from './with-call-state';
4
- import { EntityId } from '@ngrx/signals/entities';
5
- import { EntityState, NamedEntityComputed } from './shared/signal-store-models';
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
6
  export type Filter = Record<string, unknown>;
7
7
  export type Entity = {
8
8
  id: EntityId;
@@ -89,7 +89,7 @@ export declare function withDataService<E extends Entity, F extends Filter, Coll
89
89
  filter: F;
90
90
  collection: Collection;
91
91
  }): SignalStoreFeature<EmptyFeatureResult & {
92
- props: NamedEntityComputed<E, Collection>;
92
+ state: NamedCallStateSlice<Collection> & NamedEntityState<E, Collection>;
93
93
  }, {
94
94
  state: NamedDataServiceState<E, F, Collection>;
95
95
  props: NamedDataServiceComputed<E, Collection>;
@@ -0,0 +1,28 @@
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 {};
@@ -6,8 +6,8 @@
6
6
  * This feature implements the local pagination.
7
7
  */
8
8
  import { Signal } from '@angular/core';
9
- import { SignalStoreFeature, EmptyFeatureResult } from '@ngrx/signals';
10
- import { EntityComputed, EntityState, NamedEntityComputed } from './shared/signal-store-models';
9
+ import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
10
+ import { MethodsDictionary } from '@ngrx/signals/src/signal-store-models';
11
11
  export type Page = {
12
12
  label: string | number;
13
13
  value: number;
@@ -46,19 +46,6 @@ export type NamedPaginationServiceSignals<E, Collection extends string> = {
46
46
  } & {
47
47
  [K in Collection as `hasPrevious${Capitalize<K>}Page`]: Signal<boolean>;
48
48
  };
49
- export type NamedPaginationServiceMethods<Collection extends string> = {
50
- [K in Collection as `set${Capitalize<K>}PageSize`]: (size: number) => void;
51
- } & {
52
- [K in Collection as `next${Capitalize<K>}Page`]: () => void;
53
- } & {
54
- [K in Collection as `previous${Capitalize<K>}Page`]: () => void;
55
- } & {
56
- [K in Collection as `last${Capitalize<K>}Page`]: () => void;
57
- } & {
58
- [K in Collection as `first${Capitalize<K>}Page`]: () => void;
59
- } & {
60
- [K in Collection as `goto${Capitalize<K>}Page`]: (page: number) => void;
61
- };
62
49
  export type PaginationServiceState<E> = {
63
50
  selectedPageEntities: Array<E>;
64
51
  currentPage: number;
@@ -79,32 +66,19 @@ export type PaginationServiceSignals<E> = {
79
66
  hasNextPage: Signal<boolean>;
80
67
  hasPreviousPage: Signal<boolean>;
81
68
  };
82
- export type PaginationServiceMethods = {
83
- setPageSize: (size: number) => void;
84
- nextPageKey: () => void;
85
- previousPage: () => void;
86
- lastPage: () => void;
87
- firstPage: () => void;
88
- gotoPage: (page: number) => void;
89
- };
90
69
  export type SetPaginationState<E, Collection extends string | undefined> = Collection extends string ? NamedPaginationServiceState<E, Collection> : PaginationServiceState<E>;
91
70
  export declare function withPagination<E, Collection extends string>(options: {
92
71
  entity: E;
93
72
  collection: Collection;
94
- }): SignalStoreFeature<EmptyFeatureResult & {
95
- props: NamedEntityComputed<E, Collection>;
96
- }, {
73
+ }): SignalStoreFeature<EmptyFeatureResult, {
97
74
  state: NamedPaginationServiceState<E, Collection>;
98
75
  props: NamedPaginationServiceSignals<E, Collection>;
99
- methods: NamedPaginationServiceMethods<Collection>;
76
+ methods: MethodsDictionary;
100
77
  }>;
101
- export declare function withPagination<E>(): SignalStoreFeature<EmptyFeatureResult & {
102
- state: EntityState<E>;
103
- props: EntityComputed<E>;
104
- }, {
78
+ export declare function withPagination<E>(): SignalStoreFeature<EmptyFeatureResult, {
105
79
  state: PaginationServiceState<E>;
106
80
  props: PaginationServiceSignals<E>;
107
- methods: PaginationServiceMethods;
81
+ methods: MethodsDictionary;
108
82
  }>;
109
83
  export declare function gotoPage<E, Collection extends string>(page: number, options?: {
110
84
  collection: Collection;
@@ -1,5 +1,5 @@
1
- import { Observable } from 'rxjs';
2
1
  import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult, WritableStateSource } from '@ngrx/signals';
2
+ import { Observable } from 'rxjs';
3
3
  /** Actions **/
4
4
  type Payload = Record<string, unknown>;
5
5
  type ActionFn<Type extends string = string, ActionPayload extends Payload = Payload> = ((payload: ActionPayload) => ActionPayload & {
@@ -81,6 +81,8 @@ type EffectsFactory<StateActionFns extends ActionFns> = (actions: StateActionFns
81
81
  type: string;
82
82
  }>(action: EffectAction) => Observable<ActionFnPayload<EffectAction>>) => Record<string, Observable<unknown>>;
83
83
  /**
84
+ * @deprecated Use NgRx's `@ngrx/signals/events` starting in 19.2
85
+ *
84
86
  * Creates the effects function to separate the effects logic into another file.
85
87
  *
86
88
  * ```typescript
@@ -1,5 +1,5 @@
1
- import { SignalStoreFeature, EmptyFeatureResult, SignalStoreFeatureResult } from '@ngrx/signals';
2
1
  import { Signal } from '@angular/core';
2
+ import { EmptyFeatureResult, SignalStoreFeature, SignalStoreFeatureResult } from '@ngrx/signals';
3
3
  export type StackItem = Record<string, unknown>;
4
4
  export type NormalizedUndoRedoOptions = {
5
5
  maxStackSize: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-architects/ngrx-toolkit",
3
- "version": "19.0.2",
3
+ "version": "19.2.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "GitHub",
@@ -9,8 +9,8 @@
9
9
  "peerDependencies": {
10
10
  "@angular/core": "^19.0.0",
11
11
  "@angular/common": "^19.0.0",
12
- "@ngrx/signals": "^19.0.0",
13
- "@ngrx/store": "^19.0.0",
12
+ "@ngrx/signals": "19.2.1",
13
+ "@ngrx/store": "^19.2.1",
14
14
  "rxjs": "^7.0.0"
15
15
  },
16
16
  "peerDependenciesMeta": {
@@ -1,5 +1,5 @@
1
- import { Injector, Signal } from "@angular/core";
2
- import { Observable } from "rxjs";
1
+ import { Injector, Signal } from '@angular/core';
2
+ import { Observable } from 'rxjs';
3
3
  type RxMethodInput<Input> = Input | Observable<Input> | Signal<Input>;
4
4
  type RxMethodRef = {
5
5
  destroy: () => void;
@@ -1,23 +1,11 @@
1
- import { Action, ActionCreator } from "@ngrx/store";
2
- import { MapperTypes } from "./model";
1
+ import { Action, ActionCreator } from '@ngrx/store';
2
+ import { MapperTypes } from './model';
3
3
  import * as i0 from "@angular/core";
4
4
  export declare class SignalReduxStore {
5
5
  private mapperDict;
6
- dispatch: ((input: Action<string> | import("rxjs").Observable<Action<string>> | import("@angular/core").Signal<Action<string>>, config?: {
7
- injector?: import("@angular/core").Injector;
8
- }) => {
9
- destroy: () => void;
10
- }) & {
11
- destroy: () => void;
12
- };
6
+ dispatch: import("@ngrx/signals/rxjs-interop").RxMethod<Action<string>>;
13
7
  connectFeatureStore(mappers: MapperTypes<ActionCreator<any, any>[]>[]): void;
14
8
  static ɵfac: i0.ɵɵFactoryDeclaration<SignalReduxStore, never>;
15
9
  static ɵprov: i0.ɵɵInjectableDeclaration<SignalReduxStore>;
16
10
  }
17
- export declare function injectReduxDispatch(): ((input: Action<string> | import("rxjs").Observable<Action<string>> | import("@angular/core").Signal<Action<string>>, config?: {
18
- injector?: import("@angular/core").Injector;
19
- }) => {
20
- destroy: () => void;
21
- }) & {
22
- destroy: () => void;
23
- };
11
+ export declare function injectReduxDispatch(): import("@ngrx/signals/rxjs-interop").RxMethod<Action<string>>;