@@ -80,7 +80,7 @@ export type CaseReducerWithPrepare<State, Action extends PayloadAction> = {
80
80
prepare: PrepareAction <Action [' payload' ]>;
81
81
};
82
82
83
- // @alpha (undocumented)
83
+ // @public (undocumented)
84
84
export type Comparer <T > = (a : T , b : T ) => number ;
85
85
86
86
// @public
@@ -104,7 +104,7 @@ export function createAction<P = void, T extends string = string>(type: T): Payl
104
104
// @public
105
105
export function createAction<PA extends PrepareAction <any >, T extends string = string >(type : T , prepareAction : PA ): PayloadActionCreator <ReturnType <PA >[' payload' ], T , PA >;
106
106
107
- // @alpha (undocumented)
107
+ // @public (undocumented)
108
108
export function createAsyncThunk<Returned , ThunkArg = void , ThunkApiConfig extends AsyncThunkConfig = {}>(type : string , payloadCreator : (arg : ThunkArg , thunkAPI : GetThunkAPI <ThunkApiConfig >) => Promise <Returned | RejectWithValue <GetRejectValue <ThunkApiConfig >>> | Returned | RejectWithValue <GetRejectValue <ThunkApiConfig >>): ((arg : ThunkArg ) => (dispatch : GetDispatch <ThunkApiConfig >, getState : () => GetState <ThunkApiConfig >, extra : GetExtra <ThunkApiConfig >) => Promise <PayloadAction <Returned , string , {
109
109
arg: ThunkArg ;
110
110
requestId: string ;
@@ -130,7 +130,7 @@ export function createAsyncThunk<Returned, ThunkArg = void, ThunkApiConfig exten
130
130
}>;
131
131
};
132
132
133
- // @alpha (undocumented)
133
+ // @public (undocumented)
134
134
export function createEntityAdapter<T >(options ? : {
135
135
selectId? : IdSelector <T >;
136
136
sortComparer? : false | Comparer <T >;
@@ -163,7 +163,7 @@ export interface CreateSliceOptions<State = any, CR extends SliceCaseReducers<St
163
163
reducers: ValidateSliceCaseReducers <State , CR >;
164
164
}
165
165
166
- // @alpha (undocumented)
166
+ // @public (undocumented)
167
167
export interface Dictionary <T > extends DictionaryNum <T > {
168
168
// (undocumented)
169
169
[id : string ]: T | undefined ;
@@ -176,7 +176,7 @@ export interface EnhancedStore<S = any, A extends Action = AnyAction, M extends
176
176
dispatch: DispatchForMiddlewares <M > & Dispatch <A >;
177
177
}
178
178
179
- // @alpha (undocumented)
179
+ // @public (undocumented)
180
180
export interface EntityAdapter <T > extends EntityStateAdapter <T > {
181
181
// (undocumented)
182
182
getInitialState(): EntityState <T >;
@@ -192,14 +192,73 @@ export interface EntityAdapter<T> extends EntityStateAdapter<T> {
192
192
sortComparer: false | Comparer <T >;
193
193
}
194
194
195
- // @alpha (undocumented)
195
+ // @public (undocumented)
196
+ export type EntityId = number | string ;
197
+
198
+ // @public (undocumented)
199
+ export interface EntitySelectors <T , V > {
200
+ // (undocumented)
201
+ selectAll: (state : V ) => T [];
202
+ // (undocumented)
203
+ selectById: (state : V , id : EntityId ) => T | undefined ;
204
+ // (undocumented)
205
+ selectEntities: (state : V ) => Dictionary <T >;
206
+ // (undocumented)
207
+ selectIds: (state : V ) => EntityId [];
208
+ // (undocumented)
209
+ selectTotal: (state : V ) => number ;
210
+ }
211
+
212
+ // @public (undocumented)
196
213
export interface EntityState <T > {
197
214
// (undocumented)
198
215
entities: Dictionary <T >;
199
216
// (undocumented)
200
217
ids: EntityId [];
201
218
}
202
219
220
+ // @public (undocumented)
221
+ export interface EntityStateAdapter <T > {
222
+ // (undocumented)
223
+ addMany<S extends EntityState <T >>(state : PreventAny <S , T >, entities : T [] | Record <EntityId , T >): S ;
224
+ // (undocumented)
225
+ addMany<S extends EntityState <T >>(state : PreventAny <S , T >, entities : PayloadAction <T [] | Record <EntityId , T >>): S ;
226
+ // (undocumented)
227
+ addOne<S extends EntityState <T >>(state : PreventAny <S , T >, entity : T ): S ;
228
+ // (undocumented)
229
+ addOne<S extends EntityState <T >>(state : PreventAny <S , T >, action : PayloadAction <T >): S ;
230
+ // (undocumented)
231
+ removeAll<S extends EntityState <T >>(state : PreventAny <S , T >): S ;
232
+ // (undocumented)
233
+ removeMany<S extends EntityState <T >>(state : PreventAny <S , T >, keys : EntityId []): S ;
234
+ // (undocumented)
235
+ removeMany<S extends EntityState <T >>(state : PreventAny <S , T >, keys : PayloadAction <EntityId []>): S ;
236
+ // (undocumented)
237
+ removeOne<S extends EntityState <T >>(state : PreventAny <S , T >, key : EntityId ): S ;
238
+ // (undocumented)
239
+ removeOne<S extends EntityState <T >>(state : PreventAny <S , T >, key : PayloadAction <EntityId >): S ;
240
+ // (undocumented)
241
+ setAll<S extends EntityState <T >>(state : PreventAny <S , T >, entities : T [] | Record <EntityId , T >): S ;
242
+ // (undocumented)
243
+ setAll<S extends EntityState <T >>(state : PreventAny <S , T >, entities : PayloadAction <T [] | Record <EntityId , T >>): S ;
244
+ // (undocumented)
245
+ updateMany<S extends EntityState <T >>(state : PreventAny <S , T >, updates : Update <T >[]): S ;
246
+ // (undocumented)
247
+ updateMany<S extends EntityState <T >>(state : PreventAny <S , T >, updates : PayloadAction <Update <T >[]>): S ;
248
+ // (undocumented)
249
+ updateOne<S extends EntityState <T >>(state : PreventAny <S , T >, update : Update <T >): S ;
250
+ // (undocumented)
251
+ updateOne<S extends EntityState <T >>(state : PreventAny <S , T >, update : PayloadAction <Update <T >>): S ;
252
+ // (undocumented)
253
+ upsertMany<S extends EntityState <T >>(state : PreventAny <S , T >, entities : T [] | Record <EntityId , T >): S ;
254
+ // (undocumented)
255
+ upsertMany<S extends EntityState <T >>(state : PreventAny <S , T >, entities : PayloadAction <T [] | Record <EntityId , T >>): S ;
256
+ // (undocumented)
257
+ upsertOne<S extends EntityState <T >>(state : PreventAny <S , T >, entity : T ): S ;
258
+ // (undocumented)
259
+ upsertOne<S extends EntityState <T >>(state : PreventAny <S , T >, entity : PayloadAction <T >): S ;
260
+ }
261
+
203
262
// @public (undocumented)
204
263
export function findNonSerializableValue(value : unknown , path ? : ReadonlyArray <string >, isSerializable ? : (value : unknown ) => boolean , getEntries ? : (value : unknown ) => [string , any ][], ignoredPaths ? : string []): NonSerializableValue | false ;
205
264
@@ -213,7 +272,7 @@ export function getDefaultMiddleware<S = any, O extends Partial<GetDefaultMiddle
213
272
// @public
214
273
export function getType<T extends string >(actionCreator : PayloadActionCreator <any , T >): T ;
215
274
216
- // @alpha (undocumented)
275
+ // @public (undocumented)
217
276
export type IdSelector <T > = (model : T ) => EntityId ;
218
277
219
278
// @public
@@ -278,7 +337,7 @@ export interface SerializableStateInvariantMiddlewareOptions {
278
337
warnAfter? : number ;
279
338
}
280
339
281
- // @alpha (undocumented)
340
+ // @public (undocumented)
282
341
export interface SerializedError {
283
342
// (undocumented)
284
343
code? : string ;
@@ -310,10 +369,10 @@ export { ThunkAction }
310
369
311
370
export { ThunkDispatch }
312
371
313
- // @alpha (undocumented)
372
+ // @public (undocumented)
314
373
export function unwrapResult<R extends ActionTypesWithOptionalErrorAction >(returned : R ): PayloadForActionTypesExcludingErrorActions <R >;
315
374
316
- // @alpha (undocumented)
375
+ // @public (undocumented)
317
376
export type Update <T > = {
318
377
id: EntityId ;
319
378
changes: Partial <T >;
0 commit comments