@genesislcap/foundation-redux 14.310.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.
@@ -0,0 +1,222 @@
1
+ import { Action } from '@reduxjs/toolkit';
2
+ import { createSlice } from '@reduxjs/toolkit';
3
+ import { PayloadAction } from '@reduxjs/toolkit';
4
+ import { Reducer } from '@reduxjs/toolkit';
5
+ import { ReducersMapObject } from '@reduxjs/toolkit';
6
+ import { ThunkAction } from '@reduxjs/toolkit';
7
+
8
+ /**
9
+ * Extracts the bound actions type from an array of slices.
10
+ *
11
+ * @remarks
12
+ * This utility type creates a nested object structure where each slice name maps to its actions.
13
+ * Actions are bound to the store and automatically dispatch when called.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const { actions } = createStore([userSlice, cartSlice], initialState);
18
+ * // actions.user.setUser({ name: 'John' })
19
+ * // actions.cart.addItem({ id: 'item1', quantity: 1 })
20
+ * ```
21
+ *
22
+ * @public
23
+ */
24
+ export declare type ActionsFromSlices<S extends SliceArray> = {
25
+ [K in S[number]['name']]: {
26
+ [ActionKey in keyof Extract<S[number], {
27
+ name: K;
28
+ }>['actions']]: (payload: FirstParameter<Extract<S[number], {
29
+ name: K;
30
+ }>['actions'][ActionKey]>) => void;
31
+ };
32
+ };
33
+
34
+ export { createSlice }
35
+
36
+ /**
37
+ * Creates a Redux store with FAST component integration.
38
+ *
39
+ * @remarks
40
+ * This function creates a Redux store that integrates seamlessly with FAST components.
41
+ * It automatically binds actions and selectors, provides subscription methods, and handles
42
+ * FAST Observable notifications.
43
+ *
44
+ * @param slices - Array of slices to combine into the store
45
+ * @param preloadedState - Initial state that matches the slice structure
46
+ * @returns Object containing store, actions, selectors, and utility functions
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * const { store, actions, selectors, subscribeKey } = createStore(
51
+ * [userSlice, cartSlice],
52
+ * {
53
+ * user: { name: '', email: '' },
54
+ * cart: { items: [], total: 0 }
55
+ * }
56
+ * );
57
+ * ```
58
+ *
59
+ * @public
60
+ */
61
+ export declare const createStore: <S extends SliceArray>(slices: S, preloadedState: RootStateFromSlices<S>) => StoreReturn<S>;
62
+
63
+ declare type FirstIndex = 0;
64
+
65
+ declare type FirstParameter<T> = T extends (...args: infer P) => any ? P[FirstIndex] : never;
66
+
67
+ export { PayloadAction }
68
+
69
+ declare type RemoveFirstParameter<T> = T extends (arg1: any, ...rest: infer Rest) => any ? Rest : never;
70
+
71
+ /**
72
+ * Extracts the root state type from an array of slices.
73
+ *
74
+ * @remarks
75
+ * This utility type maps over the slice names and extracts the state type for each slice.
76
+ * The resulting type represents the complete state structure of your Redux store.
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const slices = [userSlice, cartSlice];
81
+ * type RootState = RootStateFromSlices<typeof slices>;
82
+ * // Result: { user: UserState, cart: CartState }
83
+ * ```
84
+ *
85
+ * @public
86
+ */
87
+ export declare type RootStateFromSlices<S extends SliceArray> = {
88
+ [K in S[number]['name']]: Extract<S[number], {
89
+ name: K;
90
+ }> extends Slice<infer State> ? State : never;
91
+ };
92
+
93
+ /**
94
+ * Extracts the bound selectors type from an array of slices.
95
+ *
96
+ * @remarks
97
+ * This utility type creates a nested object structure where each slice name maps to its selectors.
98
+ * Selectors are bound to the store and can access the current state.
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const { selectors } = createStore([userSlice, cartSlice], initialState);
103
+ * // const userName = selectors.user.getUserName()
104
+ * // const cartTotal = selectors.cart.getTotal()
105
+ * ```
106
+ *
107
+ * @public
108
+ */
109
+ export declare type SelectorsFromSlices<S extends SliceArray> = {
110
+ [K in S[number]['name']]: {
111
+ [SelectorKey in keyof Extract<S[number], {
112
+ name: K;
113
+ }>['selectors']]: (...payload: RemoveFirstParameter<Extract<S[number], {
114
+ name: K;
115
+ }>['selectors'][SelectorKey]>) => ReturnType<Extract<S[number], {
116
+ name: K;
117
+ }>['selectors'][SelectorKey]> extends void ? any : ReturnType<Extract<S[number], {
118
+ name: K;
119
+ }>['selectors'][SelectorKey]>;
120
+ };
121
+ };
122
+
123
+ /**
124
+ * Represents a Redux slice with actions and selectors.
125
+ *
126
+ * @remarks
127
+ * A slice contains the reducer, actions, and selectors for a specific domain of your application state.
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const userSlice: Slice = {
132
+ * name: 'user',
133
+ * reducer: userReducer,
134
+ * actions: { setUser, logout },
135
+ * selectors: { getUser, isLoggedIn }
136
+ * };
137
+ * ```
138
+ *
139
+ * @public
140
+ */
141
+ export declare interface Slice<State = any> {
142
+ /** The unique name of the slice */
143
+ name: string;
144
+ /** The Redux reducer function for this slice */
145
+ reducer: Reducer<State, Action>;
146
+ /** Action creators for this slice */
147
+ actions: Record<string, (payload: any) => Action>;
148
+ /** Selector functions for this slice */
149
+ selectors: Record<string, (...args: any[]) => any>;
150
+ }
151
+
152
+ /**
153
+ * An array of slices that will be combined into a single store.
154
+ *
155
+ * @remarks
156
+ * This type represents the collection of slices that will be used to create a Redux store.
157
+ * Each slice in the array will become a top-level key in the store's state.
158
+ *
159
+ * @example
160
+ * ```typescript
161
+ * const slices: SliceArray = [userSlice, cartSlice, preferencesSlice];
162
+ * const { store } = createStore(slices, initialState);
163
+ * ```
164
+ *
165
+ * @public
166
+ */
167
+ export declare type SliceArray = Slice[];
168
+
169
+ /**
170
+ * The return type of the createStore function.
171
+ *
172
+ * @remarks
173
+ * This type represents all the utilities and functions returned when creating a store.
174
+ * It provides access to the store state, actions, selectors, and subscription methods.
175
+ *
176
+ * @example
177
+ * ```typescript
178
+ * const { store, actions, selectors, subscribeKey } = createStore(slices, initialState);
179
+ * ```
180
+ *
181
+ * @public
182
+ */
183
+ export declare type StoreReturn<S extends SliceArray> = {
184
+ /** Proxy object for accessing slice state */
185
+ store: RootStateFromSlices<S>;
186
+ /** Bound actions for each slice */
187
+ actions: ActionsFromSlices<S>;
188
+ /** Bound selectors for each slice */
189
+ selectors: SelectorsFromSlices<S>;
190
+ /** The root reducer combining all slices */
191
+ rootReducer: ReducersMapObject<RootStateFromSlices<S>>;
192
+ /** Performance-optimized subscription function for specific values */
193
+ subscribeKey: (checkerFn: (s: RootStateFromSlices<S>) => string, callbackFn: (s: RootStateFromSlices<S>) => void) => void;
194
+ /** Function to dispatch actions or thunks */
195
+ dispatch: (action: Action | ThunkDispatch<S>) => void;
196
+ /** Function to notify FAST components of slice changes */
197
+ notify: (sliceName: keyof RootStateFromSlices<S>) => void;
198
+ /** General subscription function for all state changes */
199
+ subscribe: (cb: (state: RootStateFromSlices<S>) => void) => void;
200
+ /** Function to get the current state */
201
+ getState: () => RootStateFromSlices<S>;
202
+ };
203
+
204
+ /**
205
+ * Type for thunk actions that can be dispatched to the store.
206
+ *
207
+ * @remarks
208
+ * This type represents thunk actions that can access the store's dispatch and getState functions.
209
+ * Thunks are useful for handling asynchronous operations and complex logic.
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const fetchUserThunk: ThunkDispatch<typeof slices> = (dispatch, getState) => {
214
+ * fetch('/api/user').then(user => dispatch(actions.user.setUser(user)));
215
+ * };
216
+ * ```
217
+ *
218
+ * @public
219
+ */
220
+ export declare type ThunkDispatch<S extends SliceArray> = ThunkAction<void, RootStateFromSlices<S>, any, Action>;
221
+
222
+ export { }
@@ -0,0 +1,11 @@
1
+ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
+ // It should be published with your NPM package. It should not be tracked by Git.
3
+ {
4
+ "tsdocVersion": "0.12",
5
+ "toolPackages": [
6
+ {
7
+ "packageName": "@microsoft/api-extractor",
8
+ "packageVersion": "7.52.10"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,2 @@
1
+ *.md -diff
2
+ *.md linguist-generated
@@ -0,0 +1,36 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-redux](./foundation-redux.md) &gt; [ActionsFromSlices](./foundation-redux.actionsfromslices.md)
4
+
5
+ ## ActionsFromSlices type
6
+
7
+ Extracts the bound actions type from an array of slices.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type ActionsFromSlices<S extends SliceArray> = {
13
+ [K in S[number]['name']]: {
14
+ [ActionKey in keyof Extract<S[number], {
15
+ name: K;
16
+ }>['actions']]: (payload: FirstParameter<Extract<S[number], {
17
+ name: K;
18
+ }>['actions'][ActionKey]>) => void;
19
+ };
20
+ };
21
+ ```
22
+ **References:** [SliceArray](./foundation-redux.slicearray.md)
23
+
24
+ ## Remarks
25
+
26
+ This utility type creates a nested object structure where each slice name maps to its actions. Actions are bound to the store and automatically dispatch when called.
27
+
28
+ ## Example
29
+
30
+
31
+ ```typescript
32
+ const { actions } = createStore([userSlice, cartSlice], initialState);
33
+ // actions.user.setUser({ name: 'John' })
34
+ // actions.cart.addItem({ id: 'item1', quantity: 1 })
35
+ ```
36
+
@@ -0,0 +1,89 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-redux](./foundation-redux.md) &gt; [createStore](./foundation-redux.createstore.md)
4
+
5
+ ## createStore() function
6
+
7
+ Creates a Redux store with FAST component integration.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ createStore: <S extends SliceArray>(slices: S, preloadedState: RootStateFromSlices<S>) => StoreReturn<S>
13
+ ```
14
+
15
+ ## Parameters
16
+
17
+ <table><thead><tr><th>
18
+
19
+ Parameter
20
+
21
+
22
+ </th><th>
23
+
24
+ Type
25
+
26
+
27
+ </th><th>
28
+
29
+ Description
30
+
31
+
32
+ </th></tr></thead>
33
+ <tbody><tr><td>
34
+
35
+ slices
36
+
37
+
38
+ </td><td>
39
+
40
+ S
41
+
42
+
43
+ </td><td>
44
+
45
+ Array of slices to combine into the store
46
+
47
+
48
+ </td></tr>
49
+ <tr><td>
50
+
51
+ preloadedState
52
+
53
+
54
+ </td><td>
55
+
56
+ [RootStateFromSlices](./foundation-redux.rootstatefromslices.md)<!-- -->&lt;S&gt;
57
+
58
+
59
+ </td><td>
60
+
61
+ Initial state that matches the slice structure
62
+
63
+
64
+ </td></tr>
65
+ </tbody></table>
66
+
67
+ **Returns:**
68
+
69
+ [StoreReturn](./foundation-redux.storereturn.md)<!-- -->&lt;S&gt;
70
+
71
+ Object containing store, actions, selectors, and utility functions
72
+
73
+ ## Remarks
74
+
75
+ This function creates a Redux store that integrates seamlessly with FAST components. It automatically binds actions and selectors, provides subscription methods, and handles FAST Observable notifications.
76
+
77
+ ## Example
78
+
79
+
80
+ ```typescript
81
+ const { store, actions, selectors, subscribeKey } = createStore(
82
+ [userSlice, cartSlice],
83
+ {
84
+ user: { name: '', email: '' },
85
+ cart: { items: [], total: 0 }
86
+ }
87
+ );
88
+ ```
89
+
@@ -0,0 +1,139 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-redux](./foundation-redux.md)
4
+
5
+ ## foundation-redux package
6
+
7
+ ## Functions
8
+
9
+ <table><thead><tr><th>
10
+
11
+ Function
12
+
13
+
14
+ </th><th>
15
+
16
+ Description
17
+
18
+
19
+ </th></tr></thead>
20
+ <tbody><tr><td>
21
+
22
+ [createStore(slices, preloadedState)](./foundation-redux.createstore.md)
23
+
24
+
25
+ </td><td>
26
+
27
+ Creates a Redux store with FAST component integration.
28
+
29
+
30
+ </td></tr>
31
+ </tbody></table>
32
+
33
+ ## Interfaces
34
+
35
+ <table><thead><tr><th>
36
+
37
+ Interface
38
+
39
+
40
+ </th><th>
41
+
42
+ Description
43
+
44
+
45
+ </th></tr></thead>
46
+ <tbody><tr><td>
47
+
48
+ [Slice](./foundation-redux.slice.md)
49
+
50
+
51
+ </td><td>
52
+
53
+ Represents a Redux slice with actions and selectors.
54
+
55
+
56
+ </td></tr>
57
+ </tbody></table>
58
+
59
+ ## Type Aliases
60
+
61
+ <table><thead><tr><th>
62
+
63
+ Type Alias
64
+
65
+
66
+ </th><th>
67
+
68
+ Description
69
+
70
+
71
+ </th></tr></thead>
72
+ <tbody><tr><td>
73
+
74
+ [ActionsFromSlices](./foundation-redux.actionsfromslices.md)
75
+
76
+
77
+ </td><td>
78
+
79
+ Extracts the bound actions type from an array of slices.
80
+
81
+
82
+ </td></tr>
83
+ <tr><td>
84
+
85
+ [RootStateFromSlices](./foundation-redux.rootstatefromslices.md)
86
+
87
+
88
+ </td><td>
89
+
90
+ Extracts the root state type from an array of slices.
91
+
92
+
93
+ </td></tr>
94
+ <tr><td>
95
+
96
+ [SelectorsFromSlices](./foundation-redux.selectorsfromslices.md)
97
+
98
+
99
+ </td><td>
100
+
101
+ Extracts the bound selectors type from an array of slices.
102
+
103
+
104
+ </td></tr>
105
+ <tr><td>
106
+
107
+ [SliceArray](./foundation-redux.slicearray.md)
108
+
109
+
110
+ </td><td>
111
+
112
+ An array of slices that will be combined into a single store.
113
+
114
+
115
+ </td></tr>
116
+ <tr><td>
117
+
118
+ [StoreReturn](./foundation-redux.storereturn.md)
119
+
120
+
121
+ </td><td>
122
+
123
+ The return type of the createStore function.
124
+
125
+
126
+ </td></tr>
127
+ <tr><td>
128
+
129
+ [ThunkDispatch](./foundation-redux.thunkdispatch.md)
130
+
131
+
132
+ </td><td>
133
+
134
+ Type for thunk actions that can be dispatched to the store.
135
+
136
+
137
+ </td></tr>
138
+ </tbody></table>
139
+
@@ -0,0 +1,32 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-redux](./foundation-redux.md) &gt; [RootStateFromSlices](./foundation-redux.rootstatefromslices.md)
4
+
5
+ ## RootStateFromSlices type
6
+
7
+ Extracts the root state type from an array of slices.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type RootStateFromSlices<S extends SliceArray> = {
13
+ [K in S[number]['name']]: Extract<S[number], {
14
+ name: K;
15
+ }> extends Slice<infer State> ? State : never;
16
+ };
17
+ ```
18
+ **References:** [SliceArray](./foundation-redux.slicearray.md)<!-- -->, [Slice](./foundation-redux.slice.md)
19
+
20
+ ## Remarks
21
+
22
+ This utility type maps over the slice names and extracts the state type for each slice. The resulting type represents the complete state structure of your Redux store.
23
+
24
+ ## Example
25
+
26
+
27
+ ```typescript
28
+ const slices = [userSlice, cartSlice];
29
+ type RootState = RootStateFromSlices<typeof slices>;
30
+ // Result: { user: UserState, cart: CartState }
31
+ ```
32
+
@@ -0,0 +1,40 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-redux](./foundation-redux.md) &gt; [SelectorsFromSlices](./foundation-redux.selectorsfromslices.md)
4
+
5
+ ## SelectorsFromSlices type
6
+
7
+ Extracts the bound selectors type from an array of slices.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export type SelectorsFromSlices<S extends SliceArray> = {
13
+ [K in S[number]['name']]: {
14
+ [SelectorKey in keyof Extract<S[number], {
15
+ name: K;
16
+ }>['selectors']]: (...payload: RemoveFirstParameter<Extract<S[number], {
17
+ name: K;
18
+ }>['selectors'][SelectorKey]>) => ReturnType<Extract<S[number], {
19
+ name: K;
20
+ }>['selectors'][SelectorKey]> extends void ? any : ReturnType<Extract<S[number], {
21
+ name: K;
22
+ }>['selectors'][SelectorKey]>;
23
+ };
24
+ };
25
+ ```
26
+ **References:** [SliceArray](./foundation-redux.slicearray.md)
27
+
28
+ ## Remarks
29
+
30
+ This utility type creates a nested object structure where each slice name maps to its selectors. Selectors are bound to the store and can access the current state.
31
+
32
+ ## Example
33
+
34
+
35
+ ```typescript
36
+ const { selectors } = createStore([userSlice, cartSlice], initialState);
37
+ // const userName = selectors.user.getUserName()
38
+ // const cartTotal = selectors.cart.getTotal()
39
+ ```
40
+
@@ -0,0 +1,13 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [@genesislcap/foundation-redux](./foundation-redux.md) &gt; [Slice](./foundation-redux.slice.md) &gt; [actions](./foundation-redux.slice.actions.md)
4
+
5
+ ## Slice.actions property
6
+
7
+ Action creators for this slice
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ actions: Record<string, (payload: any) => Action>;
13
+ ```