diff --git a/src/actions.d.ts b/src/actions.d.ts index 880f6d8..6986c8d 100644 --- a/src/actions.d.ts +++ b/src/actions.d.ts @@ -1,5 +1,5 @@ import { AnyAction } from 'redux' -import type { Feature, FeatureState, FeatureAction } from './index' +import type { Feature, FeatureState } from './index' export declare const ACTION_TYPE_PREFIX = '@@redux-features/' export declare const ADD_FEATURE: '@@redux-features/ADD_FEATURE' export declare const REPLACE_FEATURE: '@@redux-features/REPLACE_FEATURE' @@ -7,21 +7,61 @@ export declare const LOAD_FEATURE: '@@redux-features/LOAD_FEATURE' export declare const INSTALL_FEATURE: '@@redux-features/INSTALL_FEATURE' export declare const SET_FEATURE_STATE: '@@redux-features/SET_FEATURE_STATE' export declare const LOAD_INITIAL_FEATURES: '@@redux-features/LOAD_INITIAL_FEATURES' + +export type AddFeatureAction = { + type: typeof ADD_FEATURE + payload: Feature + meta: { id: string } +} export declare function addFeature( id: string, feature: Feature -): FeatureAction +): AddFeatureAction + +export type ReplaceFeatureAction = { + type: typeof REPLACE_FEATURE + feature: Feature + meta: { id: string } +} export declare function replaceFeature< S = any, A extends AnyAction = AnyAction ->(id: string, feature: Feature): FeatureAction -export declare function loadFeature(id: string): FeatureAction +>(id: string, feature: Feature): ReplaceFeatureAction + +export type LoadFeatureAction = { + type: typeof LOAD_FEATURE + meta: { id: string } +} +export declare function loadFeature(id: string): LoadFeatureAction + +export type InstallFeatureAction = { + type: typeof INSTALL_FEATURE + feature: Feature + meta: { id: string } +} export declare function installFeature< S = any, A extends AnyAction = AnyAction ->(id: string, feature: Feature): FeatureAction +>(id: string, feature: Feature): InstallFeatureAction + +export type SetFeatureStateAction = { + type: typeof SET_FEATURE_STATE + payload: FeatureState +} export declare function setFeatureState( id: string, payload: FeatureState -): FeatureAction -export declare function loadInitialFeatures(): FeatureAction +): SetFeatureStateAction + +export type LoadInitialFeaturesAction = { + type: typeof LOAD_INITIAL_FEATURES +} +export declare function loadInitialFeatures(): LoadInitialFeaturesAction + +export type FeatureAction = + | AddFeatureAction + | ReplaceFeatureAction + | LoadFeatureAction + | InstallFeatureAction + | SetFeatureStateAction + | LoadInitialFeaturesAction diff --git a/src/index.d.ts b/src/index.d.ts index a1e96be..ffed97f 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -18,6 +18,13 @@ import { replaceFeature, setFeatureState, loadInitialFeatures, + AddFeatureAction, + LoadFeatureAction, + InstallFeatureAction, + ReplaceFeatureAction, + SetFeatureStateAction, + LoadInitialFeaturesAction, + FeatureAction, } from './actions' export { featuresReducer, @@ -39,6 +46,13 @@ export { replaceFeature, setFeatureState, loadInitialFeatures, + AddFeatureAction, + LoadFeatureAction, + InstallFeatureAction, + ReplaceFeatureAction, + SetFeatureStateAction, + LoadInitialFeaturesAction, + FeatureAction, } import type { MiddlewareAPI, @@ -80,11 +94,3 @@ export type Features< A extends AnyAction = AnyAction, D extends Dispatch = Dispatch > = Record> - -export type FeatureAction = { - type: string - payload?: any - meta?: { - id: string - } -}