@woocommerce/data
Version:
WooCommerce Admin data store and utilities
66 lines • 2.44 kB
TypeScript
import { select as wpSelect } from '@wordpress/data';
import { ItemInfer, ItemType, Query } from './types';
import { ItemsSelector } from './';
type Options = {
id: number;
per_page: number;
persisted_query: Query;
filterQuery: Query;
query: {
[key: string]: string | undefined;
};
select: typeof wpSelect;
defaultDateRange: string;
};
/**
* Returns leaderboard data to render a leaderboard table.
*
* @param {Object} options arguments
* @param {string} options.id Leaderboard ID
* @param {number} options.per_page Per page limit
* @param {Object} options.persisted_query Persisted query passed to endpoint
* @param {Object} options.query Query parameters in the url
* @param {Object} options.filterQuery Query parameters to filter the leaderboard
* @param {Object} options.select Instance of @wordpress/select
* @param {string} options.defaultDateRange User specified default date range.
* @return {Object} Object containing leaderboard responses.
*/
export declare function getLeaderboard(options: Options): {
isRequesting: boolean;
isError: boolean;
rows: never[];
} | {
rows: {
display: string;
value: string;
} | undefined;
isRequesting: boolean;
isError: boolean;
};
/**
* Returns items based on a search query.
*
* @param {Object} selector Instance of @wordpress/select response
* @param {string} endpoint Report API Endpoint
* @param {string[]} search Array of search strings.
* @param {Object} options Query options.
* @return {Object} Object containing API request information and the matching items.
*/
export declare function searchItemsByString<T extends ItemType>(selector: ItemsSelector, endpoint: T, search: string[], options?: Query): {
items: Record<number, ItemInfer<T> | undefined>;
isRequesting: boolean;
isError: boolean;
};
/**
* Generate a resource name for item totals count.
*
* It omits query parameters from the identifier that don't affect
* totals values like pagination and response field filtering.
*
* @param {string} itemType Item type for totals count.
* @param {Object} query Query for item totals count.
* @return {string} Resource name for item totals.
*/
export declare function getTotalCountResourceName(itemType: string, query: Query): string;
export {};
//# sourceMappingURL=utils.d.ts.map