@10up/block-components
Version:
10up Components built for the WordPress Block Editor.
56 lines • 2.09 kB
TypeScript
import type { WP_REST_API_User, WP_REST_API_Search_Result } from 'wp-types';
import type { ContentSearchMode, QueryFilter } from './types';
interface IdentifiableObject extends Object {
id: number;
}
interface FilterResultsArgs {
results: WP_REST_API_User[] | WP_REST_API_Search_Result[];
excludeItems: Array<IdentifiableObject>;
}
export declare const filterOutExcludedItems: ({ results, excludeItems }: FilterResultsArgs) => (WP_REST_API_User | WP_REST_API_Search_Result)[];
interface PrepareSearchQueryArgs {
keyword: string;
page: number;
mode: ContentSearchMode;
perPage: number;
contentTypes: Array<string>;
queryFilter: QueryFilter;
}
export declare const prepareSearchQuery: ({ keyword, page, mode, perPage, contentTypes, queryFilter, }: PrepareSearchQueryArgs) => string;
interface NormalizeResultsArgs {
mode: ContentSearchMode;
results: WP_REST_API_Search_Result[] | WP_REST_API_User[];
excludeItems: Array<IdentifiableObject>;
}
export declare const normalizeResults: ({ mode, results, excludeItems, }: NormalizeResultsArgs) => Array<{
id: number;
subtype: ContentSearchMode | string;
title: string;
type: ContentSearchMode | string;
url: string;
}>;
export type NormalizedSuggestions = ReturnType<typeof normalizeResults>;
export type NormalizedSuggestion = NormalizedSuggestions[number];
interface FetchSearchResultsArgs {
keyword: string;
page: number;
mode: ContentSearchMode;
perPage: number;
contentTypes: Array<string>;
queryFilter: QueryFilter;
excludeItems: Array<IdentifiableObject>;
signal?: AbortSignal;
}
export declare function fetchSearchResults({ keyword, page, mode, perPage, contentTypes, queryFilter, excludeItems, signal, }: FetchSearchResultsArgs): Promise<{
results: {
id: number;
subtype: ContentSearchMode | string;
title: string;
type: ContentSearchMode | string;
url: string;
}[];
nextPage: number | undefined;
previousPage: number | undefined;
}>;
export {};
//# sourceMappingURL=utils.d.ts.map