From 04f2a20037b79aa513a0b6283b2d2f8caa042166 Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Thu, 10 Jun 2021 17:04:19 +0200 Subject: [PATCH] feat(ts): document renderingContent (#1273) * feat(ts): document renderingContent DX-2066 see also the helper PR: https://github.com/algolia/algoliasearch-helper-js/pull/823 * Update packages/client-search/src/types/SearchResponse.ts --- packages/client-search/src/types/Rule.ts | 12 ++++-- .../client-search/src/types/SearchResponse.ts | 4 +- packages/client-search/src/types/Settings.ts | 39 +++++++++++++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/packages/client-search/src/types/Rule.ts b/packages/client-search/src/types/Rule.ts index ecca56b36..8412dc250 100644 --- a/packages/client-search/src/types/Rule.ts +++ b/packages/client-search/src/types/Rule.ts @@ -1,4 +1,4 @@ -import { SearchOptions } from '.'; +import { SearchOptions, Settings } from '.'; export type Rule = { /** @@ -125,6 +125,12 @@ export type ConsequenceParams = { * Behaves like optionalFilters. */ readonly automaticOptionalFacetFilters?: readonly AutomaticFacetFilter[]; + + /** + * Content defining how the search interface should be rendered. + * A default value for this can be set via settings + */ + readonly renderingContent?: Settings['renderingContent']; }; export type Condition = { @@ -186,12 +192,12 @@ export type Consequence = { export type TimeRange = { /** - * DateTime with UTC offset for Serialization/Deserialization in unix timespam. + * DateTime with UTC offset for Serialization/Deserialization in unix timespan. */ readonly from: number; /** - * DateTime with UTC offset for Serialization/Deserialization in unix timespam. + * DateTime with UTC offset for Serialization/Deserialization in unix timespan. */ readonly until: number; }; diff --git a/packages/client-search/src/types/SearchResponse.ts b/packages/client-search/src/types/SearchResponse.ts index 2bf309a5d..698fe3245 100644 --- a/packages/client-search/src/types/SearchResponse.ts +++ b/packages/client-search/src/types/SearchResponse.ts @@ -1,4 +1,4 @@ -import { Hit } from '.'; +import { Hit, Settings } from '.'; export type SearchResponse = { /** @@ -225,4 +225,6 @@ export type SearchResponse = { * The relevancy threshold applied to search in a virtual index. */ appliedRelevancyStrictness?: number; + + renderingContent?: Settings['renderingContent']; }; diff --git a/packages/client-search/src/types/Settings.ts b/packages/client-search/src/types/Settings.ts index 5e9b58509..309317e63 100644 --- a/packages/client-search/src/types/Settings.ts +++ b/packages/client-search/src/types/Settings.ts @@ -304,4 +304,43 @@ export type Settings = { * less relevant results. */ readonly relevancyStrictness?: number; + + /** + * Content defining how the search interface should be rendered. + * This is set via the settings for a default value and can be overridden via rules + */ + readonly renderingContent?: { + /** + * defining how facets should be ordered + */ + readonly facetOrdering?: { + /** + * the ordering of facets (widgets) + */ + readonly facet?: { + /** + * pinned order of facet lists + */ + readonly order: readonly string[]; + }; + /** + * the ordering of facet values, within an individual list + */ + readonly values?: { + readonly [facet: string]: { + /** + * pinned order of facet values + */ + readonly order: readonly string[]; + /** + * How to display the remaining items. + * - facet count (descending) + * - alphabetical (ascending) + * - hidden (show only pinned values) + */ + readonly sortRemainingBy: 'count' | 'alpha' | 'hidden'; + }; + }; + }; + }; };