search-client
Version:
Javascript library for executing searches in the Haive search-index via the SearchManager REST interface.
255 lines (254 loc) • 7.88 kB
TypeScript
/**
* Defines a dictionary type for mapping CategoryPresentation objects using a string, typically a
* pipe-concatenated list of categoryNames as a string.
*/
export interface ICategoryPresentationMap {
[categoryNames: string]: CategoryPresentation;
}
/**
* The configuration describes how the specific node is to be filtered, sorted, and/or grouped.
* Applied in this order:
* - grouping: Grouping might change all items on this level (introduces an extra layer).
* If an extra group-level is introduced then it will be subject for all
* consecutive processes in this class.
* - filter: Reduces which child-categories that passes through based on filter.
* - sorting: Changes the order of the categories.
* - limit: Limits the no of categories to display.
* - expanded: If any categories are left to be shown then this setting indicates whether or not
* to show the categories in the UI. Note that this is not available for the root-
* level node, as it always shows the first-level of category-nodes.
*
* @default - All features disabled.
*/
export declare class CategoryPresentation {
/**
* Used to create an extra level of categories that group items together. Default: Disabled
*/
group?: GroupConfiguration;
/**
* Used to include only categories that match the provided filter (regex + minCount). Default: Disabled
*/
filter?: FilterConfiguration;
/**
* Used to change the order of the categories. Default: Disabled
*/
sort?: SortConfiguration;
/**
* Used to limit the number of items to display. Default: Disabled
*/
limit?: LimitPageConfiguration;
/**
* Used to indicate whether tho show category-children or not. Default: undefined (N/A for the root-element)
* Default: null
*/
expanded?: boolean | null;
/**
* Creates a CategoryPresentation instance. Default: All features disabled.
* @param settings A CategoryPresentation object describing the behavior
*/
constructor(settings?: CategoryPresentation);
}
/**
* Defines how grouping is to be applied on a given categories' children
* Can be set to only be executed when the number of child-categories exceeds a given number.
*/
export declare class GroupConfiguration {
/**
* Enables or disables the feature.
* Default: false
*/
enabled?: boolean;
/**
* Only applies grouping when the number of children reaches this number.
* Default: 20
*/
minCount?: number;
/**
* DisplayName or MatchCount.
* Default: GroupingMode.DisplayName.
*/
mode?: GroupingMode;
/**
* The regex to group on.
* Default: Matches first character /^./
*/
match?: RegExp;
/**
* The casing to apply on the match group ($0).
* Default: Casing.Title
*/
matchCase?: Casing;
/**
* Only creates the group when number of matches per group reaches this number.
* Default: 5
*/
minCountPerGroup?: number;
/**
* Creates a GroupingConfiguration instance.
*
* @param settings A GroupingPresentation object describing the behavior.
*/
constructor(settings?: GroupConfiguration);
getMatch?(input: string): string;
}
export declare enum GroupingMode {
DisplayName = "DisplayName",
MatchCount = "MatchCount"
}
export declare enum Casing {
Unchanged = "Unchanged",
Upper = "Upper",
Lower = "Lower",
Title = "Title"
}
/**
* Defines how to filter items.
*/
export declare class FilterConfiguration {
/**
* Enables or disables the feature.
* Default: false
*/
enabled?: boolean;
/**
* The current regex match filter, applied on the Name or DisplayName (see matchMode).
* Default: "" (empty - no matches)
*/
match?: RegExp;
/**
* The current match-mode for the regex filter.
* Default: DisplayName
*/
matchMode?: MatchMode;
/**
* The maximum no of matches for the category to be included.
* Default: -1 (disabled)
*/
maxMatchCount?: number;
/**
* Hints the UI to show an input box when the number of hits exceeds a given number.
* Default: 20
*/
uiHintShowFilterInputThreshold?: number;
/**
* Creates a FilterConfiguration instance that describes how to filter categories.
*
* @param settings A FilterConfiguration object describing the behavior
*/
constructor(settings?: FilterConfiguration);
}
export declare enum MatchMode {
Name = "Name",
DisplayName = "DisplayName"
}
/**
* Defines how sorting is to be applied.
* First handles the static strings, then applies the SortPartConfigurations until there are no items left.
* Note: If there are additional items left when done above then these will be added at the bottom in the original sorting order.
*/
export declare class SortConfiguration {
/**
* Defines whether or not to enable sort for this category-level.
* Default: false
*/
enabled?: boolean;
/**
* A list of SortPartConfigurations.
* Default: Empty list.
*/
parts?: SortPartConfiguration[];
/**
* Creates a sort-configuration that defines how to order the items scoped.
*
* @param settings A SortConfiguration object that describes the wanted behavior
*/
constructor(settings?: SortConfiguration);
private setupParts;
}
/**
* Defines how sorting is to be applied for the given part.
*/
export declare class SortPartConfiguration {
/**
* Defines the match (string or regex) that defines the scope of items to sort.
* Default: ".*" (anything)
*/
match?: RegExp | string;
/**
* The current match-mode for the regex filter.
* Default: DisplayName
*/
matchMode?: MatchMode;
/**
* Defines the method/field and order to use when sorting.
* Default: Original
*/
sortMethod?: SortMethod;
/**
* Creates a sort-part that defines how to order the items scoped.
*
* @param settings A SortPartConfiguration object that describes the wanted behavior
*/
constructor(settings?: SortPartConfiguration);
}
/**
* Defines how to sort the part.
*
*/
export declare enum SortMethod {
/**
* Sort in the order received from the server.
*/
Original = "Original",
/**
* Sort Ascending by Name/DisplayName field.
*/
AlphaAsc = "AlphaAsc",
/**
* Sort Descending by Name/DisplayName field.
*/
AlphaDesc = "AlphaDesc",
/**
* Sort Ascending by MatchCount field.
*/
CountAsc = "CountAsc",
/**
* Sort Descending by MatchCount field.
*/
CountDesc = "CountDesc"
}
/**
* Defines paging parameters for controlling which range of items to show.
* Used to limit the number of items to display.
* The regular use-case is to set a pageSize, which acts as the number of items to show.
* The limit is also designed to allow paging, by changing page from 1 and thus allowing
* paging the categories.
*/
export declare class LimitPageConfiguration {
/**
* Enables or disables the feature.
* Default: false
*/
enabled?: boolean;
/**
* Defines the page to show.
* Default: 1
*/
page?: number;
/**
* Defines the pageSize that with the `page` controls which item-range to show.
* Default: 5
*/
pageSize?: number;
/**
* Hints the ui to show a pager to allow browsing the categories in the node.
* Default: true
*/
uiHintShowPager?: boolean;
/**
* Creates a LimitPageConfiguration instance. Default: Show first page, with 5 items.
*
* @param settings A LimitPageConfiguration object that describes the wanted behavior
*/
constructor(settings?: LimitPageConfiguration);
}