Skip to content

Instantly share code, notes, and snippets.

@btaillon-coveo
Last active January 6, 2023 16:20
Show Gist options
  • Save btaillon-coveo/8a88b39f8869b88d1f302a37077f6535 to your computer and use it in GitHub Desktop.
Save btaillon-coveo/8a88b39f8869b88d1f302a37077f6535 to your computer and use it in GitHub Desktop.
KIT-2174 parsed_doc diff
This file has been truncated, but you can view the full file.
[
{
"name": "search",
"controllers": [
{
"initializer": {
"kind": "function",
"name": "buildHistoryManager",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "HistoryManager",
"isOptional": false,
"type": "HistoryManager",
"desc": "The `HistoryManager` controller is in charge of allowing navigating back and forward in the search interface history.",
"members": [
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "StateWithHistory<HistoryState>",
"desc": "The state relevant to the `HistoryManager` controller."
},
{
"kind": "function",
"name": "back",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "Promise<void>",
"isOptional": false,
"desc": "A promise that resolves when the previous state has been restored."
},
"desc": "Move backward in the interface history."
},
{
"kind": "function",
"name": "backOnNoResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "Promise<void>",
"isOptional": false,
"desc": "A promise that resolves when the previous state has been restored."
},
"desc": "Move backward in the interface history when there are no results."
},
{
"kind": "function",
"name": "forward",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "Promise<void>",
"isOptional": false,
"desc": "A promise that resolves when the next state has been restored."
},
"desc": "Move forward in the interface history."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "HistoryManager"
},
"desc": "Creates a `HistoryManager` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/history-manager/history-manager.class.tsx",
"code": "import {\n buildHistoryManager,\n HistoryManager as HeadlessHistoryManager,\n HistoryManagerState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class HistoryManager extends Component<{}, HistoryManagerState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessHistoryManager;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildHistoryManager(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n <button\n disabled={this.state.past.length === 0}\n onClick={() => this.controller.back()}\n >\n Back\n </button>\n <button\n disabled={this.state.future.length === 0}\n onClick={() => this.controller.forward()}\n >\n Forward\n </button>\n </div>\n );\n }\n}\n",
"fileName": "history-manager.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/history-manager/history-manager.fn.tsx",
"code": "import {HistoryManager as HeadlessHistoryManager} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface HistoryManagerProps {\n controller: HeadlessHistoryManager;\n}\n\nexport const HistoryManager: FunctionComponent<HistoryManagerProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <div>\n <button\n disabled={state.past.length === 0}\n onClick={() => controller.back()}\n >\n Back\n </button>\n <button\n disabled={state.future.length === 0}\n onClick={() => controller.forward()}\n >\n Forward\n </button>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildHistoryManager(engine);\n *\n * <History controller={controller} />;\n * ```\n */\n",
"fileName": "history-manager.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildFacet",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `Facet` properties.",
"type": "FacetProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "FacetOptions",
"desc": "The options for the `Facet` controller.",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "allowedValues",
"isOptional": true,
"type": "string[]",
"desc": "Specifies an explicit list of `allowedValues` in the Search API request.\n\nIf you specify a list of values for this option, the facet uses only these values (if they are available in the current result set).\n\nThe maximum amount of allowed values is 25.\n\nDefault value is `undefined`, and the facet uses all available values for its `field` in the current result set."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a random unique identifier is generated."
},
{
"kind": "object",
"name": "facetSearch",
"isOptional": true,
"type": "FacetSearchOptions",
"desc": "Facet search options.",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetSearchOptions"
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude the parents of folded results when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "hasBreadcrumbs",
"isOptional": true,
"type": "boolean",
"desc": "Specifies whether breadcrumbs appear for the facet",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`8`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'score' | 'alphanumeric' | 'occurrences' | 'automatic'",
"desc": "The criterion to use for sorting returned facet values. Learn more about `sortCriteria` values and the default behavior of specific facets in the [Search API documentation](https://docs.coveo.com/en/1461/build-a-search-ui/query-parameters#RestFacetRequest-sortCriteria).",
"defaultValue": "`automatic`"
}
],
"isTypeExtracted": false,
"typeName": "FacetOptions"
}
],
"isTypeExtracted": false,
"typeName": "FacetProps"
}
],
"returnType": {
"kind": "object",
"name": "Facet",
"isOptional": false,
"type": "Facet",
"desc": "",
"members": [
{
"kind": "object",
"name": "facetSearch",
"isOptional": false,
"type": "FacetSearch",
"desc": "Provides methods to search the facet's values.",
"members": [
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Resets the query and empties the values."
},
{
"kind": "function",
"name": "search",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Performs a facet search."
},
{
"kind": "function",
"name": "select",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The search result to select.",
"type": "SpecificFacetSearchResult",
"members": [],
"isTypeExtracted": true,
"typeName": "SpecificFacetSearchResult"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects a facet search result."
},
{
"kind": "function",
"name": "showMoreResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Shows more facet search results."
},
{
"kind": "function",
"name": "singleSelect",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The search result to select.",
"type": "SpecificFacetSearchResult",
"members": [],
"isTypeExtracted": true,
"typeName": "SpecificFacetSearchResult"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects a search result while deselecting facet values."
},
{
"kind": "function",
"name": "updateCaptions",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "captions",
"isOptional": false,
"desc": "A dictionary that maps index field values to facet value display names.",
"type": "Record<string, string>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the facet value captions."
},
{
"kind": "function",
"name": "updateText",
"params": [
{
"kind": "primitive",
"name": "text",
"isOptional": false,
"desc": "The query to search.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the facet search query."
}
],
"isTypeExtracted": false,
"typeName": "FacetSearch"
},
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "FacetState",
"desc": "The state of the `Facet` controller.",
"members": [
{
"kind": "object",
"name": "facetSearch",
"isOptional": false,
"type": "FacetSearchState",
"desc": "The state of the facet's searchbox.",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetSearchState"
},
{
"kind": "primitive",
"name": "canShowLessValues",
"isOptional": false,
"type": "boolean",
"desc": "`true` if fewer values can be displayed and `false` otherwise."
},
{
"kind": "primitive",
"name": "canShowMoreValues",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there are more values to display and `false` otherwise."
},
{
"kind": "primitive",
"name": "enabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether the facet is enabled and its values are used to filter search results."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet ID."
},
{
"kind": "primitive",
"name": "hasActiveValues",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is at least one non-idle value and `false` otherwise."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "`true` if a search is in progress and `false` otherwise."
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriterion",
"isOptional": false,
"type": "'score' | 'alphanumeric' | 'occurrences' | 'automatic'",
"desc": "The active sortCriterion of the facet."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "FacetValue[]",
"desc": "The values of the facet.",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetValue"
}
],
"isTypeExtracted": false,
"typeName": "FacetState"
},
{
"kind": "function",
"name": "deselectAll",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects all facet values."
},
{
"kind": "function",
"name": "disable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disables the facet. I.e., prevents it from filtering results."
},
{
"kind": "function",
"name": "enable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Enables the facet. I.e., undoes the effects of `disable`."
},
{
"kind": "function",
"name": "isSortedBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion to compare.",
"type": "'score' | 'alphanumeric' | 'occurrences' | 'automatic'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the facet values are sorted according to the specified criterion."
},
"desc": "Checks whether the facet values are sorted according to the specified criterion."
},
{
"kind": "function",
"name": "isValueSelected",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The facet value to check.",
"type": "FacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the specified facet value is selected."
},
"desc": "Checks whether the specified facet value is selected."
},
{
"kind": "function",
"name": "showLessValues",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sets the number of values displayed in the facet to the originally configured value."
},
{
"kind": "function",
"name": "showMoreValues",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Increases the number of values displayed in the facet to the next multiple of the originally configured value."
},
{
"kind": "function",
"name": "sortBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion to use for sorting values.",
"type": "'score' | 'alphanumeric' | 'occurrences' | 'automatic'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sorts the facet values according to the specified criterion."
},
{
"kind": "function",
"name": "toggleSelect",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to toggle.",
"type": "FacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified facet value."
},
{
"kind": "function",
"name": "toggleSingleSelect",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to toggle.",
"type": "FacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified facet value, deselecting others."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "Facet"
},
"desc": "Creates a `Facet` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "FacetSearchOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "captions",
"isOptional": true,
"type": "Record<string, string>",
"desc": "A dictionary that maps index field values to facet value display names."
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The maximum number of values to fetch.",
"defaultValue": "`10`"
},
{
"kind": "primitive",
"name": "query",
"isOptional": true,
"type": "string",
"desc": "The query to search the facet values with."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "SpecificFacetSearchResult",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "count",
"isOptional": false,
"type": "number",
"desc": "An estimate of the number of result items matching both the current query and the filter expression that would get generated if the facet value were selected."
},
{
"kind": "primitive",
"name": "displayValue",
"isOptional": false,
"type": "string",
"desc": "The custom facet value display name, as specified in the `captions` argument of the facet request."
},
{
"kind": "primitive",
"name": "rawValue",
"isOptional": false,
"type": "string",
"desc": "The original facet value, as retrieved from the field in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FacetSearchState",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "`true` if the facet search is in progress and `false` otherwise."
},
{
"kind": "primitive",
"name": "moreValuesAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more values are available."
},
{
"kind": "primitive",
"name": "query",
"isOptional": false,
"type": "string",
"desc": "The current query in the facet search box."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "SpecificFacetSearchResult[]",
"desc": "The facet search results.",
"members": [],
"isTypeExtracted": true,
"typeName": "SpecificFacetSearchResult"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "Whether a facet value is filtering results (`selected`) or not (`idle`)."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The facet value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/facet/facet.class.tsx",
"code": "import {\n buildFacet,\n Facet as HeadlessFacet,\n FacetOptions,\n FacetState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {FacetSearch} from './facet-search';\n\ninterface FacetProps extends FacetOptions {\n facetId: string;\n}\n\nexport class Facet extends Component<FacetProps, FacetState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessFacet;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildFacet(this.context.engine!, {\n options: this.props,\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n if (!this.state.values.length) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n <li>\n <FacetSearch\n controller={this.controller.facetSearch}\n facetState={this.state.facetSearch}\n isValueSelected={(facetSearchValue) =>\n !!this.state.values.find(\n (facetValue) =>\n facetValue.value === facetSearchValue.displayValue &&\n this.controller.isValueSelected(facetValue)\n )\n }\n />\n </li>\n <li>\n <ul>\n {this.state.values.map((value) => (\n <li key={value.value}>\n <input\n type=\"checkbox\"\n checked={this.controller.isValueSelected(value)}\n onChange={() => this.controller.toggleSelect(value)}\n disabled={this.state.isLoading}\n />\n {value.value} ({value.numberOfResults} results)\n </li>\n ))}\n </ul>\n </li>\n </ul>\n );\n }\n}\n",
"fileName": "facet.class.tsx"
},
{
"path": "packages/samples/headless-react/src/components/facet/facet-search.tsx",
"code": "import {\n FacetSearch as HeadlessFacetSearch,\n FacetSearchState,\n SpecificFacetSearchResult,\n} from '@coveo/headless';\nimport {FunctionComponent} from 'react';\n\nexport interface FacetSearchProps {\n controller: HeadlessFacetSearch;\n facetState: FacetSearchState;\n isValueSelected: (facetSearchValue: SpecificFacetSearchResult) => boolean;\n}\n\nexport const FacetSearch: FunctionComponent<FacetSearchProps> = (props) => {\n const onInput = (text: string) => {\n props.controller.updateText(text);\n props.controller.search();\n };\n\n return (\n <div>\n <input onInput={(e) => onInput(e.currentTarget.value)} />\n <ul>\n {props.facetState.values.map((facetSearchValue) => (\n <li key={facetSearchValue.rawValue}>\n <button\n onClick={() => props.controller.select(facetSearchValue)}\n disabled={props.isValueSelected(facetSearchValue)}\n >\n {facetSearchValue.displayValue} ({facetSearchValue.count} results)\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n",
"fileName": "facet-search.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/facet/facet.fn.tsx",
"code": "import {Facet as HeadlessFacet} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\nimport {FacetSearch} from './facet-search';\n\ninterface FacetProps {\n controller: HeadlessFacet;\n}\n\nexport const Facet: FunctionComponent<FacetProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n if (!state.values.length) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n <li>\n <FacetSearch\n controller={controller.facetSearch}\n facetState={state.facetSearch}\n isValueSelected={(facetSearchValue) =>\n !!state.values.find(\n (facetValue) =>\n facetValue.value === facetSearchValue.displayValue &&\n controller.isValueSelected(facetValue)\n )\n }\n />\n </li>\n <li>\n <ul>\n {state.values.map((value) => (\n <li key={value.value}>\n <input\n type=\"checkbox\"\n checked={controller.isValueSelected(value)}\n onChange={() => controller.toggleSelect(value)}\n disabled={state.isLoading}\n />\n {value.value} ({value.numberOfResults} results)\n </li>\n ))}\n </ul>\n </li>\n </ul>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const options: FacetOptions = {field: 'objecttype'};\n * const controller = buildFacet(engine, {options});\n *\n * <Facet controller={controller} />;\n * ```\n */\n",
"fileName": "facet.fn.tsx"
},
{
"path": "packages/samples/headless-react/src/components/facet/facet-search.tsx",
"code": "import {\n FacetSearch as HeadlessFacetSearch,\n FacetSearchState,\n SpecificFacetSearchResult,\n} from '@coveo/headless';\nimport {FunctionComponent} from 'react';\n\nexport interface FacetSearchProps {\n controller: HeadlessFacetSearch;\n facetState: FacetSearchState;\n isValueSelected: (facetSearchValue: SpecificFacetSearchResult) => boolean;\n}\n\nexport const FacetSearch: FunctionComponent<FacetSearchProps> = (props) => {\n const onInput = (text: string) => {\n props.controller.updateText(text);\n props.controller.search();\n };\n\n return (\n <div>\n <input onInput={(e) => onInput(e.currentTarget.value)} />\n <ul>\n {props.facetState.values.map((facetSearchValue) => (\n <li key={facetSearchValue.rawValue}>\n <button\n onClick={() => props.controller.select(facetSearchValue)}\n disabled={props.isValueSelected(facetSearchValue)}\n >\n {facetSearchValue.displayValue} ({facetSearchValue.count} results)\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n",
"fileName": "facet-search.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildSort",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `Sort` controller properties.",
"type": "SortProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "SortInitialState",
"desc": "The initial state that should be applied to this `Sort` controller.",
"members": [
{
"kind": "primitive",
"name": "criterion",
"isOptional": true,
"type": "SortCriterion | SortCriterion[]",
"desc": "The initial sort criterion to register in state."
}
],
"isTypeExtracted": false,
"typeName": "SortInitialState"
}
],
"isTypeExtracted": false,
"typeName": "SortProps"
}
],
"returnType": {
"kind": "object",
"name": "Sort",
"isOptional": false,
"type": "Sort",
"desc": "The `Sort` controller manages how the results are sorted.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "SortState",
"desc": "A scoped and simplified part of the headless state that is relevant to the `Sort` controller.",
"members": [
{
"kind": "primitive",
"name": "sortCriteria",
"isOptional": false,
"type": "string",
"desc": "The current sort criteria."
}
],
"isTypeExtracted": false,
"typeName": "SortState"
},
{
"kind": "function",
"name": "isSortedBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion to compare.",
"type": "SortByRelevancy | SortByQRE | SortByDate | SortByField | SortByNoSort"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "`true` if the passed sort criterion matches the value in state, and `false` otherwise."
},
"desc": "Checks whether the specified sort criterion matches the value in state."
},
{
"kind": "function",
"name": "sortBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The new sort criterion.",
"type": "SortByRelevancy | SortByQRE | SortByDate | SortByField | SortByNoSort"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the sort criterion and executes a new search."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "Sort"
},
"desc": "Creates a `Sort` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/sort/sort.class.tsx",
"code": "import {\n buildCriterionExpression,\n buildSort,\n Sort as HeadlessSort,\n SortCriterion,\n SortState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\ninterface SortProps {\n criteria: [string, SortCriterion][];\n initialCriterion: SortCriterion;\n}\n\nexport class Sort extends Component<SortProps, SortState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessSort;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildSort(this.context.engine!, {\n initialState: {criterion: this.props.initialCriterion},\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private getCriterionFromName(name: string) {\n return this.props.criteria.find(\n ([criterionName]) => criterionName === name\n )!;\n }\n\n private get currentCriterion() {\n return this.props.criteria.find(\n ([, criterion]) =>\n this.state.sortCriteria === buildCriterionExpression(criterion)\n )!;\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <select\n value={this.currentCriterion[0]}\n onChange={(e) =>\n this.controller.sortBy(this.getCriterionFromName(e.target.value)[1])\n }\n >\n {this.props.criteria.map(([criterionName]) => (\n <option key={criterionName} value={criterionName}>\n {criterionName}\n </option>\n ))}\n </select>\n );\n }\n}\n",
"fileName": "sort.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/sort/sort.fn.tsx",
"code": "import {\n buildCriterionExpression,\n Sort as HeadlessSort,\n SortCriterion,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface SortProps {\n controller: HeadlessSort;\n criteria: [string, SortCriterion][];\n}\n\nexport const Sort: FunctionComponent<SortProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const getCriterionFromName = (name: string) =>\n props.criteria.find(([criterionName]) => criterionName === name)!;\n\n const getCurrentCriterion = () =>\n props.criteria.find(\n ([, criterion]) =>\n state.sortCriteria === buildCriterionExpression(criterion)\n )!;\n\n return (\n <select\n value={getCurrentCriterion()[0]}\n onChange={(e) =>\n controller.sortBy(getCriterionFromName(e.target.value)[1])\n }\n >\n {props.criteria.map(([criterionName]) => (\n <option key={criterionName} value={criterionName}>\n {criterionName}\n </option>\n ))}\n </select>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const criteria: [string, SortCriterion][] = [\n * ['Relevance', buildRelevanceSortCriterion()],\n * ['Date (Ascending)', buildDateSortCriterion(SortOrder.Ascending)],\n * ['Date (Descending)', buildDateSortCriterion(SortOrder.Descending)],\n * ['Size (Ascending)', buildFieldSortCriterion('size', SortOrder.Ascending)],\n * ['Size (Descending)', buildFieldSortCriterion('size', SortOrder.Descending)],\n * ];\n * const initialCriterion = criteria[0][1];\n * const controller = buildSort(engine, {\n * initialState: {criterion: initialCriterion},\n * });\n *\n * <Sort controller={controller} criteria={criteria} />;\n * ```\n */\n",
"fileName": "sort.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildNumericFacet",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `NumericFacet` properties.",
"type": "NumericFacetProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "NumericFacetOptions",
"desc": "The options for the `NumericFacet` controller.",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "generateAutomaticRanges",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index should automatically create range values.\n\nTip: If you set this parameter to true, you should ensure that the ['Use cache for numeric queries' option](https://docs.coveo.com/en/1982/#use-cache-for-numeric-queries) is enabled for this facet's field in your index in order to speed up automatic range evaluation."
},
{
"kind": "object",
"name": "currentValues",
"isOptional": true,
"type": "NumericRangeRequest[]",
"desc": "The values displayed by the facet in the search interface at the moment of the request.\n\nIf `generateAutomaticRanges` is false, values must be specified. If `generateAutomaticRanges` is true, automatic ranges are going to be appended after the specified values.",
"defaultValue": "`[]`",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericRangeRequest"
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a unique random identifier is generated."
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude folded result parents when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`8`"
},
{
"kind": "primitive-with-type-alias",
"name": "rangeAlgorithm",
"isOptional": true,
"type": "'even' | 'equiprobable'",
"desc": "The algorithm that's used for generating the ranges of this facet when they aren't manually defined. The default value of `\"even\"` generates equally sized facet ranges across all of the results. The value `\"equiprobable\"` generates facet ranges which vary in size but have a more balanced number of results within each range.",
"defaultValue": "`even`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'ascending' | 'descending'",
"desc": "The sort criterion to apply to the returned facet values.",
"defaultValue": "`ascending`"
}
],
"isTypeExtracted": false,
"typeName": "NumericFacetOptions"
}
],
"isTypeExtracted": false,
"typeName": "NumericFacetProps"
}
],
"returnType": {
"kind": "object",
"name": "NumericFacet",
"isOptional": false,
"type": "NumericFacet",
"desc": "The `NumericFacet` controller makes it possible to create a facet with numeric ranges.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "NumericFacetState",
"desc": "The state of the `NumericFacet` controller.",
"members": [
{
"kind": "primitive",
"name": "enabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether the facet is enabled and its values are used to filter search results."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet ID."
},
{
"kind": "primitive",
"name": "hasActiveValues",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is at least one non-idle value and `false` otherwise."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "`true` if a search is in progress and `false` otherwise."
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriterion",
"isOptional": false,
"type": "'ascending' | 'descending'",
"desc": "The active sortCriterion of the facet."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "NumericFacetValue[]",
"desc": "The values of the facet.",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"isTypeExtracted": false,
"typeName": "NumericFacetState"
},
{
"kind": "function",
"name": "deselectAll",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects all facet values."
},
{
"kind": "function",
"name": "disable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disables the facet. I.e., prevents it from filtering results."
},
{
"kind": "function",
"name": "enable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Enables the facet. I.e., undoes the effects of `disable`."
},
{
"kind": "function",
"name": "isSortedBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion to compare.",
"type": "'ascending' | 'descending'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the facet values are sorted according to the specified criterion."
},
"desc": "Checks whether the facet values are sorted according to the specified criterion."
},
{
"kind": "function",
"name": "isValueSelected",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to check.",
"type": "NumericFacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the specified facet value is selected."
},
"desc": "Checks whether the specified facet value is selected."
},
{
"kind": "function",
"name": "sortBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion to sort values by.",
"type": "'ascending' | 'descending'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sorts the facet values according to the specified criterion."
},
{
"kind": "function",
"name": "toggleSelect",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to toggle.",
"type": "NumericFacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified facet value."
},
{
"kind": "function",
"name": "toggleSingleSelect",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to toggle.",
"type": "NumericFacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified facet value, deselecting others."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "NumericFacet"
},
"desc": "Creates a `NumericFacet` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "NumericRangeRequest",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The end value of the range."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether to include the `end` value in the range."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The start value of the range."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The current facet value state."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The ending value for the numeric range."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The starting value for the numeric range."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericRangeOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The ending value of the numeric range."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The starting value of the numeric range."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": true,
"type": "boolean",
"desc": "Whether to include the `end` value in the range.",
"defaultValue": "`false`"
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": true,
"type": "'idle' | 'selected'",
"desc": "The current facet value state.",
"defaultValue": "`idle`"
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [
{
"kind": "function",
"name": "buildNumericRange",
"params": [
{
"kind": "object",
"name": "config",
"isOptional": false,
"desc": "The options with which to create a `NumericRangeRequest`.",
"type": "NumericRangeOptions",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericRangeOptions"
}
],
"returnType": {
"kind": "object",
"name": "NumericRangeRequest",
"isOptional": false,
"type": "NumericRangeRequest",
"desc": "The options defining a value to display in a `NumericFacet`.",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericRangeRequest"
},
"desc": "Creates a `NumericRangeRequest`."
}
],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/numeric-facet/numeric-facet.class.tsx",
"code": "import {\n buildNumericFacet,\n NumericFacet as HeadlessNumericFacet,\n NumericFacetOptions,\n NumericFacetState,\n NumericFacetValue,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\ninterface NumericFacetProps extends NumericFacetOptions {\n format: (n: number) => string;\n facetId: string;\n}\n\nexport class NumericFacet extends Component<\n NumericFacetProps,\n NumericFacetState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessNumericFacet;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildNumericFacet(this.context.engine!, {\n options: {\n field: this.props.field,\n facetId: this.props.facetId,\n generateAutomaticRanges: this.props.generateAutomaticRanges,\n ...(this.props.currentValues && {\n currentValues: this.props.currentValues,\n }),\n },\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private getKeyForRange(value: NumericFacetValue) {\n return `[${value.start}..${value.end}${value.endInclusive ? ']' : '['}`;\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n if (\n !this.state.values.filter(\n (value) => value.state !== 'idle' || value.numberOfResults > 0\n ).length\n ) {\n return <div>No facet values</div>;\n }\n\n const {format} = this.props;\n\n return (\n <ul>\n {this.state.values.map((value) => (\n <li key={this.getKeyForRange(value)}>\n <input\n type=\"checkbox\"\n checked={this.controller.isValueSelected(value)}\n onChange={() => this.controller.toggleSelect(value)}\n disabled={this.state.isLoading}\n />\n {format(value.start)} to {format(value.end)}{' '}\n {value.endInclusive ? 'inclusively' : 'exclusively'} (\n {value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </li>\n ))}\n </ul>\n );\n }\n}\n",
"fileName": "numeric-facet.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/numeric-facet/numeric-facet.fn.tsx",
"code": "import {\n NumericFacet as HeadlessNumericFacet,\n NumericFacetValue,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface NumericFacetProps {\n controller: HeadlessNumericFacet;\n format: (n: number) => string;\n}\n\nexport const NumericFacet: FunctionComponent<NumericFacetProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n function getKeyForRange(value: NumericFacetValue) {\n return `[${value.start}..${value.end}${value.endInclusive ? ']' : '['}`;\n }\n\n if (\n !state.values.filter(\n (value) => value.state !== 'idle' || value.numberOfResults > 0\n ).length\n ) {\n return <div>No facet values</div>;\n }\n\n const {format} = props;\n\n return (\n <ul>\n {state.values.map((value) => (\n <li key={getKeyForRange(value)}>\n <input\n type=\"checkbox\"\n checked={controller.isValueSelected(value)}\n onChange={() => controller.toggleSelect(value)}\n disabled={state.isLoading}\n />\n {format(value.start)} to {format(value.end)}{' '}\n {value.endInclusive ? 'inclusively' : 'exclusively'} (\n {value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </li>\n ))}\n </ul>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const [KB, MB, GB] = [1e3, 1e6, 1e9];\n *\n * const controller = buildNumericFacet(engine, {\n * options: {\n * field: 'size',\n * generateAutomaticRanges: false,\n * currentValues: [ // Must be specified when `generateAutomaticRanges` is false.\n * buildNumericRange({start: 0, end: 5 * KB}),\n * buildNumericRange({start: 5 * KB, end: 5 * MB}),\n * buildNumericRange({start: 5 * MB, end: 5 * GB}),\n * ],\n * },\n * });\n *\n * <NumericFacet controller={controller} format={(bytes) => `${bytes} bytes`} />;\n * ```\n */\n",
"fileName": "numeric-facet.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildNumericFilter",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `NumericFilter` controller properties.",
"type": "NumericFilterProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "NumericFilterOptions",
"desc": "The options for the `NumericFilter` controller.",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the filter."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a unique random ID is generated."
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude folded result parents when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
}
],
"isTypeExtracted": false,
"typeName": "NumericFilterOptions"
},
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "NumericFilterInitialState",
"desc": "The initial state.",
"members": [
{
"kind": "object",
"name": "range",
"isOptional": false,
"type": "NumericFilterRange",
"desc": "The initial selected range.",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFilterRange"
}
],
"isTypeExtracted": false,
"typeName": "NumericFilterInitialState"
}
],
"isTypeExtracted": false,
"typeName": "NumericFilterProps"
}
],
"returnType": {
"kind": "object",
"name": "NumericFilter",
"isOptional": false,
"type": "NumericFilter",
"desc": "The `NumericFilter` controller makes it possible to create a numeric filter.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "NumericFilterState",
"desc": "The state of the `NumericFilter` controller.",
"members": [
{
"kind": "primitive",
"name": "enabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether the filter is enabled and its value is used to filter search results."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet ID."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if a search is in progress, and `false` if not."
},
{
"kind": "object",
"name": "range",
"isOptional": true,
"type": "NumericFacetValue",
"desc": "The current selected range.",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"isTypeExtracted": false,
"typeName": "NumericFilterState"
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Clears the current filter."
},
{
"kind": "function",
"name": "disable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disables the filter. I.e., prevents it from filtering results."
},
{
"kind": "function",
"name": "enable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Enables the filter. I.e., undoes the effects of `disable`."
},
{
"kind": "function",
"name": "setRange",
"params": [
{
"kind": "object",
"name": "range",
"isOptional": false,
"desc": "The numeric range.",
"type": "NumericFilterRange",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFilterRange"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the range is valid."
},
"desc": "Updates the selected range."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "NumericFilter"
},
"desc": "Creates a `NumericFilter` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "NumericFilterRange",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The ending value for the numeric range."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The starting value for the numeric range."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The ending value for the numeric range."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The starting value for the numeric range."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/numeric-filter/numeric-filter.class.tsx",
"code": "import {\n buildNumericFilter,\n NumericFilter as HeadlessNumericFilter,\n NumericFilterOptions,\n NumericFilterState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\ninterface NumericFilterProps extends NumericFilterOptions {\n facetId: string;\n}\n\nexport class NumericFilter extends Component<\n NumericFilterProps,\n NumericFilterState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessNumericFilter;\n private unsubscribe: Unsubscribe = () => {};\n private startRef!: HTMLInputElement;\n private endRef!: HTMLInputElement;\n\n componentDidMount() {\n this.controller = buildNumericFilter(this.context.engine!, {\n options: {\n field: this.props.field,\n facetId: this.props.facetId,\n },\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n const {range} = this.state;\n\n return [\n <input\n key=\"start\"\n type=\"number\"\n ref={(ref) => (this.startRef = ref!)}\n defaultValue={range?.start}\n placeholder=\"Start\"\n />,\n <input\n key=\"end\"\n type=\"number\"\n ref={(ref) => (this.endRef = ref!)}\n defaultValue={range?.end}\n placeholder=\"End\"\n />,\n <button\n key=\"apply\"\n onClick={() =>\n this.controller.setRange({\n start: this.startRef.valueAsNumber,\n end: this.endRef.valueAsNumber,\n })\n }\n >\n Apply\n </button>,\n ];\n }\n}\n",
"fileName": "numeric-filter.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/numeric-filter/numeric-filter.fn.tsx",
"code": "import {NumericFilter as HeadlessNumericFilter} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent, Fragment} from 'react';\n\ninterface NumericFilterProps {\n controller: HeadlessNumericFilter;\n}\n\nexport const NumericFilter: FunctionComponent<NumericFilterProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n let startRef: HTMLInputElement;\n let endRef: HTMLInputElement;\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const {range} = state;\n\n return (\n <Fragment>\n <input\n key=\"start\"\n type=\"number\"\n ref={(ref) => (startRef = ref!)}\n defaultValue={range?.start}\n placeholder=\"Start\"\n />\n <input\n key=\"end\"\n type=\"number\"\n ref={(ref) => (endRef = ref!)}\n defaultValue={range?.end}\n placeholder=\"End\"\n />\n <button\n key=\"apply\"\n onClick={() =>\n controller.setRange({\n start: startRef.valueAsNumber,\n end: endRef.valueAsNumber,\n })\n }\n >\n Apply\n </button>\n </Fragment>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildNumericFilter(engine, {\n * options: {\n * field: 'size',\n * },\n * });\n *\n * <NumericFilter controller={controller} />;\n * ```\n */\n",
"fileName": "numeric-filter.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildDateFacet",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `DateFacet` controller properties.",
"type": "DateFacetProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "DateFacetOptions",
"desc": "The options for the `DateFacet` controller.",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "generateAutomaticRanges",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index should automatically create range values.\n\nTip: If you set this parameter to true, you should ensure that the ['Use cache for numeric queries' option](https://docs.coveo.com/en/1982/#use-cache-for-numeric-queries) is enabled for this facet's field in your index in order to speed up automatic range evaluation."
},
{
"kind": "object",
"name": "currentValues",
"isOptional": true,
"type": "DateRangeRequest[]",
"desc": "The values displayed by the facet in the search interface at the moment of the request.\n\nIf `generateAutomaticRanges` is false, values must be specified. If `generateAutomaticRanges` is true, automatic ranges are going to be appended after the specified values.",
"defaultValue": "`[]`",
"members": [],
"isTypeExtracted": true,
"typeName": "DateRangeRequest"
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a unique random identifier is generated."
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude folded result parents when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`8`"
},
{
"kind": "primitive-with-type-alias",
"name": "rangeAlgorithm",
"isOptional": true,
"type": "'even' | 'equiprobable'",
"desc": "The algorithm that's used for generating the ranges of this facet when they aren't manually defined. The default value of `\"even\"` generates equally sized facet ranges across all of the results. The value `\"equiprobable\"` generates facet ranges which vary in size but have a more balanced number of results within each range.",
"defaultValue": "`even`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'ascending' | 'descending'",
"desc": "The sort criterion to apply to the returned facet values.",
"defaultValue": "`ascending`"
}
],
"isTypeExtracted": false,
"typeName": "DateFacetOptions"
}
],
"isTypeExtracted": false,
"typeName": "DateFacetProps"
}
],
"returnType": {
"kind": "object",
"name": "DateFacet",
"isOptional": false,
"type": "DateFacet",
"desc": "The `DateFacet` controller makes it possible to create a facet with date ranges.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "DateFacetState",
"desc": "The state of the `DateFacet` controller.",
"members": [
{
"kind": "primitive",
"name": "enabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether the facet is enabled and its values are used to filter search results."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet ID."
},
{
"kind": "primitive",
"name": "hasActiveValues",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is at least one non-idle value and `false` otherwise."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "`true` if a search is in progress and `false` otherwise."
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriterion",
"isOptional": false,
"type": "'ascending' | 'descending'",
"desc": "The active sortCriterion of the facet."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "DateFacetValue[]",
"desc": "The values of the facet.",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"isTypeExtracted": false,
"typeName": "DateFacetState"
},
{
"kind": "function",
"name": "deselectAll",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects all facet values."
},
{
"kind": "function",
"name": "disable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disables the facet. I.e., prevents it from filtering results."
},
{
"kind": "function",
"name": "enable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Enables the facet. I.e., undoes the effects of `disable`."
},
{
"kind": "function",
"name": "isSortedBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion to compare.",
"type": "'ascending' | 'descending'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the facet values are sorted according to the specified criterion."
},
"desc": "Checks whether the facet values are sorted according to the specified criterion."
},
{
"kind": "function",
"name": "isValueSelected",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to check.",
"type": "DateFacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the specified facet value is selected."
},
"desc": "Checks whether the specified facet value is selected."
},
{
"kind": "function",
"name": "sortBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion by which to sort values.",
"type": "'ascending' | 'descending'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sorts the facet values according to the specified criterion."
},
{
"kind": "function",
"name": "toggleSelect",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to toggle.",
"type": "DateFacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified facet value."
},
{
"kind": "function",
"name": "toggleSingleSelect",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to toggle.",
"type": "DateFacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified facet value, deselecting others."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "DateFacet"
},
"desc": "Creates a `DateFacet` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "DateRangeRequest",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "string",
"desc": "The ending value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the [Relative Date](https://docs.coveo.com/en/headless/latest/reference/search/search-date-facet-controller/relative-date-format/) format \"period-amount-unit\"."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether to include the `end` value in the range."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "string",
"desc": "The starting value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the [Relative Date](https://docs.coveo.com/en/headless/latest/reference/search/search-date-facet-controller/relative-date-format/) format \"period-amount-unit\"."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The current facet value state."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "string",
"desc": "The ending value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "string",
"desc": "The starting value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateRangeOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive-with-type-alias",
"name": "end",
"isOptional": false,
"type": "AbsoluteDate | RelativeDate",
"desc": "The ending value for the date range. A date range can be either absolute or [relative](https://docs.coveo.com/en/headless/latest/reference/search/search-date-facet-controller/relative-date-format/)."
},
{
"kind": "primitive-with-type-alias",
"name": "start",
"isOptional": false,
"type": "AbsoluteDate | RelativeDate",
"desc": "The starting value for the date range. A date range can be either absolute or [relative](https://docs.coveo.com/en/headless/latest/reference/search/search-date-facet-controller/relative-date-format/)."
},
{
"kind": "primitive",
"name": "dateFormat",
"isOptional": true,
"type": "string",
"desc": "Allows specifying a custom string date format. See [Day.js](https://day.js.org/docs/en/parse/string-format#list-of-all-available-parsing-tokens) for possible parsing tokens. Assumes [ISO 8601](https://day.js.org/docs/en/parse/string) format by default."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": true,
"type": "boolean",
"desc": "Whether to include the end value in the range.",
"defaultValue": "`false`"
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": true,
"type": "'idle' | 'selected'",
"desc": "The current facet value state.",
"defaultValue": "`idle`"
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [
{
"kind": "function",
"name": "buildDateRange",
"params": [
{
"kind": "object",
"name": "config",
"isOptional": false,
"desc": "The options with which to create a `DateRangeRequest`.",
"type": "DateRangeOptions",
"members": [],
"isTypeExtracted": true,
"typeName": "DateRangeOptions"
}
],
"returnType": {
"kind": "object",
"name": "DateRangeRequest",
"isOptional": false,
"type": "DateRangeRequest",
"desc": "The options defining a value to display in a `DateFacet`.",
"members": [],
"isTypeExtracted": true,
"typeName": "DateRangeRequest"
},
"desc": "Creates a `DateRangeRequest`."
}
],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/date-facet/date-facet.class.tsx",
"code": "import {\n buildDateFacet,\n DateFacet as HeadlessDateFacet,\n DateFacetOptions,\n DateFacetState,\n DateFacetValue,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {parseDate} from './date-utils';\n\ninterface DateFacetProps extends DateFacetOptions {\n facetId: string;\n}\n\nexport class DateFacet extends Component<DateFacetProps, DateFacetState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessDateFacet;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildDateFacet(this.context.engine!, {\n options: this.props,\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private getKeyForRange(value: DateFacetValue) {\n return `[${value.start}..${value.end}]`;\n }\n\n private format(dateStr: string) {\n return parseDate(dateStr).format('MMMM D YYYY');\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n if (\n !this.state.values.filter(\n (value) => value.state !== 'idle' || value.numberOfResults > 0\n ).length\n ) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n {this.state.values.map((value) => (\n <li key={this.getKeyForRange(value)}>\n <input\n type=\"checkbox\"\n checked={this.controller.isValueSelected(value)}\n onChange={() => this.controller.toggleSelect(value)}\n disabled={this.state.isLoading}\n />\n {this.format(value.start)} to {this.format(value.end)} (\n {value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </li>\n ))}\n </ul>\n );\n }\n}\n",
"fileName": "date-facet.class.tsx"
},
{
"path": "packages/samples/headless-react/src/components/relative-date-facet/relative-date-facet.class.tsx",
"code": "import {\n buildDateFacet,\n DateFacet,\n DateFacetOptions,\n DateFacetState,\n DateFacetValue,\n Unsubscribe,\n deserializeRelativeDate,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\ninterface RelativeDateFacetProps extends DateFacetOptions {\n facetId: string;\n}\n\nexport class RelativeDateFacet extends Component<\n RelativeDateFacetProps,\n DateFacetState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: DateFacet;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildDateFacet(this.context.engine!, {\n options: this.props,\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private getKeyForRange(value: DateFacetValue) {\n return `[${value.start}..${value.end}]`;\n }\n\n private format(value: string) {\n const relativeDate = deserializeRelativeDate(value);\n return relativeDate.period === 'now'\n ? relativeDate.period\n : `${relativeDate.period} ${relativeDate.amount} ${relativeDate.unit}`;\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n if (\n !this.state.values.filter(\n (value) => value.state !== 'idle' || value.numberOfResults > 0\n ).length\n ) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n {this.state.values.map((value) => (\n <li key={this.getKeyForRange(value)}>\n <input\n type=\"checkbox\"\n checked={this.controller.isValueSelected(value)}\n onChange={() => this.controller.toggleSelect(value)}\n disabled={this.state.isLoading}\n />\n {this.format(value.start)} to {this.format(value.end)} (\n {value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </li>\n ))}\n </ul>\n );\n }\n}\n",
"fileName": "relative-date-facet.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/date-facet/date-facet.fn.tsx",
"code": "import {DateFacet as HeadlessDateFacet, DateFacetValue} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\nimport {parseDate} from './date-utils';\n\ninterface DateFacetProps {\n controller: HeadlessDateFacet;\n}\n\nexport const DateFacet: FunctionComponent<DateFacetProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n function getKeyForRange(value: DateFacetValue) {\n return `[${value.start}..${value.end}]`;\n }\n\n function format(dateStr: string) {\n return parseDate(dateStr).format('MMMM D YYYY');\n }\n\n if (\n !state.values.filter(\n (value) => value.state !== 'idle' || value.numberOfResults > 0\n ).length\n ) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n {state.values.map((value) => (\n <li key={getKeyForRange(value)}>\n <input\n type=\"checkbox\"\n checked={controller.isValueSelected(value)}\n onChange={() => controller.toggleSelect(value)}\n disabled={state.isLoading}\n />\n {format(value.start)} to {format(value.end)} ({value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </li>\n ))}\n </ul>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildDateFacet(engine, {\n * options: {\n * field: 'created',\n * generateAutomaticRanges: false,\n * currentValues: [ // Must be specified when `generateAutomaticRanges` is false.\n * buildDateRange({\n * start: new Date(2015, 1),\n * end: new Date(2018, 1),\n * }),\n * buildDateRange({\n * start: new Date(2018, 1),\n * end: new Date(2020, 1),\n * }),\n * buildDateRange({\n * start: new Date(2020, 1),\n * end: new Date(2021, 1),\n * }),\n * ],\n * },\n * });\n *\n * <DateFacet controller={controller} />;\n * ```\n */\n",
"fileName": "date-facet.fn.tsx"
},
{
"path": "packages/samples/headless-react/src/components/relative-date-facet/relative-date-facet.fn.tsx",
"code": "import {\n DateFacet,\n DateFacetValue,\n deserializeRelativeDate,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface RelativeDateFacetProps {\n controller: DateFacet;\n}\n\nexport const RelativeDateFacet: FunctionComponent<RelativeDateFacetProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n function getKeyForRange(value: DateFacetValue) {\n return `[${value.start}..${value.end}]`;\n }\n\n function format(value: string) {\n const relativeDate = deserializeRelativeDate(value);\n return relativeDate.period === 'now'\n ? relativeDate.period\n : `${relativeDate.period} ${relativeDate.amount} ${relativeDate.unit}`;\n }\n\n if (\n !state.values.filter(\n (value) => value.state !== 'idle' || value.numberOfResults > 0\n ).length\n ) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n {state.values.map((value) => (\n <li key={getKeyForRange(value)}>\n <input\n type=\"checkbox\"\n checked={controller.isValueSelected(value)}\n onChange={() => controller.toggleSingleSelect(value)}\n disabled={state.isLoading}\n />\n {format(value.start)} to {format(value.end)} ({value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </li>\n ))}\n </ul>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildDateFacet(engine, {\n * options: {\n * field: 'created',\n * generateAutomaticRanges: false,\n * currentValues: [\n * buildDateRange({\n * start: {period: 'past', unit: 'day', amount: 1},\n * end: {period: 'now'},\n * }),\n * buildDateRange({\n * start: {period: 'past', unit: 'week', amount: 1},\n * end: {period: 'now'},\n * }),\n * ],\n * },\n * });\n *\n * <DateFacet controller={controller} />;\n * ```\n */\n",
"fileName": "relative-date-facet.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildDateFilter",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `DateFilter` controller properties.",
"type": "DateFilterProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "DateFilterOptions",
"desc": "The options for the `DateFilter` controller.",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the filter."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a unique random identifier is generated."
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude folded result parents when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
}
],
"isTypeExtracted": false,
"typeName": "DateFilterOptions"
},
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "DateFilterInitialState",
"desc": "The initial state.",
"members": [
{
"kind": "object",
"name": "range",
"isOptional": false,
"type": "DateFilterRange",
"desc": "The initial selected range.",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFilterRange"
}
],
"isTypeExtracted": false,
"typeName": "DateFilterInitialState"
}
],
"isTypeExtracted": false,
"typeName": "DateFilterProps"
}
],
"returnType": {
"kind": "object",
"name": "DateFilter",
"isOptional": false,
"type": "DateFilter",
"desc": "The `DateFilter` controller makes it possible to create a date filter.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "DateFilterState",
"desc": "The state of the `DateFilter` controller.",
"members": [
{
"kind": "primitive",
"name": "enabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether the filter is enabled and its value is used to filter search results."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet ID."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if a search is in progress, and `false` if not."
},
{
"kind": "object",
"name": "range",
"isOptional": true,
"type": "DateFacetValue",
"desc": "The current selected range.",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"isTypeExtracted": false,
"typeName": "DateFilterState"
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Clears the current filter."
},
{
"kind": "function",
"name": "disable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disables the filter. I.e., prevents it from filtering results."
},
{
"kind": "function",
"name": "enable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Enables the filter. I.e., undoes the effects of `disable`."
},
{
"kind": "function",
"name": "setRange",
"params": [
{
"kind": "object",
"name": "range",
"isOptional": false,
"desc": "The date range.",
"type": "DateFilterRange",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFilterRange"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the range is valid."
},
"desc": "Updates the selected range.\n\nYou can use the `buildDateRange` utility method in order to format the range values correctly."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "DateFilter"
},
"desc": "Creates a `DateFilter` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "DateFilterRange",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "string",
"desc": "The ending value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "string",
"desc": "The starting value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "string",
"desc": "The ending value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "string",
"desc": "The starting value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/date-filter/date-filter.class.tsx",
"code": "import {\n buildDateFilter,\n buildDateRange,\n DateFilter as HeadlessDateFilter,\n DateFilterOptions,\n DateFilterState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {parseDate} from '../date-facet/date-utils';\n\ninterface DateFilterProps extends DateFilterOptions {\n facetId: string;\n}\n\nexport class DateFilter extends Component<DateFilterProps, DateFilterState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessDateFilter;\n private unsubscribe: Unsubscribe = () => {};\n private startRef!: HTMLInputElement;\n private endRef!: HTMLInputElement;\n\n componentDidMount() {\n this.controller = buildDateFilter(this.context.engine!, {\n options: {\n field: this.props.field,\n facetId: this.props.facetId,\n },\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private formattedDateValue(date?: string | Date) {\n if (!date) {\n return '';\n }\n return parseDate(date).format('YYYY-MM-DD');\n }\n\n private apply() {\n if (!this.startRef.validity.valid || !this.endRef.validity.valid) {\n return;\n }\n\n this.controller.setRange(\n buildDateRange({\n start: this.startRef.valueAsDate!,\n end: this.endRef.valueAsDate!,\n })\n );\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n const {range} = this.state;\n\n return [\n <input\n key=\"start\"\n type=\"date\"\n ref={(ref) => (this.startRef = ref!)}\n defaultValue={this.formattedDateValue(range?.start)}\n placeholder=\"Start\"\n />,\n <input\n key=\"end\"\n type=\"date\"\n ref={(ref) => (this.endRef = ref!)}\n defaultValue={this.formattedDateValue(range?.end)}\n placeholder=\"End\"\n />,\n <button key=\"apply\" onClick={() => this.apply()}>\n Apply\n </button>,\n ];\n }\n}\n",
"fileName": "date-filter.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/date-filter/date-filter.fn.tsx",
"code": "import {\n buildDateRange,\n DateFilter as HeadlessDateFilter,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent, Fragment} from 'react';\nimport {parseDate} from '../date-facet/date-utils';\n\ninterface DateFilterProps {\n controller: HeadlessDateFilter;\n}\n\nfunction formattedDateValue(date?: string | Date) {\n if (!date) {\n return '';\n }\n return parseDate(date).format('YYYY-MM-DD');\n}\n\nexport const DateFilter: FunctionComponent<DateFilterProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n let startRef: HTMLInputElement;\n let endRef: HTMLInputElement;\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const {range} = state;\n\n return (\n <Fragment>\n <input\n key=\"start\"\n type=\"Date\"\n ref={(ref) => (startRef = ref!)}\n defaultValue={formattedDateValue(range?.start)}\n placeholder=\"Start\"\n />\n <input\n key=\"end\"\n type=\"Date\"\n ref={(ref) => (endRef = ref!)}\n defaultValue={formattedDateValue(range?.end)}\n placeholder=\"End\"\n />\n <button\n key=\"apply\"\n onClick={() => {\n if (!startRef.validity.valid || !endRef.validity.valid) {\n return;\n }\n\n controller.setRange(\n buildDateRange({\n start: startRef.valueAsDate!,\n end: endRef.valueAsDate!,\n })\n );\n }}\n >\n Apply\n </button>\n </Fragment>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildDateFilter(engine, {\n * options: {\n * field: 'date',\n * },\n * });\n *\n * <DateFilter controller={controller} />;\n * ```\n */\n",
"fileName": "date-filter.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildPager",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `Pager` properties.",
"type": "PagerProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "PagerInitialState",
"desc": "The initial state that should be applied to the `Pager` controller.",
"members": [
{
"kind": "primitive",
"name": "page",
"isOptional": true,
"type": "number",
"desc": "The initial page number."
}
],
"isTypeExtracted": false,
"typeName": "PagerInitialState"
},
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "PagerOptions",
"desc": "The options for the `Pager` controller.",
"members": [
{
"kind": "primitive",
"name": "numberOfPages",
"isOptional": true,
"type": "number",
"desc": "The number of pages to display in the pager.",
"defaultValue": "`5`"
}
],
"isTypeExtracted": false,
"typeName": "PagerOptions"
}
],
"isTypeExtracted": false,
"typeName": "PagerProps"
}
],
"returnType": {
"kind": "object",
"name": "Pager",
"isOptional": false,
"type": "Pager",
"desc": "The `Pager` controller allows to navigate through the different result pages.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "PagerState",
"desc": "The state of the Pager controller.",
"members": [
{
"kind": "primitive",
"name": "currentPage",
"isOptional": false,
"type": "number",
"desc": "The active page number."
},
{
"kind": "primitive",
"name": "currentPages",
"isOptional": false,
"type": "number[]",
"desc": "The page range to display."
},
{
"kind": "primitive",
"name": "hasNextPage",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` when a next page is available, and `false` otherwise."
},
{
"kind": "primitive",
"name": "hasPreviousPage",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` when a previous page is available, and `false` otherwise."
},
{
"kind": "primitive",
"name": "maxPage",
"isOptional": false,
"type": "number",
"desc": "The maximum available page."
}
],
"isTypeExtracted": false,
"typeName": "PagerState"
},
{
"kind": "function",
"name": "isCurrentPage",
"params": [
{
"kind": "primitive",
"name": "page",
"isOptional": false,
"desc": "The page number to check.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the passed page is selected."
},
"desc": "Returns `true` when the current page is equal to the passed page, and `false` otherwise."
},
{
"kind": "function",
"name": "nextPage",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the results to those on the next page."
},
{
"kind": "function",
"name": "previousPage",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the results to those on the previous page."
},
{
"kind": "function",
"name": "selectPage",
"params": [
{
"kind": "primitive",
"name": "page",
"isOptional": false,
"desc": "The page number.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the results to those on the passed page."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "Pager"
},
"desc": "Creates a `Pager` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/pager/pager.class.tsx",
"code": "import {\n buildPager,\n Pager as HeadlessPager,\n PagerState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class Pager extends Component<{}, PagerState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessPager;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildPager(this.context.engine!, {\n options: {numberOfPages: 6},\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <nav>\n <button\n disabled={!this.state.hasPreviousPage}\n onClick={() => this.controller.previousPage()}\n >\n {'<'}\n </button>\n {this.state.currentPages.map((page) => (\n <button\n key={page}\n disabled={this.controller.isCurrentPage(page)}\n onClick={() => this.controller.selectPage(page)}\n >\n {page}\n </button>\n ))}\n <button\n disabled={!this.state.hasNextPage}\n onClick={() => this.controller.nextPage()}\n >\n {'>'}\n </button>\n </nav>\n );\n }\n}\n",
"fileName": "pager.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/pager/pager.fn.tsx",
"code": "import {Pager as HeadlessPager} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface PagerProps {\n controller: HeadlessPager;\n}\n\nexport const Pager: FunctionComponent<PagerProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <nav>\n <button\n disabled={!state.hasPreviousPage}\n onClick={() => controller.previousPage()}\n >\n {'<'}\n </button>\n {state.currentPages.map((page) => (\n <button\n key={page}\n disabled={controller.isCurrentPage(page)}\n onClick={() => controller.selectPage(page)}\n >\n {page}\n </button>\n ))}\n <button\n disabled={!state.hasNextPage}\n onClick={() => controller.nextPage()}\n >\n {'>'}\n </button>\n </nav>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const options: PagerOptions = {numberOfPages: 6};\n * const controller = buildPager(engine, {options});\n *\n * <Pager controller={controller} />;\n * ```\n */\n",
"fileName": "pager.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildContext",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "Context",
"isOptional": false,
"type": "Context",
"desc": "The `Context` controller injects [custom contextual information](https://docs.coveo.com/en/399/) into the search requests and usage analytics search events sent from a search interface.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "ContextState",
"desc": "The state of the `Context` controller.",
"members": [
{
"kind": "primitive",
"name": "values",
"isOptional": false,
"type": "Record<string, ContextValue>",
"desc": "An object holding the context keys and their values."
}
],
"isTypeExtracted": false,
"typeName": "ContextState"
},
{
"kind": "function",
"name": "add",
"params": [
{
"kind": "primitive",
"name": "contextKey",
"isOptional": false,
"desc": "The context key to add.",
"type": "string"
},
{
"kind": "primitive-with-type-alias",
"name": "contextValue",
"isOptional": false,
"desc": "The context value to add.",
"type": "string | string[]"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Adds (or, if one is already present, replaces) a new context key-value pair."
},
{
"kind": "function",
"name": "remove",
"params": [
{
"kind": "primitive",
"name": "key",
"isOptional": false,
"desc": "The context key to remove.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Removes a context key from the query."
},
{
"kind": "function",
"name": "set",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "context",
"isOptional": false,
"desc": "The context to set for the query.",
"type": "Record<string, ContextValue>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sets the context for the query. This replaces any existing context with the new one."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "Context"
},
"desc": "Creates a `Context` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [],
"fn": [
{
"path": "packages/samples/headless-react/src/components/context/context.ts",
"code": "import {buildContext} from '@coveo/headless';\nimport {useContext} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport function Context() {\n const {engine} = useContext(AppContext);\n const ctx = buildContext(engine!);\n\n ctx.set({ageGroup: '30-45', interests: ['sports', 'camping', 'electronics']});\n\n return null;\n}\n",
"fileName": "context.ts"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildDictionaryFieldContext",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "DictionaryFieldContext",
"isOptional": false,
"type": "DictionaryFieldContext",
"desc": "The `DictionaryFieldContext` controller allows specifying which [dictionary field](https://docs.coveo.com/en/2036/index-content/about-fields#dictionary-fields) keys to retrieve.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "DictionaryFieldContextState",
"desc": "The state of the `DictionaryFieldContext` controller.",
"members": [
{
"kind": "primitive",
"name": "values",
"isOptional": false,
"type": "Record<string, string>",
"desc": "An object holding the dictionary field context fields and keys to retrieve values for."
}
],
"isTypeExtracted": false,
"typeName": "DictionaryFieldContextState"
},
{
"kind": "function",
"name": "add",
"params": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"desc": "The dictionary field name.",
"type": "string"
},
{
"kind": "primitive",
"name": "key",
"isOptional": false,
"desc": "The dictionary field key for which to retrieve a value.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Adds (or, if one is already present, replaces) a new dictionary field context key-value pair."
},
{
"kind": "function",
"name": "remove",
"params": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"desc": "The field to remove.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Removes a dictionary field from the query."
},
{
"kind": "function",
"name": "set",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "context",
"isOptional": false,
"desc": "The dictionary field context to set for the query.",
"type": "Record<string, string>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sets the dictionary field context for the query. This replaces any existing context with the new one."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "DictionaryFieldContext"
},
"desc": "Creates a `DictionaryFieldContext` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [],
"fn": [
{
"path": "packages/samples/headless-react/src/components/dictionary-field-context/dictionary-field-context.fn.ts",
"code": "import {buildDictionaryFieldContext} from '@coveo/headless';\nimport {useContext} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport function DictionaryFieldContext() {\n const {engine} = useContext(AppContext);\n const ctx = buildDictionaryFieldContext(engine!);\n\n ctx.set({price_currency: 'fr', price_discounted: 'fr'});\n\n return null;\n}\n",
"fileName": "dictionary-field-context.fn.ts"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildCategoryFacet",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `CategoryFacet` properties.",
"type": "CategoryFacetProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "CategoryFacetOptions",
"desc": "The options for the `CategoryFacet` controller.",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "basePath",
"isOptional": true,
"type": "string[]",
"desc": "The base path shared by all values for the facet.",
"defaultValue": "`[]`"
},
{
"kind": "primitive",
"name": "delimitingCharacter",
"isOptional": true,
"type": "string",
"desc": "The character that specifies the hierarchical dependency.",
"defaultValue": "`;`"
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a random unique ID is generated."
},
{
"kind": "object",
"name": "facetSearch",
"isOptional": true,
"type": "CategoryFacetSearchOptions",
"desc": "Facet search options.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetSearchOptions"
},
{
"kind": "primitive",
"name": "filterByBasePath",
"isOptional": true,
"type": "boolean",
"desc": "Whether to filter the results using `basePath`.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude the parents of folded results when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all of the potential facet values.\n\n**Note:** A high `injectionDepth` may reduce facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. This option also determines the number of additional values to request each time this facet is expanded, as well as the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`5`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'alphanumeric' | 'occurrences'",
"desc": "The criterion to use for sorting returned facet values.",
"defaultValue": "`occurrences`"
}
],
"isTypeExtracted": false,
"typeName": "CategoryFacetOptions"
}
],
"isTypeExtracted": false,
"typeName": "CategoryFacetProps"
}
],
"returnType": {
"kind": "object",
"name": "CategoryFacet",
"isOptional": false,
"type": "CategoryFacet",
"desc": "",
"members": [
{
"kind": "object",
"name": "facetSearch",
"isOptional": false,
"type": "CategoryFacetSearch",
"desc": "Provides methods to search the facet's values.",
"members": [
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Resets the query and empties the values."
},
{
"kind": "function",
"name": "search",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Performs a facet search."
},
{
"kind": "function",
"name": "select",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The search result to select.",
"type": "CategoryFacetSearchResult",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetSearchResult"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects a facet search result."
},
{
"kind": "function",
"name": "showMoreResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Shows more facet search results."
},
{
"kind": "function",
"name": "updateCaptions",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "captions",
"isOptional": false,
"desc": "A dictionary that maps index field values to facet value display names.",
"type": "Record<string, string>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the facet value captions."
},
{
"kind": "function",
"name": "updateText",
"params": [
{
"kind": "primitive",
"name": "text",
"isOptional": false,
"desc": "The facet search query.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the facet search query."
}
],
"isTypeExtracted": false,
"typeName": "CategoryFacetSearch"
},
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "CategoryFacetState",
"desc": "The state of the `Facet` controller.",
"members": [
{
"kind": "object",
"name": "facetSearch",
"isOptional": false,
"type": "CategoryFacetSearchState",
"desc": "The state of the facet's searchbox.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetSearchState"
},
{
"kind": "primitive",
"name": "canShowLessValues",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if fewer values can be displayed, and `false` if not."
},
{
"kind": "primitive",
"name": "canShowMoreValues",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if there are more values to display and, `false` if not."
},
{
"kind": "primitive",
"name": "enabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether the facet is enabled and its values are used to filter search results."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet ID."
},
{
"kind": "primitive",
"name": "hasActiveValues",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if there's at least one non-idle value, and `false` if not."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if a search is in progress, and `false` if not."
},
{
"kind": "object",
"name": "parents",
"isOptional": false,
"type": "CategoryFacetValue[]",
"desc": "The facet's parent values.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": false,
"type": "'alphanumeric' | 'occurrences'",
"desc": "The facet's active `sortCriterion`."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "CategoryFacetValue[]",
"desc": "The facet's values.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
}
],
"isTypeExtracted": false,
"typeName": "CategoryFacetState"
},
{
"kind": "function",
"name": "deselectAll",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects all facet values."
},
{
"kind": "function",
"name": "disable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disables the facet. I.e., prevents it from filtering results."
},
{
"kind": "function",
"name": "enable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Enables the facet. I.e., undoes the effects of `disable`."
},
{
"kind": "function",
"name": "isSortedBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion to compare.",
"type": "'alphanumeric' | 'occurrences'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the facet values are sorted according to the specified criterion."
},
"desc": "Checks whether the facet values are sorted according to the specified criterion."
},
{
"kind": "function",
"name": "showLessValues",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sets the number of values displayed in the facet to the originally configured value."
},
{
"kind": "function",
"name": "showMoreValues",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Increases the number of values displayed in the facet to the next multiple of the originally configured value."
},
{
"kind": "function",
"name": "sortBy",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The criterion by which to sort values.",
"type": "'alphanumeric' | 'occurrences'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Sorts the facet values according to the specified criterion."
},
{
"kind": "function",
"name": "toggleSelect",
"params": [
{
"kind": "object",
"name": "selection",
"isOptional": false,
"desc": "The facet value to toggle.",
"type": "CategoryFacetValue",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified facet value."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "CategoryFacet"
},
"desc": "Creates a `CategoryFacet` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "CategoryFacetSearchOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "captions",
"isOptional": true,
"type": "Record<string, string>",
"desc": "A dictionary that maps index field values to facet value display names."
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The maximum number of values to fetch.",
"defaultValue": "`10`"
},
{
"kind": "primitive",
"name": "query",
"isOptional": true,
"type": "string",
"desc": "The string to match."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "CategoryFacetSearchResult",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "count",
"isOptional": false,
"type": "number",
"desc": "An estimate of the number of result items that match both the current query and the filter expression which would be generated if the facet value were selected."
},
{
"kind": "primitive",
"name": "displayValue",
"isOptional": false,
"type": "string",
"desc": "The custom facet value display name, as specified in the `captions` argument of the facet request."
},
{
"kind": "primitive",
"name": "path",
"isOptional": false,
"type": "string[]",
"desc": "The hierarchical path to the facet value."
},
{
"kind": "primitive",
"name": "rawValue",
"isOptional": false,
"type": "string",
"desc": "The original facet value, as retrieved from the field in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "CategoryFacetSearchState",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if the facet search is in progress, and `false` if not."
},
{
"kind": "primitive",
"name": "moreValuesAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more values are available."
},
{
"kind": "primitive",
"name": "query",
"isOptional": false,
"type": "string",
"desc": "The current query in the facet search box."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "CategoryFacetSearchResult[]",
"desc": "The facet search results.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetSearchResult"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "CategoryFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "children",
"isOptional": false,
"type": "CategoryFacetValue[]",
"desc": "The children of this facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
},
{
"kind": "primitive",
"name": "isLeafValue",
"isOptional": false,
"type": "boolean",
"desc": "When the hierarchical value has no children, this property is true."
},
{
"kind": "primitive",
"name": "moreValuesAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more facet values are available."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that match the facet value."
},
{
"kind": "primitive",
"name": "path",
"isOptional": false,
"type": "string[]",
"desc": "The hierarchical path to the facet value."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "Whether a facet value is filtering results (`selected`) or not (`idle`)."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The facet value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/category-facet/category-facet.class.tsx",
"code": "import {\n buildCategoryFacet,\n CategoryFacet as HeadlessCategoryFacet,\n CategoryFacetOptions,\n CategoryFacetState,\n CategoryFacetValue,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {CategoryFacetSearch} from './category-facet-search';\n\ninterface CategoryFacetProps extends CategoryFacetOptions {\n facetId: string;\n}\n\nexport class CategoryFacet extends Component<\n CategoryFacetProps,\n CategoryFacetState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessCategoryFacet;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildCategoryFacet(this.context.engine!, {\n options: this.props,\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private getUniqueKeyForValue(value: CategoryFacetValue) {\n return value.path.join('>');\n }\n\n private renderSearch() {\n return (\n <CategoryFacetSearch\n controller={this.controller.facetSearch}\n searchState={this.state.facetSearch}\n />\n );\n }\n\n private renderClearButton() {\n return (\n <button onClick={() => this.controller.deselectAll()}>\n All categories\n </button>\n );\n }\n\n private renderParents() {\n return (\n this.state.hasActiveValues && (\n <div>\n Filtering by: {this.renderClearButton()}\n {this.state.parents.map((parentValue, i) => {\n const isSelectedValue = i === this.state.parents.length - 1;\n\n return (\n <span key={this.getUniqueKeyForValue(parentValue)}>\n &rarr;\n {!isSelectedValue ? (\n <button\n onClick={() => this.controller.toggleSelect(parentValue)}\n >\n {parentValue.value}\n </button>\n ) : (\n <span>{parentValue.value}</span>\n )}\n </span>\n );\n })}\n </div>\n )\n );\n }\n\n private renderActiveValues() {\n return (\n <ul>\n {this.state.values.map((value) => (\n <li key={this.getUniqueKeyForValue(value)}>\n <button onClick={() => this.controller.toggleSelect(value)}>\n {value.value} ({value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </button>\n </li>\n ))}\n </ul>\n );\n }\n\n private renderCanShowMoreLess() {\n return (\n <div>\n {this.state.canShowLessValues && (\n <button onClick={() => this.controller.showLessValues()}>\n Show less\n </button>\n )}\n {this.state.canShowMoreValues && (\n <button onClick={() => this.controller.showMoreValues()}>\n Show more\n </button>\n )}\n </div>\n );\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n if (!this.state.hasActiveValues && this.state.values.length === 0) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n <li>{this.renderSearch()}</li>\n <li>\n {this.renderParents()}\n {this.renderActiveValues()}\n {this.renderCanShowMoreLess()}\n </li>\n </ul>\n );\n }\n}\n",
"fileName": "category-facet.class.tsx"
},
{
"path": "packages/samples/headless-react/src/components/category-facet/category-facet-search.tsx",
"code": "import {\n CategoryFacetSearch as HeadlessCategoryFacetSearch,\n CategoryFacetSearchState,\n} from '@coveo/headless';\nimport {FunctionComponent} from 'react';\n\nexport interface CategoryFacetSearchProps {\n controller: HeadlessCategoryFacetSearch;\n searchState: CategoryFacetSearchState;\n}\n\nexport const CategoryFacetSearch: FunctionComponent<\n CategoryFacetSearchProps\n> = (props) => {\n const onInput = (text: string) => {\n props.controller.updateText(text);\n props.controller.search();\n };\n\n return (\n <div>\n <input onInput={(e) => onInput(e.currentTarget.value)} />\n <ul>\n {props.searchState.values.map((value) => (\n <li key={[...value.path, value.rawValue].join('>')}>\n <button onClick={() => props.controller.select(value)}>\n {value.displayValue} ({value.count} results)\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n",
"fileName": "category-facet-search.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/category-facet/category-facet.fn.tsx",
"code": "import {\n CategoryFacet as HeadlessCategoryFacet,\n CategoryFacetValue,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\nimport {CategoryFacetSearch} from './category-facet-search';\n\ninterface CategoryFacetProps {\n controller: HeadlessCategoryFacet;\n}\n\nexport const CategoryFacet: FunctionComponent<CategoryFacetProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n function getUniqueKeyForValue(value: CategoryFacetValue) {\n return value.path.join('>');\n }\n\n function renderSearch() {\n return (\n <CategoryFacetSearch\n controller={controller.facetSearch}\n searchState={state.facetSearch}\n />\n );\n }\n\n function renderClearButton() {\n return (\n <button onClick={() => controller.deselectAll()}>All categories</button>\n );\n }\n\n function renderParents() {\n return (\n state.hasActiveValues && (\n <div>\n Filtering by: {renderClearButton()}\n {state.parents.map((parentValue, i) => {\n const isSelectedValue = i === state.parents.length - 1;\n\n return (\n <span key={getUniqueKeyForValue(parentValue)}>\n &rarr;\n {!isSelectedValue ? (\n <button onClick={() => controller.toggleSelect(parentValue)}>\n {parentValue.value}\n </button>\n ) : (\n <span>{parentValue.value}</span>\n )}\n </span>\n );\n })}\n </div>\n )\n );\n }\n\n function renderActiveValues() {\n return (\n <ul>\n {state.values.map((value) => (\n <li key={getUniqueKeyForValue(value)}>\n <button onClick={() => controller.toggleSelect(value)}>\n {value.value} ({value.numberOfResults}{' '}\n {value.numberOfResults === 1 ? 'result' : 'results'})\n </button>\n </li>\n ))}\n </ul>\n );\n }\n\n function renderCanShowMoreLess() {\n return (\n <div>\n {state.canShowLessValues && (\n <button onClick={() => controller.showLessValues()}>Show less</button>\n )}\n {state.canShowMoreValues && (\n <button onClick={() => controller.showMoreValues()}>Show more</button>\n )}\n </div>\n );\n }\n\n if (!state.hasActiveValues && state.values.length === 0) {\n return <div>No facet values</div>;\n }\n\n return (\n <ul>\n <li>{renderSearch()}</li>\n <li>\n {renderParents()}\n {renderActiveValues()}\n {renderCanShowMoreLess()}\n </li>\n </ul>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const options: CategoryFacetOptions = {field: 'geographicalhierarchy'};\n * const controller = buildCategoryFacet(engine, {options});\n *\n * <CategoryFacet controller={controller} />;\n * ```\n */\n",
"fileName": "category-facet.fn.tsx"
},
{
"path": "packages/samples/headless-react/src/components/category-facet/category-facet-search.tsx",
"code": "import {\n CategoryFacetSearch as HeadlessCategoryFacetSearch,\n CategoryFacetSearchState,\n} from '@coveo/headless';\nimport {FunctionComponent} from 'react';\n\nexport interface CategoryFacetSearchProps {\n controller: HeadlessCategoryFacetSearch;\n searchState: CategoryFacetSearchState;\n}\n\nexport const CategoryFacetSearch: FunctionComponent<\n CategoryFacetSearchProps\n> = (props) => {\n const onInput = (text: string) => {\n props.controller.updateText(text);\n props.controller.search();\n };\n\n return (\n <div>\n <input onInput={(e) => onInput(e.currentTarget.value)} />\n <ul>\n {props.searchState.values.map((value) => (\n <li key={[...value.path, value.rawValue].join('>')}>\n <button onClick={() => props.controller.select(value)}>\n {value.displayValue} ({value.count} results)\n </button>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n",
"fileName": "category-facet-search.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildDidYouMean",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "DidYouMean",
"isOptional": false,
"type": "DidYouMean",
"desc": "",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "DidYouMeanState",
"desc": "The state of the `DidYouMean` controller.",
"members": [
{
"kind": "primitive",
"name": "hasQueryCorrection",
"isOptional": false,
"type": "boolean",
"desc": "Specifies if there is a query correction to apply."
},
{
"kind": "primitive",
"name": "originalQuery",
"isOptional": false,
"type": "string",
"desc": "The original query that was performed, without any automatic correction applied."
},
{
"kind": "object",
"name": "queryCorrection",
"isOptional": false,
"type": "QueryCorrection",
"desc": "The query correction that is currently applied by the \"did you mean\" module.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryCorrection"
},
{
"kind": "primitive",
"name": "wasAutomaticallyCorrected",
"isOptional": false,
"type": "boolean",
"desc": "Specifies if the query was automatically corrected by Headless.\n\nThis happens when there is no result returned by the API for a particular mispelling."
},
{
"kind": "primitive",
"name": "wasCorrectedTo",
"isOptional": false,
"type": "string",
"desc": "The correction that was applied to the query. If no correction was applied, will default to an empty string."
}
],
"isTypeExtracted": false,
"typeName": "DidYouMeanState"
},
{
"kind": "function",
"name": "applyCorrection",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Apply query correction using the query correction, if any, currently present in the state."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "DidYouMean"
},
"desc": "The DidYouMean controller is responsible for handling query corrections. When a query returns no result but finds a possible query correction, the controller either suggests the correction or automatically triggers a new query with the suggested term."
},
"extractedTypes": [
{
"kind": "object",
"name": "QueryCorrection",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "correctedQuery",
"isOptional": false,
"type": "string",
"desc": "The query once corrected"
},
{
"kind": "object",
"name": "wordCorrections",
"isOptional": false,
"type": "WordCorrection[]",
"desc": "Array of correction for each word in the query",
"members": [],
"isTypeExtracted": true,
"typeName": "WordCorrection"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "WordCorrection",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "correctedWord",
"isOptional": false,
"type": "string",
"desc": "The new corrected word"
},
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "Length of the correction"
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "Offset, from the beginning of the query"
},
{
"kind": "primitive",
"name": "originalWord",
"isOptional": false,
"type": "string",
"desc": "The original word that was corrected"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/did-you-mean/did-you-mean.class.tsx",
"code": "import {\n buildDidYouMean,\n DidYouMean as HeadlessDidYouMean,\n DidYouMeanState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class DidYouMean extends Component<{}, DidYouMeanState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessDidYouMean;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildDidYouMean(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state?.hasQueryCorrection) {\n return null;\n }\n\n if (this.state.wasAutomaticallyCorrected) {\n return (\n <div>\n <p>\n No results for{' '}\n <b>{this.state.queryCorrection.wordCorrections[0].originalWord}</b>\n </p>\n <p>\n Query was automatically corrected to{' '}\n <b>{this.state.wasCorrectedTo}</b>\n </p>\n </div>\n );\n }\n\n return (\n <button onClick={() => this.controller.applyCorrection()}>\n Did you mean: {this.state.queryCorrection.correctedQuery} ?\n </button>\n );\n }\n}\n",
"fileName": "did-you-mean.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/did-you-mean/did-you-mean.fn.tsx",
"code": "import {DidYouMean as HeadlessDidYouMean} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface DidYouMeanProps {\n controller: HeadlessDidYouMean;\n}\n\nexport const DidYouMean: FunctionComponent<DidYouMeanProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n if (!state.hasQueryCorrection) {\n return null;\n }\n\n if (state.wasAutomaticallyCorrected) {\n return (\n <div>\n <p>\n No results for{' '}\n <b>{state.queryCorrection.wordCorrections[0].originalWord}</b>\n </p>\n <p>\n Query was automatically corrected to <b>{state.wasCorrectedTo}</b>\n </p>\n </div>\n );\n }\n\n return (\n <button onClick={() => controller.applyCorrection()}>\n Did you mean: {state.queryCorrection.correctedQuery} ?\n </button>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildDidYouMean(engine);\n *\n * <DidYouMean controller={controller} />;\n * ```\n */\n",
"fileName": "did-you-mean.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildFacetManager",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "FacetManager",
"isOptional": false,
"type": "FacetManager",
"desc": "The `FacetManager` controller helps reorder facets to match the most recent search response.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "FacetManagerState",
"desc": "The state of the `CoreFacetManager` controller.",
"members": [
{
"kind": "primitive",
"name": "facetIds",
"isOptional": false,
"type": "string[]",
"desc": "The facet ids sorted in the same order as the latest response."
}
],
"isTypeExtracted": false,
"typeName": "FacetManagerState"
},
{
"kind": "function",
"name": "sort",
"params": [
{
"kind": "object",
"name": "facets",
"isOptional": false,
"desc": "An array of facet payloads to sort.",
"type": "FacetManagerPayload<T>[]",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetManagerPayload<T>"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "FacetManagerPayload<T>[]",
"isOptional": false,
"desc": "A sorted array.",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetManagerPayload<T>"
},
"desc": "Sorts the facets to match the order in the most recent search response."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "FacetManager"
},
"desc": "Creates a `FacetManager` instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "FacetManagerPayload<T>",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "A unique string identifying a facet."
},
{
"kind": "primitive",
"name": "payload",
"isOptional": false,
"type": "T",
"desc": "The payload to associate with the facetId. This can be anything e.g., a DOM element, JSX, a string."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/facet-manager/facet-manager.class.tsx",
"code": "import {\n buildFacetManager,\n FacetManager as HeadlessFacetManager,\n FacetManagerPayload,\n FacetManagerState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Children, Component, ContextType, ReactElement} from 'react';\nimport {AppContext} from '../../context/engine';\n\ntype FacetManagerChild = ReactElement<{facetId: string}>;\nexport class FacetManager extends Component<\n {\n children?: FacetManagerChild | FacetManagerChild[];\n },\n FacetManagerState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessFacetManager;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildFacetManager(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private createPayload(\n facets: FacetManagerChild[]\n ): FacetManagerPayload<FacetManagerChild>[] {\n return facets.map((facet) => ({\n facetId: facet.props.facetId,\n payload: facet,\n }));\n }\n\n render() {\n if (!this.state) {\n return <>{this.props.children}</>;\n }\n\n const childFacets = Children.toArray(\n this.props.children\n ) as FacetManagerChild[];\n const payload = this.createPayload(childFacets);\n const sortedFacets = this.controller.sort(payload).map((p) => p.payload);\n\n return <>{sortedFacets}</>;\n }\n}\n",
"fileName": "facet-manager.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/facet-manager/facet-manager.fn.tsx",
"code": "import {\n FacetManager as HeadlessFacetManager,\n Facet as HeadlessFacet,\n FacetManagerPayload,\n} from '@coveo/headless';\nimport {\n useEffect,\n useState,\n FunctionComponent,\n ReactElement,\n Children,\n} from 'react';\n\ntype FacetManagerChild = ReactElement<{controller: HeadlessFacet}>;\n\ninterface FacetManagerProps {\n controller: HeadlessFacetManager;\n children: FacetManagerChild | FacetManagerChild[];\n}\n\nexport const FacetManager: FunctionComponent<FacetManagerProps> = (props) => {\n const {controller} = props;\n const [, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n function createPayload(\n facets: FacetManagerChild[]\n ): FacetManagerPayload<FacetManagerChild>[] {\n return facets.map((facet) => ({\n facetId: facet.props.controller.state.facetId,\n payload: facet,\n }));\n }\n\n const childFacets = Children.toArray(props.children) as FacetManagerChild[];\n const payload = createPayload(childFacets);\n const sortedFacets = controller.sort(payload).map((p) => p.payload);\n\n return <div>{sortedFacets}</div>;\n};\n\n// usage\n\n/**\n * ```tsx\n * const facetManager = buildFacetManager(engine);\n * const facetA = buildFacet(engine, {options: {field: 'abc'}});\n * const facetB = buildFacet(engine, {options: {field: 'def'}});\n *\n * <FacetManager controller={facetManager}>\n * <Facet controller={facetA} />\n * <Facet controller={facetB} />\n * </FacetManager>\n * ```\n */\n",
"fileName": "facet-manager.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildQueryError",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "QueryError",
"isOptional": false,
"type": "QueryError",
"desc": "The `QueryError` controller allows to retrieve information about the current error returned by the search API, if any.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "QueryErrorState",
"desc": "The state of the `QueryError` controller.",
"members": [
{
"kind": "primitive",
"name": "error",
"isOptional": false,
"type": "ErrorPayload | null",
"desc": "The current error for the last executed query, or `null` if none is present."
},
{
"kind": "primitive",
"name": "hasError",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is an error for the last executed query and `false` otherwise."
}
],
"isTypeExtracted": false,
"typeName": "QueryErrorState"
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "QueryError"
},
"desc": "Creates a `QueryError` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/query-error/query-error.class.tsx",
"code": "import {\n buildQueryError,\n QueryError as HeadlessQueryError,\n QueryErrorState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class QueryError extends Component<{}, QueryErrorState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessQueryError;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildQueryError(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state?.hasError) {\n return null;\n }\n\n return (\n <div>\n <div>Oops {this.state.error!.message}</div>\n <code>{JSON.stringify(this.state.error)}</code>\n </div>\n );\n }\n}\n",
"fileName": "query-error.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/query-error/query-error.fn.tsx",
"code": "import {QueryError as HeadlessQueryError} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface QueryErrorProps {\n controller: HeadlessQueryError;\n}\n\nexport const QueryError: FunctionComponent<QueryErrorProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n if (!state.hasError) {\n return null;\n }\n\n return (\n <div>\n <div>Oops {state.error!.message}</div>\n <code>{JSON.stringify(state.error)}</code>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```ts\n * const controller = buildQueryError(engine);\n *\n * <QueryError controller={controller} />;\n * ```\n */\n",
"fileName": "query-error.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildBreadcrumbManager",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "BreadcrumbManager",
"isOptional": false,
"type": "BreadcrumbManager",
"desc": "The `BreadcrumbManager` headless controller manages a summary of the currently active facet filters.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "BreadcrumbManagerState",
"desc": "The state of the `BreadcrumbManager` controller.",
"members": [
{
"kind": "object",
"name": "categoryFacetBreadcrumbs",
"isOptional": false,
"type": "CategoryFacetBreadcrumb[]",
"desc": "The list of category facet breadcrumbs.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetBreadcrumb"
},
{
"kind": "primitive-with-type-alias",
"name": "dateFacetBreadcrumbs",
"isOptional": false,
"type": "Breadcrumb<DateFacetValue>",
"desc": "The list of date facet breadcrumbs."
},
{
"kind": "primitive-with-type-alias",
"name": "facetBreadcrumbs",
"isOptional": false,
"type": "Breadcrumb<FacetValue>",
"desc": "The list of specific facet breadcrumbs."
},
{
"kind": "primitive",
"name": "hasBreadcrumbs",
"isOptional": false,
"type": "boolean",
"desc": "Returns `true` if there are any available breadcrumbs (i.e., if there are any active facet values), and `false` if not."
},
{
"kind": "primitive-with-type-alias",
"name": "numericFacetBreadcrumbs",
"isOptional": false,
"type": "Breadcrumb<NumericFacetValue>",
"desc": "The list of numeric facet breadcrumbs."
},
{
"kind": "object",
"name": "staticFilterBreadcrumbs",
"isOptional": false,
"type": "StaticFilterBreadcrumb[]",
"desc": "The list of static filter breadcrumbs.",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterBreadcrumb"
}
],
"isTypeExtracted": false,
"typeName": "BreadcrumbManagerState"
},
{
"kind": "function",
"name": "deselectAll",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects all facet values."
},
{
"kind": "function",
"name": "deselectBreadcrumb",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The breadcrumb value to deselect.",
"type": "DeselectableValue",
"members": [],
"isTypeExtracted": true,
"typeName": "DeselectableValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects a breadcrumb value."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "BreadcrumbManager"
},
"desc": "Creates a `BreadcrumbManager` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "CategoryFacetBreadcrumb",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The ID of the underlying facet."
},
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field on which the underlying facet is configured."
},
{
"kind": "object",
"name": "path",
"isOptional": false,
"type": "CategoryFacetValue[]",
"desc": "The complete path to the underlying facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
},
{
"kind": "function",
"name": "deselect",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "A function that when called dispatches actions to deselect a breadcrumb value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "CategoryFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "children",
"isOptional": false,
"type": "CategoryFacetValue[]",
"desc": "The children of this facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
},
{
"kind": "primitive",
"name": "isLeafValue",
"isOptional": false,
"type": "boolean",
"desc": "When the hierarchical value has no children, this property is true."
},
{
"kind": "primitive",
"name": "moreValuesAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more facet values are available."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that match the facet value."
},
{
"kind": "primitive",
"name": "path",
"isOptional": false,
"type": "string[]",
"desc": "The hierarchical path to the facet value."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "Whether a facet value is filtering results (`selected`) or not (`idle`)."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The facet value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "StaticFilterBreadcrumb",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The ID of the underlying static filter."
},
{
"kind": "primitive-with-type-alias",
"name": "values",
"isOptional": false,
"type": "StaticFilterBreadcrumbValue[]",
"desc": "The list of static filter values currently selected."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DeselectableValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "function",
"name": "deselect",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "A function that when called dispatches actions to deselect a breadcrumb value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/breadcrumb-manager/breadcrumb-manager.class.tsx",
"code": "import {\n buildBreadcrumbManager,\n BreadcrumbManager as HeadlessBreadcrumbManager,\n BreadcrumbManagerState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class BreadcrumbManager extends Component<{}, BreadcrumbManagerState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessBreadcrumbManager;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildBreadcrumbManager(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state?.hasBreadcrumbs) {\n return null;\n }\n\n return (\n <ul>\n {this.state.facetBreadcrumbs.map((facet) => (\n <li key={facet.facetId}>\n {facet.field}:{' '}\n {facet.values.map((breadcrumb) => (\n <button\n key={breadcrumb.value.value}\n onClick={() => breadcrumb.deselect()}\n >\n {breadcrumb.value.value}\n </button>\n ))}\n </li>\n ))}\n </ul>\n );\n }\n}\n",
"fileName": "breadcrumb-manager.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/breadcrumb-manager/breadcrumb-manager.fn.tsx",
"code": "import {BreadcrumbManager as HeadlessBreadcrumbManager} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface BreadcrumbManagerProps {\n controller: HeadlessBreadcrumbManager;\n}\n\nexport const BreadcrumbManager: FunctionComponent<BreadcrumbManagerProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n if (!state?.hasBreadcrumbs) {\n return null;\n }\n\n return (\n <ul>\n {state.facetBreadcrumbs.map((facet) => (\n <li key={facet.facetId}>\n {facet.field}:{' '}\n {facet.values.map((breadcrumb) => (\n <button\n key={breadcrumb.value.value}\n onClick={() => breadcrumb.deselect()}\n >\n {breadcrumb.value.value}\n </button>\n ))}\n </li>\n ))}\n </ul>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildBreadcrumbManager(engine);\n *\n * <BreadcrumbManager controller={controller} />;\n * ```\n */\n",
"fileName": "breadcrumb-manager.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildQuerySummary",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine instance.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "QuerySummary",
"isOptional": false,
"type": "QuerySummary",
"desc": "The `QuerySummary` headless controller offers a high-level interface for designing a common query summary UI controller.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "QuerySummaryState",
"desc": "The state relevant to the `CoreQuerySummary` controller.",
"members": [
{
"kind": "primitive",
"name": "durationInMilliseconds",
"isOptional": false,
"type": "number",
"desc": "The duration, in milliseconds, that the last query took to execute."
},
{
"kind": "primitive",
"name": "durationInSeconds",
"isOptional": false,
"type": "number",
"desc": "The duration, in seconds, that the last query took to execute."
},
{
"kind": "primitive",
"name": "firstResult",
"isOptional": false,
"type": "number",
"desc": "The 1-based index of the first search result returned for the current page."
},
{
"kind": "primitive",
"name": "hasDuration",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a query execution time is available."
},
{
"kind": "primitive",
"name": "hasQuery",
"isOptional": false,
"type": "boolean",
"desc": "Determines if non-empty query has been executed."
},
{
"kind": "primitive",
"name": "lastResult",
"isOptional": false,
"type": "number",
"desc": "The 1-based index of the last search result returned for the current page."
},
{
"kind": "primitive",
"name": "query",
"isOptional": false,
"type": "string",
"desc": "The query that was last executed (the content of the searchbox)."
},
{
"kind": "primitive",
"name": "total",
"isOptional": false,
"type": "number",
"desc": "The total count of results available."
},
{
"kind": "primitive",
"name": "firstSearchExecuted",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a first search has been executed."
},
{
"kind": "primitive",
"name": "hasError",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is an error for the last executed query and `false` otherwise."
},
{
"kind": "primitive",
"name": "hasResults",
"isOptional": false,
"type": "boolean",
"desc": "Determines if there are results available for the last executed query."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a search is in progress."
}
],
"isTypeExtracted": false,
"typeName": "QuerySummaryState"
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "QuerySummary"
},
"desc": "Creates a `QuerySummary` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/query-summary/query-summary.class.tsx",
"code": "import {\n buildQuerySummary,\n QuerySummary as HeadlessQuerySummary,\n QuerySummaryState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class QuerySummary extends Component<{}, QuerySummaryState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessQuerySummary;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildQuerySummary(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n const {\n hasResults,\n hasQuery,\n hasDuration,\n firstResult,\n lastResult,\n total,\n query,\n durationInSeconds,\n } = this.state;\n\n if (!hasResults) {\n return null;\n }\n\n const summary = [`Results ${firstResult}-${lastResult} of ${total}`];\n\n if (hasQuery) {\n summary.push(`for ${query}`);\n }\n\n if (hasDuration) {\n summary.push(`in ${durationInSeconds} seconds`);\n }\n\n return <p>{summary.join(' ')}</p>;\n }\n}\n",
"fileName": "query-summary.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/query-summary/query-summary.fn.tsx",
"code": "import {QuerySummary as HeadlessQuerySummary} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface QuerySummaryProps {\n controller: HeadlessQuerySummary;\n}\n\nexport const QuerySummary: FunctionComponent<QuerySummaryProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const {\n hasResults,\n hasQuery,\n hasDuration,\n firstResult,\n lastResult,\n total,\n query,\n durationInSeconds,\n } = state;\n\n if (!hasResults) {\n return null;\n }\n\n const summary = [`Results ${firstResult}-${lastResult} of ${total}`];\n\n if (hasQuery) {\n summary.push(`for ${query}`);\n }\n\n if (hasDuration) {\n summary.push(`in ${durationInSeconds} seconds`);\n }\n\n return <p>{summary.join(' ')}</p>;\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildQuerySummary(engine);\n *\n * <QuerySummary controller={controller} />;\n * ```\n */\n",
"fileName": "query-summary.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildResultList",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `ResultList` properties.",
"type": "ResultListProps",
"members": [
{
"kind": "primitive",
"name": "fetchMoreResultsActionCreator",
"isOptional": true,
"type": "() => AsyncThunkAction<unknown, void, any>",
"desc": "The action creator to build the `fetchMoreResults` action."
},
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "ResultListOptions",
"desc": "The options for the `ResultList` controller.",
"members": [
{
"kind": "primitive",
"name": "fieldsToInclude",
"isOptional": true,
"type": "string[]",
"desc": "A list of indexed fields to include in the objects returned by the result list. These results are included in addition to the default fields. If this is left empty only the default fields are included."
}
],
"isTypeExtracted": false,
"typeName": "ResultListOptions"
}
],
"isTypeExtracted": false,
"typeName": "ResultListProps"
}
],
"returnType": {
"kind": "object",
"name": "ResultList",
"isOptional": false,
"type": "ResultList",
"desc": "The `ResultList` headless controller offers a high-level interface for designing a common result list UI controller.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "ResultListState",
"desc": "The state of the `ResultList` controller.",
"members": [
{
"kind": "primitive",
"name": "moreResultsAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more results are available, using the same parameters as the last successful query.\n\nThis property is not compatible with the `Pager` controller."
},
{
"kind": "object",
"name": "results",
"isOptional": false,
"type": "Result[]",
"desc": "The results of the last executed search.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
},
{
"kind": "primitive",
"name": "searchResponseId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the response where the results were fetched, this value does not change when loading more results."
},
{
"kind": "primitive",
"name": "firstSearchExecuted",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a first search has been executed."
},
{
"kind": "primitive",
"name": "hasError",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is an error for the last executed query and `false` otherwise."
},
{
"kind": "primitive",
"name": "hasResults",
"isOptional": false,
"type": "boolean",
"desc": "Determines if there are results available for the last executed query."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a search is in progress."
}
],
"isTypeExtracted": false,
"typeName": "ResultListState"
},
{
"kind": "function",
"name": "fetchMoreResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Using the same parameters as the last successful query, fetch another batch of results, if available. Particularly useful for infinite scrolling, for example.\n\nThis method is not compatible with the `Pager` controller."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "ResultList"
},
"desc": "Creates a `ResultList` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/result-list/result-list.class.tsx",
"code": "import {\n buildResultList,\n ResultList as ResultListController,\n ResultListState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {Quickview} from '../quickview/quickview.class';\nimport {ResultLink} from './result-link';\n\nexport class ResultList extends Component<{}, ResultListState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: ResultListController;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildResultList(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n if (!this.state.results.length) {\n return <div>No results</div>;\n }\n\n return (\n <div>\n <ul style={{textAlign: 'left'}}>\n {this.state.results.map((result) => (\n <li key={result.uniqueId}>\n <article>\n <h3>\n {/* Make sure to log analytics when the result link is clicked. */}\n <ResultLink result={result}>{result.title}</ResultLink>\n </h3>\n <p>{result.excerpt}</p>\n <div>\n <Quickview result={result} />\n </div>\n </article>\n </li>\n ))}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "result-list.class.tsx"
},
{
"path": "packages/samples/headless-react/src/components/result-list/result-link.tsx",
"code": "import {buildInteractiveResult, Result} from '@coveo/headless';\nimport {\n FunctionComponent,\n useContext,\n useEffect,\n PropsWithChildren,\n} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {filterProtocol} from '../../utils/filter-protocol';\n\ninterface LinkProps extends PropsWithChildren {\n result: Result;\n}\n\nexport const ResultLink: FunctionComponent<LinkProps> = (props) => {\n const {engine} = useContext(AppContext);\n\n const interactiveResult = buildInteractiveResult(engine!, {\n options: {result: props.result},\n });\n\n useEffect(() => () => interactiveResult.cancelPendingSelect(), []);\n\n return (\n <a\n href={filterProtocol(props.result.clickUri)}\n onClick={() => interactiveResult.select()}\n onContextMenu={() => interactiveResult.select()}\n onMouseDown={() => interactiveResult.select()}\n onMouseUp={() => interactiveResult.select()}\n onTouchStart={() => interactiveResult.beginDelayedSelect()}\n onTouchEnd={() => interactiveResult.cancelPendingSelect()}\n >\n {props.children}\n </a>\n );\n};\n",
"fileName": "result-link.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/result-list/result-list.fn.tsx",
"code": "import {ResultList as HeadlessResultList} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\nimport {Quickview} from '../quickview/quickview.fn';\nimport {ResultLink} from './result-link';\n\ninterface ResultListProps {\n controller: HeadlessResultList;\n}\n\nexport const ResultList: FunctionComponent<ResultListProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n if (!state.results.length) {\n return <div>No results</div>;\n }\n\n return (\n <div>\n <ul style={{textAlign: 'left'}}>\n {state.results.map((result) => (\n <li key={result.uniqueId}>\n <article>\n <h3>\n {/* Make sure to log analytics when the result link is clicked. */}\n <ResultLink result={result}>{result.title}</ResultLink>\n </h3>\n <p>{result.excerpt}</p>\n <div>\n <Quickview result={result} />\n </div>\n </article>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildResultList(engine);\n *\n * <ResultList controller={controller} />;\n * ```\n */\n",
"fileName": "result-list.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildTab",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `Tab` properties.",
"type": "TabProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "TabOptions",
"desc": "The options for the `Tab` controller.",
"members": [
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "A constant query expression or filter that the Tab should add to any outgoing query.\n\n**Example:**\n\n`@objecttype==Message`"
},
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "A unique identifier for the tab. The value will be used as the originLevel2 when the tab is active."
}
],
"isTypeExtracted": false,
"typeName": "TabOptions"
},
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "TabInitialState",
"desc": "The initial state that should be applied to this `Tab` controller.",
"members": [
{
"kind": "primitive",
"name": "isActive",
"isOptional": false,
"type": "boolean",
"desc": "Specifies if the tab is currently selected. Note that there can be only one active tab for a given headless engine."
}
],
"isTypeExtracted": false,
"typeName": "TabInitialState"
}
],
"isTypeExtracted": false,
"typeName": "TabProps"
}
],
"returnType": {
"kind": "object",
"name": "Tab",
"isOptional": false,
"type": "Tab",
"desc": "The `Tab` headless controller offers a high-level interface for designing a common tab UI controller.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "TabState",
"desc": "The state of the `Tab` controller.",
"members": [
{
"kind": "primitive",
"name": "isActive",
"isOptional": false,
"type": "boolean",
"desc": "Indicates whether the current tab is selected."
}
],
"isTypeExtracted": false,
"typeName": "TabState"
},
{
"kind": "function",
"name": "select",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Activates the tab."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "Tab"
},
"desc": "Creates a `Tab` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QueryExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "function",
"name": "addDateField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A date field expression.",
"type": "DateFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a date `field` to a `value`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "addDateRangeField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A numeric field expression.",
"type": "DateRangeFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "DateRangeFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that returns all items for which the `value` of the date `field` is within the defined range."
},
{
"kind": "function",
"name": "addExactMatch",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "An exact match expression.",
"type": "ExactMatchExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "ExactMatchExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that must appear in its entirety, at least once, for an item to be returned."
},
{
"kind": "function",
"name": "addExpression",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "The query expression instance to add.",
"type": "QueryExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds a `QueryExpression` to the current instance."
},
{
"kind": "function",
"name": "addFieldExists",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A field exists expressions.",
"type": "FieldExistsExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "FieldExistsExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression returning all items where the defined field exists."
},
{
"kind": "function",
"name": "addKeyword",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A keyword expression.",
"type": "KeywordExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "KeywordExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression containing terms to match. Terms can be in any order, and may also be expanded with stemming."
},
{
"kind": "function",
"name": "addNear",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A near expression.",
"type": "NearExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "NearExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that returns all of the items in which the specified `startTerm` appears no more than `maxKeywordsBetween` from the endTerm, for each element in `otherTerms`."
},
{
"kind": "function",
"name": "addNumericField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A numeric field expression.",
"type": "NumericFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a numeric `field` to a `value`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "addNumericRangeField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A numeric field expression.",
"type": "NumericRangeFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericRangeFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that returns all items for which the `value` of the numeric `field` is within the defined range."
},
{
"kind": "function",
"name": "addQueryExtension",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A query extension expression.",
"type": "QueryExtensionExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExtensionExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that invokes a query extension."
},
{
"kind": "function",
"name": "addStringFacetField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A string facet field expression.",
"type": "StringFacetFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "StringFacetFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a string facet `field` to a `value`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "addStringField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A string field expression.",
"type": "StringFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "StringFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a string `field` against certain `values`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "joinUsing",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"desc": "The boolean operator to join individual expressions with.",
"type": "BooleanOperator"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Allows specifying a boolean operator join expressions with. Possible values are `and` and `or`."
},
{
"kind": "function",
"name": "toQuerySyntax",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "string",
"isOptional": false,
"desc": "A string representation of the configured expressions."
},
"desc": "Joins all expressions using the configured boolean operator."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "NumericOperator",
"desc": "The operator to use when comparing `field` and `value`. Options for the operator are: `\"isExactly\" | \"lowerThan\" | \"lowerThanOrEqual\" | \"greaterThan\" | \"greaterThanOrEqual\"`."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The value to match against the field. For absolute dates, please use form YYYY/MM/DD. For relative dates, please refer to the supported [date/time operators](https://docs.coveo.com/en/1814/#datetime-operators)."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateRangeFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive",
"name": "from",
"isOptional": false,
"type": "string",
"desc": "The start of the range. For absolute dates, please use form YYYY/MM/DD. For relative dates, please refer to the supported [date/time operators](https://docs.coveo.com/en/1814/#datetime-operators)."
},
{
"kind": "primitive",
"name": "to",
"isOptional": false,
"type": "string",
"desc": "The end of the range. For absolute dates, please use form YYYY/MM/DD. For relative dates, please refer to the supported [date/time operators](https://docs.coveo.com/en/1814/#datetime-operators)."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ExactMatchExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "An expression that must appear in its entirety at least once for an item to be returned.\n\ne.g. specifying `Star Wars` will only return items containing the exact phrase."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FieldExistsExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field that should be defined on all matching items."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "KeywordExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "An expression containing terms to match. Terms can be in any order, and may also be expanded with stemming.\n\ne.g. specifying `Star Wars` will return items containing either `Star` or `Wars` or both."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NearExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "otherTerms",
"isOptional": false,
"type": "OtherTerm[]",
"desc": "The other terms to check against the reference term. See [NEAR](https://docs.coveo.com/en/1814/#near) for an example.",
"members": [],
"isTypeExtracted": true,
"typeName": "OtherTerm"
},
{
"kind": "primitive",
"name": "startTerm",
"isOptional": false,
"type": "string",
"desc": "The reference term."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "OtherTerm",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "endTerm",
"isOptional": false,
"type": "string",
"desc": "The term to check against the reference term."
},
{
"kind": "primitive",
"name": "maxKeywordsBetween",
"isOptional": false,
"type": "number",
"desc": "The maximum number of keywords that should exist between the current term and the reference term."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "NumericOperator",
"desc": "The operator to use when comparing `field` and `value`."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "number",
"desc": "The value to match against the field."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericRangeFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive",
"name": "from",
"isOptional": false,
"type": "number",
"desc": "The start of the range."
},
{
"kind": "primitive",
"name": "to",
"isOptional": false,
"type": "number",
"desc": "The end of the range."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QueryExtensionExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "name",
"isOptional": false,
"type": "string",
"desc": "The query extension name without the leading $ sign. See [Standard Query Extensions](https://docs.coveo.com/en/1462) for examples."
},
{
"kind": "primitive-with-type-alias",
"name": "parameters",
"isOptional": false,
"type": "QueryExtensionParameters",
"desc": "The query extension parameters where applicable."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "StringFacetFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "StringFacetFieldOperator",
"desc": "The operator to use when comparing `field` and `value`."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The value to match against the field."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "StringFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "StringOperator",
"desc": "The operator to use when comparing `field` and `values`."
},
{
"kind": "primitive",
"name": "values",
"isOptional": false,
"type": "string[]",
"desc": "The values to match against the field."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [
{
"kind": "function",
"name": "buildQueryExpression",
"params": [],
"returnType": {
"kind": "object",
"name": "QueryExpression",
"isOptional": false,
"type": "QueryExpression",
"desc": "A utility to help build query expressions.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Creates an `QueryExpression` instance."
}
],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/tab/tab.class.tsx",
"code": "import {\n buildTab,\n Tab as HeadlessTab,\n TabState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType, PropsWithChildren} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport interface TabProps {\n id: string;\n expression: string;\n active?: boolean;\n}\n\nexport class Tab extends Component<PropsWithChildren<TabProps>, TabState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessTab;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildTab(this.context.engine!, {\n initialState: {isActive: !!this.props.active},\n options: {\n expression: this.props.expression,\n id: this.props.id,\n },\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <button\n disabled={this.state.isActive}\n onClick={() => this.controller.select()}\n >\n {this.props.children}\n </button>\n );\n }\n}\n",
"fileName": "tab.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/tab/tab.fn.tsx",
"code": "import {Tab as HeadlessTab} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent, PropsWithChildren} from 'react';\n\ninterface TabProps extends PropsWithChildren {\n controller: HeadlessTab;\n}\n\nexport const Tab: FunctionComponent<TabProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <button disabled={state.isActive} onClick={() => controller.select()}>\n {props.children}\n </button>\n );\n};\n\n/* Usage\n\nconst messageExpression = buildQueryExpression()\n .addStringField({\n field: 'objecttype',\n operator: 'isExactly',\n values: ['Message'],\n })\n .toQuerySyntax();\n\nconst controller = buildTab(engine, {\n initialState: {isActive: true},\n options: {\n id: 'messages',\n expression: messageExpression,\n },\n});\n\n<Tab controller={controller}>Messages</Tab>;\n*/\n",
"fileName": "tab.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildStaticFilter",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `Sort` controller properties.",
"type": "StaticFilterProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "StaticFilterOptions",
"desc": "The options for the `StaticFilter` controller.",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "A unique identifier for the static filter."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "StaticFilterValue[]",
"desc": "The values the static filter is responsible for managing.",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValue"
}
],
"isTypeExtracted": false,
"typeName": "StaticFilterOptions"
}
],
"isTypeExtracted": false,
"typeName": "StaticFilterProps"
}
],
"returnType": {
"kind": "object",
"name": "StaticFilter",
"isOptional": false,
"type": "StaticFilter",
"desc": "The `StaticFilter` controller manages a collection of filter values.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "StaticFilterState",
"desc": "A state of the `StaticFilter` controller.",
"members": [
{
"kind": "primitive",
"name": "hasActiveValues",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is at least one non-idle value and `false` otherwise."
},
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The static filter id."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "StaticFilterValue[]",
"desc": "The static filter values.",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValue"
}
],
"isTypeExtracted": false,
"typeName": "StaticFilterState"
},
{
"kind": "function",
"name": "deselectAll",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects all static filter values."
},
{
"kind": "function",
"name": "isValueSelected",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The static filter value to check.",
"type": "StaticFilterValue",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "Whether the specified static filter value is selected."
},
"desc": "Checks whether the specified static filter value is selected."
},
{
"kind": "function",
"name": "toggleSelect",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The static filter value to toggle.",
"type": "StaticFilterValue",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified static filter value."
},
{
"kind": "function",
"name": "toggleSingleSelect",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The static filter value to toggle.",
"type": "StaticFilterValue",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Toggles the specified static filter value, deselecting others."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "StaticFilter"
},
"desc": "Creates a `Static Filter` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "StaticFilterValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "caption",
"isOptional": false,
"type": "string",
"desc": "A human-readable caption for the expression (e.g., `Youtube`)."
},
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "The query filter expression to apply when the value is selected (e.g., `@filetype==\"youtubevideo\"`)."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the static filter value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "StaticFilterValueOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "caption",
"isOptional": false,
"type": "string",
"desc": "A human-readable caption for the expression (e.g., `Youtube`)."
},
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "The query filter expression to apply when the value is selected (e.g., `@filetype==\"youtubevideo\"`)."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": true,
"type": "'idle' | 'selected'",
"desc": "The state of the static filter value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QueryExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "function",
"name": "addDateField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A date field expression.",
"type": "DateFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a date `field` to a `value`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "addDateRangeField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A numeric field expression.",
"type": "DateRangeFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "DateRangeFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that returns all items for which the `value` of the date `field` is within the defined range."
},
{
"kind": "function",
"name": "addExactMatch",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "An exact match expression.",
"type": "ExactMatchExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "ExactMatchExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that must appear in its entirety, at least once, for an item to be returned."
},
{
"kind": "function",
"name": "addExpression",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "The query expression instance to add.",
"type": "QueryExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds a `QueryExpression` to the current instance."
},
{
"kind": "function",
"name": "addFieldExists",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A field exists expressions.",
"type": "FieldExistsExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "FieldExistsExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression returning all items where the defined field exists."
},
{
"kind": "function",
"name": "addKeyword",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A keyword expression.",
"type": "KeywordExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "KeywordExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression containing terms to match. Terms can be in any order, and may also be expanded with stemming."
},
{
"kind": "function",
"name": "addNear",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A near expression.",
"type": "NearExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "NearExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that returns all of the items in which the specified `startTerm` appears no more than `maxKeywordsBetween` from the endTerm, for each element in `otherTerms`."
},
{
"kind": "function",
"name": "addNumericField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A numeric field expression.",
"type": "NumericFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a numeric `field` to a `value`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "addNumericRangeField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A numeric field expression.",
"type": "NumericRangeFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericRangeFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that returns all items for which the `value` of the numeric `field` is within the defined range."
},
{
"kind": "function",
"name": "addQueryExtension",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A query extension expression.",
"type": "QueryExtensionExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExtensionExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that invokes a query extension."
},
{
"kind": "function",
"name": "addStringFacetField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A string facet field expression.",
"type": "StringFacetFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "StringFacetFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a string facet `field` to a `value`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "addStringField",
"params": [
{
"kind": "object",
"name": "expression",
"isOptional": false,
"desc": "A string field expression.",
"type": "StringFieldExpression",
"members": [],
"isTypeExtracted": true,
"typeName": "StringFieldExpression"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Adds an expression that uses an `operator` to compare a string `field` against certain `values`. Returns all of the items for which the expression evaluates to true."
},
{
"kind": "function",
"name": "joinUsing",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"desc": "The boolean operator to join individual expressions with.",
"type": "BooleanOperator"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "QueryExpression",
"isOptional": false,
"desc": "The `QueryExpression` instance.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Allows specifying a boolean operator join expressions with. Possible values are `and` and `or`."
},
{
"kind": "function",
"name": "toQuerySyntax",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "string",
"isOptional": false,
"desc": "A string representation of the configured expressions."
},
"desc": "Joins all expressions using the configured boolean operator."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "NumericOperator",
"desc": "The operator to use when comparing `field` and `value`. Options for the operator are: `\"isExactly\" | \"lowerThan\" | \"lowerThanOrEqual\" | \"greaterThan\" | \"greaterThanOrEqual\"`."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The value to match against the field. For absolute dates, please use form YYYY/MM/DD. For relative dates, please refer to the supported [date/time operators](https://docs.coveo.com/en/1814/#datetime-operators)."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateRangeFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive",
"name": "from",
"isOptional": false,
"type": "string",
"desc": "The start of the range. For absolute dates, please use form YYYY/MM/DD. For relative dates, please refer to the supported [date/time operators](https://docs.coveo.com/en/1814/#datetime-operators)."
},
{
"kind": "primitive",
"name": "to",
"isOptional": false,
"type": "string",
"desc": "The end of the range. For absolute dates, please use form YYYY/MM/DD. For relative dates, please refer to the supported [date/time operators](https://docs.coveo.com/en/1814/#datetime-operators)."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ExactMatchExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "An expression that must appear in its entirety at least once for an item to be returned.\n\ne.g. specifying `Star Wars` will only return items containing the exact phrase."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FieldExistsExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field that should be defined on all matching items."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "KeywordExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "An expression containing terms to match. Terms can be in any order, and may also be expanded with stemming.\n\ne.g. specifying `Star Wars` will return items containing either `Star` or `Wars` or both."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NearExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "otherTerms",
"isOptional": false,
"type": "OtherTerm[]",
"desc": "The other terms to check against the reference term. See [NEAR](https://docs.coveo.com/en/1814/#near) for an example.",
"members": [],
"isTypeExtracted": true,
"typeName": "OtherTerm"
},
{
"kind": "primitive",
"name": "startTerm",
"isOptional": false,
"type": "string",
"desc": "The reference term."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "OtherTerm",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "endTerm",
"isOptional": false,
"type": "string",
"desc": "The term to check against the reference term."
},
{
"kind": "primitive",
"name": "maxKeywordsBetween",
"isOptional": false,
"type": "number",
"desc": "The maximum number of keywords that should exist between the current term and the reference term."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "NumericOperator",
"desc": "The operator to use when comparing `field` and `value`."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "number",
"desc": "The value to match against the field."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericRangeFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive",
"name": "from",
"isOptional": false,
"type": "number",
"desc": "The start of the range."
},
{
"kind": "primitive",
"name": "to",
"isOptional": false,
"type": "number",
"desc": "The end of the range."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QueryExtensionExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "name",
"isOptional": false,
"type": "string",
"desc": "The query extension name without the leading $ sign. See [Standard Query Extensions](https://docs.coveo.com/en/1462) for examples."
},
{
"kind": "primitive-with-type-alias",
"name": "parameters",
"isOptional": false,
"type": "QueryExtensionParameters",
"desc": "The query extension parameters where applicable."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "StringFacetFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "StringFacetFieldOperator",
"desc": "The operator to use when comparing `field` and `value`."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The value to match against the field."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "StringFieldExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive-with-type-alias",
"name": "operator",
"isOptional": false,
"type": "StringOperator",
"desc": "The operator to use when comparing `field` and `values`."
},
{
"kind": "primitive",
"name": "values",
"isOptional": false,
"type": "string[]",
"desc": "The values to match against the field."
},
{
"kind": "primitive",
"name": "negate",
"isOptional": true,
"type": "boolean",
"desc": "If `true`, the inverse expression will be created."
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [
{
"kind": "function",
"name": "buildStaticFilterValue",
"params": [
{
"kind": "object",
"name": "config",
"isOptional": false,
"desc": "The options with which to create a `StaticFilterValue`.",
"type": "StaticFilterValueOptions",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValueOptions"
}
],
"returnType": {
"kind": "object",
"name": "StaticFilterValue",
"isOptional": false,
"type": "StaticFilterValue",
"desc": "",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValue"
},
"desc": "Creates a `StaticFilterValue`."
},
{
"kind": "function",
"name": "buildQueryExpression",
"params": [],
"returnType": {
"kind": "object",
"name": "QueryExpression",
"isOptional": false,
"type": "QueryExpression",
"desc": "A utility to help build query expressions.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpression"
},
"desc": "Creates an `QueryExpression` instance."
}
],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/static-filter/static-filter.class.tsx",
"code": "import {\n buildStaticFilter,\n StaticFilter as HeadlessStaticFilter,\n StaticFilterOptions,\n StaticFilterState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class StaticFilter extends Component<\n StaticFilterOptions,\n StaticFilterState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessStaticFilter;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildStaticFilter(this.context.engine!, {\n options: this.props,\n });\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n public render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <ul>\n {this.state.values.map((value) => {\n return (\n <li key={value.caption}>\n <input\n type=\"checkbox\"\n checked={this.controller.isValueSelected(value)}\n onChange={() => this.controller.toggleSelect(value)}\n />\n <span>{value.caption}</span>\n </li>\n );\n })}\n </ul>\n );\n }\n}\n",
"fileName": "static-filter.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/static-filter/static-filter.fn.tsx",
"code": "import {StaticFilterOptions, buildStaticFilter} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent, useContext} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport const StaticFilter: FunctionComponent<StaticFilterOptions> = (props) => {\n const {engine} = useContext(AppContext);\n const controller = buildStaticFilter(engine!, {options: props});\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <ul>\n {state.values.map((value) => {\n return (\n <li key={value.caption}>\n <input\n type=\"checkbox\"\n checked={controller.isValueSelected(value)}\n onChange={() => controller.toggleSelect(value)}\n />\n <span>{value.caption}</span>\n </li>\n );\n })}\n </ul>\n );\n};\n\n/* Usage\n\nconst youtubeExpression = buildQueryExpression()\n .addStringField({\n field: 'filetype',\n operator: 'isExactly',\n values: ['youtubevideo'],\n })\n .toQuerySyntax();\n\nconst dropboxExpression = buildQueryExpression()\n .addStringField({\n field: 'connectortype',\n operator: 'isExactly',\n values: ['DropboxCrawler'],\n })\n .addStringField({\n field: 'objecttype',\n operator: 'isExactly',\n values: ['File'],\n })\n .toQuerySyntax();\n\nconst youtube = buildStaticFilterValue({\n caption: 'Youtube',\n expression: youtubeExpression,\n})\nconst dropbox = buildStaticFilterValue({\n caption: 'Dropbox',\n expression: dropboxExpression,\n})\n\n<StaticFilter id=\"fileType\" values={[youtube, dropbox]}/>;\n*/\n",
"fileName": "static-filter.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildSearchStatus",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "SearchStatus",
"isOptional": false,
"type": "SearchStatus",
"desc": "",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "SearchStatusState",
"desc": "The state of the `SearchStatus` controller.",
"members": [
{
"kind": "primitive",
"name": "firstSearchExecuted",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a first search has been executed."
},
{
"kind": "primitive",
"name": "hasError",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is an error for the last executed query and `false` otherwise."
},
{
"kind": "primitive",
"name": "hasResults",
"isOptional": false,
"type": "boolean",
"desc": "Determines if there are results available for the last executed query."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a search is in progress."
}
],
"isTypeExtracted": false,
"typeName": "SearchStatusState"
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "SearchStatus"
},
"desc": "Creates a `SearchStatus` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/search-status/search-status.class.tsx",
"code": "import {\n buildSearchStatus,\n SearchStatus as HeadlessSearchStatus,\n SearchStatusState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class SearchStatus extends Component<{}, SearchStatusState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessSearchStatus;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildSearchStatus(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n const {hasResults, firstSearchExecuted, isLoading} = this.state;\n\n if (!hasResults && !firstSearchExecuted && isLoading) {\n return <p>The first search ever is currently loading.</p>;\n }\n\n if (!hasResults && !firstSearchExecuted && !isLoading) {\n return <p>No search was ever executed.</p>;\n }\n\n if (!hasResults && firstSearchExecuted && isLoading) {\n <p>The previous search gave no results, but new ones are pending.</p>;\n }\n\n if (!hasResults && firstSearchExecuted && !isLoading) {\n return <p>A search was executed but gave no results.</p>;\n }\n\n if (hasResults && isLoading) {\n return <p>The previous search gave results, but new ones are loading.</p>;\n }\n\n if (hasResults && !isLoading) {\n return <p>There are results and no pending search.</p>;\n }\n\n // Unreachable. The code is structured this way to demonstrate possible states.\n return null;\n }\n}\n",
"fileName": "search-status.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/search-status/search-status.fn.tsx",
"code": "import {SearchStatus as HeadlessSearchStatus} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface SearchStatusProps {\n controller: HeadlessSearchStatus;\n}\n\nexport const SearchStatus: FunctionComponent<SearchStatusProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const {hasResults, firstSearchExecuted, isLoading} = state;\n\n if (!hasResults && !firstSearchExecuted && isLoading) {\n return <p>The first search ever is currently loading.</p>;\n }\n\n if (!hasResults && !firstSearchExecuted && !isLoading) {\n return <p>No search was ever executed.</p>;\n }\n\n if (!hasResults && firstSearchExecuted && isLoading) {\n <p>The previous search gave no results, but new ones are pending.</p>;\n }\n\n if (!hasResults && firstSearchExecuted && !isLoading) {\n return <p>A search was executed but gave no results.</p>;\n }\n\n if (hasResults && isLoading) {\n return <p>The previous search gave results, but new ones are loading.</p>;\n }\n\n if (hasResults && !isLoading) {\n return <p>There are results and no pending search.</p>;\n }\n\n // Unreachable. The code is structured this way to demonstrate possible states.\n return null;\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildSearchStatus(engine);\n *\n * <SearchStatus controller={controller} />;\n * ```\n */\n",
"fileName": "search-status.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildSearchBox",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `SearchBox` properties.",
"type": "SearchBoxProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "SearchBoxOptions",
"desc": "The `SearchBox` controller options.",
"members": [
{
"kind": "primitive",
"name": "clearFilters",
"isOptional": true,
"type": "boolean",
"desc": "Whether to clear all active query filters when the end user submits a new query from the search box. Setting this option to \"false\" is not recommended & can lead to an increasing number of queries returning no results."
},
{
"kind": "primitive",
"name": "enableQuerySyntax",
"isOptional": true,
"type": "boolean",
"desc": "Whether to interpret advanced [Coveo Cloud query syntax](https://docs.coveo.com/en/1814/searching-with-coveo/search-prefixes-and-operators) in the query.",
"defaultValue": "`false`"
},
{
"kind": "object",
"name": "highlightOptions",
"isOptional": true,
"type": "SuggestionHighlightingOptions",
"desc": "Specifies delimiters to highlight parts of a query suggestion that e.g match, do not match the query.",
"members": [],
"isTypeExtracted": true,
"typeName": "SuggestionHighlightingOptions"
},
{
"kind": "primitive",
"name": "id",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a unique random identifier is generated."
},
{
"kind": "primitive",
"name": "numberOfSuggestions",
"isOptional": true,
"type": "number",
"desc": "The number of query suggestions to request from Coveo ML (e.g., `3`).\n\nUsing the value `0` disables the query suggest feature.",
"defaultValue": "`5`"
}
],
"isTypeExtracted": false,
"typeName": "SearchBoxOptions"
}
],
"isTypeExtracted": false,
"typeName": "SearchBoxProps"
}
],
"returnType": {
"kind": "object",
"name": "SearchBox",
"isOptional": false,
"type": "SearchBox",
"desc": "The `SearchBox` headless controller offers a high-level interface for designing a common search box UI controller with [highlighting for query suggestions](https://docs.coveo.com/en/headless/latest/usage/highlighting/).",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "SearchBoxState",
"desc": "The state of the `SearchBox` controller.",
"members": [
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a search is in progress."
},
{
"kind": "primitive",
"name": "isLoadingSuggestions",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a query suggest request is in progress."
},
{
"kind": "object",
"name": "suggestions",
"isOptional": false,
"type": "Suggestion[]",
"desc": "The query suggestions for the search box query.",
"members": [],
"isTypeExtracted": true,
"typeName": "Suggestion"
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The current query in the search box."
}
],
"isTypeExtracted": false,
"typeName": "SearchBoxState"
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Clears the search box text and the suggestions."
},
{
"kind": "function",
"name": "selectSuggestion",
"params": [
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"desc": "The string value of the suggestion to select",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects a suggestion and calls `submit`."
},
{
"kind": "function",
"name": "showSuggestions",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Shows the suggestions for the current search box value."
},
{
"kind": "function",
"name": "submit",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Deselects all facets and triggers a search query."
},
{
"kind": "function",
"name": "updateText",
"params": [
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"desc": "The string value to update the search box with.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the search box text value and shows the suggestions for that value."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "SearchBox"
},
"desc": "Creates a `SearchBox` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "SuggestionHighlightingOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "correctionDelimiters",
"isOptional": true,
"type": "Delimiters",
"desc": "Delimiters for substrings that are correction of the input",
"members": [],
"isTypeExtracted": true,
"typeName": "Delimiters"
},
{
"kind": "object",
"name": "exactMatchDelimiters",
"isOptional": true,
"type": "Delimiters",
"desc": "Delimiters for substrings that are exact match of the input",
"members": [],
"isTypeExtracted": true,
"typeName": "Delimiters"
},
{
"kind": "object",
"name": "notMatchDelimiters",
"isOptional": true,
"type": "Delimiters",
"desc": "Delimiters for substrings that do not match the input",
"members": [],
"isTypeExtracted": true,
"typeName": "Delimiters"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Delimiters",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "close",
"isOptional": false,
"type": "string",
"desc": "Closing delimiter"
},
{
"kind": "primitive",
"name": "open",
"isOptional": false,
"type": "string",
"desc": "Opening delimiter"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Suggestion",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "highlightedValue",
"isOptional": false,
"type": "string",
"desc": "The suggestion after applying any `highlightOptions`."
},
{
"kind": "primitive",
"name": "rawValue",
"isOptional": false,
"type": "string",
"desc": "The suggestion text."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/search-box/search-box.class.tsx",
"code": "import {\n buildSearchBox,\n SearchBox as HeadlessSearchBox,\n SearchBoxState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class SearchBox extends Component<{}, SearchBoxState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessSearchBox;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildSearchBox(this.context.engine!, {\n options: {numberOfSuggestions: 8},\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private isEnterKey(e: React.KeyboardEvent<HTMLInputElement>) {\n return e.key === 'Enter';\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n <input\n value={this.state.value}\n onChange={(e) => this.controller.updateText(e.target.value)}\n onKeyDown={(e) => this.isEnterKey(e) && this.controller.submit()}\n />\n <ul>\n {this.state.suggestions.map((suggestion) => {\n const value = suggestion.rawValue;\n return (\n <li\n key={value}\n onClick={() => this.controller.selectSuggestion(value)}\n >\n {value}\n </li>\n );\n })}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "search-box.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/search-box/search-box.fn.tsx",
"code": "import {SearchBox as HeadlessSearchBox} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface SearchBoxProps {\n controller: HeadlessSearchBox;\n}\n\nexport const SearchBox: FunctionComponent<SearchBoxProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n const isEnterKey = (e: React.KeyboardEvent<HTMLInputElement>) =>\n e.key === 'Enter';\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <div>\n <input\n value={state.value}\n onChange={(e) => controller.updateText(e.target.value)}\n onKeyDown={(e) => isEnterKey(e) && controller.submit()}\n />\n <ul>\n {state.suggestions.map((suggestion) => {\n const value = suggestion.rawValue;\n return (\n <li key={value} onClick={() => controller.selectSuggestion(value)}>\n {value}\n </li>\n );\n })}\n </ul>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const options: SearchBoxOptions = {numberOfSuggestions: 8};\n * const controller = buildSearchBox(engine, {options});\n *\n * <SearchBox controller={controller} />;\n * ```\n */\n",
"fileName": "search-box.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildStandaloneSearchBox",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `StandaloneSearchBox` properties.",
"type": "StandaloneSearchBoxProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "StandaloneSearchBoxOptions",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "redirectionUrl",
"isOptional": false,
"type": "string",
"desc": "The default Url the user should be redirected to, when a query is submitted. If a query pipeline redirect is triggered, it will redirect to that Url instead."
},
{
"kind": "primitive",
"name": "clearFilters",
"isOptional": true,
"type": "boolean",
"desc": "Whether to clear all active query filters when the end user submits a new query from the search box. Setting this option to \"false\" is not recommended & can lead to an increasing number of queries returning no results."
},
{
"kind": "primitive",
"name": "enableQuerySyntax",
"isOptional": true,
"type": "boolean",
"desc": "Whether to interpret advanced [Coveo Cloud query syntax](https://docs.coveo.com/en/1814/searching-with-coveo/search-prefixes-and-operators) in the query.",
"defaultValue": "`false`"
},
{
"kind": "object",
"name": "highlightOptions",
"isOptional": true,
"type": "SuggestionHighlightingOptions",
"desc": "Specifies delimiters to highlight parts of a query suggestion that e.g match, do not match the query.",
"members": [],
"isTypeExtracted": true,
"typeName": "SuggestionHighlightingOptions"
},
{
"kind": "primitive",
"name": "id",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a unique random identifier is generated."
},
{
"kind": "primitive",
"name": "numberOfSuggestions",
"isOptional": true,
"type": "number",
"desc": "The number of query suggestions to request from Coveo ML (e.g., `3`).\n\nUsing the value `0` disables the query suggest feature.",
"defaultValue": "`5`"
}
],
"isTypeExtracted": false,
"typeName": "StandaloneSearchBoxOptions"
}
],
"isTypeExtracted": false,
"typeName": "StandaloneSearchBoxProps"
}
],
"returnType": {
"kind": "object",
"name": "StandaloneSearchBox",
"isOptional": false,
"type": "StandaloneSearchBox",
"desc": "The `StandaloneSearchBox` headless controller offers a high-level interface for designing a common search box UI controller. Meant to be used for a search box that will redirect instead of executing a query.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "StandaloneSearchBoxState",
"desc": "A scoped and simplified part of the headless state that is relevant to the `StandaloneSearchBox` controller.",
"members": [
{
"kind": "primitive-with-type-alias",
"name": "analytics",
"isOptional": false,
"type": "InitialData | SearchFromLinkData | OmniboxFromLinkData",
"desc": "The analytics data to send when performing the first query on the search page the user is redirected to."
},
{
"kind": "primitive",
"name": "redirectTo",
"isOptional": false,
"type": "string",
"desc": "The Url to redirect to."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a search is in progress."
},
{
"kind": "primitive",
"name": "isLoadingSuggestions",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a query suggest request is in progress."
},
{
"kind": "object",
"name": "suggestions",
"isOptional": false,
"type": "Suggestion[]",
"desc": "The query suggestions for the search box query.",
"members": [],
"isTypeExtracted": true,
"typeName": "Suggestion"
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The current query in the search box."
}
],
"isTypeExtracted": false,
"typeName": "StandaloneSearchBoxState"
},
{
"kind": "function",
"name": "afterRedirection",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Resets the standalone search box state. To be dispatched on single page applications after the redirection has been triggered."
},
{
"kind": "function",
"name": "submit",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Triggers a redirection."
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Clears the search box text and the suggestions."
},
{
"kind": "function",
"name": "selectSuggestion",
"params": [
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"desc": "The string value of the suggestion to select",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects a suggestion and calls `submit`."
},
{
"kind": "function",
"name": "showSuggestions",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Shows the suggestions for the current search box value."
},
{
"kind": "function",
"name": "updateText",
"params": [
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"desc": "The string value to update the search box with.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the search box text value and shows the suggestions for that value."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "StandaloneSearchBox"
},
"desc": "Creates a `StandaloneSearchBox` instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "SuggestionHighlightingOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "correctionDelimiters",
"isOptional": true,
"type": "Delimiters",
"desc": "Delimiters for substrings that are correction of the input",
"members": [],
"isTypeExtracted": true,
"typeName": "Delimiters"
},
{
"kind": "object",
"name": "exactMatchDelimiters",
"isOptional": true,
"type": "Delimiters",
"desc": "Delimiters for substrings that are exact match of the input",
"members": [],
"isTypeExtracted": true,
"typeName": "Delimiters"
},
{
"kind": "object",
"name": "notMatchDelimiters",
"isOptional": true,
"type": "Delimiters",
"desc": "Delimiters for substrings that do not match the input",
"members": [],
"isTypeExtracted": true,
"typeName": "Delimiters"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Delimiters",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "close",
"isOptional": false,
"type": "string",
"desc": "Closing delimiter"
},
{
"kind": "primitive",
"name": "open",
"isOptional": false,
"type": "string",
"desc": "Opening delimiter"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Suggestion",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "highlightedValue",
"isOptional": false,
"type": "string",
"desc": "The suggestion after applying any `highlightOptions`."
},
{
"kind": "primitive",
"name": "rawValue",
"isOptional": false,
"type": "string",
"desc": "The suggestion text."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/standalone-search-box/standalone-search-box.class.tsx",
"code": "import {\n buildStandaloneSearchBox,\n StandaloneSearchBox as HeadlessStandaloneSearchBox,\n StandaloneSearchBoxState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {standaloneSearchBoxStorageKey} from './standalone-search-box-storage-key';\n\nexport class StandaloneSearchBox extends Component<\n {},\n StandaloneSearchBoxState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessStandaloneSearchBox;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildStandaloneSearchBox(this.context.engine!, {\n options: {redirectionUrl: '/search-page'},\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n componentDidUpdate() {\n const {redirectTo, value, analytics} = this.state;\n\n if (!redirectTo) {\n return;\n }\n\n const data = JSON.stringify({value, analytics});\n localStorage.setItem(standaloneSearchBoxStorageKey, data);\n window.location.href = redirectTo;\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private isEnterKey(e: React.KeyboardEvent<HTMLInputElement>) {\n return e.key === 'Enter';\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n <input\n value={this.state.value}\n onChange={(e) => this.controller.updateText(e.target.value)}\n onKeyDown={(e) => this.isEnterKey(e) && this.controller.submit()}\n />\n <ul>\n {this.state.suggestions.map((suggestion) => {\n const value = suggestion.rawValue;\n return (\n <li\n key={value}\n onClick={() => this.controller.selectSuggestion(value)}\n >\n {value}\n </li>\n );\n })}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "standalone-search-box.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/standalone-search-box/standalone-search-box.fn.tsx",
"code": "import {\n buildStandaloneSearchBox,\n StandaloneSearchBoxOptions,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent, useContext} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {standaloneSearchBoxStorageKey} from './standalone-search-box-storage-key';\n\nexport const StandaloneSearchBox: FunctionComponent<\n StandaloneSearchBoxOptions\n> = (props) => {\n const {engine} = useContext(AppContext);\n const controller = buildStandaloneSearchBox(engine!, {options: props});\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n function isEnterKey(e: React.KeyboardEvent<HTMLInputElement>) {\n return e.key === 'Enter';\n }\n\n if (!state) {\n return null;\n }\n\n if (state.redirectTo) {\n const {redirectTo, value, analytics} = state;\n const data = JSON.stringify({value, analytics});\n localStorage.setItem(standaloneSearchBoxStorageKey, data);\n window.location.href = redirectTo;\n return null;\n }\n\n return (\n <div>\n <input\n value={state.value}\n onChange={(e) => controller.updateText(e.target.value)}\n onKeyDown={(e) => isEnterKey(e) && controller.submit()}\n />\n <ul>\n {state.suggestions.map((suggestion) => {\n const value = suggestion.rawValue;\n return (\n <li key={value} onClick={() => controller.selectSuggestion(value)}>\n {value}\n </li>\n );\n })}\n </ul>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * <StandaloneSearchBox id=\"ssb-1\" redirectionUrl=\"/search-page\"/>;\n * ```\n */\n",
"fileName": "standalone-search-box.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildInteractiveResult",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `InteractiveResult` properties.",
"type": "InteractiveResultProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "InteractiveResultOptions",
"desc": "The options for the `InteractiveResult` controller.",
"members": [
{
"kind": "object",
"name": "result",
"isOptional": false,
"type": "Result",
"desc": "The query result.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
},
{
"kind": "primitive",
"name": "debounceWait",
"isOptional": true,
"type": "number",
"desc": "The number of seconds for which the debounced function should continue catching subsequent calls.",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "selectionDelay",
"isOptional": true,
"type": "number",
"desc": "The amount of time to wait before selecting the result after calling `beginDelayedSelect`.",
"defaultValue": "`1000`"
}
],
"isTypeExtracted": false,
"typeName": "InteractiveResultOptions"
}
],
"isTypeExtracted": false,
"typeName": "InteractiveResultProps"
}
],
"returnType": {
"kind": "object",
"name": "InteractiveResult",
"isOptional": false,
"type": "InteractiveResult",
"desc": "The `InteractiveResult` controller provides an interface for triggering desirable side effects, such as logging UA events to the Coveo Platform, when a user selects a query result.",
"members": [
{
"kind": "function",
"name": "beginDelayedSelect",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Prepares to select the result after a certain delay, sending analytics if it was never selected before.\n\nIn a DOM context, it's recommended to call this method on the `touchstart` event."
},
{
"kind": "function",
"name": "cancelPendingSelect",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Cancels the pending selection caused by `beginDelayedSelect`.\n\nIn a DOM context, it's recommended to call this method on the `touchend` event."
},
{
"kind": "function",
"name": "select",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects the result, logging a UA event to the Coveo Platform if the result wasn't selected before.\n\nIn a DOM context, it's recommended to call this method on all of the following events: * `contextmenu` * `click` * `mouseup` * `mousedown`"
}
],
"isTypeExtracted": false,
"typeName": "InteractiveResult"
},
"desc": "Creates an `InteractiveResult` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [],
"fn": [
{
"path": "packages/samples/headless-react/src/components/result-list/result-link.tsx",
"code": "import {buildInteractiveResult, Result} from '@coveo/headless';\nimport {\n FunctionComponent,\n useContext,\n useEffect,\n PropsWithChildren,\n} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {filterProtocol} from '../../utils/filter-protocol';\n\ninterface LinkProps extends PropsWithChildren {\n result: Result;\n}\n\nexport const ResultLink: FunctionComponent<LinkProps> = (props) => {\n const {engine} = useContext(AppContext);\n\n const interactiveResult = buildInteractiveResult(engine!, {\n options: {result: props.result},\n });\n\n useEffect(() => () => interactiveResult.cancelPendingSelect(), []);\n\n return (\n <a\n href={filterProtocol(props.result.clickUri)}\n onClick={() => interactiveResult.select()}\n onContextMenu={() => interactiveResult.select()}\n onMouseDown={() => interactiveResult.select()}\n onMouseUp={() => interactiveResult.select()}\n onTouchStart={() => interactiveResult.beginDelayedSelect()}\n onTouchEnd={() => interactiveResult.cancelPendingSelect()}\n >\n {props.children}\n </a>\n );\n};\n",
"fileName": "result-link.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildResultsPerPage",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `ResultsPerPage` properties.",
"type": "ResultsPerPageProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "ResultsPerPageInitialState",
"desc": "The initial state that should be applied to this `ResultsPerPage` controller.",
"members": [
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": true,
"type": "number",
"desc": "The initial number of results to register in state."
}
],
"isTypeExtracted": false,
"typeName": "ResultsPerPageInitialState"
}
],
"isTypeExtracted": false,
"typeName": "ResultsPerPageProps"
}
],
"returnType": {
"kind": "object",
"name": "ResultsPerPage",
"isOptional": false,
"type": "ResultsPerPage",
"desc": "The `ResultsPerPage` controller allows the end user to choose how many results to display per page.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "ResultsPerPageState",
"desc": "The state of the `ResultsPerPage` controller.",
"members": [
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results per page."
}
],
"isTypeExtracted": false,
"typeName": "ResultsPerPageState"
},
{
"kind": "function",
"name": "isSetTo",
"params": [
{
"kind": "primitive",
"name": "num",
"isOptional": false,
"desc": "The number of results.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "boolean",
"isOptional": false,
"desc": "`true` if the number of results is equal to the passed value, and `false` otherwise."
},
"desc": "Checks whether the number of results per page is equal to the specified number."
},
{
"kind": "function",
"name": "set",
"params": [
{
"kind": "primitive",
"name": "num",
"isOptional": false,
"desc": "The number of results.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the number of results to request per page."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "ResultsPerPage"
},
"desc": "Creates a `ResultsPerPage` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/results-per-page/results-per-page.class.tsx",
"code": "import {\n buildResultsPerPage,\n ResultsPerPage as HeadlessResultsPerPage,\n ResultsPerPageState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\ninterface ResultsPerPageProps {\n options: number[];\n}\n\nexport class ResultsPerPage extends Component<\n ResultsPerPageProps,\n ResultsPerPageState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessResultsPerPage;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildResultsPerPage(this.context.engine!, {\n initialState: {numberOfResults: this.props.options[0]},\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <ul>\n {this.props.options.map((numberOfResults) => (\n <li key={numberOfResults}>\n <button\n disabled={this.controller.isSetTo(numberOfResults)}\n onClick={() => this.controller.set(numberOfResults)}\n >\n {numberOfResults}\n </button>\n </li>\n ))}\n </ul>\n );\n }\n}\n",
"fileName": "results-per-page.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/results-per-page/results-per-page.fn.tsx",
"code": "import {ResultsPerPage as HeadlessResultsPerPage} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface ResultsPerPageProps {\n controller: HeadlessResultsPerPage;\n options: number[];\n}\n\nexport const ResultsPerPage: FunctionComponent<ResultsPerPageProps> = (\n props\n) => {\n const {controller, options} = props;\n const [, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <ul>\n {options.map((numberOfResults) => (\n <li key={numberOfResults}>\n <button\n disabled={controller.isSetTo(numberOfResults)}\n onClick={() => controller.set(numberOfResults)}\n >\n {numberOfResults}\n </button>\n </li>\n ))}\n </ul>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const options = [10, 25, 50, 100];\n * const controller = buildResultsPerPage(engine, {\n * initialState: {numberOfResults: options[0]},\n * });\n *\n * <ResultsPerPage controller={controller} options={options} />;\n * ```\n */\n",
"fileName": "results-per-page.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildRelevanceInspector",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `RelevanceInspector` properties.",
"type": "RelevanceInspectorProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "RelevanceInspectorInitialState",
"desc": "The initial state that should be applied to the `RelevanceInspector` controller.",
"members": [
{
"kind": "primitive",
"name": "enabled",
"isOptional": true,
"type": "boolean",
"desc": "Whether debug mode should be enabled."
}
],
"isTypeExtracted": false,
"typeName": "RelevanceInspectorInitialState"
}
],
"isTypeExtracted": false,
"typeName": "RelevanceInspectorProps"
}
],
"returnType": {
"kind": "object",
"name": "RelevanceInspector",
"isOptional": false,
"type": "RelevanceInspector",
"desc": "The `RelevanceInspector` controller is in charge of allowing displaying various debug information.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "RelevanceInspectorState",
"desc": "The state of the `RelevanceInspector` controller.",
"members": [
{
"kind": "primitive",
"name": "isEnabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether debug mode is enabled."
},
{
"kind": "object",
"name": "executionReport",
"isOptional": true,
"type": "ExecutionReport",
"desc": "The query execution report.",
"members": [],
"isTypeExtracted": true,
"typeName": "ExecutionReport"
},
{
"kind": "object",
"name": "expressions",
"isOptional": true,
"type": "QueryExpressions",
"desc": "The query expressions sent in the request.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryExpressions"
},
{
"kind": "primitive",
"name": "fetchAllFields",
"isOptional": true,
"type": "boolean",
"desc": "Whether fields debugging is enabled, returning all fields available on query results."
},
{
"kind": "object",
"name": "fieldsDescription",
"isOptional": true,
"type": "FieldDescription[]",
"desc": "The description of all fields available in the index.",
"members": [],
"isTypeExtracted": true,
"typeName": "FieldDescription"
},
{
"kind": "object",
"name": "rankingExpressions",
"isOptional": true,
"type": "QueryRankingExpression[]",
"desc": "The ranking expressions.",
"members": [],
"isTypeExtracted": true,
"typeName": "QueryRankingExpression"
},
{
"kind": "object",
"name": "rankingInformation",
"isOptional": true,
"type": "ResultRankingInformation[]",
"desc": "The ranking information for every result.",
"members": [],
"isTypeExtracted": true,
"typeName": "ResultRankingInformation"
},
{
"kind": "object",
"name": "userIdentities",
"isOptional": true,
"type": "SecurityIdentity[]",
"desc": "The security identities.",
"members": [],
"isTypeExtracted": true,
"typeName": "SecurityIdentity"
}
],
"isTypeExtracted": false,
"typeName": "RelevanceInspectorState"
},
{
"kind": "function",
"name": "disable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disables debug mode."
},
{
"kind": "function",
"name": "disableFetchAllFields",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Disable fetching all available fields from the index."
},
{
"kind": "function",
"name": "enable",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Enables debug mode."
},
{
"kind": "function",
"name": "enableFetchAllFields",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Fetch all fields available from the index on each individual results."
},
{
"kind": "function",
"name": "fetchFieldsDescription",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Fetch the description of all fields available from the index."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "RelevanceInspector"
},
"desc": "Creates a `RelevanceInspector` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "ExecutionReport",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "children",
"isOptional": false,
"type": "ExecutionStep[]",
"desc": "The steps involved in processing the query.",
"members": [],
"isTypeExtracted": true,
"typeName": "ExecutionStep"
},
{
"kind": "primitive",
"name": "duration",
"isOptional": false,
"type": "number",
"desc": "The total time, in milliseconds, needed to process the query."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ExecutionStep",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys for the step, holding additional debugging information."
},
{
"kind": "primitive",
"name": "description",
"isOptional": false,
"type": "string",
"desc": "The step description."
},
{
"kind": "primitive",
"name": "duration",
"isOptional": false,
"type": "number",
"desc": "The time, in milliseconds, spent on the step."
},
{
"kind": "primitive",
"name": "name",
"isOptional": false,
"type": "string",
"desc": "The step name."
},
{
"kind": "object",
"name": "children",
"isOptional": true,
"type": "ExecutionStep[]",
"desc": "The sub-steps making up the step.",
"members": [],
"isTypeExtracted": true,
"typeName": "ExecutionStep"
},
{
"kind": "primitive",
"name": "result",
"isOptional": true,
"type": "Record<string, unknown>",
"desc": "The values returned by the step."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QueryExpressions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "advancedExpression",
"isOptional": false,
"type": "string",
"desc": "The dynamic filter expression, sent as the `aq` parameter in the request."
},
{
"kind": "primitive",
"name": "basicExpression",
"isOptional": false,
"type": "string",
"desc": "The search query."
},
{
"kind": "primitive",
"name": "constantExpression",
"isOptional": false,
"type": "string",
"desc": "The static filter expression, typically set by a `Tab`."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FieldDescription",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "defaultValue",
"isOptional": false,
"type": "string",
"desc": "The default value of the field."
},
{
"kind": "primitive",
"name": "description",
"isOptional": false,
"type": "string",
"desc": "A modest description of the field."
},
{
"kind": "primitive",
"name": "fieldSourceType",
"isOptional": false,
"type": "string",
"desc": "The `fieldSourceType`."
},
{
"kind": "primitive",
"name": "fieldType",
"isOptional": false,
"type": "string",
"desc": "The `fieldType` (eg., Date, Double, Integer, LargeString, Long, SmallString)."
},
{
"kind": "primitive",
"name": "groupByField",
"isOptional": false,
"type": "boolean",
"desc": "Whether the field is considered `groupBy` (facet)."
},
{
"kind": "primitive",
"name": "includeInQuery",
"isOptional": false,
"type": "boolean",
"desc": "Whether the field can be referenced in a query."
},
{
"kind": "primitive",
"name": "includeInResults",
"isOptional": false,
"type": "boolean",
"desc": "Whether the field is returned with results."
},
{
"kind": "primitive",
"name": "name",
"isOptional": false,
"type": "string",
"desc": "The field name."
},
{
"kind": "primitive",
"name": "sortByField",
"isOptional": false,
"type": "boolean",
"desc": "Whether the field can be used to sort results."
},
{
"kind": "primitive",
"name": "splitGroupByField",
"isOptional": false,
"type": "boolean",
"desc": "Whether the field is considered `splitGroupBy` (ie., facet with values delimited by `;`)."
},
{
"kind": "primitive",
"name": "type",
"isOptional": false,
"type": "string",
"desc": "The field type."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QueryRankingExpression",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "The query ranking expression (QRE)."
},
{
"kind": "primitive",
"name": "modifier",
"isOptional": false,
"type": "string",
"desc": "The change to the ranking score applied by the query ranking expression (QRE)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ResultRankingInformation",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "ranking",
"isOptional": false,
"type": "RankingInformation | null",
"desc": "The ranking information for the associated result."
},
{
"kind": "object",
"name": "result",
"isOptional": false,
"type": "Result",
"desc": "The result.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "SecurityIdentity",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "name",
"isOptional": false,
"type": "string",
"desc": "The security identity name."
},
{
"kind": "primitive",
"name": "provider",
"isOptional": false,
"type": "string",
"desc": "The security identity provider."
},
{
"kind": "primitive",
"name": "type",
"isOptional": false,
"type": "string",
"desc": "The security identity type. Possible values are `USER`, `GROUP`, `VIRTUAL_GROUP`, or `UNKNOWN`."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/relevance-inspector/relevance-inspector.class.tsx",
"code": "import {\n buildRelevanceInspector,\n RelevanceInspector as HeadlessRelevanceInspector,\n RelevanceInspectorState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class RelevanceInspector extends Component<{}, RelevanceInspectorState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessRelevanceInspector;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildRelevanceInspector(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n componentDidUpdate() {\n console.info('Debug information [class]', this.state);\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n <label>\n Enable debug mode:{' '}\n <input\n type=\"checkbox\"\n checked={this.state.isEnabled}\n onChange={() =>\n this.state.isEnabled\n ? this.controller.disable()\n : this.controller.enable()\n }\n />\n </label>\n <label>\n Enable fetch all fields:{' '}\n <input\n type=\"checkbox\"\n checked={this.state.fetchAllFields}\n onChange={() =>\n this.state.fetchAllFields\n ? this.controller.disableFetchAllFields()\n : this.controller.enableFetchAllFields()\n }\n />\n </label>\n <button onClick={() => this.controller.fetchFieldsDescription()}>\n {' '}\n Retrieve fields description\n </button>\n </div>\n );\n }\n}\n",
"fileName": "relevance-inspector.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/relevance-inspector/relevance-inspector.fn.tsx",
"code": "import {RelevanceInspector as HeadlessRelevanceInspector} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface RelevanceInspectorProps {\n controller: HeadlessRelevanceInspector;\n}\n\nexport const RelevanceInspector: FunctionComponent<RelevanceInspectorProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(\n () =>\n controller.subscribe(() => {\n console.info('Debug information [fn]', controller.state);\n setState(controller.state);\n }),\n []\n );\n\n return (\n <div>\n <label>\n Enable debug mode:{' '}\n <input\n type=\"checkbox\"\n checked={state.isEnabled}\n onChange={() =>\n state.isEnabled ? controller.disable() : controller.enable()\n }\n />\n </label>\n <label>\n Enable fetch all fields:{' '}\n <input\n type=\"checkbox\"\n checked={state.fetchAllFields}\n onChange={() =>\n state.fetchAllFields\n ? controller.disableFetchAllFields()\n : controller.enableFetchAllFields()\n }\n />\n </label>\n <button onClick={() => controller.fetchFieldsDescription()}>\n {' '}\n Retrieve fields description\n </button>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildRelevanceInspector(engine);\n *\n * <RelevanceInspector controller={controller} />;\n * ```\n */\n",
"fileName": "relevance-inspector.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildSearchParameterManager",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `SearchParameterManager` properties.",
"type": "SearchParameterManagerProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": false,
"type": "SearchParameterManagerInitialState",
"desc": "The initial state that should be applied to the `SearchParameterManager` controller.",
"members": [
{
"kind": "object",
"name": "parameters",
"isOptional": false,
"type": "SearchParameters",
"desc": "The parameters affecting the search response.",
"members": [],
"isTypeExtracted": true,
"typeName": "SearchParameters"
}
],
"isTypeExtracted": false,
"typeName": "SearchParameterManagerInitialState"
}
],
"isTypeExtracted": false,
"typeName": "SearchParameterManagerProps"
}
],
"returnType": {
"kind": "object",
"name": "SearchParameterManager",
"isOptional": false,
"type": "SearchParameterManager",
"desc": "The `SearchParameterManager` controller allows restoring parameters that affect the results from e.g. a url.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "SearchParameterManagerState",
"desc": "The state relevant to the `SearchParameterManager` controller.",
"members": [
{
"kind": "object",
"name": "parameters",
"isOptional": false,
"type": "SearchParameters",
"desc": "The parameters affecting the search response.",
"members": [],
"isTypeExtracted": true,
"typeName": "SearchParameters"
}
],
"isTypeExtracted": false,
"typeName": "SearchParameterManagerState"
},
{
"kind": "function",
"name": "synchronize",
"params": [
{
"kind": "object",
"name": "parameters",
"isOptional": false,
"desc": "The search parameters to synchronize.",
"type": "SearchParameters",
"members": [],
"isTypeExtracted": true,
"typeName": "SearchParameters"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the search parameters in state with the passed parameters and executes a search. Unspecified keys are reset to their initial values."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "SearchParameterManager"
},
"desc": "Creates a `SearchParameterManager` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "SearchParameters",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "aq",
"isOptional": true,
"type": "string",
"desc": "The advanced query expression."
},
{
"kind": "primitive",
"name": "cf",
"isOptional": true,
"type": "Record<string, string[]>",
"desc": "A record of the category facets, where the key is the facet id, and value is an array containing the parts of the selected path."
},
{
"kind": "primitive",
"name": "cq",
"isOptional": true,
"type": "string",
"desc": "The constant query expression."
},
{
"kind": "primitive",
"name": "debug",
"isOptional": true,
"type": "boolean",
"desc": "Determines whether to return debug information for a query."
},
{
"kind": "primitive",
"name": "df",
"isOptional": true,
"type": "Record<string, DateRangeRequest[]>",
"desc": "A record of the date facets, where the key is the facet id, and value is an array containing the date ranges to request."
},
{
"kind": "primitive",
"name": "enableQuerySyntax",
"isOptional": true,
"type": "boolean",
"desc": "Whether to interpret advanced [Coveo Cloud query syntax](https://docs.coveo.com/en/1814/searching-with-coveo/search-prefixes-and-operators) in the query."
},
{
"kind": "primitive",
"name": "f",
"isOptional": true,
"type": "Record<string, string[]>",
"desc": "A record of the facets, where the key is the facet id, and value is an array containing the selected values."
},
{
"kind": "primitive",
"name": "firstResult",
"isOptional": true,
"type": "number",
"desc": "A zero-based index of the first result."
},
{
"kind": "primitive",
"name": "nf",
"isOptional": true,
"type": "Record<string, NumericRangeRequest[]>",
"desc": "A record of the numeric facets, where the key is the facet id, and value is an array containing the numeric ranges to request."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": true,
"type": "number",
"desc": "The number of results to return."
},
{
"kind": "primitive",
"name": "q",
"isOptional": true,
"type": "string",
"desc": "The query."
},
{
"kind": "primitive",
"name": "sf",
"isOptional": true,
"type": "Record<string, string[]>",
"desc": "A record of the static filters, where the key is the static filter id, and value is an array containing the selected static filter captions."
},
{
"kind": "primitive",
"name": "sortCriteria",
"isOptional": true,
"type": "string",
"desc": "The sort expression to order returned results by."
},
{
"kind": "primitive",
"name": "tab",
"isOptional": true,
"type": "string",
"desc": "The active tab id."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [],
"fn": []
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildUrlManager",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `UrlManager` properties.",
"type": "UrlManagerProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": false,
"type": "UrlManagerInitialState",
"desc": "The initial state that should be applied to the `UrlManager` controller.",
"members": [
{
"kind": "primitive",
"name": "fragment",
"isOptional": false,
"type": "string",
"desc": "The part of the url that contains search parameters. E.g., `q=windmill&f[author]=Cervantes`"
}
],
"isTypeExtracted": false,
"typeName": "UrlManagerInitialState"
}
],
"isTypeExtracted": false,
"typeName": "UrlManagerProps"
}
],
"returnType": {
"kind": "object",
"name": "UrlManager",
"isOptional": false,
"type": "UrlManager",
"desc": "The `UrlManager` controller can parse an url fragment to extract search parameters which affect the search response.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "UrlManagerState",
"desc": "The state relevant to the `UrlManager` controller.",
"members": [
{
"kind": "primitive",
"name": "fragment",
"isOptional": false,
"type": "string",
"desc": "The part of the url that contains search parameters. E.g., `q=windmill&f[author]=Cervantes`"
}
],
"isTypeExtracted": false,
"typeName": "UrlManagerState"
},
{
"kind": "function",
"name": "synchronize",
"params": [
{
"kind": "primitive",
"name": "fragment",
"isOptional": false,
"desc": "The part of the url that contains search parameters. E.g., `q=windmill&f[author]=Cervantes`",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the search parameters in state with those from the url & launches a search."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "UrlManager"
},
"desc": "Creates a `UrlManager` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/url-manager/url-manager.ts",
"code": "import {buildUrlManager, SearchEngine} from '@coveo/headless';\n\n/**\n * Search parameters, defined in the url's hash, should not be restored until all components are registered.\n *\n * Additionally, a search should not be executed until search parameters are restored.\n *\n * @param engine - A headless search engine instance.\n * @returns An unsubscribe function to remove attached event listeners.\n */\nexport function bindUrlManager(engine: SearchEngine) {\n const fragment = () => window.location.hash.slice(1);\n\n const urlManager = buildUrlManager(engine, {\n initialState: {fragment: fragment()},\n });\n const onHashChange = () => {\n urlManager.synchronize(fragment());\n };\n\n window.addEventListener('hashchange', onHashChange);\n const unsubscribeManager = urlManager.subscribe(() => {\n const hash = `#${urlManager.state.fragment}`;\n history.pushState(null, document.title, hash);\n });\n\n return () => {\n window.removeEventListener('hashchange', onHashChange);\n unsubscribeManager();\n };\n}\n",
"fileName": "url-manager.ts"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/url-manager/url-manager.ts",
"code": "import {buildUrlManager, SearchEngine} from '@coveo/headless';\n\n/**\n * Search parameters, defined in the url's hash, should not be restored until all components are registered.\n *\n * Additionally, a search should not be executed until search parameters are restored.\n *\n * @param engine - A headless search engine instance.\n * @returns An unsubscribe function to remove attached event listeners.\n */\nexport function bindUrlManager(engine: SearchEngine) {\n const fragment = () => window.location.hash.slice(1);\n\n const urlManager = buildUrlManager(engine, {\n initialState: {fragment: fragment()},\n });\n const onHashChange = () => {\n urlManager.synchronize(fragment());\n };\n\n window.addEventListener('hashchange', onHashChange);\n const unsubscribeManager = urlManager.subscribe(() => {\n const hash = `#${urlManager.state.fragment}`;\n history.pushState(null, document.title, hash);\n });\n\n return () => {\n window.removeEventListener('hashchange', onHashChange);\n unsubscribeManager();\n };\n}\n",
"fileName": "url-manager.ts"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildQuickview",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `Quickview` properties.",
"type": "QuickviewProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "QuickviewOptions",
"desc": "The options for the `Quickview` controller.",
"members": [
{
"kind": "object",
"name": "result",
"isOptional": false,
"type": "Result",
"desc": "The result to retrieve a quickview for.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
},
{
"kind": "primitive",
"name": "maximumPreviewSize",
"isOptional": true,
"type": "number",
"desc": "The maximum preview size to retrieve, in bytes. By default, the full preview is retrieved."
},
{
"kind": "primitive",
"name": "onlyContentURL",
"isOptional": true,
"type": "boolean",
"desc": "Whether to only update the `contentURL` attribute when using `fetchResultContent` rather than updating `content`. Use this if you are using an iframe with `state.contentURL` as the source url."
}
],
"isTypeExtracted": false,
"typeName": "QuickviewOptions"
}
],
"isTypeExtracted": false,
"typeName": "QuickviewProps"
}
],
"returnType": {
"kind": "object",
"name": "Quickview",
"isOptional": false,
"type": "Quickview",
"desc": "",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "QuickviewState",
"desc": "The state for the `Quickview` controller.",
"members": [
{
"kind": "primitive",
"name": "content",
"isOptional": false,
"type": "string",
"desc": "The result preview HTML content."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "`true` if content is being fetched, and `false` otherwise."
},
{
"kind": "primitive",
"name": "resultHasPreview",
"isOptional": false,
"type": "boolean",
"desc": "`true` if the configured result has a preview, and `false` otherwise."
},
{
"kind": "primitive",
"name": "contentURL",
"isOptional": true,
"type": "string",
"desc": "The `src` path to use if rendering the quickview in an iframe."
}
],
"isTypeExtracted": false,
"typeName": "QuickviewState"
},
{
"kind": "function",
"name": "fetchResultContent",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Retrieves the preview content for the configured result. If `options.onlyContentURL` is `true` this will update the `contentURL` state property rather than `content`."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "Quickview"
},
"desc": "Creates a `Quickview` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/quickview/quickview.class.tsx",
"code": "import {\n buildQuickview,\n Quickview as HeadlessQuickview,\n QuickviewState as HeadlessQuickviewState,\n Unsubscribe,\n Result,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\ninterface QuickviewProps {\n result: Result;\n}\n\ninterface QuickviewState {\n isModalOpen: boolean;\n quickview: HeadlessQuickviewState;\n}\n\nexport class Quickview extends Component<QuickviewProps, QuickviewState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessQuickview;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n const result = this.props.result;\n this.controller = buildQuickview(this.context.engine!, {\n options: {result},\n });\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState({quickview: this.controller.state});\n }\n\n private openModal() {\n this.controller.fetchResultContent();\n this.setState({isModalOpen: true});\n }\n\n private closeModal() {\n this.setState({isModalOpen: false});\n }\n\n render() {\n if (!this.state?.quickview.resultHasPreview) {\n return null;\n }\n\n if (this.state.isModalOpen) {\n return (\n <div>\n <button onClick={() => this.closeModal()}>X</button>\n <iframe srcDoc={this.state.quickview.content}></iframe>\n </div>\n );\n }\n\n return <button onClick={() => this.openModal()}>view</button>;\n }\n}\n",
"fileName": "quickview.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/quickview/quickview.fn.tsx",
"code": "import {buildQuickview, Result} from '@coveo/headless';\nimport {useEffect, useState, useContext, FunctionComponent} from 'react';\nimport {AppContext} from '../../context/engine';\n\ninterface QuickviewProps {\n result: Result;\n}\n\nexport const Quickview: FunctionComponent<QuickviewProps> = (props) => {\n const {result} = props;\n const {engine} = useContext(AppContext);\n\n const controller = buildQuickview(engine!, {options: {result}});\n\n const [state, setState] = useState(controller.state);\n const [isModalOpen, toggleModal] = useState(false);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const openModal = () => {\n controller.fetchResultContent();\n toggleModal(true);\n };\n\n const closeModal = () => toggleModal(false);\n\n if (!state.resultHasPreview) {\n return null;\n }\n\n if (isModalOpen) {\n return (\n <div>\n <button onClick={() => closeModal()}>X</button>\n <iframe srcDoc={state.content}></iframe>\n </div>\n );\n }\n\n return <button onClick={() => openModal()}>view</button>;\n};\n\n// usage\n\n/**\n * ```tsx\n * <Quickview result={result} />;\n * ```\n */\n",
"fileName": "quickview.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildFoldedResultList",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `FoldedResultList` properties.",
"type": "FoldedResultListProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "FoldedResultListOptions",
"desc": "The options for the `FoldedResultList` controller.",
"members": [
{
"kind": "object",
"name": "folding",
"isOptional": true,
"type": "FoldingOptions",
"desc": "",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldingOptions"
},
{
"kind": "primitive",
"name": "fieldsToInclude",
"isOptional": true,
"type": "string[]",
"desc": "A list of indexed fields to include in the objects returned by the result list. These results are included in addition to the default fields. If this is left empty only the default fields are included."
}
],
"isTypeExtracted": false,
"typeName": "FoldedResultListOptions"
}
],
"isTypeExtracted": false,
"typeName": "FoldedResultListProps"
}
],
"returnType": {
"kind": "object",
"name": "FoldedResultList",
"isOptional": false,
"type": "FoldedResultList",
"desc": "The `FoldedResultList` headless controller re-organizes results into hierarchical collections (a.k.a. threads).",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "FoldedResultListState",
"desc": "The state of the `FoldedResultList` controller.",
"members": [
{
"kind": "primitive",
"name": "moreResultsAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more results are available, using the same parameters as the last successful query.\n\nThis property is not compatible with the `Pager` controller."
},
{
"kind": "object",
"name": "results",
"isOptional": false,
"type": "FoldedCollection[]",
"desc": "The ordered list of collections.",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedCollection"
},
{
"kind": "primitive",
"name": "searchResponseId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the response where the results were fetched, this value does not change when loading more results."
},
{
"kind": "primitive",
"name": "firstSearchExecuted",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a first search has been executed."
},
{
"kind": "primitive",
"name": "hasError",
"isOptional": false,
"type": "boolean",
"desc": "`true` if there is an error for the last executed query and `false` otherwise."
},
{
"kind": "primitive",
"name": "hasResults",
"isOptional": false,
"type": "boolean",
"desc": "Determines if there are results available for the last executed query."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a search is in progress."
}
],
"isTypeExtracted": false,
"typeName": "FoldedResultListState"
},
{
"kind": "function",
"name": "fetchMoreResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Using the same parameters as the last successful query, fetch another batch of results, if available. Particularly useful for infinite scrolling, for example.\n\nThis method is not compatible with the `Pager` controller."
},
{
"kind": "function",
"name": "findResultByCollection",
"params": [
{
"kind": "object",
"name": "collection",
"isOptional": false,
"desc": "The folded collection whose collection name will be used to find a collection in the results.",
"type": "FoldedCollection",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedCollection"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "FoldedResult | null",
"isOptional": false,
"desc": "The `FoldedResult` associated with the collection's name.",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedResult | null"
},
"desc": "Finds a folded result by its collection."
},
{
"kind": "function",
"name": "findResultById",
"params": [
{
"kind": "object",
"name": "collection",
"isOptional": false,
"desc": "The folded collection whose ID will be used to find a collection in the results.",
"type": "FoldedCollection",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedCollection"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "FoldedResult | null",
"isOptional": false,
"desc": "The `FoldedResult` associated with the collection's ID.",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedResult | null"
},
"desc": "Finds a folded result by its unique ID."
},
{
"kind": "function",
"name": "loadCollection",
"params": [
{
"kind": "object",
"name": "collection",
"isOptional": false,
"desc": "The collection for which to load more results.",
"type": "FoldedCollection",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedCollection"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Loads all the folded results for a given collection."
},
{
"kind": "function",
"name": "logShowLessFoldedResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Logs a custom event when a user shows less folded results."
},
{
"kind": "function",
"name": "logShowMoreFoldedResults",
"params": [
{
"kind": "object",
"name": "result",
"isOptional": false,
"desc": "The result to send analytics for.",
"type": "Result",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Logs a click event when a user loads/shows more folded results."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "FoldedResultList"
},
"desc": "Creates a `FoldedResultList` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "FoldingOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "childField",
"isOptional": true,
"type": "string",
"desc": "The name of the field that uniquely identifies a result within a collection.",
"defaultValue": "`foldingchild`"
},
{
"kind": "primitive",
"name": "collectionField",
"isOptional": true,
"type": "string",
"desc": "The name of the field on which to do the folding. The folded result list component will use the values of this field to resolve the collections of result items.",
"defaultValue": "`foldingcollection`"
},
{
"kind": "primitive",
"name": "numberOfFoldedResults",
"isOptional": true,
"type": "number",
"desc": "The number of child results to fold under the root collection element, before expansion.",
"defaultValue": "`2`"
},
{
"kind": "primitive",
"name": "parentField",
"isOptional": true,
"type": "string",
"desc": "The name of the field that determines whether a certain result is a top result containing other child results within a collection.",
"defaultValue": "`foldingparent`"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FoldedCollection",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "isLoadingMoreResults",
"isOptional": false,
"type": "boolean",
"desc": "Whether there is an ongoing query to add more results to the collection."
},
{
"kind": "primitive",
"name": "moreResultsAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more results might be available in the collection."
},
{
"kind": "object",
"name": "children",
"isOptional": false,
"type": "FoldedResult[]",
"desc": "The children of this result sorted in the same order as the search results.",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedResult"
},
{
"kind": "object",
"name": "result",
"isOptional": false,
"type": "Result",
"desc": "The result at this position in the collection.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FoldedResult",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "children",
"isOptional": false,
"type": "FoldedResult[]",
"desc": "The children of this result sorted in the same order as the search results.",
"members": [],
"isTypeExtracted": false,
"typeName": "FoldedResult"
},
{
"kind": "object",
"name": "result",
"isOptional": false,
"type": "Result",
"desc": "The result at this position in the collection.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FoldedResult | null",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "children",
"isOptional": false,
"type": "FoldedResult[]",
"desc": "The children of this result sorted in the same order as the search results.",
"members": [],
"isTypeExtracted": true,
"typeName": "FoldedResult"
},
{
"kind": "object",
"name": "result",
"isOptional": false,
"type": "Result",
"desc": "The result at this position in the collection.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/folded-result-list/folded-result-list.class.tsx",
"code": "import {\n buildFoldedResultList,\n FoldedResult,\n FoldedResultList as FoldedResultListController,\n FoldedResultListState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {ResultLink} from '../result-list/result-link';\n\nexport class FoldedResultList extends Component<{}, FoldedResultListState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: FoldedResultListController;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildFoldedResultList(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private renderFoldedResults(results: FoldedResult[]) {\n return results.map(({result, children}) => (\n <li key={result.uniqueId}>\n <article>\n <h3>\n {/* Make sure to log analytics when the result link is clicked. */}\n <ResultLink result={result}>{result.title}</ResultLink>\n </h3>\n <p>{result.excerpt}</p>\n <ul>{this.renderFoldedResults(children)}</ul>\n </article>\n </li>\n ));\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n if (!this.state.results.length) {\n return <div>No results</div>;\n }\n\n return (\n <div>\n <ul style={{textAlign: 'left'}}>\n {this.state.results.map((collection) => (\n <li key={collection.result.uniqueId}>\n <article>\n <h3>\n {/* Make sure to log analytics when the result link is clicked. */}\n <ResultLink result={collection.result}>\n {collection.result.title}\n </ResultLink>\n </h3>\n <p>{collection.result.excerpt}</p>\n <ul>{this.renderFoldedResults(collection.children)}</ul>\n {collection.moreResultsAvailable && (\n <button\n disabled={collection.isLoadingMoreResults}\n onClick={() => this.controller.loadCollection(collection)}\n >\n Show more\n </button>\n )}\n </article>\n </li>\n ))}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "folded-result-list.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/folded-result-list/folded-result-list.fn.tsx",
"code": "import {\n FoldedResult,\n FoldedResultList as HeadlessFoldedResultList,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\nimport {ResultLink} from '../result-list/result-link';\n\ninterface FoldedResultListProps {\n controller: HeadlessFoldedResultList;\n}\n\nexport const FoldedResultList: FunctionComponent<FoldedResultListProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n function renderFoldedResults(results: FoldedResult[]) {\n return results.map(({result, children}) => (\n <li key={result.uniqueId}>\n <article>\n <h3>\n {/* Make sure to log analytics when the result link is clicked. */}\n <ResultLink result={result}>{result.title}</ResultLink>\n </h3>\n <p>{result.excerpt}</p>\n <ul>{renderFoldedResults(children)}</ul>\n </article>\n </li>\n ));\n }\n\n if (!state.results.length) {\n return <div>No results</div>;\n }\n\n return (\n <div>\n <ul style={{textAlign: 'left'}}>\n {state.results.map((collection) => (\n <li key={collection.result.uniqueId}>\n <article>\n <h3>\n {/* Make sure to log analytics when the result link is clicked. */}\n <ResultLink result={collection.result}>\n {collection.result.title}\n </ResultLink>\n </h3>\n <p>{collection.result.excerpt}</p>\n <ul>{renderFoldedResults(collection.children)}</ul>\n {collection.moreResultsAvailable && (\n <button\n disabled={collection.isLoadingMoreResults}\n onClick={() => controller.loadCollection(collection)}\n >\n Show more\n </button>\n )}\n </article>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildFoldedResultList(engine);\n *\n * <FoldedResultList controller={controller} />;\n * ```\n */\n",
"fileName": "folded-result-list.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildSmartSnippet",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `SmartSnippet` properties.",
"type": "SmartSnippetProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "SmartSnippetOptions",
"desc": "The options for the `SmartSnippet` controller.",
"members": [
{
"kind": "primitive",
"name": "selectionDelay",
"isOptional": true,
"type": "number",
"desc": "The amount of time in milliseconds to wait before selecting the source or inline links after calling `beginDelayedSelectSource` or `beginDelayedSelectInlineLink`.",
"defaultValue": "`1000`"
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippetOptions"
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippetProps"
}
],
"returnType": {
"kind": "object",
"name": "SmartSnippet",
"isOptional": false,
"type": "SmartSnippet",
"desc": "The `SmartSnippet` controller allows to manage the excerpt of a document that would be most likely to answer a particular query .",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "SmartSnippetState",
"desc": "The state of the SmartSnippet controller.",
"members": [
{
"kind": "primitive",
"name": "answer",
"isOptional": false,
"type": "string",
"desc": "The answer, or snippet, related to the question."
},
{
"kind": "primitive",
"name": "answerFound",
"isOptional": false,
"type": "boolean",
"desc": "Determines of there is an available answer for the current query."
},
{
"kind": "primitive",
"name": "disliked",
"isOptional": false,
"type": "boolean",
"desc": "Determines if the snippet was disliked, or downvoted by the end user."
},
{
"kind": "object",
"name": "documentId",
"isOptional": false,
"type": "QuestionAnswerDocumentIdentifier",
"desc": "The index identifier for the document that provided the answer.",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnswerDocumentIdentifier"
},
{
"kind": "primitive",
"name": "expanded",
"isOptional": false,
"type": "boolean",
"desc": "Determines if the snippet is currently expanded."
},
{
"kind": "primitive",
"name": "feedbackModalOpen",
"isOptional": false,
"type": "boolean",
"desc": "Determines if the feedback modal with the purpose of explaining why the end user disliked the snippet is currently opened."
},
{
"kind": "primitive",
"name": "liked",
"isOptional": false,
"type": "boolean",
"desc": "Determines if the snippet was liked, or upvoted by the end user."
},
{
"kind": "primitive",
"name": "question",
"isOptional": false,
"type": "string",
"desc": "The question related to the smart snippet."
},
{
"kind": "object",
"name": "source",
"isOptional": true,
"type": "Result",
"desc": "Provides the source of the smart snippet.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippetState"
},
{
"kind": "function",
"name": "beginDelayedSelectInlineLink",
"params": [
{
"kind": "object",
"name": "link",
"isOptional": false,
"desc": "The link to select.",
"type": "InlineLink",
"members": [],
"isTypeExtracted": true,
"typeName": "InlineLink"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Prepares to select a link inside the answer after a certain delay, sending analytics if it was never selected before.\n\nIn a DOM context, we recommend calling this method on the `touchstart` event."
},
{
"kind": "function",
"name": "beginDelayedSelectSource",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Prepares to select the source after a certain delay, sending analytics if it was never selected before.\n\nIn a DOM context, we recommend calling this method on the `touchstart` event."
},
{
"kind": "function",
"name": "cancelPendingSelectInlineLink",
"params": [
{
"kind": "object",
"name": "link",
"isOptional": false,
"desc": "The link to select.",
"type": "InlineLink",
"members": [],
"isTypeExtracted": true,
"typeName": "InlineLink"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Cancels the pending selection caused by `beginDelayedSelectInlineLink`.\n\nIn a DOM context, we recommend calling this method on the `touchend` event."
},
{
"kind": "function",
"name": "cancelPendingSelectSource",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Cancels the pending selection caused by `beginDelayedSelectSource`.\n\nIn a DOM context, we recommend calling this method on the `touchend` event."
},
{
"kind": "function",
"name": "closeFeedbackModal",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Allows the user to signal that they no longer wish to send feedback about why a particular answer was not relevant."
},
{
"kind": "function",
"name": "collapse",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Collapse the snippet."
},
{
"kind": "function",
"name": "dislike",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Allows the user to signal that a particular answer was not relevant."
},
{
"kind": "function",
"name": "expand",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Expand the snippet."
},
{
"kind": "function",
"name": "like",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Allows the user to signal that a particular answer was relevant."
},
{
"kind": "function",
"name": "openFeedbackModal",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Allows the user to signal that they wish to send feedback about why a particular answer was not relevant."
},
{
"kind": "function",
"name": "selectInlineLink",
"params": [
{
"kind": "object",
"name": "link",
"isOptional": false,
"desc": "The link to select.",
"type": "InlineLink",
"members": [],
"isTypeExtracted": true,
"typeName": "InlineLink"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects a link inside the answer, logging a UA event to the Coveo Platform if it was never selected before.\n\nIn a DOM context, we recommend calling this method on all of the following events: * `contextmenu` * `click` * `mouseup` * `mousedown`"
},
{
"kind": "function",
"name": "selectSource",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects the source, logging a UA event to the Coveo Platform if the source wasn't already selected before.\n\nIn a DOM context, we recommend calling this method on all of the following events: * `contextmenu` * `click` * `mouseup` * `mousedown`"
},
{
"kind": "function",
"name": "sendDetailedFeedback",
"params": [
{
"kind": "primitive",
"name": "details",
"isOptional": false,
"desc": "A personalized message from the end user about the relevance of the answer.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Allows the user to send detailed feedback about why a particular answer was not relevant."
},
{
"kind": "function",
"name": "sendFeedback",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "feedback",
"isOptional": false,
"desc": "The generic feedback that the end user wishes to send.",
"type": "'does_not_answer' | 'partially_answers' | 'was_not_a_question'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Allows the user to send feedback about why a particular answer was not relevant."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippet"
},
"desc": "Creates a `SmartSnippet` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "QuestionAnswerDocumentIdentifier",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "contentIdKey",
"isOptional": false,
"type": "string",
"desc": "The content identifier key. Typically, `permanentid` or `urihash`."
},
{
"kind": "primitive",
"name": "contentIdValue",
"isOptional": false,
"type": "string",
"desc": "The content identifier value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "InlineLink",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "linkText",
"isOptional": false,
"type": "string",
"desc": ""
},
{
"kind": "primitive",
"name": "linkURL",
"isOptional": false,
"type": "string",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/smart-snippet/smart-snippet.class.tsx",
"code": "import {\n buildSmartSnippet,\n SmartSnippet as HeadlessSmartSnippet,\n SmartSnippetState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType, createRef} from 'react';\nimport {AppContext} from '../../context/engine';\nimport {filterProtocol} from '../../utils/filter-protocol';\n\nexport class SmartSnippet extends Component<{}, SmartSnippetState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessSmartSnippet;\n private unsubscribe: Unsubscribe = () => {};\n private detailedAnswerRef = createRef<HTMLTextAreaElement>();\n\n componentDidMount() {\n this.controller = buildSmartSnippet(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private answerStyles(expanded: boolean) {\n const maskImage = () =>\n expanded\n ? 'none'\n : 'linear-gradient(to bottom, black 50%, transparent 100%)';\n\n return {\n maxHeight: expanded ? '100%' : '100px',\n maxWidth: '200px',\n overflow: 'hidden',\n marginBottom: '10px',\n maskImage: maskImage(),\n WebkitMaskImage: maskImage(),\n };\n }\n\n renderSource() {\n const {source} = this.state;\n if (!source) {\n return;\n }\n return (\n <a\n href={filterProtocol(source.clickUri)}\n onClick={() => this.controller.selectSource()}\n onContextMenu={() => this.controller.selectSource()}\n onMouseDown={() => this.controller.selectSource()}\n onMouseUp={() => this.controller.selectSource()}\n onTouchStart={() => this.controller.beginDelayedSelectSource()}\n onTouchEnd={() => this.controller.cancelPendingSelectSource()}\n >\n Source\n </a>\n );\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n const {\n answerFound,\n answer,\n question,\n liked,\n disliked,\n expanded,\n feedbackModalOpen,\n } = this.state;\n\n if (!answerFound) {\n return <div>Sorry, no answer has been found for this query.</div>;\n }\n\n if (feedbackModalOpen) {\n return (\n <div role=\"dialog\">\n <h1>What's wrong with this snippet?</h1>\n <fieldset>\n <legend>Give a simple answer</legend>\n <ul>\n <li>\n <button\n onClick={() =>\n this.controller.sendFeedback('does_not_answer')\n }\n >\n It does not answer my question\n </button>\n </li>\n <li>\n <button\n onClick={() =>\n this.controller.sendFeedback('partially_answers')\n }\n >\n It only partially answers my question\n </button>\n </li>\n <li>\n <button\n onClick={() =>\n this.controller.sendFeedback('was_not_a_question')\n }\n >\n I was not asking a question\n </button>\n </li>\n </ul>\n </fieldset>\n OR\n <fieldset>\n <legend>Give a detailed answer</legend>\n <textarea ref={this.detailedAnswerRef}></textarea>\n <button\n onClick={() =>\n this.detailedAnswerRef.current &&\n this.controller.sendDetailedFeedback(\n this.detailedAnswerRef.current.value\n )\n }\n >\n Send feedback\n </button>\n </fieldset>\n <button onClick={() => this.controller.closeFeedbackModal()}>\n Cancel\n </button>\n </div>\n );\n }\n\n return (\n <div style={{textAlign: 'left'}}>\n <dl>\n <dt>{question}</dt>\n <dd>\n <div\n dangerouslySetInnerHTML={{__html: answer}}\n style={this.answerStyles(expanded)}\n ></div>\n <button\n style={{display: expanded ? 'none' : 'block'}}\n onClick={() => this.controller.expand()}\n >\n Show complete answer\n </button>\n <button\n style={{display: expanded ? 'block' : 'none'}}\n onClick={() => this.controller.collapse()}\n >\n Collapse answer\n </button>\n <button\n style={{fontWeight: liked ? 'bold' : 'normal'}}\n onClick={() => this.controller.like()}\n >\n Thumbs up\n </button>\n <button\n style={{fontWeight: disliked ? 'bold' : 'normal'}}\n onClick={() => this.controller.dislike()}\n >\n Thumbs down\n </button>\n {this.renderSource()}\n {disliked ? (\n <button onClick={() => this.controller.openFeedbackModal()}>\n Explain why\n </button>\n ) : (\n []\n )}\n </dd>\n </dl>\n </div>\n );\n }\n}\n",
"fileName": "smart-snippet.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/smart-snippet/smart-snippet.fn.tsx",
"code": "import {SmartSnippet as HeadlessSmartSnippet} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent, useRef} from 'react';\nimport {filterProtocol} from '../../utils/filter-protocol';\n\ninterface SmartSnippetProps {\n controller: HeadlessSmartSnippet;\n}\n\nexport const SmartSnippet: FunctionComponent<SmartSnippetProps> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n const detailedAnswerRef = useRef<HTMLTextAreaElement>(null);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const answerStyles = (expanded: boolean) => {\n const maskImage = () =>\n expanded\n ? 'none'\n : 'linear-gradient(to bottom, black 50%, transparent 100%)';\n\n return {\n maxHeight: expanded ? '100%' : '100px',\n maxWidth: '200px',\n overflow: 'hidden',\n marginBottom: '10px',\n maskImage: maskImage(),\n WebkitMaskImage: maskImage(),\n };\n };\n\n const {\n answerFound,\n answer,\n question,\n liked,\n disliked,\n expanded,\n source,\n feedbackModalOpen,\n } = state;\n\n if (!answerFound) {\n return <div>Sorry, no answer has been found for this query.</div>;\n }\n\n function renderSource() {\n if (!source) {\n return;\n }\n return (\n <a\n href={filterProtocol(source.clickUri)}\n onClick={() => controller.selectSource()}\n onContextMenu={() => controller.selectSource()}\n onMouseDown={() => controller.selectSource()}\n onMouseUp={() => controller.selectSource()}\n onTouchStart={() => controller.beginDelayedSelectSource()}\n onTouchEnd={() => controller.cancelPendingSelectSource()}\n >\n Source\n </a>\n );\n }\n\n if (feedbackModalOpen) {\n return (\n <div role=\"dialog\">\n <h1>What's wrong with this snippet?</h1>\n <fieldset>\n <legend>Give a simple answer</legend>\n <ul>\n <li>\n <button\n onClick={() => controller.sendFeedback('does_not_answer')}\n >\n It does not answer my question\n </button>\n </li>\n <li>\n <button\n onClick={() => controller.sendFeedback('partially_answers')}\n >\n It only partially answers my question\n </button>\n </li>\n <li>\n <button\n onClick={() => controller.sendFeedback('was_not_a_question')}\n >\n I was not asking a question\n </button>\n </li>\n </ul>\n </fieldset>\n OR\n <fieldset>\n <legend>Give a detailed answer</legend>\n <textarea ref={detailedAnswerRef}></textarea>\n <button\n onClick={() =>\n detailedAnswerRef.current &&\n controller.sendDetailedFeedback(detailedAnswerRef.current.value)\n }\n >\n Send feedback\n </button>\n </fieldset>\n <button onClick={() => controller.closeFeedbackModal()}>Cancel</button>\n </div>\n );\n }\n\n return (\n <div style={{textAlign: 'left'}}>\n <dl>\n <dt>{question}</dt>\n <dd>\n <div\n dangerouslySetInnerHTML={{__html: answer}}\n style={answerStyles(expanded)}\n ></div>\n <button\n style={{display: expanded ? 'none' : 'block'}}\n onClick={() => controller.expand()}\n >\n Show complete answer\n </button>\n <button\n style={{display: expanded ? 'block' : 'none'}}\n onClick={() => controller.collapse()}\n >\n Collapse answer\n </button>\n <button\n style={{fontWeight: liked ? 'bold' : 'normal'}}\n onClick={() => controller.like()}\n >\n Thumbs up\n </button>\n <button\n style={{fontWeight: disliked ? 'bold' : 'normal'}}\n onClick={() => controller.dislike()}\n >\n Thumbs down\n </button>\n {renderSource()}\n {disliked ? (\n <button onClick={() => controller.openFeedbackModal()}>\n Explain why\n </button>\n ) : (\n []\n )}\n </dd>\n </dl>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildSmartSnippet(engine);\n *\n * <SmartSnippet controller={controller} />;\n * ```\n */\n",
"fileName": "smart-snippet.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildSmartSnippetQuestionsList",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `SmartSnippetQuestionsList` properties.",
"type": "SmartSnippetQuestionsListProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "SmartSnippetQuestionsListOptions",
"desc": "The options for the `SmartSnippetQuestionsList` controller.",
"members": [
{
"kind": "primitive",
"name": "selectionDelay",
"isOptional": true,
"type": "number",
"desc": "The amount of time in milliseconds to wait before selecting the source after calling `beginDelayedSelect`.",
"defaultValue": "`1000`"
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippetQuestionsListOptions"
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippetQuestionsListProps"
}
],
"returnType": {
"kind": "object",
"name": "SmartSnippetQuestionsList",
"isOptional": false,
"type": "SmartSnippetQuestionsList",
"desc": "The `SmartSnippetQuestionsList` controller allows to manage additional queries for which a SmartSnippet model can provide relevant excerpts.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "SmartSnippetQuestionsListState",
"desc": "The state of the SmartSnippetQuestionsList controller.",
"members": [
{
"kind": "object",
"name": "questions",
"isOptional": false,
"type": "SmartSnippetRelatedQuestion[]",
"desc": "The related questions for the current query",
"members": [],
"isTypeExtracted": true,
"typeName": "SmartSnippetRelatedQuestion"
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippetQuestionsListState"
},
{
"kind": "function",
"name": "beginDelayedSelectInlineLink",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet containing the link.",
"type": "string"
},
{
"kind": "object",
"name": "link",
"isOptional": false,
"desc": "The link to select.",
"type": "InlineLink",
"members": [],
"isTypeExtracted": true,
"typeName": "InlineLink"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Prepares to select a link inside an answer after a certain delay, sending analytics if it was never selected before.\n\nIn a DOM context, we recommend calling this method on the `touchstart` event."
},
{
"kind": "function",
"name": "beginDelayedSelectSource",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet to collapse.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Prepares to select the source after a certain delay, sending analytics if it hadn't been selected before.\n\nIn a DOM context, we recommend calling this method on the `touchstart` event."
},
{
"kind": "function",
"name": "cancelPendingSelectInlineLink",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet containing the link.",
"type": "string"
},
{
"kind": "object",
"name": "link",
"isOptional": false,
"desc": "The link to select.",
"type": "InlineLink",
"members": [],
"isTypeExtracted": true,
"typeName": "InlineLink"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Cancels the pending selection caused by `beginDelayedSelectInlineLink`.\n\nIn a DOM context, we recommend calling this method on the `touchend` event."
},
{
"kind": "function",
"name": "cancelPendingSelectSource",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet to collapse.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Cancels the pending selection caused by `beginDelayedSelect`.\n\nIn a DOM context, we recommend calling this method on the `touchend` event."
},
{
"kind": "function",
"name": "collapse",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet to collapse.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Collapse the specified snippet suggestion."
},
{
"kind": "function",
"name": "expand",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet to expand.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Expand the specified snippet suggestion."
},
{
"kind": "function",
"name": "selectInlineLink",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet containing the link.",
"type": "string"
},
{
"kind": "object",
"name": "link",
"isOptional": false,
"desc": "The link to select.",
"type": "InlineLink",
"members": [],
"isTypeExtracted": true,
"typeName": "InlineLink"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects a link inside an answer, logging a UA event to the Coveo Platform if it was never selected before.\n\nIn a DOM context, we recommend calling this method on all of the following events: * `contextmenu` * `click` * `mouseup` * `mousedown`"
},
{
"kind": "function",
"name": "selectSource",
"params": [
{
"kind": "primitive",
"name": "identifier",
"isOptional": false,
"desc": "The `questionAnswerId` of the smart snippet to collapse.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Selects the source, logging a UA event to the Coveo Platform if the source hadn't been selected before.\n\nIn a DOM context, we recommend calling this method on all of the following events: * `contextmenu` * `click` * `mouseup` * `mousedown`"
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "SmartSnippetQuestionsList"
},
"desc": "Creates a `SmartSnippetQuestionsList` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "SmartSnippetRelatedQuestion",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "answer",
"isOptional": false,
"type": "string",
"desc": "The answer, or snippet, related to the question.\n\nThis can contain HTML markup, depending on the source of the answer."
},
{
"kind": "object",
"name": "documentId",
"isOptional": false,
"type": "QuestionAnswerDocumentIdentifier",
"desc": "The index identifier for the document that provided the answer.",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnswerDocumentIdentifier"
},
{
"kind": "primitive",
"name": "expanded",
"isOptional": false,
"type": "boolean",
"desc": "Determines if the snippet is currently expanded."
},
{
"kind": "primitive",
"name": "question",
"isOptional": false,
"type": "string",
"desc": "The question related to the smart snippet."
},
{
"kind": "primitive",
"name": "questionAnswerId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier for this question & answer."
},
{
"kind": "object",
"name": "source",
"isOptional": true,
"type": "Result",
"desc": "Provides the source of the smart snippet.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QuestionAnswerDocumentIdentifier",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "contentIdKey",
"isOptional": false,
"type": "string",
"desc": "The content identifier key. Typically, `permanentid` or `urihash`."
},
{
"kind": "primitive",
"name": "contentIdValue",
"isOptional": false,
"type": "string",
"desc": "The content identifier value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "InlineLink",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "linkText",
"isOptional": false,
"type": "string",
"desc": ""
},
{
"kind": "primitive",
"name": "linkURL",
"isOptional": false,
"type": "string",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/smart-snippet-questions-list/smart-snippet-questions-list.class.tsx",
"code": "import {\n buildSmartSnippetQuestionsList,\n SmartSnippetQuestionsList as HeadlessSmartSnippetQuestionsList,\n SmartSnippetQuestionsListState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class SmartSnippetQuestionsList extends Component<\n {},\n SmartSnippetQuestionsListState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessSmartSnippetQuestionsList;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildSmartSnippetQuestionsList(this.context.engine!);\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n const {questions} = this.state;\n\n if (questions.length === 0) {\n return <div>Sorry, no related questions found</div>;\n }\n\n return (\n <div style={{textAlign: 'left'}}>\n People also ask:\n <dl>\n {questions.map((question) => {\n return (\n <>\n <dt>{question.question}</dt>\n <dd>\n <div\n style={{display: question.expanded ? 'block' : 'none'}}\n dangerouslySetInnerHTML={{__html: question.answer}}\n ></div>\n <button\n style={{display: question.expanded ? 'none' : 'block'}}\n onClick={() =>\n this.controller.expand(question.questionAnswerId)\n }\n >\n Show answer\n </button>\n <button\n style={{display: question.expanded ? 'block' : 'none'}}\n onClick={() =>\n this.controller.collapse(question.questionAnswerId)\n }\n >\n Hide answer\n </button>\n </dd>\n </>\n );\n })}\n </dl>\n </div>\n );\n }\n}\n",
"fileName": "smart-snippet-questions-list.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/smart-snippet-questions-list/smart-snippet-questions-list.fn.tsx",
"code": "import {SmartSnippetQuestionsList as HeadlessSmartSnippetQuestionsList} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface SmartSnippetQuestionsListProps {\n controller: HeadlessSmartSnippetQuestionsList;\n}\n\nexport const SmartSnippetQuestionsList: FunctionComponent<\n SmartSnippetQuestionsListProps\n> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const {questions} = state;\n\n if (questions.length === 0) {\n return <div>Sorry, no related questions found</div>;\n }\n\n return (\n <div style={{textAlign: 'left'}}>\n People also ask:\n <dl>\n {questions.map((question) => {\n return (\n <>\n <dt>{question.question}</dt>\n <dd>\n <div\n style={{display: question.expanded ? 'block' : 'none'}}\n dangerouslySetInnerHTML={{__html: question.answer}}\n ></div>\n <button\n style={{display: question.expanded ? 'none' : 'block'}}\n onClick={() => controller.expand(question.questionAnswerId)}\n >\n Show answer\n </button>\n <button\n style={{display: question.expanded ? 'block' : 'none'}}\n onClick={() => controller.collapse(question.questionAnswerId)}\n >\n Hide answer\n </button>\n </dd>\n </>\n );\n })}\n </dl>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildSmartSnippetQuestionsList(engine);\n *\n * <SmartSnippetQuestionsList controller={controller} />;\n * ```\n */\n",
"fileName": "smart-snippet-questions-list.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildQueryTrigger",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "QueryTrigger",
"isOptional": false,
"type": "QueryTrigger",
"desc": "The `QueryTrigger` controller handles query triggers.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "QueryTriggerState",
"desc": "The state of the `QueryTrigger` controller.",
"members": [
{
"kind": "primitive",
"name": "newQuery",
"isOptional": false,
"type": "string",
"desc": "The new query to perform a search with after receiving a query trigger."
},
{
"kind": "primitive",
"name": "originalQuery",
"isOptional": false,
"type": "string",
"desc": "The query used to perform the search that received a query trigger in its response."
},
{
"kind": "primitive",
"name": "wasQueryModified",
"isOptional": false,
"type": "boolean",
"desc": "A boolean to specify if the controller was triggered resulting in a modification to the query."
}
],
"isTypeExtracted": false,
"typeName": "QueryTriggerState"
},
{
"kind": "function",
"name": "undo",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Undoes a query trigger's correction."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "QueryTrigger"
},
"desc": "Creates a `QueryTrigger` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/triggers/query-trigger.class.tsx",
"code": "import {\n buildQueryTrigger,\n QueryTrigger as HeadlessQueryTrigger,\n QueryTriggerState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class QueryTrigger extends Component<{}, QueryTriggerState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessQueryTrigger;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildQueryTrigger(this.context.engine!);\n this.updateState();\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n if (this.state.wasQueryModified) {\n return (\n <div>\n The query changed from {this.state.originalQuery + ' '}\n to {this.state.newQuery}\n </div>\n );\n }\n return null;\n }\n}\n",
"fileName": "query-trigger.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/triggers/query-trigger.fn.tsx",
"code": "import {QueryTrigger as HeadlessQueryTrigger} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface HeadlessQueryTriggerProps {\n controller: HeadlessQueryTrigger;\n}\n\nexport const QueryTrigger: FunctionComponent<HeadlessQueryTriggerProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => updateState()), []);\n\n const updateState = () => {\n setState(props.controller.state);\n };\n\n if (state.wasQueryModified) {\n return (\n <div>\n The query changed from {state.originalQuery} to {state.newQuery}\n </div>\n );\n }\n return null;\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildQueryTrigger(engine);\n *\n * <QueryTriggerFn controller={controller} />;\n * ```\n */\n",
"fileName": "query-trigger.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildExecuteTrigger",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "ExecuteTrigger",
"isOptional": false,
"type": "ExecuteTrigger",
"desc": "The `ExecuteTrigger` controller handles execute trigger actions.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "ExecuteTriggerState",
"desc": "The state of the `ExecuteTrigger` controller.",
"members": [
{
"kind": "object",
"name": "executions",
"isOptional": false,
"type": "FunctionExecutionTrigger[]",
"desc": "The functions to be executed.",
"members": [],
"isTypeExtracted": true,
"typeName": "FunctionExecutionTrigger"
}
],
"isTypeExtracted": false,
"typeName": "ExecuteTriggerState"
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "ExecuteTrigger"
},
"desc": "Creates a `ExecuteTrigger` controller instance. An execute trigger is configured in the Administration console, and used to execute a function in the browser when a certain condition is met."
},
"extractedTypes": [
{
"kind": "object",
"name": "FunctionExecutionTrigger",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "functionName",
"isOptional": false,
"type": "string",
"desc": "The name of the function to execute."
},
{
"kind": "primitive-with-type-alias",
"name": "params",
"isOptional": false,
"type": "(string | number | boolean)[]",
"desc": "The parameters of the function to execute."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/triggers/execute-trigger.class.tsx",
"code": "import {\n buildExecuteTrigger,\n ExecuteTrigger as HeadlessExecuteTrigger,\n ExecuteTriggerState,\n ExecuteTriggerParams,\n Unsubscribe,\n FunctionExecutionTrigger,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class ExecuteTrigger extends Component<{}, ExecuteTriggerState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessExecuteTrigger;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildExecuteTrigger(this.context.engine!);\n this.unsubscribe = this.controller.subscribe(() =>\n this.controller.state.executions.forEach((execution) =>\n this.executeFunction(execution)\n )\n );\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private executeFunction = (execution: FunctionExecutionTrigger) => {\n const {functionName, params} = execution;\n\n if (functionName === 'log') {\n this.log(params);\n }\n };\n\n private log = (params: ExecuteTriggerParams) => {\n console.log('params: ', params);\n };\n\n render() {\n return null;\n }\n}\n",
"fileName": "execute-trigger.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/triggers/execute-trigger.tsx",
"code": "import {\n buildExecuteTrigger,\n SearchEngine,\n ExecuteTriggerParams,\n FunctionExecutionTrigger,\n} from '@coveo/headless';\n\n/**\n * This sample creates an instance of the headless execute trigger controller\n * and shows how to utilize the controller with the user defined functions.\n *\n * @param engine - a headless search engine instance\n * @returns An unsubscribe function\n */\nexport function bindExecuteTrigger(engine: SearchEngine) {\n const controller = buildExecuteTrigger(engine);\n\n const executeFunction = (execution: FunctionExecutionTrigger) => {\n const {functionName, params} = execution;\n\n if (functionName === 'log') {\n log(params);\n }\n };\n\n const log = (params: ExecuteTriggerParams) => {\n console.log('params: ', params);\n };\n\n const unsubscribe = controller.subscribe(() =>\n controller.state.executions.forEach((execution) =>\n executeFunction(execution)\n )\n );\n return unsubscribe;\n}\n",
"fileName": "execute-trigger.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildNotifyTrigger",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "NotifyTrigger",
"isOptional": false,
"type": "NotifyTrigger",
"desc": "The `NotifyTrigger` controller handles Notify triggers.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "NotifyTriggerState",
"desc": "the state of the `NotifyTrigger` controller.",
"members": [
{
"kind": "primitive",
"name": "notifications",
"isOptional": false,
"type": "string[]",
"desc": "The notifications to display to the user after receiving notification triggers."
}
],
"isTypeExtracted": false,
"typeName": "NotifyTriggerState"
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "NotifyTrigger"
},
"desc": "Creates a `NotifyTrigger` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/triggers/notify-trigger.class.tsx",
"code": "import {\n buildNotifyTrigger,\n NotifyTrigger as HeadlessNotifyTrigger,\n NotifyTriggerState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class NotifyTrigger extends Component<{}, NotifyTriggerState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessNotifyTrigger;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildNotifyTrigger(this.context.engine!);\n this.updateState();\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state, () => {\n this.state.notifications.forEach((notification) => {\n alert('Notification: ' + notification);\n });\n });\n }\n\n render() {\n return null;\n }\n}\n",
"fileName": "notify-trigger.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/triggers/notify-trigger.fn.tsx",
"code": "import {NotifyTrigger as HeadlessNotifyTrigger} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface HeadlessNotifyTriggerProps {\n controller: HeadlessNotifyTrigger;\n}\n\nexport const NotifyTrigger: FunctionComponent<HeadlessNotifyTriggerProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => updateState()), []);\n useEffect(() => notify(), [state.notifications]);\n\n const updateState = () => {\n setState(props.controller.state);\n };\n\n const notify = () => {\n state.notifications.forEach((notification) => {\n alert('Notification: ' + notification);\n });\n };\n\n return null;\n};\n\n// usage\n\n/**\n * ```tsx\n * const controller = buildNotifyTrigger(engine);\n *\n * <NotifyTriggerFn controller={controller} />;\n * ```\n */\n",
"fileName": "notify-trigger.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildRedirectionTrigger",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "RedirectionTrigger",
"isOptional": false,
"type": "RedirectionTrigger",
"desc": "The `RedirectionTrigger` controller handles redirection actions.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "RedirectionTriggerState",
"desc": "the state of the `RedirectionTrigger` controller.",
"members": [
{
"kind": "primitive",
"name": "redirectTo",
"isOptional": false,
"type": "string",
"desc": "The url used for the redirection."
}
],
"isTypeExtracted": false,
"typeName": "RedirectionTriggerState"
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "RedirectionTrigger"
},
"desc": "Creates a `RedirectionTrigger` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/triggers/redirection-trigger.class.tsx",
"code": "import {\n buildRedirectionTrigger,\n RedirectionTrigger as HeadlessRedirectionTrigger,\n RedirectionTriggerState,\n Unsubscribe,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class RedirectionTrigger extends Component<{}, RedirectionTriggerState> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessRedirectionTrigger;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildRedirectionTrigger(this.context.engine!);\n this.redirect();\n this.unsubscribe = this.controller.subscribe(() => this.redirect());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private redirect() {\n this.setState(this.controller.state, () => {\n if (!this.controller.state.redirectTo) {\n return;\n }\n window.location.replace(this.controller.state.redirectTo);\n });\n }\n\n render() {\n return null;\n }\n}\n",
"fileName": "redirection-trigger.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/triggers/redirection-trigger.fn.tsx",
"code": "import {RedirectionTrigger as HeadlessRedirectionTrigger} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface HeadlessRedirectionTriggerProps {\n controller: HeadlessRedirectionTrigger;\n}\n\nexport const RedirectionTrigger: FunctionComponent<\n HeadlessRedirectionTriggerProps\n> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => redirect()), []);\n useEffect(() => redirect(), [state.redirectTo]);\n\n const redirect = () => {\n setState(props.controller.state);\n if (state.redirectTo) {\n window.location.replace(controller.state.redirectTo);\n }\n };\n\n return null;\n};\n",
"fileName": "redirection-trigger.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildFieldSuggestions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `FieldSuggestions` controller properties.",
"type": "FieldSuggestionsProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "FieldSuggestionsOptions",
"desc": "The options for the `FieldSuggestions` controller.",
"members": [
{
"kind": "object",
"name": "facet",
"isOptional": false,
"type": "FacetOptions",
"desc": "The options used to register the facet used by the field suggestions controller.",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetOptions"
}
],
"isTypeExtracted": false,
"typeName": "FieldSuggestionsOptions"
}
],
"isTypeExtracted": false,
"typeName": "FieldSuggestionsProps"
}
],
"returnType": {
"kind": "object",
"name": "FieldSuggestions",
"isOptional": false,
"type": "FieldSuggestions",
"desc": "The `FieldSuggestions` controller provides query suggestions based on a particular facet field.\n\nFor example, you could use this controller to provide auto-completion suggestions while the end user is typing an item title.\n\nThis controller is a wrapper around the basic facet controller search functionality, and thus exposes similar options and properties.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "FieldSuggestionsState",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Whether the request for field suggestions is in progress."
},
{
"kind": "primitive",
"name": "moreValuesAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more field suggestions are available."
},
{
"kind": "primitive",
"name": "query",
"isOptional": false,
"type": "string",
"desc": "The query used to request field suggestions."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "FieldSuggestionsValue[]",
"desc": "The field suggestions.",
"members": [],
"isTypeExtracted": true,
"typeName": "FieldSuggestionsValue"
}
],
"isTypeExtracted": false,
"typeName": "FieldSuggestionsState"
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Resets the query and empties the suggestions."
},
{
"kind": "function",
"name": "search",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Requests field suggestions based on a query."
},
{
"kind": "function",
"name": "select",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The field suggestion for which to select the matching facet value.",
"type": "FieldSuggestionsValue",
"members": [],
"isTypeExtracted": true,
"typeName": "FieldSuggestionsValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Filters the search using the specified value.\n\nIf a facet exists with the configured `facetId`, selects the corresponding facet value."
},
{
"kind": "function",
"name": "showMoreResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Shows more field suggestions for the current query."
},
{
"kind": "function",
"name": "singleSelect",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The field suggestion for which to select the matching facet value.",
"type": "FieldSuggestionsValue",
"members": [],
"isTypeExtracted": true,
"typeName": "FieldSuggestionsValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Filters the search using the specified value, deselecting others.\n\nIf a facet exists with the configured `facetId`, selects the corresponding facet value while deselecting other facet values."
},
{
"kind": "function",
"name": "updateCaptions",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "captions",
"isOptional": false,
"desc": "A dictionary that maps field values to field suggestion display names.",
"type": "Record<string, string>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the captions of field suggestions."
},
{
"kind": "function",
"name": "updateText",
"params": [
{
"kind": "primitive",
"name": "text",
"isOptional": false,
"desc": "The query to search.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Requests field suggestions based on a query."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "FieldSuggestions"
},
"desc": "Creates a `FieldSuggestions` controller instance.\n\nThis controller initializes a facet under the hood, but exposes state and methods that are relevant for suggesting field values based on a query. It's important not to initialize a facet with the same `facetId` but different options, because only the options of the controller which is built first will be taken into account."
},
"extractedTypes": [
{
"kind": "object",
"name": "FacetOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "allowedValues",
"isOptional": true,
"type": "string[]",
"desc": "Specifies an explicit list of `allowedValues` in the Search API request.\n\nIf you specify a list of values for this option, the facet uses only these values (if they are available in the current result set).\n\nThe maximum amount of allowed values is 25.\n\nDefault value is `undefined`, and the facet uses all available values for its `field` in the current result set."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a random unique identifier is generated."
},
{
"kind": "object",
"name": "facetSearch",
"isOptional": true,
"type": "FacetSearchOptions",
"desc": "Facet search options.",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetSearchOptions"
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude the parents of folded results when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "hasBreadcrumbs",
"isOptional": true,
"type": "boolean",
"desc": "Specifies whether breadcrumbs appear for the facet",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`8`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'score' | 'alphanumeric' | 'occurrences' | 'automatic'",
"desc": "The criterion to use for sorting returned facet values. Learn more about `sortCriteria` values and the default behavior of specific facets in the [Search API documentation](https://docs.coveo.com/en/1461/build-a-search-ui/query-parameters#RestFacetRequest-sortCriteria).",
"defaultValue": "`automatic`"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FacetSearchOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "captions",
"isOptional": true,
"type": "Record<string, string>",
"desc": "A dictionary that maps index field values to facet value display names."
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The maximum number of values to fetch.",
"defaultValue": "`10`"
},
{
"kind": "primitive",
"name": "query",
"isOptional": true,
"type": "string",
"desc": "The query to search the facet values with."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FieldSuggestionsValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "count",
"isOptional": false,
"type": "number",
"desc": "An estimated number of result items matching both the current query and the filter expression that would get generated if this field suggestion was selected."
},
{
"kind": "primitive",
"name": "displayValue",
"isOptional": false,
"type": "string",
"desc": "The custom field suggestion display name, as specified in the `captions` argument of the `FieldSuggestion` controller."
},
{
"kind": "primitive",
"name": "rawValue",
"isOptional": false,
"type": "string",
"desc": "The original field value, as retrieved from the field in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/field-suggestions/specific-field/field-suggestions.class.tsx",
"code": "import {\n FieldSuggestions as HeadlessFieldSuggestions,\n FieldSuggestionsOptions,\n Unsubscribe,\n buildFieldSuggestions,\n FacetSearchState,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../../context/engine';\n\ntype FieldSuggestionsFacetOptions = FieldSuggestionsOptions['facet'];\n\ninterface FieldSuggestionsProps extends FieldSuggestionsFacetOptions {\n facetId: string;\n}\n\nexport class FieldSuggestions extends Component<\n FieldSuggestionsProps,\n FacetSearchState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessFieldSuggestions;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildFieldSuggestions(this.context.engine!, {\n options: {facet: this.props},\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private onInput(text: string) {\n if (text === '') {\n this.controller.clear();\n return;\n }\n this.controller.updateText(text);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n <input onInput={(e) => this.onInput(e.currentTarget.value)} />\n <ul>\n {this.state.values.map((facetSearchValue) => (\n <li\n key={facetSearchValue.rawValue}\n onClick={() => this.controller.select(facetSearchValue)}\n >\n {facetSearchValue.displayValue} ({facetSearchValue.count} results)\n </li>\n ))}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "field-suggestions.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/field-suggestions/specific-field/field-suggestions.fn.tsx",
"code": "import {FieldSuggestions as HeadlessFieldSuggestions} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface FieldSuggestionsProps {\n controller: HeadlessFieldSuggestions;\n}\n\nexport const FieldSuggestions: FunctionComponent<FieldSuggestionsProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const onInput = (text: string) => {\n if (text === '') {\n controller.clear();\n return;\n }\n controller.updateText(text);\n };\n\n return (\n <div>\n <input onInput={(e) => onInput(e.currentTarget.value)} />\n <ul>\n {state.values.map((facetSearchValue) => (\n <li\n key={facetSearchValue.rawValue}\n onClick={() => controller.select(facetSearchValue)}\n >\n {facetSearchValue.displayValue} ({facetSearchValue.count} results)\n </li>\n ))}\n </ul>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const options: FieldSuggestionsOptions = {field: 'author'};\n * const controller = buildFieldSuggestions(engine, {options});\n *\n * <FieldSuggestions controller={controller} />;\n * ```\n */\n",
"fileName": "field-suggestions.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildCategoryFieldSuggestions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `CategoryFieldSuggestions` controller properties.",
"type": "CategoryFieldSuggestionsProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "CategoryFieldSuggestionsOptions",
"desc": "The options for the `CategoryFieldSuggestions` controller.",
"members": [
{
"kind": "object",
"name": "facet",
"isOptional": false,
"type": "CategoryFacetOptions",
"desc": "The options used to register the category facet used under the hood by the field suggestions controller.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetOptions"
}
],
"isTypeExtracted": false,
"typeName": "CategoryFieldSuggestionsOptions"
}
],
"isTypeExtracted": false,
"typeName": "CategoryFieldSuggestionsProps"
}
],
"returnType": {
"kind": "object",
"name": "CategoryFieldSuggestions",
"isOptional": false,
"type": "CategoryFieldSuggestions",
"desc": "The `CategoryFieldSuggestions` controller provides query suggestions based on a particular category facet field.\n\nFor example, you could use this controller to provide auto-completion suggestions while the end user is typing an item category.\n\nThis controller is a wrapper around the basic category facet controller search functionality, and thus exposes similar options and properties.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "CategoryFieldSuggestionsState",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Whether the request for field suggestions is in progress."
},
{
"kind": "primitive",
"name": "moreValuesAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more field suggestions are available."
},
{
"kind": "primitive",
"name": "query",
"isOptional": false,
"type": "string",
"desc": "The query used to request field suggestions."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "CategoryFieldSuggestionsValue[]",
"desc": "The field suggestions.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFieldSuggestionsValue"
}
],
"isTypeExtracted": false,
"typeName": "CategoryFieldSuggestionsState"
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Resets the query and empties the suggestions."
},
{
"kind": "function",
"name": "search",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Requests field suggestions based on a query."
},
{
"kind": "function",
"name": "select",
"params": [
{
"kind": "object",
"name": "value",
"isOptional": false,
"desc": "The field suggestion to select.",
"type": "CategoryFieldSuggestionsValue",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFieldSuggestionsValue"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Filters the search using the specified value.\n\nIf a facet exists with the configured `facetId`, selects the corresponding facet value."
},
{
"kind": "function",
"name": "showMoreResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Shows more field suggestions for the current query."
},
{
"kind": "function",
"name": "updateCaptions",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "captions",
"isOptional": false,
"desc": "A dictionary that maps field values to field suggestion display names.",
"type": "Record<string, string>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the captions of field suggestions."
},
{
"kind": "function",
"name": "updateText",
"params": [
{
"kind": "primitive",
"name": "text",
"isOptional": false,
"desc": "The query with which to request field suggestions.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Requests field suggestions based on a query."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "CategoryFieldSuggestions"
},
"desc": "Creates a `CategoryFieldSuggestions` controller instance.\n\nThis controller initializes a category facet under the hood, but exposes state and methods that are relevant for suggesting field values based on a query. It's important not to initialize a category facet with the same `facetId` but different options, because only the options of the controller which is built first will be taken into account."
},
"extractedTypes": [
{
"kind": "object",
"name": "CategoryFacetOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "basePath",
"isOptional": true,
"type": "string[]",
"desc": "The base path shared by all values for the facet.",
"defaultValue": "`[]`"
},
{
"kind": "primitive",
"name": "delimitingCharacter",
"isOptional": true,
"type": "string",
"desc": "The character that specifies the hierarchical dependency.",
"defaultValue": "`;`"
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the controller. By default, a random unique ID is generated."
},
{
"kind": "object",
"name": "facetSearch",
"isOptional": true,
"type": "CategoryFacetSearchOptions",
"desc": "Facet search options.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetSearchOptions"
},
{
"kind": "primitive",
"name": "filterByBasePath",
"isOptional": true,
"type": "boolean",
"desc": "Whether to filter the results using `basePath`.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude the parents of folded results when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all of the potential facet values.\n\n**Note:** A high `injectionDepth` may reduce facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. This option also determines the number of additional values to request each time this facet is expanded, as well as the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`5`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'alphanumeric' | 'occurrences'",
"desc": "The criterion to use for sorting returned facet values.",
"defaultValue": "`occurrences`"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "CategoryFacetSearchOptions",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "captions",
"isOptional": true,
"type": "Record<string, string>",
"desc": "A dictionary that maps index field values to facet value display names."
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The maximum number of values to fetch.",
"defaultValue": "`10`"
},
{
"kind": "primitive",
"name": "query",
"isOptional": true,
"type": "string",
"desc": "The string to match."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "CategoryFieldSuggestionsValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "count",
"isOptional": false,
"type": "number",
"desc": "An estimated number of result items matching both the current query and the filter expression that would get generated if this field suggestion was selected."
},
{
"kind": "primitive",
"name": "displayValue",
"isOptional": false,
"type": "string",
"desc": "The custom field suggestion display name, as specified in the `captions` argument of the `FieldSuggestion` controller."
},
{
"kind": "primitive",
"name": "path",
"isOptional": false,
"type": "string[]",
"desc": "The hierarchical path to the value."
},
{
"kind": "primitive",
"name": "rawValue",
"isOptional": false,
"type": "string",
"desc": "The original field value, as retrieved from the field in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/field-suggestions/category-field/category-suggestions.class.tsx",
"code": "import {\n CategoryFieldSuggestions as HeadlessCategoryFieldSuggestions,\n CategoryFieldSuggestionsOptions,\n Unsubscribe,\n buildCategoryFieldSuggestions,\n CategoryFacetSearchState,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../../context/engine';\n\ntype CategoryFieldSuggestionsFacetOptions =\n CategoryFieldSuggestionsOptions['facet'];\n\ninterface CategoryFieldSuggestionsProps\n extends CategoryFieldSuggestionsFacetOptions {\n facetId: string;\n}\n\nexport class CategoryFieldSuggestions extends Component<\n CategoryFieldSuggestionsProps,\n CategoryFacetSearchState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessCategoryFieldSuggestions;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildCategoryFieldSuggestions(this.context.engine!, {\n options: {facet: this.props},\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n private onInput(text: string) {\n if (text === '') {\n this.controller.clear();\n return;\n }\n this.controller.updateText(text);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n <input onInput={(e) => this.onInput(e.currentTarget.value)} />\n <ul>\n {this.state.values.map((facetSearchValue) => (\n <li\n key={[...facetSearchValue.path, facetSearchValue.rawValue].join(\n '>'\n )}\n onClick={() => this.controller.select(facetSearchValue)}\n >\n {[...facetSearchValue.path, facetSearchValue.displayValue].join(\n ' > '\n )}{' '}\n ({facetSearchValue.count} results)\n </li>\n ))}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "category-suggestions.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/field-suggestions/category-field/category-suggestions.fn.tsx",
"code": "import {CategoryFieldSuggestions as HeadlessCategoryFieldSuggestions} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface CategoryFieldSuggestionsProps {\n controller: HeadlessCategoryFieldSuggestions;\n}\n\nexport const CategoryFieldSuggestions: FunctionComponent<\n CategoryFieldSuggestionsProps\n> = (props) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n const onInput = (text: string) => {\n if (text === '') {\n controller.clear();\n return;\n }\n controller.updateText(text);\n };\n\n return (\n <div>\n <input onInput={(e) => onInput(e.currentTarget.value)} />\n <ul>\n {state.values.map((facetSearchValue) => (\n <li\n key={[...facetSearchValue.path, facetSearchValue.rawValue].join(\n '>'\n )}\n onClick={() => controller.select(facetSearchValue)}\n >\n {[...facetSearchValue.path, facetSearchValue.displayValue].join(\n ' > '\n )}{' '}\n ({facetSearchValue.count} results)\n </li>\n ))}\n </ul>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const options: CategoryFieldSuggestionsOptions = {field: 'geographicalhierarchy'};\n * const controller = buildCategoryFieldSuggestions(engine, {options});\n *\n * <CategoryFieldSuggestions controller={controller} />;\n * ```\n */\n",
"fileName": "category-suggestions.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildRecentQueriesList",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configuration `RecentQueriesList` properties.",
"type": "RecentQueriesListProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "RecentQueriesListInitialState",
"desc": "The initial state that should be applied to the `RecentQueriesList` controller.",
"members": [
{
"kind": "primitive",
"name": "queries",
"isOptional": false,
"type": "string[]",
"desc": "The list of recent queries.",
"defaultValue": "`[]`"
}
],
"isTypeExtracted": false,
"typeName": "RecentQueriesListInitialState"
},
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "RecentQueriesListOptions",
"desc": "The configuration options that should be applied to the `RecentQueriesList` controller.",
"members": [
{
"kind": "primitive",
"name": "maxLength",
"isOptional": false,
"type": "number",
"desc": "The maximum number of queries to retain in the list.",
"defaultValue": "`10`"
},
{
"kind": "primitive",
"name": "clearFilters",
"isOptional": true,
"type": "boolean",
"desc": "Whether to clear all active query filters when the end user submits a new query from the recent queries list. Setting this option to \"false\" is not recommended & can lead to an increasing number of queries returning no results."
}
],
"isTypeExtracted": false,
"typeName": "RecentQueriesListOptions"
}
],
"isTypeExtracted": false,
"typeName": "RecentQueriesListProps"
}
],
"returnType": {
"kind": "object",
"name": "RecentQueriesList",
"isOptional": false,
"type": "RecentQueriesList",
"desc": "The `RecentQueriesList` controller manages the user's recent queries.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "RecentQueriesState",
"desc": "The state of the RecentQueriesList controller.",
"members": [
{
"kind": "primitive",
"name": "analyticsEnabled",
"isOptional": false,
"type": "boolean",
"desc": "Whether analytics & tracking are enabled. In the case where it is disabled, it is recommended not to save recent queries."
},
{
"kind": "primitive",
"name": "maxLength",
"isOptional": false,
"type": "number",
"desc": "The maximum number of queries to retain in the list."
},
{
"kind": "primitive",
"name": "queries",
"isOptional": false,
"type": "string[]",
"desc": "The list of recent queries."
}
],
"isTypeExtracted": false,
"typeName": "RecentQueriesState"
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Clears the recent queries list."
},
{
"kind": "function",
"name": "executeRecentQuery",
"params": [
{
"kind": "primitive",
"name": "index",
"isOptional": false,
"desc": "The index of the recent query to execute.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Executes the given recent query."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "RecentQueriesList"
},
"desc": "Creates a `RecentQueriesList` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/recent-queries/recent-queries.class.tsx",
"code": "import {\n buildRecentQueriesList,\n RecentQueriesListOptions,\n RecentQueriesList as HeadlessRecentQueriesList,\n Unsubscribe,\n RecentQueriesState,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class RecentQueriesList extends Component<\n RecentQueriesListOptions,\n RecentQueriesState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessRecentQueriesList;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildRecentQueriesList(this.context.engine!, {\n options: this.props,\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n Recent queries:\n <ul>\n {this.state.queries.map((query) => (\n <li key={query}>{query}</li>\n ))}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "recent-queries.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/recent-queries/recent-queries.fn.tsx",
"code": "import {RecentQueriesList as HeadlessRecentQueriesList} from '@coveo/headless';\nimport {useEffect, useState} from 'react';\n\nexport interface RecentQueriesProps {\n controller: HeadlessRecentQueriesList;\n}\n\nexport const RecentQueriesList: React.FunctionComponent<RecentQueriesProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <div>\n Recent queries:\n <ul>\n {state.queries.map((query) => (\n <li key={query}>{query}</li>\n ))}\n </ul>\n </div>\n );\n};\n",
"fileName": "recent-queries.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildRecentResultsList",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configuration `RecentResultsList` properties.",
"type": "RecentResultsListProps",
"members": [
{
"kind": "object",
"name": "initialState",
"isOptional": true,
"type": "RecentResultsListInitialState",
"desc": "The initial state that should be applied to the `RecentResultsList` controller.",
"members": [
{
"kind": "object",
"name": "results",
"isOptional": false,
"type": "Result[]",
"desc": "The list of recent results.",
"defaultValue": "`[]`",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": "RecentResultsListInitialState"
},
{
"kind": "object",
"name": "options",
"isOptional": true,
"type": "RecentResultsListOptions",
"desc": "The configuration options that should be applied to the `RecentResultsList` controller.",
"members": [
{
"kind": "primitive",
"name": "maxLength",
"isOptional": false,
"type": "number",
"desc": "The maximum number of results to retain in the list.",
"defaultValue": "`10`"
}
],
"isTypeExtracted": false,
"typeName": "RecentResultsListOptions"
}
],
"isTypeExtracted": false,
"typeName": "RecentResultsListProps"
}
],
"returnType": {
"kind": "object",
"name": "RecentResultsList",
"isOptional": false,
"type": "RecentResultsList",
"desc": "The `RecentResultsList` controller manages the user's recent results.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "RecentResultsState",
"desc": "The state of the RecentResultsList controller.",
"members": [
{
"kind": "primitive",
"name": "maxLength",
"isOptional": false,
"type": "number",
"desc": "The maximum number of results to retain in the list."
},
{
"kind": "object",
"name": "results",
"isOptional": false,
"type": "Result[]",
"desc": "The list of recent results.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": "RecentResultsState"
},
{
"kind": "function",
"name": "clear",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Clears the recent results list."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "RecentResultsList"
},
"desc": "Creates a `RecentResultsList` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/recent-results/recent-results.class.tsx",
"code": "import {\n RecentResultsListOptions,\n RecentResultsList as HeadlessRecentResultsList,\n Unsubscribe,\n buildRecentResultsList,\n RecentResultsState,\n} from '@coveo/headless';\nimport {Component, ContextType} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class RecentResultsList extends Component<\n RecentResultsListOptions,\n RecentResultsState\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controller!: HeadlessRecentResultsList;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n this.controller = buildRecentResultsList(this.context.engine!, {\n options: this.props,\n });\n this.updateState();\n\n this.unsubscribe = this.controller.subscribe(() => this.updateState());\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState(this.controller.state);\n }\n\n render() {\n if (!this.state) {\n return null;\n }\n\n return (\n <div>\n Recent results:\n <ul>\n {this.state.results.map((result) => (\n <li key={result.uniqueId}>{result.title}</li>\n ))}\n </ul>\n </div>\n );\n }\n}\n",
"fileName": "recent-results.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/recent-results/recent-results.fn.tsx",
"code": "import {RecentResultsList as HeadlessRecentResultsList} from '@coveo/headless';\nimport {useEffect, useState} from 'react';\n\nexport interface RecentResultsProps {\n controller: HeadlessRecentResultsList;\n}\n\nexport const RecentResultsList: React.FunctionComponent<RecentResultsProps> = (\n props\n) => {\n const {controller} = props;\n const [state, setState] = useState(controller.state);\n\n useEffect(() => controller.subscribe(() => setState(controller.state)), []);\n\n return (\n <div>\n Recent results:\n <ul>\n {state.results.map((result) => (\n <li key={result.uniqueId}>{result.title}</li>\n ))}\n </ul>\n </div>\n );\n};\n",
"fileName": "recent-results.fn.tsx"
}
]
}
}
}
},
{
"initializer": {
"kind": "function",
"name": "buildInstantResults",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The Headless engine.",
"type": "SearchEngine"
},
{
"kind": "object",
"name": "props",
"isOptional": false,
"desc": "The configurable `InstantResults` properties.",
"type": "InstantResultProps",
"members": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"type": "InstantResultOptions",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "maxResultsPerQuery",
"isOptional": false,
"type": "number",
"desc": "The maximum items to be stored in the instant result list for each query."
},
{
"kind": "primitive",
"name": "cacheTimeout",
"isOptional": true,
"type": "number",
"desc": "Number in milliseconds that cached results will be valid for. Defaults to 1 minute. Set to 0 so that results never expire."
},
{
"kind": "primitive",
"name": "searchBoxId",
"isOptional": true,
"type": "string",
"desc": "A unique identifier for the search box."
}
],
"isTypeExtracted": false,
"typeName": "InstantResultOptions"
}
],
"isTypeExtracted": false,
"typeName": "InstantResultProps"
}
],
"returnType": {
"kind": "object",
"name": "InstantResults",
"isOptional": false,
"type": "InstantResults",
"desc": "The `InstantResults` controller allows the end user to manage instant results queries.",
"members": [
{
"kind": "object",
"name": "state",
"isOptional": false,
"type": "InstantResultsState",
"desc": "The state of the `InstantResults` controller.",
"members": [
{
"kind": "primitive",
"name": "error",
"isOptional": false,
"type": "SearchAPIErrorWithStatusCode | SerializedError | null",
"desc": "An error returned when executing an instant results request, if any. This is `null` otherwise."
},
{
"kind": "primitive",
"name": "isLoading",
"isOptional": false,
"type": "boolean",
"desc": "Determines if a search is in progress for the current query."
},
{
"kind": "primitive",
"name": "q",
"isOptional": false,
"type": "string",
"desc": "The current query for instant results."
},
{
"kind": "object",
"name": "results",
"isOptional": false,
"type": "Result[]",
"desc": "The instant results for the current query.",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"isTypeExtracted": false,
"typeName": "InstantResultsState"
},
{
"kind": "function",
"name": "clearExpired",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Clears all expired instant results queries."
},
{
"kind": "function",
"name": "updateQuery",
"params": [
{
"kind": "primitive",
"name": "q",
"isOptional": false,
"desc": "The query to get instant results for. For more precise instant results, query suggestions are recommended.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "void",
"isOptional": false,
"desc": ""
},
"desc": "Updates the specified query and shows instant results for it."
},
{
"kind": "function",
"name": "subscribe",
"params": [
{
"kind": "primitive",
"name": "listener",
"isOptional": false,
"desc": "A callback that's invoked on state change.",
"type": "() => void"
}
],
"returnType": {
"kind": "object",
"name": "returnType",
"type": "Unsubscribe",
"isOptional": false,
"desc": "A function to remove the listener.",
"members": [],
"isTypeExtracted": true,
"typeName": "Unsubscribe"
},
"desc": "Adds a callback that's invoked on state change."
}
],
"isTypeExtracted": false,
"typeName": "InstantResults"
},
"desc": "Creates an `InstantResults` controller instance."
},
"extractedTypes": [
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated by the index to detail how the item was ranked. This property is null unless the debug query parameter is set to true."
},
{
"kind": "object",
"name": "raw",
"isOptional": false,
"type": "Raw",
"desc": "The values of the fields which were retrieved for this item (see the fieldsToInclude and fieldsToExclude query parameters).",
"members": [],
"isTypeExtracted": true,
"typeName": "Raw"
},
{
"kind": "primitive",
"name": "score",
"isOptional": false,
"type": "number",
"desc": "The total ranking score computed for the item (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "summary",
"isOptional": false,
"type": "null",
"desc": "The item summary (see the summaryLength query parameter)."
},
{
"kind": "object",
"name": "summaryHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item summary string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "title",
"isOptional": false,
"type": "string",
"desc": "Contains the title of the item."
},
{
"kind": "object",
"name": "titleHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item title string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "uniqueId",
"isOptional": false,
"type": "string",
"desc": "The unique item identifier. You should consider the uniqueId value as an opaque string."
},
{
"kind": "primitive",
"name": "uri",
"isOptional": false,
"type": "string",
"desc": "The item URI. Notes: Avoid using the uri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "primitive",
"name": "rankingModifier",
"isOptional": true,
"type": "string",
"desc": "If applicable, represents the type of ranking modification that was applied to this result."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "HighlightKeyword",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "length",
"isOptional": false,
"type": "number",
"desc": "The length of the offset."
},
{
"kind": "primitive",
"name": "offset",
"isOptional": false,
"type": "number",
"desc": "The 0 based offset inside the string where the highlight should start."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Raw",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "[key: string]",
"isOptional": false,
"type": "unknown",
"desc": "Custom keys that depend on the documents in the index."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "Unsubscribe",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "(call)",
"isOptional": false,
"type": "(): void",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
],
"utils": [],
"codeSampleInfo": {
"githubInfo": {
"owner": "coveo",
"repo": "ui-kit",
"ref": "v2.3.0"
},
"samples": {
"react": {
"class": [
{
"path": "packages/samples/headless-react/src/components/instant-results/instant-results.class.tsx",
"code": "import {\n buildSearchBox,\n SearchBox as HeadlessSearchbox,\n buildInstantResults,\n InstantResults as HeadlessInstantResults,\n InstantResultsState,\n Unsubscribe,\n SearchBoxState,\n} from '@coveo/headless';\nimport {Component, ContextType, ReactNode} from 'react';\nimport {AppContext} from '../../context/engine';\n\nexport class InstantResults extends Component<\n {},\n {searchbox: SearchBoxState; instantResults: InstantResultsState}\n> {\n static contextType = AppContext;\n context!: ContextType<typeof AppContext>;\n\n private controllerInstantResults!: HeadlessInstantResults;\n private controllerSearchbox!: HeadlessSearchbox;\n private unsubscribe: Unsubscribe = () => {};\n\n componentDidMount() {\n const sharedIdBetweenSearchboxAndInstantResult = 'sample-instant-results';\n\n this.controllerSearchbox = buildSearchBox(this.context.engine!, {\n options: {id: sharedIdBetweenSearchboxAndInstantResult},\n });\n\n this.controllerInstantResults = buildInstantResults(this.context.engine!, {\n options: {\n maxResultsPerQuery: 5,\n searchBoxId: sharedIdBetweenSearchboxAndInstantResult,\n },\n });\n this.updateState();\n\n const unsubInstantResults = this.controllerInstantResults.subscribe(() =>\n this.updateState()\n );\n const unsubSearchbox = this.controllerSearchbox.subscribe(() => {\n this.updateState();\n });\n\n this.unsubscribe = () => {\n unsubInstantResults();\n unsubSearchbox();\n };\n }\n\n componentWillUnmount() {\n this.unsubscribe();\n }\n\n private updateState() {\n this.setState({\n instantResults: this.controllerInstantResults.state,\n searchbox: this.controllerSearchbox.state,\n });\n }\n\n private isEnterKey(e: React.KeyboardEvent<HTMLInputElement>) {\n return e.key === 'Enter';\n }\n\n render(): ReactNode {\n if (!this.state) {\n return;\n }\n return (\n <div>\n <p>\n Type in the searchbox and hover a query suggestion to preview\n associated results\n </p>\n\n <input\n value={this.state.searchbox.value}\n onChange={(e) => this.controllerSearchbox.updateText(e.target.value)}\n onKeyDown={(e) =>\n this.isEnterKey(e) && this.controllerSearchbox.submit()\n }\n />\n\n <div style={{display: 'flex'}}>\n <ul>\n {this.state.searchbox.suggestions.map((suggestion) => {\n const value = suggestion.rawValue;\n return (\n <li\n key={value}\n onMouseEnter={() =>\n this.controllerInstantResults.updateQuery(value)\n }\n onClick={() =>\n this.controllerSearchbox.selectSuggestion(value)\n }\n >\n {value}\n </li>\n );\n })}\n </ul>\n <ul>\n {this.state.instantResults.results.map((result) => {\n return (\n <li>\n <div>\n {result.title}: {result.raw.source}\n </div>\n <pre>{result.excerpt}</pre>\n </li>\n );\n })}\n </ul>\n </div>\n </div>\n );\n }\n}\n",
"fileName": "instant-results.class.tsx"
}
],
"fn": [
{
"path": "packages/samples/headless-react/src/components/instant-results/instant-results.fn.tsx",
"code": "import {\n SearchBox as HeadlessSearchBox,\n InstantResults as HeadlessInstantResults,\n} from '@coveo/headless';\nimport {useEffect, useState, FunctionComponent} from 'react';\n\ninterface InstantResultsProps {\n controllerSearchbox: HeadlessSearchBox;\n controllerInstantResults: HeadlessInstantResults;\n}\n\nexport const InstantResults: FunctionComponent<InstantResultsProps> = (\n props\n) => {\n const {controllerSearchbox, controllerInstantResults} = props;\n const isEnterKey = (e: React.KeyboardEvent<HTMLInputElement>) =>\n e.key === 'Enter';\n const [searchboxState, setStateSearchbox] = useState(\n controllerSearchbox.state\n );\n const [instantResultsState, setStateInstantResults] = useState(\n controllerInstantResults.state\n );\n\n useEffect(\n () =>\n controllerSearchbox.subscribe(() =>\n setStateSearchbox(controllerSearchbox.state)\n ),\n []\n );\n useEffect(\n () =>\n controllerInstantResults.subscribe(() =>\n setStateInstantResults(controllerInstantResults.state)\n ),\n []\n );\n\n return (\n <div>\n <p>\n Type in the searchbox and hover a query suggestion to preview associated\n results\n </p>\n\n <input\n value={searchboxState.value}\n onChange={(e) => controllerSearchbox.updateText(e.target.value)}\n onKeyDown={(e) => isEnterKey(e) && controllerSearchbox.submit()}\n />\n\n <div style={{display: 'flex'}}>\n <ul>\n {searchboxState.suggestions.map((suggestion) => {\n const value = suggestion.rawValue;\n return (\n <li\n key={value}\n onMouseEnter={() => controllerInstantResults.updateQuery(value)}\n onClick={() => controllerSearchbox.selectSuggestion(value)}\n >\n {value}\n </li>\n );\n })}\n </ul>\n <ul>\n {instantResultsState.results.map((result) => {\n return (\n <li>\n <div>\n {result.title}: {result.raw.source}\n </div>\n <pre>{result.excerpt}</pre>\n </li>\n );\n })}\n </ul>\n </div>\n </div>\n );\n};\n\n// usage\n\n/**\n * ```tsx\n * const controllerSearchbox = buildSearchBox(engine, {options: {id: 'foo'}});\n * const controllerInstantResults = buildInstantResults(engine, {options: {maxResultsPerQuery: 5, searchBoxId: 'foo'}});\n *\n * <InstantResults controllerSearchbox={controllerSearchbox} controllerInstantResults={controllerInstantResults} />;\n * ```\n */\n",
"fileName": "instant-results.fn.tsx"
}
]
}
}
}
}
],
"actions": [
{
"initializer": {
"kind": "function",
"name": "loadSearchActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "SearchActionCreators",
"isOptional": false,
"type": "SearchActionCreators",
"desc": "The search action creators.",
"members": [
{
"kind": "function",
"name": "executeSearch",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "analyticsSearchAction",
"isOptional": false,
"desc": "The analytics action to log after a successful query. See `loadSearchAnalyticsActions` for possible values.",
"type": "SearchAction"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<ExecuteSearchThunkReturn, SearchAction, AsyncThunkOptions<StateNeededByExecuteSearch, ClientThunkExtraArguments<SearchAPIClient>>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Creates an action that executes a search query."
},
{
"kind": "function",
"name": "fetchFacetValues",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "analyticsSearchAction",
"isOptional": false,
"desc": "The analytics action to log after a successful query. See `loadSearchAnalyticsActions` for possible values.",
"type": "SearchAction"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<ExecuteSearchThunkReturn, SearchAction, AsyncThunkOptions<StateNeededByExecuteSearch, ClientThunkExtraArguments<SearchAPIClient>>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Creates an action that only fetches facet values without affecting the rest of the state."
},
{
"kind": "function",
"name": "fetchInstantResults",
"params": [
{
"kind": "object",
"name": "options",
"isOptional": false,
"desc": "The options for fetching instant results.",
"type": "FetchInstantResultsActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "FetchInstantResultsActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<FetchInstantResultsThunkReturn, FetchInstantResultsActionCreatorPayload, AsyncThunkSearchOptions<StateNeededByExecuteSearch & InstantResultSection>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Creates an action that fetches instant results."
},
{
"kind": "function",
"name": "fetchMoreResults",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<ExecuteSearchThunkReturn, void, AsyncThunkOptions<StateNeededByExecuteSearch, ClientThunkExtraArguments<SearchAPIClient>>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Creates an action that fetches more results."
},
{
"kind": "function",
"name": "fetchPage",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "analyticsSearchAction",
"isOptional": false,
"desc": "The analytics action to log after a successful query. See `loadSearchAnalyticsActions` for possible values.",
"type": "SearchAction"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<ExecuteSearchThunkReturn, SearchAction, AsyncThunkOptions<StateNeededByExecuteSearch, ClientThunkExtraArguments<SearchAPIClient>>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Creates an action that executes a search query to fetch a new page of results."
}
],
"isTypeExtracted": false,
"typeName": "SearchActionCreators"
},
"desc": "Loads the `search` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "FetchInstantResultsActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The search box ID."
},
{
"kind": "primitive",
"name": "maxResultsPerQuery",
"isOptional": false,
"type": "number",
"desc": "The maximum items to be stored in the instant result list for each query."
},
{
"kind": "primitive",
"name": "q",
"isOptional": false,
"type": "string",
"desc": "The query for which instant results are retrieved."
},
{
"kind": "primitive",
"name": "cacheTimeout",
"isOptional": true,
"type": "number",
"desc": "Number in milliseconds that cached results will be valid for. Set to 0 so that results never expire."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadAdvancedSearchQueryActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "AdvancedSearchQueryActionCreators",
"isOptional": false,
"type": "AdvancedSearchQueryActionCreators",
"desc": "The advanced search query action creators.",
"members": [
{
"kind": "function",
"name": "registerAdvancedSearchQueries",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The initial state of the advanced search queries.",
"type": "AdvancedSearchQueryActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "AdvancedSearchQueryActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<AdvancedSearchQueryActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers the initial state of the advanced search queries."
},
{
"kind": "function",
"name": "updateAdvancedSearchQueries",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The current state of the advanced search queries.",
"type": "AdvancedSearchQueryActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "AdvancedSearchQueryActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<AdvancedSearchQueryActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Update the values of the advanced search queries."
}
],
"isTypeExtracted": false,
"typeName": "AdvancedSearchQueryActionCreators"
},
"desc": "Loads the `advancedSearchQueries` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "AdvancedSearchQueryActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "aq",
"isOptional": true,
"type": "string",
"desc": "The advanced query."
},
{
"kind": "primitive",
"name": "cq",
"isOptional": true,
"type": "string",
"desc": "The constant query."
},
{
"kind": "primitive",
"name": "dq",
"isOptional": true,
"type": "string",
"desc": "The disjunction query"
},
{
"kind": "primitive",
"name": "lq",
"isOptional": true,
"type": "string",
"desc": "The large query."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadConfigurationActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "ConfigurationActionCreators",
"isOptional": false,
"type": "ConfigurationActionCreators",
"desc": "The configuration action creators.",
"members": [
{
"kind": "function",
"name": "disableAnalytics",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Disables analytics tracking."
},
{
"kind": "function",
"name": "enableAnalytics",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Enables analytics tracking."
},
{
"kind": "function",
"name": "setOriginLevel2",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "SetOriginLevel2ActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "SetOriginLevel2ActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<SetOriginLevel2ActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Sets originLevel2 for analytics tracking."
},
{
"kind": "function",
"name": "setOriginLevel3",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "SetOriginLevel3ActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "SetOriginLevel3ActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<SetOriginLevel3ActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Sets originLevel3 for analytics tracking."
},
{
"kind": "function",
"name": "updateAnalyticsConfiguration",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateAnalyticsConfigurationActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateAnalyticsConfigurationActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateAnalyticsConfigurationActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the analytics configuration."
},
{
"kind": "function",
"name": "updateBasicConfiguration",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateBasicConfigurationActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateBasicConfigurationActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateBasicConfigurationActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the global headless engine configuration."
}
],
"isTypeExtracted": false,
"typeName": "ConfigurationActionCreators"
},
"desc": "Loads the `configuration` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "SetOriginLevel2ActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "originLevel2",
"isOptional": false,
"type": "string",
"desc": "The origin level 2 usage analytics event metadata whose value should typically be the identifier of the tab (e.g., `All`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "SetOriginLevel3ActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "originLevel3",
"isOptional": false,
"type": "string",
"desc": "The origin level 3 usage analytics event metadata whose value should typically be the URL of the page that linked to the search interface (e.g., `https://connect.coveo.com/s/`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateAnalyticsConfigurationActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "anonymous",
"isOptional": true,
"type": "boolean",
"desc": "Whether analytics events should be logged anonymously. If set to true, the Usage Analytics Write API will not extract the name and userDisplayName, if present, from the search token"
},
{
"kind": "primitive",
"name": "apiBaseUrl",
"isOptional": true,
"type": "string",
"desc": "The Usage Analytics API base URL to use (e.g., `https://platform.cloud.coveo.com/rest/ua`)."
},
{
"kind": "primitive",
"name": "deviceId",
"isOptional": true,
"type": "string",
"desc": "The name of the device that the end user is using. It should be explicitly configured in the context of a native mobile app."
},
{
"kind": "primitive",
"name": "documentLocation",
"isOptional": true,
"type": "string",
"desc": "Specifies the URL of the current page or component."
},
{
"kind": "primitive",
"name": "enabled",
"isOptional": true,
"type": "boolean",
"desc": "Whether to enable usage analytics tracking."
},
{
"kind": "primitive",
"name": "originContext",
"isOptional": true,
"type": "string",
"desc": "Sets the Origin Context dimension on the analytic events.\n\nYou can use this dimension to specify the context of your application. Suggested values are \"Search\", \"InternalSearch\" and \"CommunitySearch\""
},
{
"kind": "primitive",
"name": "originLevel2",
"isOptional": true,
"type": "string",
"desc": "The origin level 2 usage analytics event metadata whose value should typically be the identifier of the tab from which the usage analytics event originates (e.g., `All`)."
},
{
"kind": "primitive",
"name": "originLevel3",
"isOptional": true,
"type": "string",
"desc": "The origin level 3 usage analytics event metadata whose value should typically be the URL of the page that linked to the search interface that’s making the request (e.g., `https://connect.coveo.com/s/`)."
},
{
"kind": "primitive-with-type-alias",
"name": "runtimeEnvironment",
"isOptional": true,
"type": "IRuntimeEnvironment",
"desc": "The Coveo analytics runtime to use, see https://github.com/coveo/coveo.analytics.js for more info."
},
{
"kind": "primitive",
"name": "userDisplayName",
"isOptional": true,
"type": "string",
"desc": "Specifies the user display name for the usage analytics logs."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateBasicConfigurationActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "accessToken",
"isOptional": true,
"type": "string",
"desc": "The access token to use to authenticate requests against the Coveo Cloud endpoints. Typically, this will be an API key or search token that grants the privileges to execute queries and push usage analytics data in the target Coveo Cloud organization."
},
{
"kind": "primitive",
"name": "organizationId",
"isOptional": true,
"type": "string",
"desc": "The unique identifier of the target Coveo Cloud organization (e.g., `mycoveocloudorganizationg8tp8wu3`)"
},
{
"kind": "primitive",
"name": "platformUrl",
"isOptional": true,
"type": "string",
"desc": "The Plaform URL to use (e.g., `https://platform.cloud.coveo.com`)."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadSearchConfigurationActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "RecommendationEngine | SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "SearchConfigurationActionCreators",
"isOptional": false,
"type": "SearchConfigurationActionCreators",
"desc": "The search configuration action creators.",
"members": [
{
"kind": "function",
"name": "updateSearchConfiguration",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateSearchConfigurationActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateSearchConfigurationActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateSearchConfigurationActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the search configuration."
}
],
"isTypeExtracted": false,
"typeName": "SearchConfigurationActionCreators"
},
"desc": "Loads the necessary reducers and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "UpdateSearchConfigurationActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "apiBaseUrl",
"isOptional": true,
"type": "string",
"desc": "The Search API base URL to use (e.g., `https://platform.cloud.coveo.com/rest/search/v2`)."
},
{
"kind": "primitive",
"name": "authenticationProviders",
"isOptional": true,
"type": "string[]",
"desc": "Specifies the name of the authentication providers to use to perform queries.\n\nSee [SAML Authentication](https://docs.coveo.com/en/91/)."
},
{
"kind": "primitive",
"name": "locale",
"isOptional": true,
"type": "string",
"desc": "The locale of the current user. Must comply with IETF’s BCP 47 definition: https://www.rfc-editor.org/rfc/bcp/bcp47.txt."
},
{
"kind": "primitive",
"name": "pipeline",
"isOptional": true,
"type": "string",
"desc": "The name of the query pipeline to use for the query (e.g., `External Search`)."
},
{
"kind": "primitive",
"name": "searchHub",
"isOptional": true,
"type": "string",
"desc": "The first level of origin of the request, typically the identifier of the graphical search interface from which the request originates (e.g., `ExternalSearch`)."
},
{
"kind": "primitive",
"name": "timezone",
"isOptional": true,
"type": "string",
"desc": "The [tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) identifier of the time zone of the user."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadContextActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "ContextActionCreators",
"isOptional": false,
"type": "ContextActionCreators",
"desc": "The context action creators.",
"members": [
{
"kind": "function",
"name": "addContext",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "AddContextActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "AddContextActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<AddContextActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Adds a new context value."
},
{
"kind": "function",
"name": "removeContext",
"params": [
{
"kind": "primitive",
"name": "key",
"isOptional": false,
"desc": "The key to remove from the context (e.g., \"age\").",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Removes a context key-value pair."
},
{
"kind": "function",
"name": "setContext",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "Record<string, ContextValue>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<ContextPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Sets the query context."
}
],
"isTypeExtracted": false,
"typeName": "ContextActionCreators"
},
"desc": "Loads the `context` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "AddContextActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "contextKey",
"isOptional": false,
"type": "string",
"desc": "The name of the key to store the context value in."
},
{
"kind": "primitive-with-type-alias",
"name": "contextValue",
"isOptional": false,
"type": "string | string[]",
"desc": "The context value."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadDictionaryFieldContextActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "DictionaryFieldContextActionCreators",
"isOptional": false,
"type": "DictionaryFieldContextActionCreators",
"desc": "The dictionary field context action creators.",
"members": [
{
"kind": "function",
"name": "addContext",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "AddDictionaryFieldContextActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "AddDictionaryFieldContextActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<AddDictionaryFieldContextActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Adds a new dictionary field context field-key pair."
},
{
"kind": "function",
"name": "removeContext",
"params": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"desc": "The field to remove from the context (e.g., \"price\").",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Removes a dictionary field context field-key pair."
},
{
"kind": "function",
"name": "setContext",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "Record<string, string>"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<DictionaryFieldContextPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Sets the dictionary field context."
}
],
"isTypeExtracted": false,
"typeName": "DictionaryFieldContextActionCreators"
},
"desc": "Loads the `context` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "AddDictionaryFieldContextActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The name of the dictionary field."
},
{
"kind": "primitive",
"name": "key",
"isOptional": false,
"type": "string",
"desc": "The dictionary field key to return the value of."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadDebugActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "DebugActionCreators",
"isOptional": false,
"type": "DebugActionCreators",
"desc": "The debug action creators.",
"members": [
{
"kind": "function",
"name": "disableDebug",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Disables debug information on requests."
},
{
"kind": "function",
"name": "enableDebug",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Enables debug information on requests."
}
],
"isTypeExtracted": false,
"typeName": "DebugActionCreators"
},
"desc": "Loads the `debug` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadDidYouMeanActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "DidYouMeanActionCreators",
"isOptional": false,
"type": "DidYouMeanActionCreators",
"desc": "The DidYouMean action creators.",
"members": [
{
"kind": "function",
"name": "applyDidYouMeanCorrection",
"params": [
{
"kind": "primitive",
"name": "correction",
"isOptional": false,
"desc": "The target correction (e.g., \"corrected string\").",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Applies a did-you-mean correction."
},
{
"kind": "function",
"name": "disableDidYouMean",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Disables did-you-mean."
},
{
"kind": "function",
"name": "enableDidYouMean",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Enables did-you-mean."
}
],
"isTypeExtracted": false,
"typeName": "DidYouMeanActionCreators"
},
"desc": "Loads the `debug` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadCategoryFacetSetActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "CategoryFacetSetActionCreators",
"isOptional": false,
"type": "CategoryFacetSetActionCreators",
"desc": "The category facet set action creators.",
"members": [
{
"kind": "function",
"name": "deselectAllCategoryFacetValues",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The unique identifier of the facet (e.g., \"1\").",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Deselects all values of a category facet."
},
{
"kind": "function",
"name": "registerCategoryFacet",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "RegisterCategoryFacetActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "RegisterCategoryFacetActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<RegisterCategoryFacetActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers a category facet in the category facet set."
},
{
"kind": "function",
"name": "toggleSelectCategoryFacetValue",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "ToggleSelectCategoryFacetValueActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "ToggleSelectCategoryFacetValueActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<ToggleSelectCategoryFacetValueActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Toggles a category facet value."
},
{
"kind": "function",
"name": "updateCategoryFacetNumberOfValues",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateCategoryFacetNumberOfValuesActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateCategoryFacetNumberOfValuesActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateCategoryFacetNumberOfValuesActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the number of values of a category facet."
},
{
"kind": "function",
"name": "updateCategoryFacetSortCriterion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateCategoryFacetSortCriterionActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateCategoryFacetSortCriterionActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateCategoryFacetSortCriterionActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the the sort criterion for the category facet."
},
{
"kind": "function",
"name": "updateFacetAutoSelection",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateFacetAutoSelectionActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateFacetAutoSelectionActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateFacetAutoSelectionActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the preventAutoSelect flag of all facets."
}
],
"isTypeExtracted": false,
"typeName": "CategoryFacetSetActionCreators"
},
"desc": "Loads the `categoryFacetSet` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "RegisterCategoryFacetActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "A unique identifier for the facet."
},
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "basePath",
"isOptional": true,
"type": "string[]",
"desc": "The base path shared by all values for the facet.",
"defaultValue": "`[]`"
},
{
"kind": "primitive",
"name": "delimitingCharacter",
"isOptional": true,
"type": "string",
"desc": "The character that specifies the hierarchical dependency.",
"defaultValue": "`;`"
},
{
"kind": "primitive",
"name": "filterByBasePath",
"isOptional": true,
"type": "boolean",
"desc": "Whether to use basePath as a filter for the results.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude the parents of folded results when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`5`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'alphanumeric' | 'occurrences'",
"desc": "The criterion to use for sorting returned facet values.",
"defaultValue": "`occurrences`"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ToggleSelectCategoryFacetValueActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "primitive",
"name": "retrieveCount",
"isOptional": false,
"type": "number",
"desc": "The number of child values to display."
},
{
"kind": "object",
"name": "selection",
"isOptional": false,
"type": "CategoryFacetValue",
"desc": "The target category facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "CategoryFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "object",
"name": "children",
"isOptional": false,
"type": "CategoryFacetValue[]",
"desc": "The children of this facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "CategoryFacetValue"
},
{
"kind": "primitive",
"name": "isLeafValue",
"isOptional": false,
"type": "boolean",
"desc": "When the hierarchical value has no children, this property is true."
},
{
"kind": "primitive",
"name": "moreValuesAvailable",
"isOptional": false,
"type": "boolean",
"desc": "Whether more facet values are available."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that match the facet value."
},
{
"kind": "primitive",
"name": "path",
"isOptional": false,
"type": "string[]",
"desc": "The hierarchical path to the facet value."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "Whether a facet value is filtering results (`selected`) or not (`idle`)."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The facet value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateCategoryFacetNumberOfValuesActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": false,
"type": "number",
"desc": "The new number of facet values (e.g., `10`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateCategoryFacetSortCriterionActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"type": "'alphanumeric' | 'occurrences'",
"desc": "The criterion by which to sort the facet."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateFacetAutoSelectionActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "allow",
"isOptional": false,
"type": "boolean",
"desc": "Whether to allow or prevent automatic selection in all facets."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadFacetSetActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "FacetSetActionCreators",
"isOptional": false,
"type": "FacetSetActionCreators",
"desc": "The facet set action creators.",
"members": [
{
"kind": "function",
"name": "deselectAllFacetValues",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The unique identifier of the facet (e.g., `\"1\"`).",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Deselects all values of a facet."
},
{
"kind": "function",
"name": "registerFacet",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "RegisterFacetActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "RegisterFacetActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<RegisterFacetActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers a facet in the facet set."
},
{
"kind": "function",
"name": "toggleSelectFacetValue",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "ToggleSelectFacetValueActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "ToggleSelectFacetValueActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<ToggleSelectFacetValueActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Toggles a facet value. If the value does not exist, it is added."
},
{
"kind": "function",
"name": "updateFacetAutoSelection",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateFacetAutoSelectionActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateFacetAutoSelectionActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateFacetAutoSelectionActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the preventAutoSelect flag of all facets"
},
{
"kind": "function",
"name": "updateFacetIsFieldExpanded",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateFacetIsFieldExpandedActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateFacetIsFieldExpandedActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateFacetIsFieldExpandedActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Whether to expand (show more values than initially configured) or shrink down the facet."
},
{
"kind": "function",
"name": "updateFacetNumberOfValues",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateFacetNumberOfValuesActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateFacetNumberOfValuesActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateFacetNumberOfValuesActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the number of values of a facet."
},
{
"kind": "function",
"name": "updateFacetSortCriterion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateFacetSortCriterionActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateFacetSortCriterionActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateFacetSortCriterionActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the sort criterion of a facet."
},
{
"kind": "function",
"name": "updateFreezeCurrentValues",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateFreezeCurrentValuesActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateFreezeCurrentValuesActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateFreezeCurrentValuesActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the updateFreezeCurrentValues flag of a facet."
}
],
"isTypeExtracted": false,
"typeName": "FacetSetActionCreators"
},
"desc": "Loads the `facetSet` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "RegisterFacetActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "A unique identifier for the facet."
},
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "allowedValues",
"isOptional": true,
"type": "{\n type: 'simple';\n values: string[];\n }",
"desc": "Specifies an explicit list of `allowedValues` in the Search API request.\n\nIf you specify a list of values for this option, the facet uses only these values (if they are available in the current result set).\n\nThe maximum amount of allowed values is 25.\n\nDefault value is `undefined`, and the facet uses all available values for its `field` in the current result set."
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude the parents of folded results when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`8`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'score' | 'alphanumeric' | 'occurrences' | 'automatic'",
"desc": "The criterion to use for sorting returned facet values. Learn more about `sortCriteria` values and the default behavior of specific facets in the [Search API documentation](https://docs.coveo.com/en/1461/build-a-search-ui/query-parameters#RestFacetRequest-sortCriteria).",
"defaultValue": "`automatic`"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ToggleSelectFacetValueActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "object",
"name": "selection",
"isOptional": false,
"type": "FacetValue",
"desc": "The target facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "FacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "Whether a facet value is filtering results (`selected`) or not (`idle`)."
},
{
"kind": "primitive",
"name": "value",
"isOptional": false,
"type": "string",
"desc": "The facet value."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateFacetAutoSelectionActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "allow",
"isOptional": false,
"type": "boolean",
"desc": "Whether to allow or prevent automatic selection in all facets."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateFacetIsFieldExpandedActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "primitive",
"name": "isFieldExpanded",
"isOptional": false,
"type": "boolean",
"desc": "Whether to expand or shrink down the facet."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateFacetNumberOfValuesActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": false,
"type": "number",
"desc": "The new number of facet values (e.g., `10`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateFacetSortCriterionActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"type": "'score' | 'alphanumeric' | 'occurrences' | 'automatic'",
"desc": "The criterion by which to sort the facet."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateFreezeCurrentValuesActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "primitive",
"name": "freezeCurrentValues",
"isOptional": false,
"type": "boolean",
"desc": "Whether the values should be frozen in the next request."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadDateFacetSetActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "DateFacetSetActionCreators",
"isOptional": false,
"type": "DateFacetSetActionCreators",
"desc": "The date facet set action creators.",
"members": [
{
"kind": "function",
"name": "deselectAllDateFacetValues",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The unique identifier of the facet (e.g., `\"1\"`).",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Deselects all values of a date facet."
},
{
"kind": "function",
"name": "registerDateFacet",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "RegisterDateFacetActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "RegisterDateFacetActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<RegisterDateFacetActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers a date facet."
},
{
"kind": "function",
"name": "toggleSelectDateFacetValue",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "ToggleSelectDateFacetValueActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "ToggleSelectDateFacetValueActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<ToggleSelectDateFacetValueActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Toggles a date facet value."
},
{
"kind": "function",
"name": "updateDateFacetSortCriterion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateDateFacetSortCriterionActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateDateFacetSortCriterionActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateDateFacetSortCriterionActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the sort criterion of a date facet."
},
{
"kind": "function",
"name": "updateDateFacetValues",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateDateFacetValuesActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateDateFacetValuesActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateDateFacetValuesActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates date facet values."
}
],
"isTypeExtracted": false,
"typeName": "DateFacetSetActionCreators"
},
"desc": "Loads the `dateFacetSet` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "RegisterDateFacetActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "A unique identifier for the facet."
},
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "generateAutomaticRanges",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index should automatically create range values.\n\nTip: If you set this parameter to true, you should ensure that the ['Use cache for numeric queries' option](https://docs.coveo.com/en/1982/#use-cache-for-numeric-queries) is enabled for this facet's field in your index in order to speed up automatic range evaluation."
},
{
"kind": "object",
"name": "currentValues",
"isOptional": true,
"type": "DateRangeRequest[]",
"desc": "The values displayed by the facet in the search interface at the moment of the request.\n\nIf `generateAutomaticRanges` is false, values must be specified. If `generateAutomaticRanges` is true, automatic ranges are going to be appended after the specified values.",
"defaultValue": "`[]`",
"members": [],
"isTypeExtracted": true,
"typeName": "DateRangeRequest"
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude folded result parents when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`8`"
},
{
"kind": "primitive-with-type-alias",
"name": "rangeAlgorithm",
"isOptional": true,
"type": "'even' | 'equiprobable'",
"desc": "The range algorithm to apply to automatically generated ranges for the range facet.",
"defaultValue": "`even`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'ascending' | 'descending'",
"desc": "The sort criterion to apply to the returned facet values.",
"defaultValue": "`ascending`"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateRangeRequest",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "string",
"desc": "The ending value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the [Relative Date](https://docs.coveo.com/en/headless/latest/reference/search/search-date-facet-controller/relative-date-format/) format \"period-amount-unit\"."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether to include the `end` value in the range."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "string",
"desc": "The starting value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the [Relative Date](https://docs.coveo.com/en/headless/latest/reference/search/search-date-facet-controller/relative-date-format/) format \"period-amount-unit\"."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The current facet value state."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ToggleSelectDateFacetValueActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "object",
"name": "selection",
"isOptional": false,
"type": "DateFacetValue",
"desc": "The target date facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "string",
"desc": "The ending value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "string",
"desc": "The starting value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateDateFacetSortCriterionActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"type": "'ascending' | 'descending'",
"desc": "The target criterion."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateDateFacetValuesActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "DateFacetValue[]",
"desc": "The date facet values.",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadNumericFacetSetActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "NumericFacetSetActionCreators",
"isOptional": false,
"type": "NumericFacetSetActionCreators",
"desc": "The numeric facet action creators.",
"members": [
{
"kind": "function",
"name": "deselectAllNumericFacetValues",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The unique identifier of the facet (e.g., \"1\").",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Deselects all values of a numeric facet."
},
{
"kind": "function",
"name": "registerNumericFacet",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "RegisterNumericFacetActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "RegisterNumericFacetActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<RegisterNumericFacetActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers a numeric facet."
},
{
"kind": "function",
"name": "toggleSelectNumericFacetValue",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "ToggleSelectNumericFacetValueActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "ToggleSelectNumericFacetValueActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<ToggleSelectNumericFacetValueActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Toggles a numeric facet value."
},
{
"kind": "function",
"name": "updateNumericFacetSortCriterion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateNumericFacetSortCriterionActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateNumericFacetSortCriterionActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateNumericFacetSortCriterionActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the sort criterion of a numeric facet."
},
{
"kind": "function",
"name": "updateNumericFacetValues",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateNumericFacetValuesActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateNumericFacetValuesActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateNumericFacetValuesActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates numeric facet values."
}
],
"isTypeExtracted": false,
"typeName": "NumericFacetSetActionCreators"
},
"desc": "Loads the `numericFacetSet` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "RegisterNumericFacetActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "A unique identifier for the numeric facet."
},
{
"kind": "primitive",
"name": "field",
"isOptional": false,
"type": "string",
"desc": "The field whose values you want to display in the facet."
},
{
"kind": "primitive",
"name": "generateAutomaticRanges",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index should automatically create range values.\n\nTip: If you set this parameter to true, you should ensure that the ['Use cache for numeric queries' option](https://docs.coveo.com/en/1982/#use-cache-for-numeric-queries) is enabled for this facet's field in your index in order to speed up automatic range evaluation."
},
{
"kind": "object",
"name": "currentValues",
"isOptional": true,
"type": "NumericRangeRequest[]",
"desc": "The values displayed by the facet in the search interface at the moment of the request.\n\nIf `generateAutomaticRanges` is false, values must be specified. If `generateAutomaticRanges` is true, automatic ranges are going to be appended after the specified values.",
"defaultValue": "`[]`",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericRangeRequest"
},
{
"kind": "primitive",
"name": "filterFacetCount",
"isOptional": true,
"type": "boolean",
"desc": "Whether to exclude folded result parents when estimating the result count for each facet value.",
"defaultValue": "`true`"
},
{
"kind": "primitive",
"name": "injectionDepth",
"isOptional": true,
"type": "number",
"desc": "The maximum number of results to scan in the index to ensure that the facet lists all potential facet values.\n\nNote: A high injectionDepth may negatively impact the facet request performance.\n\nMinimum: `0`",
"defaultValue": "`1000`"
},
{
"kind": "primitive",
"name": "numberOfValues",
"isOptional": true,
"type": "number",
"desc": "The number of values to request for this facet. Also determines the number of additional values to request each time this facet is expanded, and the number of values to display when this facet is collapsed.\n\nMinimum: `1`",
"defaultValue": "`8`"
},
{
"kind": "primitive-with-type-alias",
"name": "rangeAlgorithm",
"isOptional": true,
"type": "'even' | 'equiprobable'",
"desc": "The range algorithm to apply to automatically generated ranges for the range facet.",
"defaultValue": "`even`"
},
{
"kind": "primitive-with-type-alias",
"name": "sortCriteria",
"isOptional": true,
"type": "'ascending' | 'descending'",
"desc": "The sort criterion to apply to the returned facet values.",
"defaultValue": "`ascending`"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericRangeRequest",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The end value of the range."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether to include the `end` value in the range."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The start value of the range."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The current facet value state."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "ToggleSelectNumericFacetValueActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "object",
"name": "selection",
"isOptional": false,
"type": "NumericFacetValue",
"desc": "The target numeric facet value.",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The ending value for the numeric range."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The starting value for the numeric range."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateNumericFacetSortCriterionActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"type": "'ascending' | 'descending'",
"desc": "The target criterion."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateNumericFacetValuesActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the facet (e.g., `\"1\"`)."
},
{
"kind": "object",
"name": "values",
"isOptional": false,
"type": "NumericFacetValue[]",
"desc": "The numeric facet values.",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadFacetOptionsActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "FacetOptionsActionCreators",
"isOptional": false,
"type": "FacetOptionsActionCreators",
"desc": "The facetOptions action creators.",
"members": [
{
"kind": "function",
"name": "disableFacet",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The unique identifier of the facet (e.g., \"1\").",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Disables a facet. I.e., prevents it from filtering results."
},
{
"kind": "function",
"name": "enableFacet",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The unique identifier of the facet (e.g., \"abcd\").",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Enables a facet. I.e., undoes the effects of `disable`."
},
{
"kind": "function",
"name": "updateFacetOptions",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateFacetOptionsActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateFacetOptionsActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateFacetOptionsActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates options that affect facet reordering. For more information, refer to [the documentation on query parameters](https://docs.coveo.com/en/1461/build-a-search-ui/query-parameters#definitions-RestFacetOptions)."
}
],
"isTypeExtracted": false,
"typeName": "FacetOptionsActionCreators"
},
"desc": "Loads the `facetOptions` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "UpdateFacetOptionsActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "freezeFacetOrder",
"isOptional": true,
"type": "boolean",
"desc": "Whether facets should be returned in the same order they were requested."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadFoldingActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "FoldingActionCreators",
"isOptional": false,
"type": "FoldingActionCreators",
"desc": "The folding action creators.",
"members": [
{
"kind": "function",
"name": "loadCollection",
"params": [
{
"kind": "primitive",
"name": "collectionId",
"isOptional": false,
"desc": "The collection id to load results for.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<LoadCollectionFulfilledReturn, string, AsyncThunkSearchOptions<StateNeededByLoadCollection>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Loads the results of a collection."
},
{
"kind": "function",
"name": "registerFolding",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "RegisterFoldingActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "RegisterFoldingActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<RegisterFoldingActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers a folding configuration."
}
],
"isTypeExtracted": false,
"typeName": "FoldingActionCreators"
},
"desc": "Loads the `folding` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "RegisterFoldingActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "childField",
"isOptional": true,
"type": "string",
"desc": "The name of the field that uniquely identifies a result within a collection.",
"defaultValue": "`foldingchild`"
},
{
"kind": "primitive",
"name": "collectionField",
"isOptional": true,
"type": "string",
"desc": "The name of the field on which to do the folding. The folded result list component will use the values of this field to resolve the collections of result items.",
"defaultValue": "`foldingcollection`"
},
{
"kind": "primitive",
"name": "numberOfFoldedResults",
"isOptional": true,
"type": "number",
"desc": "The number of child results to fold under the root collection element, before expansion.",
"defaultValue": "`2`"
},
{
"kind": "primitive",
"name": "parentField",
"isOptional": true,
"type": "string",
"desc": "The name of the field that determines whether a certain result is a top result containing other child results within a collection.",
"defaultValue": "`foldingparent`"
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadFieldActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "FieldActionCreators",
"isOptional": false,
"type": "FieldActionCreators",
"desc": "The field action creators.",
"members": [
{
"kind": "function",
"name": "disableFetchAllFields",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Disable fetch all fields from the index."
},
{
"kind": "function",
"name": "enableFetchAllFields",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Enable fetch all fields from the index.\n\nThis should not be used in any production environment, as it can have a negative impact on query execution time.\n\nShould be used for debugging purposes."
},
{
"kind": "function",
"name": "fetchFieldsDescription",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<FieldDescription[], void, AsyncThunkSearchOptions<ConfigurationSection>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Fetch field descriptions from the index."
},
{
"kind": "function",
"name": "registerFieldsToInclude",
"params": [
{
"kind": "primitive",
"name": "fields",
"isOptional": false,
"desc": "The target fields (e.g., [\"field1\", \"field2\"]).",
"type": "string[]"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string[]>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers the fields to include in the query response."
}
],
"isTypeExtracted": false,
"typeName": "FieldActionCreators"
},
"desc": "Loads the `fields` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadHistoryActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "HistoryActionCreators",
"isOptional": false,
"type": "HistoryActionCreators",
"desc": "The history action creators.",
"members": [
{
"kind": "function",
"name": "back",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<void, void, {}>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Moves backward in the interface history."
},
{
"kind": "function",
"name": "forward",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<void, void, {}>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Moves forward in the interface history."
}
],
"isTypeExtracted": false,
"typeName": "HistoryActionCreators"
},
"desc": "Loads the `history` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadPaginationActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "PaginationActionCreators",
"isOptional": false,
"type": "PaginationActionCreators",
"desc": "The pagination action creators.",
"members": [
{
"kind": "function",
"name": "nextPage",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the page to the next page."
},
{
"kind": "function",
"name": "previousPage",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the page to the previous page."
},
{
"kind": "function",
"name": "registerNumberOfResults",
"params": [
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"desc": "The initial number of results.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<number>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Initializes the `numberOfResults` query parameter. For more information, refer to [the documentation on query parameters](https://docs.coveo.com/en/1461/cloud-v2-developers/query-parameters#RestQueryParameters-numberOfResults)."
},
{
"kind": "function",
"name": "registerPage",
"params": [
{
"kind": "primitive",
"name": "page",
"isOptional": false,
"desc": "The initial page number.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<number>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Sets the initial page by initializing the `firstResult` query parameter. For more information, refer to [the documentation on query parameters](https://docs.coveo.com/en/1461/cloud-v2-developers/query-parameters#RestQueryParameters-firstResult)."
},
{
"kind": "function",
"name": "updateNumberOfResults",
"params": [
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"desc": "The new number of results.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<number>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the `numberOfResults` query parameter. For more information, refer to [the documentation on query parameters](https://docs.coveo.com/en/1461/cloud-v2-developers/query-parameters#RestQueryParameters-numberOfResults)."
},
{
"kind": "function",
"name": "updatePage",
"params": [
{
"kind": "primitive",
"name": "page",
"isOptional": false,
"desc": "The new page number.",
"type": "number"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<number>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the page by updating the `firstResult` query parameter. For more information, refer to [the documentation on query parameters](https://docs.coveo.com/en/1461/cloud-v2-developers/query-parameters#RestQueryParameters-firstResult)."
}
],
"isTypeExtracted": false,
"typeName": "PaginationActionCreators"
},
"desc": "Loads the `pagination` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadPipelineActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "PipelineActionCreators",
"isOptional": false,
"type": "PipelineActionCreators",
"desc": "The pipeline action creators.",
"members": [
{
"kind": "function",
"name": "setPipeline",
"params": [
{
"kind": "primitive",
"name": "pipeline",
"isOptional": false,
"desc": "The query pipeline to set (may be empty).",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Sets the query pipeline."
}
],
"isTypeExtracted": false,
"typeName": "PipelineActionCreators"
},
"desc": "Loads the `pipeline` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadQueryActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "QueryActionCreators",
"isOptional": false,
"type": "QueryActionCreators",
"desc": "The query action creators.",
"members": [
{
"kind": "function",
"name": "updateQuery",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateQueryActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateQueryActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateQueryActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the basic query expression."
}
],
"isTypeExtracted": false,
"typeName": "QueryActionCreators"
},
"desc": "Loads the `query` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "UpdateQueryActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "enableQuerySyntax",
"isOptional": true,
"type": "boolean",
"desc": "Whether to interpret advanced [Coveo Cloud query syntax](https://docs.coveo.com/en/1814/searching-with-coveo/search-prefixes-and-operators) in the query."
},
{
"kind": "primitive",
"name": "q",
"isOptional": true,
"type": "string",
"desc": "The basic query expression (e.g., `acme tornado seeds`)."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadQuerySetActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "QuerySetActionCreators",
"isOptional": false,
"type": "QuerySetActionCreators",
"desc": "The query set action creators.",
"members": [
{
"kind": "function",
"name": "registerQuerySetQuery",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "RegisterQuerySetQueryActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "RegisterQuerySetQueryActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<RegisterQuerySetQueryActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers a query in the query set."
},
{
"kind": "function",
"name": "updateQuerySetQuery",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "UpdateQuerySetQueryActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "UpdateQuerySetQueryActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<UpdateQuerySetQueryActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates a query in the query set."
}
],
"isTypeExtracted": false,
"typeName": "QuerySetActionCreators"
},
"desc": "Loads the `querySet` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "RegisterQuerySetQueryActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the target query."
},
{
"kind": "primitive",
"name": "query",
"isOptional": false,
"type": "string",
"desc": "The initial basic query expression."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "UpdateQuerySetQueryActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the target query."
},
{
"kind": "primitive",
"name": "query",
"isOptional": false,
"type": "string",
"desc": "The new basic query expression."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadQuerySuggestActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "QuerySuggestActionCreators",
"isOptional": false,
"type": "QuerySuggestActionCreators",
"desc": "The query suggest action creators.",
"members": [
{
"kind": "function",
"name": "clearQuerySuggest",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "ClearQuerySuggestActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "ClearQuerySuggestActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<ClearQuerySuggestActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Clears the current partial basic query expression and the list of query suggestions in a specific query suggest entity."
},
{
"kind": "function",
"name": "fetchQuerySuggestions",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "FetchQuerySuggestionsActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "FetchQuerySuggestionsActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "AsyncThunkAction<FetchQuerySuggestionsThunkReturn, FetchQuerySuggestionsActionCreatorPayload, AsyncThunkSearchOptions<StateNeededByQuerySuggest>>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Fetches a list of query suggestions for a specific query suggest entity according to the current headless state."
},
{
"kind": "function",
"name": "registerQuerySuggest",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "RegisterQuerySuggestActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "RegisterQuerySuggestActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<RegisterQuerySuggestActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Registers a new query suggest entity to the headless state to enable the Coveo ML query suggestions feature."
},
{
"kind": "function",
"name": "selectQuerySuggestion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "SelectQuerySuggestionActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "SelectQuerySuggestionActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<SelectQuerySuggestionActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Selects a suggestion provided through a specific query suggest entity."
}
],
"isTypeExtracted": false,
"typeName": "QuerySuggestActionCreators"
},
"desc": "Loads the `querySuggest` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "ClearQuerySuggestActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "FetchQuerySuggestionsActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "RegisterQuerySuggestActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "A unique identifier for the new query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`)."
},
{
"kind": "primitive",
"name": "count",
"isOptional": true,
"type": "number",
"desc": "The number of query suggestions to request from Coveo ML (e.g., `3`).",
"defaultValue": "`5`."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "SelectQuerySuggestionActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "The selected query suggestion (e.g., `coveo`)."
},
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The unique identifier of the target query suggest entity (e.g., `b953ab2e-022b-4de4-903f-68b2c0682942`)."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadQuestionAnsweringActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "QuestionAnsweringActionCreators",
"isOptional": false,
"type": "QuestionAnsweringActionCreators",
"desc": "The question answering action creators.",
"members": [
{
"kind": "function",
"name": "closeFeedbackModal",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Closes the feedback modal of a smart snippet."
},
{
"kind": "function",
"name": "collapseSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Collapses a smart snippet."
},
{
"kind": "function",
"name": "collapseSmartSnippetRelatedQuestion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringUniqueIdentifierActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<QuestionAnsweringUniqueIdentifierActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Collapses the specified snippet suggestion."
},
{
"kind": "function",
"name": "dislikeSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Dislikes a smart snippet (a 'thumbs down' reaction)."
},
{
"kind": "function",
"name": "expandSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Expands a smart snippet."
},
{
"kind": "function",
"name": "expandSmartSnippetRelatedQuestion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringUniqueIdentifierActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<QuestionAnsweringUniqueIdentifierActionCreatorPayload>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Expands the specified snippet suggestion."
},
{
"kind": "function",
"name": "likeSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Likes a smart snippet (a 'thumbs up' reaction)."
},
{
"kind": "function",
"name": "openFeedbackModal",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Opens the feedback modal of a smart snippet."
}
],
"isTypeExtracted": false,
"typeName": "QuestionAnsweringActionCreators"
},
"desc": "Loads the `questionAnswering` reducer and returns possible action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "questionAnswerId",
"isOptional": false,
"type": "string",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadSearchHubActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "CoreEngine"
}
],
"returnType": {
"kind": "object",
"name": "SearchHubActionCreators",
"isOptional": false,
"type": "SearchHubActionCreators",
"desc": "The search hub action creators.",
"members": [
{
"kind": "function",
"name": "setSearchHub",
"params": [
{
"kind": "primitive",
"name": "searchHub",
"isOptional": false,
"desc": "The new search hub (may be empty).",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<string>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Sets the search hub."
}
],
"isTypeExtracted": false,
"typeName": "SearchHubActionCreators"
},
"desc": "Loads the `searchHub` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadSortCriteriaActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "SortCriteriaActionCreators",
"isOptional": false,
"type": "SortCriteriaActionCreators",
"desc": "The sort criteria action creators.",
"members": [
{
"kind": "function",
"name": "registerSortCriterion",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The initial sort criterion.",
"type": "SortByRelevancy | SortByQRE | SortByDate | SortByField | SortByNoSort"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<SortCriterion | SortCriterion[]>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Initializes the sortCriteria query parameter. For more information, refer to [the documentation on query parameters](https://docs.coveo.com/en/1461/cloud-v2-developers/query-parameters#RestQueryParameters-sortCriteria)."
},
{
"kind": "function",
"name": "updateSortCriterion",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "criterion",
"isOptional": false,
"desc": "The sort criterion to set.",
"type": "SortByRelevancy | SortByQRE | SortByDate | SortByField | SortByNoSort"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction<SortCriterion | SortCriterion[]>",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Updates the sortCriteria query parameter. For more information, refer to [the documentation on query parameters](https://docs.coveo.com/en/1461/cloud-v2-developers/query-parameters#RestQueryParameters-sortCriteria)."
}
],
"isTypeExtracted": false,
"typeName": "SortCriteriaActionCreators"
},
"desc": "Loads the `sortCriteria` reducer and returns possible action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadBreadcrumbActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "BreadcrumbActionCreators",
"isOptional": false,
"type": "BreadcrumbActionCreators",
"desc": "The breadcrumb action creators.",
"members": [
{
"kind": "function",
"name": "deselectAllBreadcrumbs",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Deselects active breadcrumb values across all facets and static filters."
},
{
"kind": "function",
"name": "deselectAllNonBreadcrumbs",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "PayloadAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "Deselects active filters that are not listed in breadcrumbs across facets and static filters which have the option `hasBreadcrumbs` set to false."
}
],
"isTypeExtracted": false,
"typeName": "BreadcrumbActionCreators"
},
"desc": "Returns breadcrumb action creators."
},
"extractedTypes": []
},
{
"initializer": {
"kind": "function",
"name": "loadSearchAnalyticsActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "SearchAnalyticsActionCreators",
"isOptional": false,
"type": "SearchAnalyticsActionCreators",
"desc": "The search analytics action creators.",
"members": [
{
"kind": "function",
"name": "logCategoryFacetBreadcrumb",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogCategoryFacetBreadcrumbActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogCategoryFacetBreadcrumbActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a category facet breadcrumb is deselected."
},
{
"kind": "function",
"name": "logClearBreadcrumbs",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when clearing breadcrumbs."
},
{
"kind": "function",
"name": "logCloseSmartSnippetFeedbackModal",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user no longer wishes to provide feedback about why the smart snippet answer wasn't relevant."
},
{
"kind": "function",
"name": "logCollapseSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a smart snippet is collapsed."
},
{
"kind": "function",
"name": "logCollapseSmartSnippetSuggestion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creation payload.",
"type": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringUniqueIdentifierActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a smart snippet suggestion, or related question, is collapsed."
},
{
"kind": "function",
"name": "logDateFacetBreadcrumb",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogDateFacetBreadcrumbActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogDateFacetBreadcrumbActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a date facet breadcrumb is deselected."
},
{
"kind": "function",
"name": "logDidYouMeanClick",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user triggers a search by clicking on a did-you-mean suggestion."
},
{
"kind": "function",
"name": "logDislikeSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user provides negative feedback for a given smart snippet answer."
},
{
"kind": "function",
"name": "logExpandSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a smart snippet is expanded."
},
{
"kind": "function",
"name": "logExpandSmartSnippetSuggestion",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringUniqueIdentifierActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a query suggestion is selected."
},
{
"kind": "function",
"name": "logFacetBreadcrumb",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogFacetBreadcrumbActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogFacetBreadcrumbActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a facet breadcrumb is deselected."
},
{
"kind": "function",
"name": "logFacetClearAll",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The facet id.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when all selected values in a facet are deselected."
},
{
"kind": "function",
"name": "logFacetDeselect",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogFacetDeselectActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogFacetDeselectActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a selected facet value is deselected."
},
{
"kind": "function",
"name": "logFacetSelect",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogFacetSelectActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogFacetSelectActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when an idle facet value is selected."
},
{
"kind": "function",
"name": "logFacetShowLess",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The facet id.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when shrinking a facet to show fewer values."
},
{
"kind": "function",
"name": "logFacetShowMore",
"params": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"desc": "The facet id.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when expanding a facet to show more values."
},
{
"kind": "function",
"name": "logFacetUpdateSort",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogFacetUpdateSortActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogFacetUpdateSortActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when the facet sort criterion is changed."
},
{
"kind": "function",
"name": "logInterfaceChange",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a tab is selected."
},
{
"kind": "function",
"name": "logInterfaceLoad",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a search interface loads for the first time."
},
{
"kind": "function",
"name": "logLikeSmartSnippet",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user provides positive feedback for a given smart snippet answer."
},
{
"kind": "function",
"name": "logNavigateBackward",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when going to the previous state of the search interface."
},
{
"kind": "function",
"name": "logNavigateForward",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when going to the next state of the search interface."
},
{
"kind": "function",
"name": "logNoResultsBack",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when no results is shown and the end users cancel last action."
},
{
"kind": "function",
"name": "logNotifyTrigger",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user action triggers a notification set in the effective query pipeline on the search page."
},
{
"kind": "function",
"name": "logNumericFacetBreadcrumb",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogNumericFacetBreadcrumbActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogNumericFacetBreadcrumbActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a numeric facet breadcrumb is deselected."
},
{
"kind": "function",
"name": "logOmniboxFromLink",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "metadata",
"isOptional": false,
"desc": "The metadata of the clicked query suggestion that triggered the redirect.",
"type": "OmniboxSuggestionMetadata"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a search interface loads for the first time, for a user who selected a query suggestion from a standalone search box."
},
{
"kind": "function",
"name": "logOpenSmartSnippetFeedbackModal",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user wishes to provide feedback about why the smart snippet answer wasn't relevant."
},
{
"kind": "function",
"name": "logPageNext",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when navigating to the next page of results."
},
{
"kind": "function",
"name": "logPageNumber",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when selecting a page in the pager."
},
{
"kind": "function",
"name": "logPagePrevious",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when navigating to the previous page of results."
},
{
"kind": "function",
"name": "logPagerResize",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when changing the number of results per page."
},
{
"kind": "function",
"name": "logQuerySuggestionClick",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "LogQuerySuggestionClickActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogQuerySuggestionClickActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a query suggestion is selected."
},
{
"kind": "function",
"name": "logResultsSort",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when the results sort criterion is changed."
},
{
"kind": "function",
"name": "logSearchboxSubmit",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when performing a search using a search box."
},
{
"kind": "function",
"name": "logSearchFromLink",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a search interface loads for the first time, for a user who performed a search using a standalone search box."
},
{
"kind": "function",
"name": "logSmartSnippetDetailedFeedback",
"params": [
{
"kind": "primitive",
"name": "details",
"isOptional": false,
"desc": "A personalized message from the end user about the relevance of the answer.",
"type": "string"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user provides detailed feedback about why the smart snippet answer wasn't relevant."
},
{
"kind": "function",
"name": "logSmartSnippetFeedback",
"params": [
{
"kind": "primitive-with-type-alias",
"name": "feedback",
"isOptional": false,
"desc": "The generic feedback that the end user wishes to send.",
"type": "'does_not_answer' | 'partially_answers' | 'was_not_a_question'"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "CustomAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user provides feedback about why the smart snippet answer wasn't relevant."
},
{
"kind": "function",
"name": "logStaticFilterClearAll",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creation payload.",
"type": "LogStaticFilterClearAllActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogStaticFilterClearAllActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when all selected values of a static filter are deselected."
},
{
"kind": "function",
"name": "logStaticFilterDeselect",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creation payload.",
"type": "LogStaticFilterToggleValueActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogStaticFilterToggleValueActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a static filter value is deselected."
},
{
"kind": "function",
"name": "logStaticFilterSelect",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creation payload.",
"type": "LogStaticFilterToggleValueActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogStaticFilterToggleValueActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a static filter value is selected."
},
{
"kind": "function",
"name": "logTriggerExecute",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user action executes a JavaScript function set in the effective query pipeline on the search page."
},
{
"kind": "function",
"name": "logTriggerQuery",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user action triggers a new query set in the effective query pipeline on the search page."
},
{
"kind": "function",
"name": "logTriggerRedirect",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user action redirects them to a URL set in the effective query pipeline on the search page."
},
{
"kind": "function",
"name": "logUndoTriggerQuery",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creation payload.",
"type": "LogUndoTriggerQueryActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "LogUndoTriggerQueryActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "SearchAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a user undoes a query set in the effective query pipeline on the search page."
}
],
"isTypeExtracted": false,
"typeName": "SearchAnalyticsActionCreators"
},
"desc": "Returns possible search analytics action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "LogCategoryFacetBreadcrumbActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "categoryFacetId",
"isOptional": false,
"type": "string",
"desc": "The category facet id."
},
{
"kind": "primitive",
"name": "categoryFacetPath",
"isOptional": false,
"type": "string[]",
"desc": "The category facet selected path."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "questionAnswerId",
"isOptional": false,
"type": "string",
"desc": ""
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogDateFacetBreadcrumbActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet id of the date facet corresponding to the breadcrumb."
},
{
"kind": "object",
"name": "selection",
"isOptional": false,
"type": "DateFacetValue",
"desc": "The date facet value deselected using the breadcrumb.",
"members": [],
"isTypeExtracted": true,
"typeName": "DateFacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "DateFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "string",
"desc": "The ending value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "string",
"desc": "The starting value for the date range, formatted as `YYYY/MM/DD@HH:mm:ss` or the Relative date format \"period-amount-unit\""
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogFacetBreadcrumbActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet id associated with the breadcrumb."
},
{
"kind": "primitive",
"name": "facetValue",
"isOptional": false,
"type": "string",
"desc": "The facet value displayed in the breadcrumb."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogFacetDeselectActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet id."
},
{
"kind": "primitive",
"name": "facetValue",
"isOptional": false,
"type": "string",
"desc": "The facet value that was deselected."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogFacetSelectActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet id."
},
{
"kind": "primitive",
"name": "facetValue",
"isOptional": false,
"type": "string",
"desc": "The facet value that was selected."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogFacetUpdateSortActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "criterion",
"isOptional": false,
"type": "FacetSortCriterion | RangeFacetSortCriterion",
"desc": "The updated sort criterion."
},
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet id."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogNumericFacetBreadcrumbActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "facetId",
"isOptional": false,
"type": "string",
"desc": "The facet id of the numeric facet corresponding to the breadcrumb."
},
{
"kind": "object",
"name": "selection",
"isOptional": false,
"type": "NumericFacetValue",
"desc": "The numeric facet value deselected using the breadcrumb.",
"members": [],
"isTypeExtracted": true,
"typeName": "NumericFacetValue"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "NumericFacetValue",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "end",
"isOptional": false,
"type": "number",
"desc": "The ending value for the numeric range."
},
{
"kind": "primitive",
"name": "endInclusive",
"isOptional": false,
"type": "boolean",
"desc": "Whether or not the end value is included in the range."
},
{
"kind": "primitive",
"name": "numberOfResults",
"isOptional": false,
"type": "number",
"desc": "The number of results that have the facet value."
},
{
"kind": "primitive",
"name": "start",
"isOptional": false,
"type": "number",
"desc": "The starting value for the numeric range."
},
{
"kind": "primitive-with-type-alias",
"name": "state",
"isOptional": false,
"type": "'idle' | 'selected'",
"desc": "The state of the facet value, indicating whether it is filtering results (`selected`) or not (`idle`)."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogQuerySuggestionClickActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "id",
"isOptional": false,
"type": "string",
"desc": "The search box id."
},
{
"kind": "primitive",
"name": "suggestion",
"isOptional": false,
"type": "string",
"desc": "The selected query suggestion."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogStaticFilterClearAllActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "staticFilterId",
"isOptional": false,
"type": "string",
"desc": "The static filter id."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogStaticFilterToggleValueActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "staticFilterId",
"isOptional": false,
"type": "string",
"desc": "The static filter id."
},
{
"kind": "object",
"name": "staticFilterValue",
"isOptional": false,
"type": "StaticFilterValueMetadata",
"desc": "The static filter value.",
"members": [],
"isTypeExtracted": true,
"typeName": "StaticFilterValueMetadata"
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "StaticFilterValueMetadata",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "caption",
"isOptional": false,
"type": "string",
"desc": "The caption displayed to the user."
},
{
"kind": "primitive",
"name": "expression",
"isOptional": false,
"type": "string",
"desc": "The query expression."
}
],
"isTypeExtracted": false,
"typeName": ""
},
{
"kind": "object",
"name": "LogUndoTriggerQueryActionCreatorPayload",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "undoneQuery",
"isOptional": false,
"type": "string",
"desc": "The query that was undone."
}
],
"isTypeExtracted": false,
"typeName": ""
}
]
},
{
"initializer": {
"kind": "function",
"name": "loadClickAnalyticsActions",
"params": [
{
"kind": "primitive",
"name": "engine",
"isOptional": false,
"desc": "The headless engine.",
"type": "SearchEngine"
}
],
"returnType": {
"kind": "object",
"name": "ClickAnalyticsActionCreators",
"isOptional": false,
"type": "ClickAnalyticsActionCreators",
"desc": "The click analytics action creators.",
"members": [
{
"kind": "function",
"name": "logDocumentOpen",
"params": [
{
"kind": "object",
"name": "result",
"isOptional": false,
"desc": "The selected result.",
"type": "Result",
"members": [],
"isTypeExtracted": true,
"typeName": "Result"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "ClickAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a result is selected."
},
{
"kind": "function",
"name": "logOpenSmartSnippetInlineLink",
"params": [
{
"kind": "object",
"name": "payload",
"isOptional": false,
"desc": "The action creator payload.",
"type": "QuestionAnsweringInlineLinkActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringInlineLinkActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "ClickAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when a link inside the snippet of a smart snippet is clicked."
},
{
"kind": "function",
"name": "logOpenSmartSnippetSource",
"params": [],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "ClickAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when the source of a smart snippet is clicked."
},
{
"kind": "function",
"name": "logOpenSmartSnippetSuggestionInlineLink",
"params": [
{
"kind": "object",
"name": "identifier",
"isOptional": false,
"desc": "The identifier of the suggestion.",
"type": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringUniqueIdentifierActionCreatorPayload"
},
{
"kind": "object",
"name": "link",
"isOptional": false,
"desc": "The link that was opened.",
"type": "QuestionAnsweringInlineLinkActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringInlineLinkActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "ClickAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when the source of a smart snippet suggestion, or related question, is clicked."
},
{
"kind": "function",
"name": "logOpenSmartSnippetSuggestionSource",
"params": [
{
"kind": "object",
"name": "identifier",
"isOptional": false,
"desc": "The identifier of the suggestion.",
"type": "QuestionAnsweringUniqueIdentifierActionCreatorPayload",
"members": [],
"isTypeExtracted": true,
"typeName": "QuestionAnsweringUniqueIdentifierActionCreatorPayload"
}
],
"returnType": {
"kind": "primitive",
"name": "returnType",
"type": "ClickAction",
"isOptional": false,
"desc": "A dispatchable action."
},
"desc": "The event to log when the source of a smart snippet suggestion, or related question, is clicked."
}
],
"isTypeExtracted": false,
"typeName": "ClickAnalyticsActionCreators"
},
"desc": "Returns possible click analytics action creators."
},
"extractedTypes": [
{
"kind": "object",
"name": "Result",
"isOptional": false,
"type": "",
"desc": "",
"members": [
{
"kind": "primitive",
"name": "absentTerms",
"isOptional": false,
"type": "string[]",
"desc": "The basic query expression terms which this query result item does not match. Note: This property is populated by terms from the query pipeline-processed q value (not from the original q value)."
},
{
"kind": "primitive",
"name": "clickUri",
"isOptional": false,
"type": "string",
"desc": "The hyperlinkable item URI. Notes: Use the clickUri value when you want to create hyperlinks to the item, rather than the uri or printableUri value."
},
{
"kind": "primitive",
"name": "excerpt",
"isOptional": false,
"type": "string",
"desc": "The contextual excerpt generated for the item (see the excerptLength query parameter)."
},
{
"kind": "object",
"name": "excerptHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item excerpt string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "firstSentences",
"isOptional": false,
"type": "string",
"desc": "The first sentences retrieved from the item (see the retrieveFirstSentences query parameter)."
},
{
"kind": "object",
"name": "firstSentencesHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item firstSentences string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "flags",
"isOptional": false,
"type": "string",
"desc": "The flags that are set on the item by the index. Distinct values are separated by semicolons."
},
{
"kind": "primitive",
"name": "hasHtmlVersion",
"isOptional": false,
"type": "boolean",
"desc": "Whether the index contains an HTML version of this item."
},
{
"kind": "primitive",
"name": "isRecommendation",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted as a Coveo ML recommendation."
},
{
"kind": "primitive",
"name": "isTopResult",
"isOptional": false,
"type": "boolean",
"desc": "Whether the item score was boosted by a featured result rule in the query pipeline."
},
{
"kind": "primitive",
"name": "percentScore",
"isOptional": false,
"type": "number",
"desc": "The item ranking score expressed as a percentage (see the sortCriteria and rankingFunctions query parameters)."
},
{
"kind": "primitive",
"name": "printableUri",
"isOptional": false,
"type": "string",
"desc": "The human readable item URI. Note: Avoid using the printableUri value to create hyperlinks to the item. Use the clickUri value instead."
},
{
"kind": "object",
"name": "printableUriHighlights",
"isOptional": false,
"type": "HighlightKeyword[]",
"desc": "The length and offset of each word to highlight in the item printableUri string.",
"members": [],
"isTypeExtracted": true,
"typeName": "HighlightKeyword"
},
{
"kind": "primitive",
"name": "rankingInfo",
"isOptional": false,
"type": "string | null",
"desc": "The raw debug information generated b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment