@angular-architects/ngrx-toolkit 19.1.0 → 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.
package/index.d.ts CHANGED
@@ -1,17 +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
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';
16
24
  export { withFeatureFactory } from './lib/with-feature-factory';
17
- export { withConditional, emptyFeature } from './lib/with-conditional';
@@ -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 {
@@ -20,10 +21,4 @@ export declare const uniqueDevtoolsId = "___uniqueDevtoolsId";
20
21
  * @param name name of the store as it should appear in the DevTools
21
22
  * @param features features to extend or modify the behavior of the Devtools
22
23
  */
23
- export declare function withDevtools(name: string, ...features: DevtoolsFeature[]): import("@ngrx/signals").SignalStoreFeature<import("@ngrx/signals").EmptyFeatureResult, {
24
- state: {};
25
- props: {};
26
- methods: {
27
- [x: string]: (newName?: unknown) => unknown;
28
- };
29
- }>;
24
+ export declare function withDevtools(name: string, ...features: DevtoolsFeature[]): SignalStoreFeature<EmptyFeatureResult, EmptyFeatureResult>;
@@ -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 & {
@@ -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>;
@@ -1,6 +1,8 @@
1
1
  import { SignalStoreFeature, SignalStoreFeatureResult, StateSignals } from '@ngrx/signals';
2
2
  type StoreForFactory<Input extends SignalStoreFeatureResult> = StateSignals<Input['state']> & Input['props'] & Input['methods'];
3
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
+ *
4
6
  * Allows to pass properties, methods, or signals from a SignalStore
5
7
  * to a feature.
6
8
  *
@@ -6,7 +6,7 @@
6
6
  * This feature implements the local pagination.
7
7
  */
8
8
  import { Signal } from '@angular/core';
9
- import { SignalStoreFeature, EmptyFeatureResult } from '@ngrx/signals';
9
+ import { EmptyFeatureResult, SignalStoreFeature } from '@ngrx/signals';
10
10
  import { MethodsDictionary } from '@ngrx/signals/src/signal-store-models';
11
11
  export type Page = {
12
12
  label: string | number;
@@ -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.1.0",
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>>;
@@ -1,52 +0,0 @@
1
- import { SignalStoreFeature, SignalStoreFeatureResult, EmptyFeatureResult } from '@ngrx/signals';
2
- type WithStorageSyncFeatureResult = EmptyFeatureResult & {
3
- methods: {
4
- clearStorage(): void;
5
- readFromStorage(): void;
6
- writeToStorage(): void;
7
- };
8
- };
9
- export type SyncConfig<State> = {
10
- /**
11
- * The key which is used to access the storage.
12
- */
13
- key: string;
14
- /**
15
- * Flag indicating if the store should read from storage on init and write to storage on every state change.
16
- *
17
- * `true` by default
18
- */
19
- autoSync?: boolean;
20
- /**
21
- * Function to select that portion of the state which should be stored.
22
- *
23
- * Returns the whole state object by default
24
- */
25
- select?: (state: State) => Partial<State>;
26
- /**
27
- * Function used to parse the state coming from storage.
28
- *
29
- * `JSON.parse()` by default
30
- */
31
- parse?: (stateString: string) => State;
32
- /**
33
- * Function used to tranform the state into a string representation.
34
- *
35
- * `JSON.stringify()` by default
36
- */
37
- stringify?: (state: State) => string;
38
- /**
39
- * Factory function used to select the storage.
40
- *
41
- * `localstorage` by default
42
- */
43
- storage?: () => Storage;
44
- };
45
- /**
46
- * Enables store synchronization with storage.
47
- *
48
- * Only works on browser platform.
49
- */
50
- export declare function withStorageSync<Input extends SignalStoreFeatureResult>(key: string): SignalStoreFeature<Input, WithStorageSyncFeatureResult>;
51
- export declare function withStorageSync<Input extends SignalStoreFeatureResult>(config: SyncConfig<Input['state']>): SignalStoreFeature<Input, WithStorageSyncFeatureResult>;
52
- export {};