Skip to content

Commit 04f2a20

Browse files
authored
feat(ts): document renderingContent (#1273)
* feat(ts): document renderingContent DX-2066 see also the helper PR: algolia/algoliasearch-helper-js#823 * Update packages/client-search/src/types/SearchResponse.ts
1 parent fec87a9 commit 04f2a20

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

packages/client-search/src/types/Rule.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SearchOptions } from '.';
1+
import { SearchOptions, Settings } from '.';
22

33
export type Rule = {
44
/**
@@ -125,6 +125,12 @@ export type ConsequenceParams = {
125125
* Behaves like optionalFilters.
126126
*/
127127
readonly automaticOptionalFacetFilters?: readonly AutomaticFacetFilter[];
128+
129+
/**
130+
* Content defining how the search interface should be rendered.
131+
* A default value for this can be set via settings
132+
*/
133+
readonly renderingContent?: Settings['renderingContent'];
128134
};
129135

130136
export type Condition = {
@@ -186,12 +192,12 @@ export type Consequence = {
186192

187193
export type TimeRange = {
188194
/**
189-
* DateTime with UTC offset for Serialization/Deserialization in unix timespam.
195+
* DateTime with UTC offset for Serialization/Deserialization in unix timespan.
190196
*/
191197
readonly from: number;
192198

193199
/**
194-
* DateTime with UTC offset for Serialization/Deserialization in unix timespam.
200+
* DateTime with UTC offset for Serialization/Deserialization in unix timespan.
195201
*/
196202
readonly until: number;
197203
};

packages/client-search/src/types/SearchResponse.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Hit } from '.';
1+
import { Hit, Settings } from '.';
22

33
export type SearchResponse<TObject = {}> = {
44
/**
@@ -225,4 +225,6 @@ export type SearchResponse<TObject = {}> = {
225225
* The relevancy threshold applied to search in a virtual index.
226226
*/
227227
appliedRelevancyStrictness?: number;
228+
229+
renderingContent?: Settings['renderingContent'];
228230
};

packages/client-search/src/types/Settings.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,4 +304,43 @@ export type Settings = {
304304
* less relevant results.
305305
*/
306306
readonly relevancyStrictness?: number;
307+
308+
/**
309+
* Content defining how the search interface should be rendered.
310+
* This is set via the settings for a default value and can be overridden via rules
311+
*/
312+
readonly renderingContent?: {
313+
/**
314+
* defining how facets should be ordered
315+
*/
316+
readonly facetOrdering?: {
317+
/**
318+
* the ordering of facets (widgets)
319+
*/
320+
readonly facet?: {
321+
/**
322+
* pinned order of facet lists
323+
*/
324+
readonly order: readonly string[];
325+
};
326+
/**
327+
* the ordering of facet values, within an individual list
328+
*/
329+
readonly values?: {
330+
readonly [facet: string]: {
331+
/**
332+
* pinned order of facet values
333+
*/
334+
readonly order: readonly string[];
335+
/**
336+
* How to display the remaining items.
337+
* - facet count (descending)
338+
* - alphabetical (ascending)
339+
* - hidden (show only pinned values)
340+
*/
341+
readonly sortRemainingBy: 'count' | 'alpha' | 'hidden';
342+
};
343+
};
344+
};
345+
};
307346
};

0 commit comments

Comments
 (0)