2022-01-13 19:43:56 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { registerStore } from '@wordpress/data';
|
|
|
|
import { controls } from '@wordpress/data-controls';
|
2022-04-25 05:40:18 +00:00
|
|
|
import { SelectFromMap, DispatchFromMap } from '@automattic/data-stores';
|
|
|
|
import { Reducer, AnyAction } from 'redux';
|
2022-01-13 19:43:56 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { STORE_NAME } from './constants';
|
|
|
|
import * as selectors from './selectors';
|
|
|
|
import * as actions from './actions';
|
|
|
|
import * as resolvers from './resolvers';
|
2022-04-25 05:40:18 +00:00
|
|
|
import reducer, { State } from './reducer';
|
|
|
|
import { WPDataSelectors } from '../types';
|
2023-05-16 00:55:50 +00:00
|
|
|
import { PromiseifySelectors } from '../types/promiseify-selectors';
|
2022-04-25 05:40:18 +00:00
|
|
|
export * from './types';
|
|
|
|
export type { State };
|
2022-01-13 19:43:56 +00:00
|
|
|
|
2022-04-25 05:40:18 +00:00
|
|
|
registerStore< State >( STORE_NAME, {
|
|
|
|
reducer: reducer as Reducer< State, AnyAction >,
|
2022-01-13 19:43:56 +00:00
|
|
|
actions,
|
|
|
|
controls,
|
|
|
|
selectors,
|
|
|
|
resolvers,
|
|
|
|
} );
|
|
|
|
|
|
|
|
export const COUNTRIES_STORE_NAME = STORE_NAME;
|
2022-04-25 05:40:18 +00:00
|
|
|
|
|
|
|
declare module '@wordpress/data' {
|
|
|
|
// TODO: convert action.js to TS
|
|
|
|
function dispatch(
|
|
|
|
key: typeof STORE_NAME
|
|
|
|
): DispatchFromMap< typeof actions >;
|
|
|
|
function select(
|
|
|
|
key: typeof STORE_NAME
|
|
|
|
): SelectFromMap< typeof selectors > & WPDataSelectors;
|
2023-05-16 00:55:50 +00:00
|
|
|
function resolveSelect(
|
|
|
|
key: typeof STORE_NAME
|
|
|
|
): PromiseifySelectors< SelectFromMap< typeof selectors > >;
|
2022-04-25 05:40:18 +00:00
|
|
|
}
|