import type { Entity, EntityListState } from './types'; const ENTITIES_IMPORT = 'ENTITIES_IMPORT' as const; const ENTITIES_DELETE = 'ENTITIES_DELETE' as const; const ENTITIES_DISMISS = 'ENTITIES_DISMISS' as const; const ENTITIES_FETCH_REQUEST = 'ENTITIES_FETCH_REQUEST' as const; const ENTITIES_FETCH_SUCCESS = 'ENTITIES_FETCH_SUCCESS' as const; const ENTITIES_FETCH_FAIL = 'ENTITIES_FETCH_FAIL' as const; const ENTITIES_INVALIDATE_LIST = 'ENTITIES_INVALIDATE_LIST' as const; /** Action to import entities into the cache. */ function importEntities(entities: Entity[], entityType: string, listKey?: string) { return { type: ENTITIES_IMPORT, entityType, entities, listKey, }; } interface DeleteEntitiesOpts { preserveLists?: boolean } function deleteEntities(ids: Iterable, entityType: string, opts: DeleteEntitiesOpts = {}) { return { type: ENTITIES_DELETE, ids, entityType, opts, }; } function dismissEntities(ids: Iterable, entityType: string, listKey: string) { return { type: ENTITIES_DISMISS, ids, entityType, listKey, }; } function entitiesFetchRequest(entityType: string, listKey?: string) { return { type: ENTITIES_FETCH_REQUEST, entityType, listKey, }; } function entitiesFetchSuccess( entities: Entity[], entityType: string, listKey?: string, newState?: EntityListState, overwrite = false, ) { return { type: ENTITIES_FETCH_SUCCESS, entityType, entities, listKey, newState, overwrite, }; } function entitiesFetchFail(entityType: string, listKey: string | undefined, error: any) { return { type: ENTITIES_FETCH_FAIL, entityType, listKey, error, }; } function invalidateEntityList(entityType: string, listKey: string) { return { type: ENTITIES_INVALIDATE_LIST, entityType, listKey, }; } /** Any action pertaining to entities. */ type EntityAction = ReturnType | ReturnType | ReturnType | ReturnType | ReturnType | ReturnType | ReturnType; export { ENTITIES_IMPORT, ENTITIES_DELETE, ENTITIES_DISMISS, ENTITIES_FETCH_REQUEST, ENTITIES_FETCH_SUCCESS, ENTITIES_FETCH_FAIL, ENTITIES_INVALIDATE_LIST, importEntities, deleteEntities, dismissEntities, entitiesFetchRequest, entitiesFetchSuccess, entitiesFetchFail, invalidateEntityList, EntityAction, }; export type { DeleteEntitiesOpts };