diff --git a/clients/algoliasearch-client-javascript/client-analytics/src/analyticsApi.ts b/clients/algoliasearch-client-javascript/client-analytics/src/analyticsApi.ts index f41e3db1d4e..3e1d144b6a1 100644 --- a/clients/algoliasearch-client-javascript/client-analytics/src/analyticsApi.ts +++ b/clients/algoliasearch-client-javascript/client-analytics/src/analyticsApi.ts @@ -712,6 +712,7 @@ export class AnalyticsApi { * @summary Returns top filter attributes. * @param getTopFilterAttributes - The getTopFilterAttributes parameters. * @param getTopFilterAttributes.index - The index name to target. + * @param getTopFilterAttributes.search - The query term to search for. Must match the exact user input. * @param getTopFilterAttributes.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. * @param getTopFilterAttributes.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. * @param getTopFilterAttributes.limit - How many items to fetch. @@ -720,6 +721,7 @@ export class AnalyticsApi { */ getTopFilterAttributes({ index, + search, startDate, endDate, limit, @@ -740,81 +742,8 @@ export class AnalyticsApi { queryParameters.index = index.toString(); } - if (startDate !== undefined) { - queryParameters.startDate = startDate.toString(); - } - - if (endDate !== undefined) { - queryParameters.endDate = endDate.toString(); - } - - if (limit !== undefined) { - queryParameters.limit = limit.toString(); - } - - if (offset !== undefined) { - queryParameters.offset = offset.toString(); - } - - if (tags !== undefined) { - queryParameters.tags = tags.toString(); - } - - const request: Request = { - method: 'GET', - path, - }; - - const requestOptions: RequestOptions = { - headers, - queryParameters, - }; - - return this.sendRequest(request, requestOptions); - } - /** - * Returns top filter attributes for a given search. Limited to the 1000 most used filters. - * - * @summary Returns top filter attributes for a given search. - * @param getTopFilterAttributesForSearch - The getTopFilterAttributesForSearch parameters. - * @param getTopFilterAttributesForSearch.index - The index name to target. - * @param getTopFilterAttributesForSearch.search - The query term. Must match the exact user input. - * @param getTopFilterAttributesForSearch.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopFilterAttributesForSearch.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopFilterAttributesForSearch.limit - How many items to fetch. - * @param getTopFilterAttributesForSearch.offset - From which position to start retrieving results. - * @param getTopFilterAttributesForSearch.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - getTopFilterAttributesForSearch({ - index, - search, - startDate, - endDate, - limit, - offset, - tags, - }: GetTopFilterAttributesForSearchProps): Promise { - const path = '/2/filters?search={search}'.replace( - '{search}', - encodeURIComponent(String(search)) - ); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (index === null || index === undefined) { - throw new Error( - 'Required parameter index was null or undefined when calling getTopFilterAttributesForSearch.' - ); - } - - if (search === null || search === undefined) { - throw new Error( - 'Required parameter search was null or undefined when calling getTopFilterAttributesForSearch.' - ); - } - - if (index !== undefined) { - queryParameters.index = index.toString(); + if (search !== undefined) { + queryParameters.search = search.toString(); } if (startDate !== undefined) { @@ -856,6 +785,7 @@ export class AnalyticsApi { * @param getTopFilterForAttribute - The getTopFilterForAttribute parameters. * @param getTopFilterForAttribute.attribute - The exact name of the attribute. * @param getTopFilterForAttribute.index - The index name to target. + * @param getTopFilterForAttribute.search - The query term to search for. Must match the exact user input. * @param getTopFilterForAttribute.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. * @param getTopFilterForAttribute.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. * @param getTopFilterForAttribute.limit - How many items to fetch. @@ -865,6 +795,7 @@ export class AnalyticsApi { getTopFilterForAttribute({ attribute, index, + search, startDate, endDate, limit, @@ -894,88 +825,8 @@ export class AnalyticsApi { queryParameters.index = index.toString(); } - if (startDate !== undefined) { - queryParameters.startDate = startDate.toString(); - } - - if (endDate !== undefined) { - queryParameters.endDate = endDate.toString(); - } - - if (limit !== undefined) { - queryParameters.limit = limit.toString(); - } - - if (offset !== undefined) { - queryParameters.offset = offset.toString(); - } - - if (tags !== undefined) { - queryParameters.tags = tags.toString(); - } - - const request: Request = { - method: 'GET', - path, - }; - - const requestOptions: RequestOptions = { - headers, - queryParameters, - }; - - return this.sendRequest(request, requestOptions); - } - /** - * Returns top filters for the given attributes and search. Several attributes can be given by separating them with a comma. Several attributes can be given by separating them with a comma. - * - * @summary Returns top filters for the given attributes and search. - * @param getTopFiltersForAttributesSearch - The getTopFiltersForAttributesSearch parameters. - * @param getTopFiltersForAttributesSearch.attributes - The exact names of the attributes, separated by commas. - * @param getTopFiltersForAttributesSearch.index - The index name to target. - * @param getTopFiltersForAttributesSearch.search - The query term. Must match the exact user input. - * @param getTopFiltersForAttributesSearch.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopFiltersForAttributesSearch.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopFiltersForAttributesSearch.limit - How many items to fetch. - * @param getTopFiltersForAttributesSearch.offset - From which position to start retrieving results. - * @param getTopFiltersForAttributesSearch.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - getTopFiltersForAttributesSearch({ - attributes, - index, - search, - startDate, - endDate, - limit, - offset, - tags, - }: GetTopFiltersForAttributesSearchProps): Promise { - const path = '/2/filters/{attributes}?search={search}' - .replace('{attributes}', encodeURIComponent(String(attributes))) - .replace('{search}', encodeURIComponent(String(search))); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (attributes === null || attributes === undefined) { - throw new Error( - 'Required parameter attributes was null or undefined when calling getTopFiltersForAttributesSearch.' - ); - } - - if (index === null || index === undefined) { - throw new Error( - 'Required parameter index was null or undefined when calling getTopFiltersForAttributesSearch.' - ); - } - - if (search === null || search === undefined) { - throw new Error( - 'Required parameter search was null or undefined when calling getTopFiltersForAttributesSearch.' - ); - } - - if (index !== undefined) { - queryParameters.index = index.toString(); + if (search !== undefined) { + queryParameters.search = search.toString(); } if (startDate !== undefined) { @@ -1016,6 +867,7 @@ export class AnalyticsApi { * @summary Returns top filters with no results. * @param getTopFiltersNoResults - The getTopFiltersNoResults parameters. * @param getTopFiltersNoResults.index - The index name to target. + * @param getTopFiltersNoResults.search - The query term to search for. Must match the exact user input. * @param getTopFiltersNoResults.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. * @param getTopFiltersNoResults.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. * @param getTopFiltersNoResults.limit - How many items to fetch. @@ -1024,6 +876,7 @@ export class AnalyticsApi { */ getTopFiltersNoResults({ index, + search, startDate, endDate, limit, @@ -1044,81 +897,8 @@ export class AnalyticsApi { queryParameters.index = index.toString(); } - if (startDate !== undefined) { - queryParameters.startDate = startDate.toString(); - } - - if (endDate !== undefined) { - queryParameters.endDate = endDate.toString(); - } - - if (limit !== undefined) { - queryParameters.limit = limit.toString(); - } - - if (offset !== undefined) { - queryParameters.offset = offset.toString(); - } - - if (tags !== undefined) { - queryParameters.tags = tags.toString(); - } - - const request: Request = { - method: 'GET', - path, - }; - - const requestOptions: RequestOptions = { - headers, - queryParameters, - }; - - return this.sendRequest(request, requestOptions); - } - /** - * Returns top filters for the given no result search. Limited to the 1000 most used filters. - * - * @summary Returns top filters for the given no result search. - * @param getTopFiltersNoResultsForSearch - The getTopFiltersNoResultsForSearch parameters. - * @param getTopFiltersNoResultsForSearch.index - The index name to target. - * @param getTopFiltersNoResultsForSearch.search - The query term. Must match the exact user input. - * @param getTopFiltersNoResultsForSearch.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopFiltersNoResultsForSearch.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopFiltersNoResultsForSearch.limit - How many items to fetch. - * @param getTopFiltersNoResultsForSearch.offset - From which position to start retrieving results. - * @param getTopFiltersNoResultsForSearch.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - getTopFiltersNoResultsForSearch({ - index, - search, - startDate, - endDate, - limit, - offset, - tags, - }: GetTopFiltersNoResultsForSearchProps): Promise { - const path = '/2/filters/noResults?search={search}'.replace( - '{search}', - encodeURIComponent(String(search)) - ); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (index === null || index === undefined) { - throw new Error( - 'Required parameter index was null or undefined when calling getTopFiltersNoResultsForSearch.' - ); - } - - if (search === null || search === undefined) { - throw new Error( - 'Required parameter search was null or undefined when calling getTopFiltersNoResultsForSearch.' - ); - } - - if (index !== undefined) { - queryParameters.index = index.toString(); + if (search !== undefined) { + queryParameters.search = search.toString(); } if (startDate !== undefined) { @@ -1159,6 +939,7 @@ export class AnalyticsApi { * @summary Returns top hits. * @param getTopHits - The getTopHits parameters. * @param getTopHits.index - The index name to target. + * @param getTopHits.search - The query term to search for. Must match the exact user input. * @param getTopHits.clickAnalytics - Whether to include the click-through and conversion rates for a search. * @param getTopHits.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. * @param getTopHits.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. @@ -1168,6 +949,7 @@ export class AnalyticsApi { */ getTopHits({ index, + search, clickAnalytics, startDate, endDate, @@ -1191,89 +973,8 @@ export class AnalyticsApi { queryParameters.index = index.toString(); } - if (clickAnalytics !== undefined) { - queryParameters.clickAnalytics = clickAnalytics.toString(); - } - - if (startDate !== undefined) { - queryParameters.startDate = startDate.toString(); - } - - if (endDate !== undefined) { - queryParameters.endDate = endDate.toString(); - } - - if (limit !== undefined) { - queryParameters.limit = limit.toString(); - } - - if (offset !== undefined) { - queryParameters.offset = offset.toString(); - } - - if (tags !== undefined) { - queryParameters.tags = tags.toString(); - } - - const request: Request = { - method: 'GET', - path, - }; - - const requestOptions: RequestOptions = { - headers, - queryParameters, - }; - - return this.sendRequest(request, requestOptions); - } - /** - * Returns top hits for the given search. Limited to the 1000 most frequent ones. - * - * @summary Returns top hits for the given search. - * @param getTopHitsForSearch - The getTopHitsForSearch parameters. - * @param getTopHitsForSearch.index - The index name to target. - * @param getTopHitsForSearch.search - The query term. Must match the exact user input. - * @param getTopHitsForSearch.clickAnalytics - Whether to include the click-through and conversion rates for a search. - * @param getTopHitsForSearch.startDate - The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopHitsForSearch.endDate - The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - * @param getTopHitsForSearch.limit - How many items to fetch. - * @param getTopHitsForSearch.offset - From which position to start retrieving results. - * @param getTopHitsForSearch.tags - Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - getTopHitsForSearch({ - index, - search, - clickAnalytics, - startDate, - endDate, - limit, - offset, - tags, - }: GetTopHitsForSearchProps): Promise< - GetTopHitsResponse | GetTopHitsResponseWithAnalytics - > { - const path = '/2/hits?search={search}'.replace( - '{search}', - encodeURIComponent(String(search)) - ); - const headers: Headers = { Accept: 'application/json' }; - const queryParameters: Record = {}; - - if (index === null || index === undefined) { - throw new Error( - 'Required parameter index was null or undefined when calling getTopHitsForSearch.' - ); - } - - if (search === null || search === undefined) { - throw new Error( - 'Required parameter search was null or undefined when calling getTopHitsForSearch.' - ); - } - - if (index !== undefined) { - queryParameters.index = index.toString(); + if (search !== undefined) { + queryParameters.search = search.toString(); } if (clickAnalytics !== undefined) { @@ -1462,11 +1163,11 @@ export type GetAverageClickPositionProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ @@ -1481,11 +1182,11 @@ export type GetClickPositionsProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ @@ -1500,11 +1201,11 @@ export type GetClickThroughRateProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ @@ -1519,11 +1220,11 @@ export type GetConversationRateProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ @@ -1538,11 +1239,11 @@ export type GetNoClickRateProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ @@ -1557,11 +1258,11 @@ export type GetNoResultsRateProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ @@ -1576,11 +1277,11 @@ export type GetSearchesCountProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ @@ -1595,11 +1296,11 @@ export type GetSearchesNoClicksProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * How many items to fetch. */ @@ -1622,11 +1323,11 @@ export type GetSearchesNoResultsProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * How many items to fetch. */ @@ -1656,11 +1357,11 @@ export type GetTopCountriesProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * How many items to fetch. */ @@ -1681,44 +1382,17 @@ export type GetTopFilterAttributesProps = { */ index: string; /** - * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - startDate?: Date; - /** - * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - endDate?: Date; - /** - * How many items to fetch. - */ - limit?: number; - /** - * From which position to start retrieving results. - */ - offset?: number; - /** - * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - tags?: string; -}; - -export type GetTopFilterAttributesForSearchProps = { - /** - * The index name to target. - */ - index: string; - /** - * The query term. Must match the exact user input. + * The query term to search for. Must match the exact user input. */ - search: string; + search?: string; /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * How many items to fetch. */ @@ -1743,48 +1417,17 @@ export type GetTopFilterForAttributeProps = { */ index: string; /** - * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - startDate?: Date; - /** - * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - endDate?: Date; - /** - * How many items to fetch. + * The query term to search for. Must match the exact user input. */ - limit?: number; - /** - * From which position to start retrieving results. - */ - offset?: number; - /** - * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - tags?: string; -}; - -export type GetTopFiltersForAttributesSearchProps = { - /** - * The exact names of the attributes, separated by commas. - */ - attributes: string; - /** - * The index name to target. - */ - index: string; - /** - * The query term. Must match the exact user input. - */ - search: string; + search?: string; /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * How many items to fetch. */ @@ -1805,44 +1448,17 @@ export type GetTopFiltersNoResultsProps = { */ index: string; /** - * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - startDate?: Date; - /** - * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - endDate?: Date; - /** - * How many items to fetch. + * The query term to search for. Must match the exact user input. */ - limit?: number; - /** - * From which position to start retrieving results. - */ - offset?: number; - /** - * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - tags?: string; -}; - -export type GetTopFiltersNoResultsForSearchProps = { - /** - * The index name to target. - */ - index: string; - /** - * The query term. Must match the exact user input. - */ - search: string; + search?: string; /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * How many items to fetch. */ @@ -1863,40 +1479,9 @@ export type GetTopHitsProps = { */ index: string; /** - * Whether to include the click-through and conversion rates for a search. - */ - clickAnalytics?: boolean; - /** - * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - startDate?: Date; - /** - * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. - */ - endDate?: Date; - /** - * How many items to fetch. - */ - limit?: number; - /** - * From which position to start retrieving results. - */ - offset?: number; - /** - * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. - */ - tags?: string; -}; - -export type GetTopHitsForSearchProps = { - /** - * The index name to target. - */ - index: string; - /** - * The query term. Must match the exact user input. + * The query term to search for. Must match the exact user input. */ - search: string; + search?: string; /** * Whether to include the click-through and conversion rates for a search. */ @@ -1904,11 +1489,11 @@ export type GetTopHitsForSearchProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * How many items to fetch. */ @@ -1935,11 +1520,11 @@ export type GetTopSearchesProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Reorder the results. */ @@ -1974,11 +1559,11 @@ export type GetUsersCountProps = { /** * The lower bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - startDate?: Date; + startDate?: string; /** * The upper bound timestamp (a date, a string like \"2006-01-02\") of the period to analyze. */ - endDate?: Date; + endDate?: string; /** * Filter metrics on the provided tags. Each tag must correspond to an analyticsTags set at search time. Multiple tags can be combined with the operators OR and AND. If a tag contains characters like spaces or parentheses, it should be URL encoded. */ diff --git a/clients/algoliasearch-client-javascript/client-analytics/utils/requester/EchoRequester.ts b/clients/algoliasearch-client-javascript/client-analytics/utils/requester/EchoRequester.ts index 41a3dd9041b..ec75b37a41b 100644 --- a/clients/algoliasearch-client-javascript/client-analytics/utils/requester/EchoRequester.ts +++ b/clients/algoliasearch-client-javascript/client-analytics/utils/requester/EchoRequester.ts @@ -2,14 +2,58 @@ import type { EndRequest, Request, Response } from '../types'; import { Requester } from './Requester'; +type AdditionalContent = { + headers: Record; + connectTimeout: number; + responseTimeout: number; + userAgent?: string; + searchParams?: Record; +}; + +function searchParamsWithoutUA( + params: URLSearchParams +): AdditionalContent['searchParams'] { + const searchParams = {}; + + for (const [k, v] of params) { + if (k === 'x-algolia-agent') { + continue; + } + + searchParams[k] = v; + } + + return Object.entries(searchParams).length === 0 ? undefined : searchParams; +} + export class EchoRequester extends Requester { constructor(private status = 200) { super(); } - send(_request: EndRequest, originalRequest: Request): Promise { + send( + { headers, url, connectTimeout, responseTimeout }: EndRequest, + { data, ...originalRequest }: Request + ): Promise { + const urlSearchParams = new URL(url).searchParams; + const userAgent = urlSearchParams.get('x-algolia-agent') || undefined; + const searchParams = searchParamsWithoutUA(urlSearchParams); + const additionalContent: AdditionalContent = { + headers, + connectTimeout, + responseTimeout, + userAgent: userAgent ? encodeURI(userAgent) : undefined, + searchParams, + }; + const originalData = + data && Object.entries(data).length > 0 ? data : undefined; + return Promise.resolve({ - content: JSON.stringify(originalRequest), + content: JSON.stringify({ + ...originalRequest, + ...additionalContent, + data: originalData, + }), isTimedOut: false, status: this.status, }); diff --git a/clients/algoliasearch-client-javascript/client-insights/utils/requester/EchoRequester.ts b/clients/algoliasearch-client-javascript/client-insights/utils/requester/EchoRequester.ts index 41a3dd9041b..ec75b37a41b 100644 --- a/clients/algoliasearch-client-javascript/client-insights/utils/requester/EchoRequester.ts +++ b/clients/algoliasearch-client-javascript/client-insights/utils/requester/EchoRequester.ts @@ -2,14 +2,58 @@ import type { EndRequest, Request, Response } from '../types'; import { Requester } from './Requester'; +type AdditionalContent = { + headers: Record; + connectTimeout: number; + responseTimeout: number; + userAgent?: string; + searchParams?: Record; +}; + +function searchParamsWithoutUA( + params: URLSearchParams +): AdditionalContent['searchParams'] { + const searchParams = {}; + + for (const [k, v] of params) { + if (k === 'x-algolia-agent') { + continue; + } + + searchParams[k] = v; + } + + return Object.entries(searchParams).length === 0 ? undefined : searchParams; +} + export class EchoRequester extends Requester { constructor(private status = 200) { super(); } - send(_request: EndRequest, originalRequest: Request): Promise { + send( + { headers, url, connectTimeout, responseTimeout }: EndRequest, + { data, ...originalRequest }: Request + ): Promise { + const urlSearchParams = new URL(url).searchParams; + const userAgent = urlSearchParams.get('x-algolia-agent') || undefined; + const searchParams = searchParamsWithoutUA(urlSearchParams); + const additionalContent: AdditionalContent = { + headers, + connectTimeout, + responseTimeout, + userAgent: userAgent ? encodeURI(userAgent) : undefined, + searchParams, + }; + const originalData = + data && Object.entries(data).length > 0 ? data : undefined; + return Promise.resolve({ - content: JSON.stringify(originalRequest), + content: JSON.stringify({ + ...originalRequest, + ...additionalContent, + data: originalData, + }), isTimedOut: false, status: this.status, }); diff --git a/clients/algoliasearch-client-javascript/client-personalization/utils/requester/EchoRequester.ts b/clients/algoliasearch-client-javascript/client-personalization/utils/requester/EchoRequester.ts index 41a3dd9041b..ec75b37a41b 100644 --- a/clients/algoliasearch-client-javascript/client-personalization/utils/requester/EchoRequester.ts +++ b/clients/algoliasearch-client-javascript/client-personalization/utils/requester/EchoRequester.ts @@ -2,14 +2,58 @@ import type { EndRequest, Request, Response } from '../types'; import { Requester } from './Requester'; +type AdditionalContent = { + headers: Record; + connectTimeout: number; + responseTimeout: number; + userAgent?: string; + searchParams?: Record; +}; + +function searchParamsWithoutUA( + params: URLSearchParams +): AdditionalContent['searchParams'] { + const searchParams = {}; + + for (const [k, v] of params) { + if (k === 'x-algolia-agent') { + continue; + } + + searchParams[k] = v; + } + + return Object.entries(searchParams).length === 0 ? undefined : searchParams; +} + export class EchoRequester extends Requester { constructor(private status = 200) { super(); } - send(_request: EndRequest, originalRequest: Request): Promise { + send( + { headers, url, connectTimeout, responseTimeout }: EndRequest, + { data, ...originalRequest }: Request + ): Promise { + const urlSearchParams = new URL(url).searchParams; + const userAgent = urlSearchParams.get('x-algolia-agent') || undefined; + const searchParams = searchParamsWithoutUA(urlSearchParams); + const additionalContent: AdditionalContent = { + headers, + connectTimeout, + responseTimeout, + userAgent: userAgent ? encodeURI(userAgent) : undefined, + searchParams, + }; + const originalData = + data && Object.entries(data).length > 0 ? data : undefined; + return Promise.resolve({ - content: JSON.stringify(originalRequest), + content: JSON.stringify({ + ...originalRequest, + ...additionalContent, + data: originalData, + }), isTimedOut: false, status: this.status, }); diff --git a/clients/algoliasearch-client-javascript/client-search/utils/requester/EchoRequester.ts b/clients/algoliasearch-client-javascript/client-search/utils/requester/EchoRequester.ts index 41a3dd9041b..ec75b37a41b 100644 --- a/clients/algoliasearch-client-javascript/client-search/utils/requester/EchoRequester.ts +++ b/clients/algoliasearch-client-javascript/client-search/utils/requester/EchoRequester.ts @@ -2,14 +2,58 @@ import type { EndRequest, Request, Response } from '../types'; import { Requester } from './Requester'; +type AdditionalContent = { + headers: Record; + connectTimeout: number; + responseTimeout: number; + userAgent?: string; + searchParams?: Record; +}; + +function searchParamsWithoutUA( + params: URLSearchParams +): AdditionalContent['searchParams'] { + const searchParams = {}; + + for (const [k, v] of params) { + if (k === 'x-algolia-agent') { + continue; + } + + searchParams[k] = v; + } + + return Object.entries(searchParams).length === 0 ? undefined : searchParams; +} + export class EchoRequester extends Requester { constructor(private status = 200) { super(); } - send(_request: EndRequest, originalRequest: Request): Promise { + send( + { headers, url, connectTimeout, responseTimeout }: EndRequest, + { data, ...originalRequest }: Request + ): Promise { + const urlSearchParams = new URL(url).searchParams; + const userAgent = urlSearchParams.get('x-algolia-agent') || undefined; + const searchParams = searchParamsWithoutUA(urlSearchParams); + const additionalContent: AdditionalContent = { + headers, + connectTimeout, + responseTimeout, + userAgent: userAgent ? encodeURI(userAgent) : undefined, + searchParams, + }; + const originalData = + data && Object.entries(data).length > 0 ? data : undefined; + return Promise.resolve({ - content: JSON.stringify(originalRequest), + content: JSON.stringify({ + ...originalRequest, + ...additionalContent, + data: originalData, + }), isTimedOut: false, status: this.status, }); diff --git a/clients/algoliasearch-client-javascript/recommend/utils/requester/EchoRequester.ts b/clients/algoliasearch-client-javascript/recommend/utils/requester/EchoRequester.ts index 41a3dd9041b..ec75b37a41b 100644 --- a/clients/algoliasearch-client-javascript/recommend/utils/requester/EchoRequester.ts +++ b/clients/algoliasearch-client-javascript/recommend/utils/requester/EchoRequester.ts @@ -2,14 +2,58 @@ import type { EndRequest, Request, Response } from '../types'; import { Requester } from './Requester'; +type AdditionalContent = { + headers: Record; + connectTimeout: number; + responseTimeout: number; + userAgent?: string; + searchParams?: Record; +}; + +function searchParamsWithoutUA( + params: URLSearchParams +): AdditionalContent['searchParams'] { + const searchParams = {}; + + for (const [k, v] of params) { + if (k === 'x-algolia-agent') { + continue; + } + + searchParams[k] = v; + } + + return Object.entries(searchParams).length === 0 ? undefined : searchParams; +} + export class EchoRequester extends Requester { constructor(private status = 200) { super(); } - send(_request: EndRequest, originalRequest: Request): Promise { + send( + { headers, url, connectTimeout, responseTimeout }: EndRequest, + { data, ...originalRequest }: Request + ): Promise { + const urlSearchParams = new URL(url).searchParams; + const userAgent = urlSearchParams.get('x-algolia-agent') || undefined; + const searchParams = searchParamsWithoutUA(urlSearchParams); + const additionalContent: AdditionalContent = { + headers, + connectTimeout, + responseTimeout, + userAgent: userAgent ? encodeURI(userAgent) : undefined, + searchParams, + }; + const originalData = + data && Object.entries(data).length > 0 ? data : undefined; + return Promise.resolve({ - content: JSON.stringify(originalRequest), + content: JSON.stringify({ + ...originalRequest, + ...additionalContent, + data: originalData, + }), isTimedOut: false, status: this.status, }); diff --git a/clients/algoliasearch-client-javascript/utils/requester/EchoRequester.ts b/clients/algoliasearch-client-javascript/utils/requester/EchoRequester.ts index 41a3dd9041b..ec75b37a41b 100644 --- a/clients/algoliasearch-client-javascript/utils/requester/EchoRequester.ts +++ b/clients/algoliasearch-client-javascript/utils/requester/EchoRequester.ts @@ -2,14 +2,58 @@ import type { EndRequest, Request, Response } from '../types'; import { Requester } from './Requester'; +type AdditionalContent = { + headers: Record; + connectTimeout: number; + responseTimeout: number; + userAgent?: string; + searchParams?: Record; +}; + +function searchParamsWithoutUA( + params: URLSearchParams +): AdditionalContent['searchParams'] { + const searchParams = {}; + + for (const [k, v] of params) { + if (k === 'x-algolia-agent') { + continue; + } + + searchParams[k] = v; + } + + return Object.entries(searchParams).length === 0 ? undefined : searchParams; +} + export class EchoRequester extends Requester { constructor(private status = 200) { super(); } - send(_request: EndRequest, originalRequest: Request): Promise { + send( + { headers, url, connectTimeout, responseTimeout }: EndRequest, + { data, ...originalRequest }: Request + ): Promise { + const urlSearchParams = new URL(url).searchParams; + const userAgent = urlSearchParams.get('x-algolia-agent') || undefined; + const searchParams = searchParamsWithoutUA(urlSearchParams); + const additionalContent: AdditionalContent = { + headers, + connectTimeout, + responseTimeout, + userAgent: userAgent ? encodeURI(userAgent) : undefined, + searchParams, + }; + const originalData = + data && Object.entries(data).length > 0 ? data : undefined; + return Promise.resolve({ - content: JSON.stringify(originalRequest), + content: JSON.stringify({ + ...originalRequest, + ...additionalContent, + data: originalData, + }), isTimedOut: false, status: this.status, }); diff --git a/specs/analytics/paths/common/parameters.yml b/specs/analytics/paths/common/parameters.yml index 6fb3d21cfd2..a92d33ea2d8 100644 --- a/specs/analytics/paths/common/parameters.yml +++ b/specs/analytics/paths/common/parameters.yml @@ -43,18 +43,9 @@ Limit: default: 10 Search: - in: path - name: search - description: The query term. Must match the exact user input. - required: true - schema: - type: string - -SearchInPath: - in: path + in: query name: search - description: The query term. Must match the exact user input. - required: true + description: The query term to search for. Must match the exact user input. schema: type: string diff --git a/specs/analytics/paths/search/getSearchAttributesTopFilters.yml b/specs/analytics/paths/search/getSearchAttributesTopFilters.yml deleted file mode 100644 index 2dbe813d59b..00000000000 --- a/specs/analytics/paths/search/getSearchAttributesTopFilters.yml +++ /dev/null @@ -1,63 +0,0 @@ -get: - tags: - - analytics - operationId: getSearchAttributesTopFilters - description: Returns top filters for the given no result search. Limited to the 1000 most used filters. - summary: Returns top filters for the given no result search. - parameters: - - $ref: '../../../common/parameters.yml#/Index' - - $ref: '../common/parameters.yml#/Search' - - $ref: '../../../common/parameters.yml#/StartDate' - - $ref: '../../../common/parameters.yml#/EndDate' - - $ref: '../common/parameters.yml#/Limit' - - $ref: '../common/parameters.yml#/Offset' - - $ref: '../common/parameters.yml#/Tags' - responses: - '200': - description: OK - content: - application/json: - schema: - title: getSearchAttributesTopFiltersResponse - type: object - additionalProperties: false - required: - - values - properties: - values: - type: array - description: A list of filters without results. - items: - type: object - additionalProperties: false - required: - - values - - count - properties: - count: - description: The number of occurrences. - type: integer - values: - type: array - items: - type: object - additionalProperties: false - required: - - attribute - - operator - - value - properties: - attribute: - $ref: '../common/parameters.yml#/attribute' - operator: - $ref: '../common/parameters.yml#/operator' - value: - $ref: '../common/parameters.yml#/value' - '400': - $ref: ../../../common/responses/BadRequest.yml - '402': - $ref: ../../../common/responses/FeatureNotEnabled.yml - '403': - $ref: ../../../common/responses/MethodNotAllowed.yml - '404': - $ref: ../../../common/responses/IndexNotFound.yml diff --git a/specs/analytics/paths/search/getTopFilterAttributes.yml b/specs/analytics/paths/search/getTopFilterAttributes.yml index 226d54638df..bdb7cc1ffa9 100644 --- a/specs/analytics/paths/search/getTopFilterAttributes.yml +++ b/specs/analytics/paths/search/getTopFilterAttributes.yml @@ -6,6 +6,7 @@ get: summary: Returns top filter attributes. parameters: - $ref: '../../../common/parameters.yml#/Index' + - $ref: '../common/parameters.yml#/Search' - $ref: '../../../common/parameters.yml#/StartDate' - $ref: '../../../common/parameters.yml#/EndDate' - $ref: '../common/parameters.yml#/Limit' diff --git a/specs/analytics/paths/search/getTopFilterAttributesForSearch.yml b/specs/analytics/paths/search/getTopFilterAttributesForSearch.yml deleted file mode 100644 index 71073a7f275..00000000000 --- a/specs/analytics/paths/search/getTopFilterAttributesForSearch.yml +++ /dev/null @@ -1,29 +0,0 @@ -get: - tags: - - analytics - operationId: getTopFilterAttributesForSearch - description: Returns top filter attributes for a given search. Limited to the 1000 most used filters. - summary: Returns top filter attributes for a given search. - parameters: - - $ref: '../../../common/parameters.yml#/Index' - - $ref: '../common/parameters.yml#/SearchInPath' - - $ref: '../../../common/parameters.yml#/StartDate' - - $ref: '../../../common/parameters.yml#/EndDate' - - $ref: '../common/parameters.yml#/Limit' - - $ref: '../common/parameters.yml#/Offset' - - $ref: '../common/parameters.yml#/Tags' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '../common/schemas/getTopFilterAttributes.yml#/getTopFilterAttributesResponse' - '400': - $ref: ../../../common/responses/BadRequest.yml - '402': - $ref: ../../../common/responses/FeatureNotEnabled.yml - '403': - $ref: ../../../common/responses/MethodNotAllowed.yml - '404': - $ref: ../../../common/responses/IndexNotFound.yml diff --git a/specs/analytics/paths/search/getTopFilterForAttribute.yml b/specs/analytics/paths/search/getTopFilterForAttribute.yml index dce6dd8306f..4d7d6e89d21 100644 --- a/specs/analytics/paths/search/getTopFilterForAttribute.yml +++ b/specs/analytics/paths/search/getTopFilterForAttribute.yml @@ -7,6 +7,7 @@ get: parameters: - $ref: '../common/parameters.yml#/Attribute' - $ref: '../../../common/parameters.yml#/Index' + - $ref: '../common/parameters.yml#/Search' - $ref: '../../../common/parameters.yml#/StartDate' - $ref: '../../../common/parameters.yml#/EndDate' - $ref: '../common/parameters.yml#/Limit' diff --git a/specs/analytics/paths/search/getTopFiltersForAttributesSearch.yml b/specs/analytics/paths/search/getTopFiltersForAttributesSearch.yml deleted file mode 100644 index 26f7cc00f6a..00000000000 --- a/specs/analytics/paths/search/getTopFiltersForAttributesSearch.yml +++ /dev/null @@ -1,35 +0,0 @@ -get: - tags: - - analytics - operationId: getTopFiltersForAttributesSearch - description: Returns top filters for the given attributes and search. Several attributes can be given by separating them with a comma. Several attributes can be given by separating them with a comma. - summary: Returns top filters for the given attributes and search. - parameters: - - in: path - name: attributes - required: true - description: The exact names of the attributes, separated by commas. - schema: - type: string - - $ref: '../../../common/parameters.yml#/Index' - - $ref: '../common/parameters.yml#/SearchInPath' - - $ref: '../../../common/parameters.yml#/StartDate' - - $ref: '../../../common/parameters.yml#/EndDate' - - $ref: '../common/parameters.yml#/Limit' - - $ref: '../common/parameters.yml#/Offset' - - $ref: '../common/parameters.yml#/Tags' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '../common/schemas/getTopFilterForAttribute.yml#/getTopFilterForAttributeResponse' - '400': - $ref: ../../../common/responses/BadRequest.yml - '402': - $ref: ../../../common/responses/FeatureNotEnabled.yml - '403': - $ref: ../../../common/responses/MethodNotAllowed.yml - '404': - $ref: ../../../common/responses/IndexNotFound.yml diff --git a/specs/analytics/paths/search/getTopFiltersNoResults.yml b/specs/analytics/paths/search/getTopFiltersNoResults.yml index 232c9840352..da2a552b87c 100644 --- a/specs/analytics/paths/search/getTopFiltersNoResults.yml +++ b/specs/analytics/paths/search/getTopFiltersNoResults.yml @@ -6,6 +6,7 @@ get: summary: Returns top filters with no results. parameters: - $ref: '../../../common/parameters.yml#/Index' + - $ref: '../common/parameters.yml#/Search' - $ref: '../../../common/parameters.yml#/StartDate' - $ref: '../../../common/parameters.yml#/EndDate' - $ref: '../common/parameters.yml#/Limit' diff --git a/specs/analytics/paths/search/getTopFiltersNoResultsForSearch.yml b/specs/analytics/paths/search/getTopFiltersNoResultsForSearch.yml deleted file mode 100644 index e6f7e768f56..00000000000 --- a/specs/analytics/paths/search/getTopFiltersNoResultsForSearch.yml +++ /dev/null @@ -1,29 +0,0 @@ -get: - tags: - - analytics - operationId: getTopFiltersNoResultsForSearch - description: Returns top filters for the given no result search. Limited to the 1000 most used filters. - summary: Returns top filters for the given no result search. - parameters: - - $ref: '../../../common/parameters.yml#/Index' - - $ref: '../common/parameters.yml#/SearchInPath' - - $ref: '../../../common/parameters.yml#/StartDate' - - $ref: '../../../common/parameters.yml#/EndDate' - - $ref: '../common/parameters.yml#/Limit' - - $ref: '../common/parameters.yml#/Offset' - - $ref: '../common/parameters.yml#/Tags' - responses: - '200': - description: OK - content: - application/json: - schema: - $ref: '../common/schemas/getTopFiltersNoResults.yml#/getTopFiltersNoResultsResponse' - '400': - $ref: ../../../common/responses/BadRequest.yml - '402': - $ref: ../../../common/responses/FeatureNotEnabled.yml - '403': - $ref: ../../../common/responses/MethodNotAllowed.yml - '404': - $ref: ../../../common/responses/IndexNotFound.yml diff --git a/specs/analytics/paths/search/getTopHits.yml b/specs/analytics/paths/search/getTopHits.yml index ce6b8af451d..ce5c0ae790a 100644 --- a/specs/analytics/paths/search/getTopHits.yml +++ b/specs/analytics/paths/search/getTopHits.yml @@ -6,6 +6,7 @@ get: summary: Returns top hits. parameters: - $ref: '../../../common/parameters.yml#/Index' + - $ref: '../common/parameters.yml#/Search' - $ref: '../common/parameters.yml#/ClickAnalytics' - $ref: '../../../common/parameters.yml#/StartDate' - $ref: '../../../common/parameters.yml#/EndDate' diff --git a/specs/analytics/paths/search/getTopHitsForSearch.yml b/specs/analytics/paths/search/getTopHitsForSearch.yml deleted file mode 100644 index a96d68a62e7..00000000000 --- a/specs/analytics/paths/search/getTopHitsForSearch.yml +++ /dev/null @@ -1,32 +0,0 @@ -get: - tags: - - analytics - operationId: getTopHitsForSearch - description: Returns top hits for the given search. Limited to the 1000 most frequent ones. - summary: Returns top hits for the given search. - parameters: - - $ref: '../../../common/parameters.yml#/Index' - - $ref: '../common/parameters.yml#/SearchInPath' - - $ref: '../common/parameters.yml#/ClickAnalytics' - - $ref: '../../../common/parameters.yml#/StartDate' - - $ref: '../../../common/parameters.yml#/EndDate' - - $ref: '../common/parameters.yml#/Limit' - - $ref: '../common/parameters.yml#/Offset' - - $ref: '../common/parameters.yml#/Tags' - responses: - '200': - description: OK - content: - application/json: - schema: - oneOf: - - $ref: '../common/schemas/getTopHits.yml#/getTopHitsResponse' - - $ref: '../common/schemas/getTopHits.yml#/getTopHitsResponseWithAnalytics' - '400': - $ref: ../../../common/responses/BadRequest.yml - '402': - $ref: ../../../common/responses/FeatureNotEnabled.yml - '403': - $ref: ../../../common/responses/MethodNotAllowed.yml - '404': - $ref: ../../../common/responses/IndexNotFound.yml diff --git a/specs/analytics/spec.yml b/specs/analytics/spec.yml index 08bf1f40b07..00594254e4f 100644 --- a/specs/analytics/spec.yml +++ b/specs/analytics/spec.yml @@ -30,22 +30,14 @@ paths: $ref: paths/search/getNoClickRate.yml /2/hits: $ref: paths/search/getTopHits.yml - /2/hits?search={search}: - $ref: paths/search/getTopHitsForSearch.yml /2/users/count: $ref: paths/search/getUsersCount.yml /2/filters: $ref: paths/search/getTopFilterAttributes.yml /2/filters/{attribute}: $ref: paths/search/getTopFilterForAttribute.yml - /2/filters?search={search}: - $ref: paths/search/getTopFilterAttributesForSearch.yml /2/filters/noResults: $ref: paths/search/getTopFiltersNoResults.yml - /2/filters/noResults?search={search}: - $ref: paths/search/getTopFiltersNoResultsForSearch.yml - /2/filters/{attributes}?search={search}: - $ref: paths/search/getTopFiltersForAttributesSearch.yml /2/countries: $ref: paths/search/getTopCountries.yml diff --git a/specs/common/parameters.yml b/specs/common/parameters.yml index 4b4fc9721c3..92093705160 100644 --- a/specs/common/parameters.yml +++ b/specs/common/parameters.yml @@ -32,7 +32,8 @@ StartDate: description: The lower bound timestamp (a date, a string like "2006-01-02") of the period to analyze. schema: type: string - format: date-time + example: 1999-09-19 + pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ EndDate: in: query @@ -40,7 +41,8 @@ EndDate: description: The upper bound timestamp (a date, a string like "2006-01-02") of the period to analyze. schema: type: string - format: date-time + example: 2000-01-21 + pattern: ^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$ ForwardToReplicas: in: query diff --git a/tests/CTS/clients/analytics/getAverageClickPosition.json b/tests/CTS/clients/analytics/getAverageClickPosition.json index 579f906124b..2a5ca624051 100644 --- a/tests/CTS/clients/analytics/getAverageClickPosition.json +++ b/tests/CTS/clients/analytics/getAverageClickPosition.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/clicks/averageClickPosition", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/clicks/averageClickPosition", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getClickPositions.json b/tests/CTS/clients/analytics/getClickPositions.json index 2f1827446fc..173abd2798d 100644 --- a/tests/CTS/clients/analytics/getClickPositions.json +++ b/tests/CTS/clients/analytics/getClickPositions.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/clicks/positions", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/clicks/positions", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getClickThroughRate.json b/tests/CTS/clients/analytics/getClickThroughRate.json index c0650975865..9fd79fa8bcb 100644 --- a/tests/CTS/clients/analytics/getClickThroughRate.json +++ b/tests/CTS/clients/analytics/getClickThroughRate.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/clicks/clickThroughRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/clicks/clickThroughRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getConversationRate.json b/tests/CTS/clients/analytics/getConversationRate.json index a829f033f10..10a3be49c27 100644 --- a/tests/CTS/clients/analytics/getConversationRate.json +++ b/tests/CTS/clients/analytics/getConversationRate.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/conversions/conversionRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/conversions/conversionRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getNoClickRate.json b/tests/CTS/clients/analytics/getNoClickRate.json index 6f7f63d80e6..ad9cbb0ef43 100644 --- a/tests/CTS/clients/analytics/getNoClickRate.json +++ b/tests/CTS/clients/analytics/getNoClickRate.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/searches/noClickRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/searches/noClickRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getNoResultsRate.json b/tests/CTS/clients/analytics/getNoResultsRate.json index e53770cea31..0033428e774 100644 --- a/tests/CTS/clients/analytics/getNoResultsRate.json +++ b/tests/CTS/clients/analytics/getNoResultsRate.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/searches/noResultRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/searches/noResultRate", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getSearchesCount.json b/tests/CTS/clients/analytics/getSearchesCount.json index 4c6a1d0aad6..3aa0651899b 100644 --- a/tests/CTS/clients/analytics/getSearchesCount.json +++ b/tests/CTS/clients/analytics/getSearchesCount.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/searches/count", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/searches/count", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getSearchesNoClicks.json b/tests/CTS/clients/analytics/getSearchesNoClicks.json index a46387382a9..e55f488a514 100644 --- a/tests/CTS/clients/analytics/getSearchesNoClicks.json +++ b/tests/CTS/clients/analytics/getSearchesNoClicks.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/searches/noClicks", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -23,7 +26,15 @@ }, "request": { "path": "/2/searches/noClicks", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getSearchesNoResults.json b/tests/CTS/clients/analytics/getSearchesNoResults.json index 0fe953f33b5..f568f1ffadc 100644 --- a/tests/CTS/clients/analytics/getSearchesNoResults.json +++ b/tests/CTS/clients/analytics/getSearchesNoResults.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/searches/noResults", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -23,7 +26,15 @@ }, "request": { "path": "/2/searches/noResults", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getStatus.json b/tests/CTS/clients/analytics/getStatus.json index 4a468d88c33..48b33963c1d 100644 --- a/tests/CTS/clients/analytics/getStatus.json +++ b/tests/CTS/clients/analytics/getStatus.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/status", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } } ] diff --git a/tests/CTS/clients/analytics/getTopCountries.json b/tests/CTS/clients/analytics/getTopCountries.json index d92f70fe377..679126e3348 100644 --- a/tests/CTS/clients/analytics/getTopCountries.json +++ b/tests/CTS/clients/analytics/getTopCountries.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/countries", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -23,7 +26,15 @@ }, "request": { "path": "/2/countries", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getTopFilterAttributes.json b/tests/CTS/clients/analytics/getTopFilterAttributes.json index 2ca6cd17aa4..f99e9386f73 100644 --- a/tests/CTS/clients/analytics/getTopFilterAttributes.json +++ b/tests/CTS/clients/analytics/getTopFilterAttributes.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/filters", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -15,6 +18,7 @@ "testName": "get getTopFilterAttributes with all parameters", "parameters": { "index": "index", + "search": "mySearch", "startDate": "1999-09-19", "endDate": "2001-01-01", "limit": 21, @@ -23,7 +27,16 @@ }, "request": { "path": "/2/filters", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "search": "mySearch", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getTopFilterAttributesForSearch.json b/tests/CTS/clients/analytics/getTopFilterAttributesForSearch.json deleted file mode 100644 index 7f79452fdd9..00000000000 --- a/tests/CTS/clients/analytics/getTopFilterAttributesForSearch.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - { - "method": "getTopFilterAttributesForSearch", - "testName": "get getTopFilterAttributesForSearch with minimal parameters", - "parameters": { - "index": "index", - "search": "mySearch" - }, - "request": { - "path": "/2/filters?search=mySearch", - "method": "GET" - } - }, - { - "method": "getTopFilterAttributesForSearch", - "testName": "get getTopFilterAttributesForSearch with all parameters", - "parameters": { - "index": "index", - "search": "mySearch", - "startDate": "1999-09-19", - "endDate": "2001-01-01", - "limit": 21, - "offset": 42, - "tags": "tag" - }, - "request": { - "path": "/2/filters?search=mySearch", - "method": "GET" - } - } -] diff --git a/tests/CTS/clients/analytics/getTopFilterForAttribute.json b/tests/CTS/clients/analytics/getTopFilterForAttribute.json index 2dddc6a1e92..3cbad8c0d99 100644 --- a/tests/CTS/clients/analytics/getTopFilterForAttribute.json +++ b/tests/CTS/clients/analytics/getTopFilterForAttribute.json @@ -8,7 +8,10 @@ }, "request": { "path": "/2/filters/myAttribute", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -20,7 +23,10 @@ }, "request": { "path": "/2/filters/myAttribute1%2CmyAttribute2", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -29,6 +35,7 @@ "parameters": { "attribute": "myAttribute", "index": "index", + "search": "mySearch", "startDate": "1999-09-19", "endDate": "2001-01-01", "limit": 21, @@ -37,7 +44,16 @@ }, "request": { "path": "/2/filters/myAttribute", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "search": "mySearch", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } }, { @@ -46,6 +62,7 @@ "parameters": { "attribute": "myAttribute1,myAttribute2", "index": "index", + "search": "mySearch", "startDate": "1999-09-19", "endDate": "2001-01-01", "limit": 21, @@ -54,7 +71,16 @@ }, "request": { "path": "/2/filters/myAttribute1%2CmyAttribute2", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "search": "mySearch", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getTopFiltersForAttributesSearch.json b/tests/CTS/clients/analytics/getTopFiltersForAttributesSearch.json deleted file mode 100644 index bef12513160..00000000000 --- a/tests/CTS/clients/analytics/getTopFiltersForAttributesSearch.json +++ /dev/null @@ -1,64 +0,0 @@ -[ - { - "method": "getTopFiltersForAttributesSearch", - "testName": "get getTopFiltersForAttributesSearch with minimal parameters", - "parameters": { - "attributes": "myAttribute", - "index": "index", - "search": "mySearch" - }, - "request": { - "path": "/2/filters/myAttribute?search=mySearch", - "method": "GET" - } - }, - { - "method": "getTopFiltersForAttributesSearch", - "testName": "get getTopFiltersForAttributesSearch with minimal parameters and multiple attributes", - "parameters": { - "attributes": "myAttribute1,myAttribute2", - "index": "index", - "search": "mySearch" - }, - "request": { - "path": "/2/filters/myAttribute1%2CmyAttribute2?search=mySearch", - "method": "GET" - } - }, - { - "method": "getTopFiltersForAttributesSearch", - "testName": "get getTopFiltersForAttributesSearch with all parameters", - "parameters": { - "attributes": "myAttribute", - "index": "index", - "search": "mySearch", - "startDate": "1999-09-19", - "endDate": "2001-01-01", - "limit": 21, - "offset": 42, - "tags": "tag" - }, - "request": { - "path": "/2/filters/myAttribute?search=mySearch", - "method": "GET" - } - }, - { - "method": "getTopFiltersForAttributesSearch", - "testName": "get getTopFiltersForAttributesSearch with all parameters and multiple attributes", - "parameters": { - "attributes": "myAttribute1,myAttribute2", - "index": "index", - "search": "mySearch", - "startDate": "1999-09-19", - "endDate": "2001-01-01", - "limit": 21, - "offset": 42, - "tags": "tag" - }, - "request": { - "path": "/2/filters/myAttribute1%2CmyAttribute2?search=mySearch", - "method": "GET" - } - } -] diff --git a/tests/CTS/clients/analytics/getTopFiltersNoResults.json b/tests/CTS/clients/analytics/getTopFiltersNoResults.json index 23c47ed2d9e..47c3b5b2880 100644 --- a/tests/CTS/clients/analytics/getTopFiltersNoResults.json +++ b/tests/CTS/clients/analytics/getTopFiltersNoResults.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/filters/noResults", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -15,6 +18,7 @@ "testName": "get getTopFiltersNoResults with all parameters", "parameters": { "index": "index", + "search": "mySearch", "startDate": "1999-09-19", "endDate": "2001-01-01", "limit": 21, @@ -23,7 +27,16 @@ }, "request": { "path": "/2/filters/noResults", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "search": "mySearch", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getTopFiltersNoResultsForSearch.json b/tests/CTS/clients/analytics/getTopFiltersNoResultsForSearch.json deleted file mode 100644 index 09b3f0ec974..00000000000 --- a/tests/CTS/clients/analytics/getTopFiltersNoResultsForSearch.json +++ /dev/null @@ -1,31 +0,0 @@ -[ - { - "method": "getTopFiltersNoResultsForSearch", - "testName": "get getTopFiltersNoResultsForSearch with minimal parameters", - "parameters": { - "index": "index", - "search": "mySearch" - }, - "request": { - "path": "/2/filters/noResults?search=mySearch", - "method": "GET" - } - }, - { - "method": "getTopFiltersNoResultsForSearch", - "testName": "get getTopFiltersNoResultsForSearch with all parameters", - "parameters": { - "index": "index", - "search": "mySearch", - "startDate": "1999-09-19", - "endDate": "2001-01-01", - "limit": 21, - "offset": 42, - "tags": "tag" - }, - "request": { - "path": "/2/filters/noResults?search=mySearch", - "method": "GET" - } - } -] diff --git a/tests/CTS/clients/analytics/getTopHits.json b/tests/CTS/clients/analytics/getTopHits.json index 49511ac82c4..9fcb31162dd 100644 --- a/tests/CTS/clients/analytics/getTopHits.json +++ b/tests/CTS/clients/analytics/getTopHits.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/hits", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -15,6 +18,7 @@ "testName": "get getTopHits with all parameters", "parameters": { "index": "index", + "search": "mySearch", "clickAnalytics": true, "startDate": "1999-09-19", "endDate": "2001-01-01", @@ -24,7 +28,17 @@ }, "request": { "path": "/2/hits", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "search": "mySearch", + "clickAnalytics": "true", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getTopHitsForSearch.json b/tests/CTS/clients/analytics/getTopHitsForSearch.json deleted file mode 100644 index 538ea778fad..00000000000 --- a/tests/CTS/clients/analytics/getTopHitsForSearch.json +++ /dev/null @@ -1,32 +0,0 @@ -[ - { - "method": "getTopHitsForSearch", - "testName": "get getTopHitsForSearch with minimal parameters", - "parameters": { - "index": "index", - "search": "mySearch" - }, - "request": { - "path": "/2/hits?search=mySearch", - "method": "GET" - } - }, - { - "method": "getTopHitsForSearch", - "testName": "get getTopHitsForSearch with all parameters", - "parameters": { - "index": "index", - "search": "mySearch", - "clickAnalytics": true, - "startDate": "1999-09-19", - "endDate": "2001-01-01", - "limit": 21, - "offset": 42, - "tags": "tag" - }, - "request": { - "path": "/2/hits?search=mySearch", - "method": "GET" - } - } -] diff --git a/tests/CTS/clients/analytics/getTopSearches.json b/tests/CTS/clients/analytics/getTopSearches.json index 37f56e735c3..d0a271c5d8e 100644 --- a/tests/CTS/clients/analytics/getTopSearches.json +++ b/tests/CTS/clients/analytics/getTopSearches.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/searches", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -26,7 +29,18 @@ }, "request": { "path": "/2/searches", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "clickAnalytics": "true", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "orderBy": "searchCount", + "direction": "asc", + "limit": "21", + "offset": "42", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/analytics/getUsersCount.json b/tests/CTS/clients/analytics/getUsersCount.json index 751edd81e53..113c78b30dd 100644 --- a/tests/CTS/clients/analytics/getUsersCount.json +++ b/tests/CTS/clients/analytics/getUsersCount.json @@ -7,7 +7,10 @@ }, "request": { "path": "/2/users/count", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index" + } } }, { @@ -21,7 +24,13 @@ }, "request": { "path": "/2/users/count", - "method": "GET" + "method": "GET", + "searchParams": { + "index": "index", + "startDate": "1999-09-19", + "endDate": "2001-01-01", + "tags": "tag" + } } } ] diff --git a/tests/CTS/clients/insights/pushEvents.json b/tests/CTS/clients/insights/pushEvents.json index 3de1e39ef2e..c6f184f0225 100644 --- a/tests/CTS/clients/insights/pushEvents.json +++ b/tests/CTS/clients/insights/pushEvents.json @@ -10,15 +10,9 @@ "index": "products", "userToken": "user-123456", "timestamp": 1641290601962, - "objectIDs": [ - "9780545139700", - "9780439784542" - ], + "objectIDs": ["9780545139700", "9780439784542"], "queryID": "43b15df305339e827f0ac0bdc5ebcaa7", - "positions": [ - 7, - 6 - ] + "positions": [7, 6] }, { "eventType": "view", @@ -26,10 +20,7 @@ "index": "products", "userToken": "user-123456", "timestamp": 1641290601962, - "objectIDs": [ - "9780545139700", - "9780439784542" - ] + "objectIDs": ["9780545139700", "9780439784542"] }, { "eventType": "conversion", @@ -37,10 +28,7 @@ "index": "products", "userToken": "user-123456", "timestamp": 1641290601962, - "objectIDs": [ - "9780545139700", - "9780439784542" - ], + "objectIDs": ["9780545139700", "9780439784542"], "queryID": "43b15df305339e827f0ac0bdc5ebcaa7" } ] @@ -57,15 +45,9 @@ "index": "products", "userToken": "user-123456", "timestamp": 1641290601962, - "objectIDs": [ - "9780545139700", - "9780439784542" - ], + "objectIDs": ["9780545139700", "9780439784542"], "queryID": "43b15df305339e827f0ac0bdc5ebcaa7", - "positions": [ - 7, - 6 - ] + "positions": [7, 6] }, { "eventType": "view", @@ -73,10 +55,7 @@ "index": "products", "userToken": "user-123456", "timestamp": 1641290601962, - "objectIDs": [ - "9780545139700", - "9780439784542" - ] + "objectIDs": ["9780545139700", "9780439784542"] }, { "eventType": "conversion", @@ -84,10 +63,7 @@ "index": "products", "userToken": "user-123456", "timestamp": 1641290601962, - "objectIDs": [ - "9780545139700", - "9780439784542" - ], + "objectIDs": ["9780545139700", "9780439784542"], "queryID": "43b15df305339e827f0ac0bdc5ebcaa7" } ] diff --git a/tests/CTS/clients/search/addApiKey.json b/tests/CTS/clients/search/addApiKey.json index 8477c1d65e0..2d5e30d7cb6 100644 --- a/tests/CTS/clients/search/addApiKey.json +++ b/tests/CTS/clients/search/addApiKey.json @@ -3,10 +3,7 @@ "method": "addApiKey", "parameters": { "apiKey": { - "acl": [ - "search", - "addObject" - ], + "acl": ["search", "addObject"], "description": "my new api key", "validity": 300, "maxQueriesPerIPPerHour": 100, @@ -17,10 +14,7 @@ "path": "/1/keys", "method": "POST", "data": { - "acl": [ - "search", - "addObject" - ], + "acl": ["search", "addObject"], "description": "my new api key", "validity": 300, "maxQueriesPerIPPerHour": 100, diff --git a/tests/CTS/clients/search/batchRules.json b/tests/CTS/clients/search/batchRules.json index c0e1656bf69..6d7653e0cd9 100644 --- a/tests/CTS/clients/search/batchRules.json +++ b/tests/CTS/clients/search/batchRules.json @@ -68,7 +68,11 @@ } } } - ] + ], + "searchParams": { + "forwardToReplicas": "true", + "clearExistingRules": "true" + } } } ] diff --git a/tests/CTS/clients/search/saveRule.json b/tests/CTS/clients/search/saveRule.json index 066c64a739b..5dbb735fb90 100644 --- a/tests/CTS/clients/search/saveRule.json +++ b/tests/CTS/clients/search/saveRule.json @@ -36,6 +36,9 @@ "filters": "brand:apple" } } + }, + "searchParams": { + "forwardToReplicas": "true" } } } diff --git a/tests/CTS/clients/search/saveSynonym.json b/tests/CTS/clients/search/saveSynonym.json index d5eb3acb52e..266e6e86fb1 100644 --- a/tests/CTS/clients/search/saveSynonym.json +++ b/tests/CTS/clients/search/saveSynonym.json @@ -7,11 +7,7 @@ "synonymHit": { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] }, "forwardToReplicas": true }, @@ -21,11 +17,10 @@ "data": { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] + }, + "searchParams": { + "forwardToReplicas": "true" } } } diff --git a/tests/CTS/clients/search/saveSynonyms.json b/tests/CTS/clients/search/saveSynonyms.json index 006a0c3f1bd..9ea6047bc3f 100644 --- a/tests/CTS/clients/search/saveSynonyms.json +++ b/tests/CTS/clients/search/saveSynonyms.json @@ -7,21 +7,13 @@ { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] }, { "objectID": "id2", "type": "onewaysynonym", "input": "iphone", - "synonyms": [ - "ephone", - "aphone", - "yphone" - ] + "synonyms": ["ephone", "aphone", "yphone"] } ], "forwardToReplicas": true, @@ -34,23 +26,19 @@ { "objectID": "id1", "type": "synonym", - "synonyms": [ - "car", - "vehicule", - "auto" - ] + "synonyms": ["car", "vehicule", "auto"] }, { "objectID": "id2", "type": "onewaysynonym", "input": "iphone", - "synonyms": [ - "ephone", - "aphone", - "yphone" - ] + "synonyms": ["ephone", "aphone", "yphone"] } - ] + ], + "searchParams": { + "forwardToReplicas": "true", + "replaceExistingSynonyms": "false" + } } } ] diff --git a/tests/CTS/clients/search/searchSynonyms.json b/tests/CTS/clients/search/searchSynonyms.json index 7784de2dc51..8357c117e07 100644 --- a/tests/CTS/clients/search/searchSynonyms.json +++ b/tests/CTS/clients/search/searchSynonyms.json @@ -8,7 +8,11 @@ }, "request": { "path": "/1/indexes/indexName/synonyms/search", - "method": "POST" + "method": "POST", + "searchParams": { + "query": "queryString", + "type": "onewaysynonym" + } } } ] diff --git a/tests/CTS/clients/search/updateApiKey.json b/tests/CTS/clients/search/updateApiKey.json index f4d1a654867..9591f4c8561 100644 --- a/tests/CTS/clients/search/updateApiKey.json +++ b/tests/CTS/clients/search/updateApiKey.json @@ -4,10 +4,7 @@ "parameters": { "key": "myApiKey", "apiKey": { - "acl": [ - "search", - "addObject" - ], + "acl": ["search", "addObject"], "validity": 300, "maxQueriesPerIPPerHour": 100, "maxHitsPerQuery": 20 @@ -17,10 +14,7 @@ "path": "/1/keys/myApiKey", "method": "PUT", "data": { - "acl": [ - "search", - "addObject" - ], + "acl": ["search", "addObject"], "validity": 300, "maxQueriesPerIPPerHour": 100, "maxHitsPerQuery": 20 diff --git a/tests/CTS/templates/javascript.mustache b/tests/CTS/templates/javascript.mustache index fdbd45f7518..5b2541fb666 100644 --- a/tests/CTS/templates/javascript.mustache +++ b/tests/CTS/templates/javascript.mustache @@ -10,18 +10,13 @@ describe('{{operationId}}', () => { {{#tests}} test('{{testName}}', async () => { const req = await client.{{method}}( - {{#hasParameters}}{ - {{#parametersWithDataType}} - {{#isDate}}{{{key}}}:new Date({{{value}}}),{{/isDate}}{{^isDate}}{{{key}}}:{{{value}}},{{/isDate}} - {{/parametersWithDataType}} - }{{/hasParameters}} + {{#hasParameters}}{{{parameters}}}{{/hasParameters}} ); - expect(req).toMatchObject({ - path: '{{{request.path}}}', - method: '{{{request.method}}}', - {{#request.data}}data: {{{.}}},{{/request.data}} - }) + expect((req as any).path).toEqual('{{{request.path}}}'); + expect((req as any).method).toEqual('{{{request.method}}}'); + expect((req as any).data).toEqual({{#request.data}}{{{request.data}}}{{/request.data}}{{^request.data}}undefined{{/request.data}}); + expect((req as any).searchParams).toEqual({{#request.searchParams}}{{{request.searchParams}}}{{/request.searchParams}}{{^request.searchParams}}undefined{{/request.searchParams}}); }); {{/tests}} diff --git a/tests/generateCTS.ts b/tests/generateCTS.ts index d362f8b14f3..0af2103492b 100644 --- a/tests/generateCTS.ts +++ b/tests/generateCTS.ts @@ -31,6 +31,7 @@ type Tests = { path: string; method: string; data?: string; + searchParams?: string; }; }; @@ -131,6 +132,7 @@ async function loadCTSForClient(client: string): Promise { // stringify request.data too test.request.data = JSON.stringify(test.request.data); + test.request.searchParams = JSON.stringify(test.request.searchParams); if (Object.keys(test.parameters).length === 0) { test.parameters = undefined; diff --git a/tests/output/javascript/analytics.test.ts b/tests/output/javascript/analytics.test.ts index 6e8db81ee1c..699732c9ff1 100644 --- a/tests/output/javascript/analytics.test.ts +++ b/tests/output/javascript/analytics.test.ts @@ -9,350 +9,360 @@ const client = new AnalyticsApi(appId, apiKey, 'de', { describe('getAverageClickPosition', () => { test('get getAverageClickPosition with minimal parameters', async () => { - const req = await client.getAverageClickPosition({ - index: 'index', - }); + const req = await client.getAverageClickPosition({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/clicks/averageClickPosition', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/clicks/averageClickPosition'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getAverageClickPosition with all parameters', async () => { const req = await client.getAverageClickPosition({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/clicks/averageClickPosition', - method: 'GET', + expect((req as any).path).toEqual('/2/clicks/averageClickPosition'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); describe('getClickPositions', () => { test('get getClickPositions with minimal parameters', async () => { - const req = await client.getClickPositions({ - index: 'index', - }); + const req = await client.getClickPositions({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/clicks/positions', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/clicks/positions'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getClickPositions with all parameters', async () => { const req = await client.getClickPositions({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/clicks/positions', - method: 'GET', + expect((req as any).path).toEqual('/2/clicks/positions'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); describe('getClickThroughRate', () => { test('get getClickThroughRate with minimal parameters', async () => { - const req = await client.getClickThroughRate({ - index: 'index', - }); + const req = await client.getClickThroughRate({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/clicks/clickThroughRate', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/clicks/clickThroughRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getClickThroughRate with all parameters', async () => { const req = await client.getClickThroughRate({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/clicks/clickThroughRate', - method: 'GET', + expect((req as any).path).toEqual('/2/clicks/clickThroughRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); describe('getConversationRate', () => { test('get getConversationRate with minimal parameters', async () => { - const req = await client.getConversationRate({ - index: 'index', - }); + const req = await client.getConversationRate({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/conversions/conversionRate', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/conversions/conversionRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getConversationRate with all parameters', async () => { const req = await client.getConversationRate({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/conversions/conversionRate', - method: 'GET', + expect((req as any).path).toEqual('/2/conversions/conversionRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); describe('getNoClickRate', () => { test('get getNoClickRate with minimal parameters', async () => { - const req = await client.getNoClickRate({ - index: 'index', - }); + const req = await client.getNoClickRate({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/searches/noClickRate', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/searches/noClickRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getNoClickRate with all parameters', async () => { const req = await client.getNoClickRate({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/searches/noClickRate', - method: 'GET', + expect((req as any).path).toEqual('/2/searches/noClickRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); describe('getNoResultsRate', () => { test('get getNoResultsRate with minimal parameters', async () => { - const req = await client.getNoResultsRate({ - index: 'index', - }); + const req = await client.getNoResultsRate({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/searches/noResultRate', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/searches/noResultRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getNoResultsRate with all parameters', async () => { const req = await client.getNoResultsRate({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/searches/noResultRate', - method: 'GET', + expect((req as any).path).toEqual('/2/searches/noResultRate'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); describe('getSearchesCount', () => { test('get getSearchesCount with minimal parameters', async () => { - const req = await client.getSearchesCount({ - index: 'index', - }); + const req = await client.getSearchesCount({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/searches/count', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/searches/count'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getSearchesCount with all parameters', async () => { const req = await client.getSearchesCount({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/searches/count', - method: 'GET', + expect((req as any).path).toEqual('/2/searches/count'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); describe('getSearchesNoClicks', () => { test('get getSearchesNoClicks with minimal parameters', async () => { - const req = await client.getSearchesNoClicks({ - index: 'index', - }); + const req = await client.getSearchesNoClicks({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/searches/noClicks', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/searches/noClicks'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getSearchesNoClicks with all parameters', async () => { const req = await client.getSearchesNoClicks({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/searches/noClicks', - method: 'GET', + expect((req as any).path).toEqual('/2/searches/noClicks'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', + tags: 'tag', }); }); }); describe('getSearchesNoResults', () => { test('get getSearchesNoResults with minimal parameters', async () => { - const req = await client.getSearchesNoResults({ - index: 'index', - }); + const req = await client.getSearchesNoResults({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/searches/noResults', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/searches/noResults'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getSearchesNoResults with all parameters', async () => { const req = await client.getSearchesNoResults({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/searches/noResults', - method: 'GET', + expect((req as any).path).toEqual('/2/searches/noResults'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', + tags: 'tag', }); }); }); describe('getStatus', () => { test('get getStatus with minimal parameters', async () => { - const req = await client.getStatus({ - index: 'index', - }); + const req = await client.getStatus({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/status', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/status'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); }); describe('getTopCountries', () => { test('get getTopCountries with minimal parameters', async () => { - const req = await client.getTopCountries({ - index: 'index', - }); + const req = await client.getTopCountries({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/countries', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/countries'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getTopCountries with all parameters', async () => { const req = await client.getTopCountries({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/countries', - method: 'GET', + expect((req as any).path).toEqual('/2/countries'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', + tags: 'tag', }); }); }); describe('getTopFilterAttributes', () => { test('get getTopFilterAttributes with minimal parameters', async () => { - const req = await client.getTopFilterAttributes({ - index: 'index', - }); + const req = await client.getTopFilterAttributes({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/filters', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/filters'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getTopFilterAttributes with all parameters', async () => { const req = await client.getTopFilterAttributes({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + search: 'mySearch', + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/filters', - method: 'GET', - }); - }); -}); - -describe('getTopFilterAttributesForSearch', () => { - test('get getTopFilterAttributesForSearch with minimal parameters', async () => { - const req = await client.getTopFilterAttributesForSearch({ - index: 'index', - search: 'mySearch', - }); - - expect(req).toMatchObject({ - path: '/2/filters?search=mySearch', - method: 'GET', - }); - }); - - test('get getTopFilterAttributesForSearch with all parameters', async () => { - const req = await client.getTopFilterAttributesForSearch({ + expect((req as any).path).toEqual('/2/filters'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index', search: 'mySearch', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), - limit: 21, - offset: 42, + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); - - expect(req).toMatchObject({ - path: '/2/filters?search=mySearch', - method: 'GET', - }); }); }); @@ -363,10 +373,10 @@ describe('getTopFilterForAttribute', () => { index: 'index', }); - expect(req).toMatchObject({ - path: '/2/filters/myAttribute', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/filters/myAttribute'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getTopFilterForAttribute with minimal parameters and multiple attributes', async () => { @@ -375,26 +385,35 @@ describe('getTopFilterForAttribute', () => { index: 'index', }); - expect(req).toMatchObject({ - path: '/2/filters/myAttribute1%2CmyAttribute2', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getTopFilterForAttribute with all parameters', async () => { const req = await client.getTopFilterForAttribute({ attribute: 'myAttribute', index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + search: 'mySearch', + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/filters/myAttribute', - method: 'GET', + expect((req as any).path).toEqual('/2/filters/myAttribute'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + search: 'mySearch', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', + tags: 'tag', }); }); @@ -402,224 +421,119 @@ describe('getTopFilterForAttribute', () => { const req = await client.getTopFilterForAttribute({ attribute: 'myAttribute1,myAttribute2', index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), - limit: 21, - offset: 42, - tags: 'tag', - }); - - expect(req).toMatchObject({ - path: '/2/filters/myAttribute1%2CmyAttribute2', - method: 'GET', - }); - }); -}); - -describe('getTopFiltersForAttributesSearch', () => { - test('get getTopFiltersForAttributesSearch with minimal parameters', async () => { - const req = await client.getTopFiltersForAttributesSearch({ - attributes: 'myAttribute', - index: 'index', - search: 'mySearch', - }); - - expect(req).toMatchObject({ - path: '/2/filters/myAttribute?search=mySearch', - method: 'GET', - }); - }); - - test('get getTopFiltersForAttributesSearch with minimal parameters and multiple attributes', async () => { - const req = await client.getTopFiltersForAttributesSearch({ - attributes: 'myAttribute1,myAttribute2', - index: 'index', - search: 'mySearch', - }); - - expect(req).toMatchObject({ - path: '/2/filters/myAttribute1%2CmyAttribute2?search=mySearch', - method: 'GET', - }); - }); - - test('get getTopFiltersForAttributesSearch with all parameters', async () => { - const req = await client.getTopFiltersForAttributesSearch({ - attributes: 'myAttribute', - index: 'index', search: 'mySearch', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/filters/myAttribute?search=mySearch', - method: 'GET', - }); - }); - - test('get getTopFiltersForAttributesSearch with all parameters and multiple attributes', async () => { - const req = await client.getTopFiltersForAttributesSearch({ - attributes: 'myAttribute1,myAttribute2', + expect((req as any).path).toEqual('/2/filters/myAttribute1%2CmyAttribute2'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index', search: 'mySearch', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), - limit: 21, - offset: 42, + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); - - expect(req).toMatchObject({ - path: '/2/filters/myAttribute1%2CmyAttribute2?search=mySearch', - method: 'GET', - }); }); }); describe('getTopFiltersNoResults', () => { test('get getTopFiltersNoResults with minimal parameters', async () => { - const req = await client.getTopFiltersNoResults({ - index: 'index', - }); + const req = await client.getTopFiltersNoResults({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/filters/noResults', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/filters/noResults'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getTopFiltersNoResults with all parameters', async () => { const req = await client.getTopFiltersNoResults({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + search: 'mySearch', + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/filters/noResults', - method: 'GET', - }); - }); -}); - -describe('getTopFiltersNoResultsForSearch', () => { - test('get getTopFiltersNoResultsForSearch with minimal parameters', async () => { - const req = await client.getTopFiltersNoResultsForSearch({ + expect((req as any).path).toEqual('/2/filters/noResults'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index', search: 'mySearch', - }); - - expect(req).toMatchObject({ - path: '/2/filters/noResults?search=mySearch', - method: 'GET', - }); - }); - - test('get getTopFiltersNoResultsForSearch with all parameters', async () => { - const req = await client.getTopFiltersNoResultsForSearch({ - index: 'index', - search: 'mySearch', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), - limit: 21, - offset: 42, + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); - - expect(req).toMatchObject({ - path: '/2/filters/noResults?search=mySearch', - method: 'GET', - }); }); }); describe('getTopHits', () => { test('get getTopHits with minimal parameters', async () => { - const req = await client.getTopHits({ - index: 'index', - }); + const req = await client.getTopHits({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/hits', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/hits'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getTopHits with all parameters', async () => { const req = await client.getTopHits({ index: 'index', + search: 'mySearch', clickAnalytics: true, - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', limit: 21, offset: 42, tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/hits', - method: 'GET', - }); - }); -}); - -describe('getTopHitsForSearch', () => { - test('get getTopHitsForSearch with minimal parameters', async () => { - const req = await client.getTopHitsForSearch({ + expect((req as any).path).toEqual('/2/hits'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index', search: 'mySearch', - }); - - expect(req).toMatchObject({ - path: '/2/hits?search=mySearch', - method: 'GET', - }); - }); - - test('get getTopHitsForSearch with all parameters', async () => { - const req = await client.getTopHitsForSearch({ - index: 'index', - search: 'mySearch', - clickAnalytics: true, - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), - limit: 21, - offset: 42, + clickAnalytics: 'true', + startDate: '1999-09-19', + endDate: '2001-01-01', + limit: '21', + offset: '42', tags: 'tag', }); - - expect(req).toMatchObject({ - path: '/2/hits?search=mySearch', - method: 'GET', - }); }); }); describe('getTopSearches', () => { test('get getTopSearches with minimal parameters', async () => { - const req = await client.getTopSearches({ - index: 'index', - }); + const req = await client.getTopSearches({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/searches', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/searches'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getTopSearches with all parameters', async () => { const req = await client.getTopSearches({ index: 'index', clickAnalytics: true, - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', orderBy: 'searchCount', direction: 'asc', limit: 21, @@ -627,36 +541,49 @@ describe('getTopSearches', () => { tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/searches', - method: 'GET', + expect((req as any).path).toEqual('/2/searches'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + clickAnalytics: 'true', + startDate: '1999-09-19', + endDate: '2001-01-01', + orderBy: 'searchCount', + direction: 'asc', + limit: '21', + offset: '42', + tags: 'tag', }); }); }); describe('getUsersCount', () => { test('get getUsersCount with minimal parameters', async () => { - const req = await client.getUsersCount({ - index: 'index', - }); + const req = await client.getUsersCount({ index: 'index' }); - expect(req).toMatchObject({ - path: '/2/users/count', - method: 'GET', - }); + expect((req as any).path).toEqual('/2/users/count'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ index: 'index' }); }); test('get getUsersCount with all parameters', async () => { const req = await client.getUsersCount({ index: 'index', - startDate: new Date('1999-09-19'), - endDate: new Date('2001-01-01'), + startDate: '1999-09-19', + endDate: '2001-01-01', tags: 'tag', }); - expect(req).toMatchObject({ - path: '/2/users/count', - method: 'GET', + expect((req as any).path).toEqual('/2/users/count'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + index: 'index', + startDate: '1999-09-19', + endDate: '2001-01-01', + tags: 'tag', }); }); }); diff --git a/tests/output/javascript/insights.test.ts b/tests/output/javascript/insights.test.ts index c0f228c75f9..ffd4004e59e 100644 --- a/tests/output/javascript/insights.test.ts +++ b/tests/output/javascript/insights.test.ts @@ -43,40 +43,39 @@ describe('pushEvents', () => { }, }); - expect(req).toMatchObject({ - path: '/1/events', - method: 'POST', - data: { - events: [ - { - eventType: 'click', - eventName: 'Product Clicked', - index: 'products', - userToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - positions: [7, 6], - }, - { - eventType: 'view', - eventName: 'Product Detail Page Viewed', - index: 'products', - userToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - }, - { - eventType: 'conversion', - eventName: 'Product Purchased', - index: 'products', - userToken: 'user-123456', - timestamp: 1641290601962, - objectIDs: ['9780545139700', '9780439784542'], - queryID: '43b15df305339e827f0ac0bdc5ebcaa7', - }, - ], - }, + expect((req as any).path).toEqual('/1/events'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + events: [ + { + eventType: 'click', + eventName: 'Product Clicked', + index: 'products', + userToken: 'user-123456', + timestamp: 1641290601962, + objectIDs: ['9780545139700', '9780439784542'], + queryID: '43b15df305339e827f0ac0bdc5ebcaa7', + positions: [7, 6], + }, + { + eventType: 'view', + eventName: 'Product Detail Page Viewed', + index: 'products', + userToken: 'user-123456', + timestamp: 1641290601962, + objectIDs: ['9780545139700', '9780439784542'], + }, + { + eventType: 'conversion', + eventName: 'Product Purchased', + index: 'products', + userToken: 'user-123456', + timestamp: 1641290601962, + objectIDs: ['9780545139700', '9780439784542'], + queryID: '43b15df305339e827f0ac0bdc5ebcaa7', + }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); }); diff --git a/tests/output/javascript/personalization.test.ts b/tests/output/javascript/personalization.test.ts index 7ad9662f9a2..5f0c629665a 100644 --- a/tests/output/javascript/personalization.test.ts +++ b/tests/output/javascript/personalization.test.ts @@ -12,14 +12,12 @@ const client = new PersonalizationApi(appId, apiKey, 'de', { describe('deleteUserProfile', () => { test('delete deleteUserProfile', async () => { - const req = await client.deleteUserProfile({ - userToken: 'UserToken', - }); + const req = await client.deleteUserProfile({ userToken: 'UserToken' }); - expect(req).toMatchObject({ - path: '/1/profiles/UserToken', - method: 'DELETE', - }); + expect((req as any).path).toEqual('/1/profiles/UserToken'); + expect((req as any).method).toEqual('DELETE'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -27,23 +25,21 @@ describe('getPersonalizationStrategy', () => { test('get getPersonalizationStrategy', async () => { const req = await client.getPersonalizationStrategy(); - expect(req).toMatchObject({ - path: '/1/strategies/personalization', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/strategies/personalization'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); describe('getUserTokenProfile', () => { test('get getUserTokenProfile', async () => { - const req = await client.getUserTokenProfile({ - userToken: 'UserToken', - }); + const req = await client.getUserTokenProfile({ userToken: 'UserToken' }); - expect(req).toMatchObject({ - path: '/1/profiles/personalization/UserToken', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/profiles/personalization/UserToken'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -57,14 +53,13 @@ describe('setPersonalizationStrategy', () => { }, }); - expect(req).toMatchObject({ - path: '/1/strategies/personalization', - method: 'POST', - data: { - eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], - facetScoring: [{ score: 42, facetName: 'Event' }], - personalizationImpact: 42, - }, + expect((req as any).path).toEqual('/1/strategies/personalization'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + eventScoring: [{ score: 42, eventName: 'Algolia', eventType: 'Event' }], + facetScoring: [{ score: 42, facetName: 'Event' }], + personalizationImpact: 42, }); + expect((req as any).searchParams).toEqual(undefined); }); }); diff --git a/tests/output/javascript/recommend.test.ts b/tests/output/javascript/recommend.test.ts index fb62ab4e397..e9fda025983 100644 --- a/tests/output/javascript/recommend.test.ts +++ b/tests/output/javascript/recommend.test.ts @@ -22,20 +22,19 @@ describe('getRecommendations', () => { }, }); - expect(req).toMatchObject({ - path: '/1/indexes/*/recommendations', - method: 'POST', - data: { - requests: [ - { - indexName: 'indexName', - objectID: 'objectID', - model: 'related-products', - threshold: 42, - }, - ], - }, + expect((req as any).path).toEqual('/1/indexes/*/recommendations'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + requests: [ + { + indexName: 'indexName', + objectID: 'objectID', + model: 'related-products', + threshold: 42, + }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); test('get recommendations with all parameters', async () => { @@ -57,25 +56,21 @@ describe('getRecommendations', () => { }, }); - expect(req).toMatchObject({ - path: '/1/indexes/*/recommendations', - method: 'POST', - data: { - requests: [ - { - indexName: 'indexName', - objectID: 'objectID', - model: 'related-products', - threshold: 42, - queryParameters: { query: 'myQuery', facetFilters: ['query'] }, - fallbackParameters: { - query: 'myQuery', - facetFilters: ['fallback'], - }, - }, - ], - }, + expect((req as any).path).toEqual('/1/indexes/*/recommendations'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + requests: [ + { + indexName: 'indexName', + objectID: 'objectID', + model: 'related-products', + threshold: 42, + queryParameters: { query: 'myQuery', facetFilters: ['query'] }, + fallbackParameters: { query: 'myQuery', facetFilters: ['fallback'] }, + }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); test('get multiple recommendations with minimal parameters', async () => { @@ -98,26 +93,25 @@ describe('getRecommendations', () => { }, }); - expect(req).toMatchObject({ - path: '/1/indexes/*/recommendations', - method: 'POST', - data: { - requests: [ - { - indexName: 'indexName1', - objectID: 'objectID1', - model: 'related-products', - threshold: 21, - }, - { - indexName: 'indexName2', - objectID: 'objectID2', - model: 'related-products', - threshold: 21, - }, - ], - }, + expect((req as any).path).toEqual('/1/indexes/*/recommendations'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'related-products', + threshold: 21, + }, + { + indexName: 'indexName2', + objectID: 'objectID2', + model: 'related-products', + threshold: 21, + }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); test('get multiple recommendations with all parameters', async () => { @@ -150,36 +144,29 @@ describe('getRecommendations', () => { }, }); - expect(req).toMatchObject({ - path: '/1/indexes/*/recommendations', - method: 'POST', - data: { - requests: [ - { - indexName: 'indexName1', - objectID: 'objectID1', - model: 'related-products', - threshold: 21, - queryParameters: { query: 'myQuery', facetFilters: ['query1'] }, - fallbackParameters: { - query: 'myQuery', - facetFilters: ['fallback1'], - }, - }, - { - indexName: 'indexName2', - objectID: 'objectID2', - model: 'related-products', - threshold: 21, - queryParameters: { query: 'myQuery', facetFilters: ['query2'] }, - fallbackParameters: { - query: 'myQuery', - facetFilters: ['fallback2'], - }, - }, - ], - }, + expect((req as any).path).toEqual('/1/indexes/*/recommendations'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'related-products', + threshold: 21, + queryParameters: { query: 'myQuery', facetFilters: ['query1'] }, + fallbackParameters: { query: 'myQuery', facetFilters: ['fallback1'] }, + }, + { + indexName: 'indexName2', + objectID: 'objectID2', + model: 'related-products', + threshold: 21, + queryParameters: { query: 'myQuery', facetFilters: ['query2'] }, + fallbackParameters: { query: 'myQuery', facetFilters: ['fallback2'] }, + }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); test('get frequently bought together recommendations', async () => { @@ -196,19 +183,18 @@ describe('getRecommendations', () => { }, }); - expect(req).toMatchObject({ - path: '/1/indexes/*/recommendations', - method: 'POST', - data: { - requests: [ - { - indexName: 'indexName1', - objectID: 'objectID1', - model: 'bought-together', - threshold: 42, - }, - ], - }, + expect((req as any).path).toEqual('/1/indexes/*/recommendations'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + requests: [ + { + indexName: 'indexName1', + objectID: 'objectID1', + model: 'bought-together', + threshold: 42, + }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); }); diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index 32455a2f0a4..c51ed002ac1 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -17,17 +17,16 @@ describe('addApiKey', () => { }, }); - expect(req).toMatchObject({ - path: '/1/keys', - method: 'POST', - data: { - acl: ['search', 'addObject'], - description: 'my new api key', - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, - }, - }); + expect((req as any).path).toEqual('/1/keys'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + acl: ['search', 'addObject'], + description: 'my new api key', + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, + }); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -43,16 +42,15 @@ describe('batchDictionaryEntries', () => { }, }); - expect(req).toMatchObject({ - path: '/1/dictionaries/compounds/batch', - method: 'POST', - data: { - requests: [ - { action: 'addEntry', body: { objectID: '1', language: 'en' } }, - { action: 'deleteEntry', body: { objectID: '2', language: 'fr' } }, - ], - }, + expect((req as any).path).toEqual('/1/dictionaries/compounds/batch'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + requests: [ + { action: 'addEntry', body: { objectID: '1', language: 'en' } }, + { action: 'deleteEntry', body: { objectID: '2', language: 'fr' } }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); test('get batchDictionaryEntries results with all parameters', async () => { @@ -87,37 +85,36 @@ describe('batchDictionaryEntries', () => { }, }); - expect(req).toMatchObject({ - path: '/1/dictionaries/compounds/batch', - method: 'POST', - data: { - clearExistingDictionaryEntries: false, - requests: [ - { - action: 'addEntry', - body: { - objectID: '1', - language: 'en', - word: 'yo', - words: ['yo', 'algolia'], - decomposition: ['yo', 'algolia'], - state: 'enabled', - }, + expect((req as any).path).toEqual('/1/dictionaries/compounds/batch'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + clearExistingDictionaryEntries: false, + requests: [ + { + action: 'addEntry', + body: { + objectID: '1', + language: 'en', + word: 'yo', + words: ['yo', 'algolia'], + decomposition: ['yo', 'algolia'], + state: 'enabled', }, - { - action: 'deleteEntry', - body: { - objectID: '2', - language: 'fr', - word: 'salut', - words: ['salut', 'algolia'], - decomposition: ['salut', 'algolia'], - state: 'enabled', - }, + }, + { + action: 'deleteEntry', + body: { + objectID: '2', + language: 'fr', + word: 'salut', + words: ['salut', 'algolia'], + decomposition: ['salut', 'algolia'], + state: 'enabled', }, - ], - }, + }, + ], }); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -141,35 +138,35 @@ describe('batchRules', () => { clearExistingRules: true, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/rules/batch', - method: 'POST', - data: [ - { - objectID: 'a-rule-id', - conditions: [{ pattern: 'smartphone', anchoring: 'contains' }], - consequence: { params: { filters: 'category:smartphone' } }, - }, - { - objectID: 'a-second-rule-id', - conditions: [{ pattern: 'apple', anchoring: 'contains' }], - consequence: { params: { filters: 'brand:apple' } }, - }, - ], + expect((req as any).path).toEqual('/1/indexes/indexName/rules/batch'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual([ + { + objectID: 'a-rule-id', + conditions: [{ pattern: 'smartphone', anchoring: 'contains' }], + consequence: { params: { filters: 'category:smartphone' } }, + }, + { + objectID: 'a-second-rule-id', + conditions: [{ pattern: 'apple', anchoring: 'contains' }], + consequence: { params: { filters: 'brand:apple' } }, + }, + ]); + expect((req as any).searchParams).toEqual({ + forwardToReplicas: 'true', + clearExistingRules: 'true', }); }); }); describe('browse', () => { test('get browse results with minimal parameters', async () => { - const req = await client.browse({ - indexName: 'indexName', - }); + const req = await client.browse({ indexName: 'indexName' }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/browse', - method: 'POST', - }); + expect((req as any).path).toEqual('/1/indexes/indexName/browse'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); test('get browse results with all parameters', async () => { @@ -181,50 +178,46 @@ describe('browse', () => { }, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/browse', - method: 'POST', - data: { params: "query=foo&facetFilters=['bar']", cursor: 'cts' }, + expect((req as any).path).toEqual('/1/indexes/indexName/browse'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + params: "query=foo&facetFilters=['bar']", + cursor: 'cts', }); + expect((req as any).searchParams).toEqual(undefined); }); }); describe('clearAllSynonyms', () => { test('clearAllSynonyms', async () => { - const req = await client.clearAllSynonyms({ - indexName: 'indexName', - }); + const req = await client.clearAllSynonyms({ indexName: 'indexName' }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/synonyms/clear', - method: 'POST', - }); + expect((req as any).path).toEqual('/1/indexes/indexName/synonyms/clear'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); describe('clearRules', () => { test('clearRules', async () => { - const req = await client.clearRules({ - indexName: 'indexName', - }); + const req = await client.clearRules({ indexName: 'indexName' }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/rules/clear', - method: 'POST', - }); + expect((req as any).path).toEqual('/1/indexes/indexName/rules/clear'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); describe('deleteApiKey', () => { test('deleteApiKey', async () => { - const req = await client.deleteApiKey({ - key: 'myTestApiKey', - }); + const req = await client.deleteApiKey({ key: 'myTestApiKey' }); - expect(req).toMatchObject({ - path: '/1/keys/myTestApiKey', - method: 'DELETE', - }); + expect((req as any).path).toEqual('/1/keys/myTestApiKey'); + expect((req as any).method).toEqual('DELETE'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -235,10 +228,10 @@ describe('deleteRule', () => { objectID: 'id1', }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/rules/id1', - method: 'DELETE', - }); + expect((req as any).path).toEqual('/1/indexes/indexName/rules/id1'); + expect((req as any).method).toEqual('DELETE'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -249,23 +242,21 @@ describe('deleteSynonym', () => { objectID: 'id1', }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/synonyms/id1', - method: 'DELETE', - }); + expect((req as any).path).toEqual('/1/indexes/indexName/synonyms/id1'); + expect((req as any).method).toEqual('DELETE'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); describe('getApiKey', () => { test('getApiKey', async () => { - const req = await client.getApiKey({ - key: 'myTestApiKey', - }); + const req = await client.getApiKey({ key: 'myTestApiKey' }); - expect(req).toMatchObject({ - path: '/1/keys/myTestApiKey', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/keys/myTestApiKey'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -273,10 +264,10 @@ describe('getDictionaryLanguages', () => { test('get getDictionaryLanguages', async () => { const req = await client.getDictionaryLanguages(); - expect(req).toMatchObject({ - path: '/1/dictionaries/*/languages', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/dictionaries/*/languages'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -284,10 +275,10 @@ describe('getDictionarySettings', () => { test('get getDictionarySettings results', async () => { const req = await client.getDictionarySettings(); - expect(req).toMatchObject({ - path: '/1/dictionaries/*/settings', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/dictionaries/*/settings'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -298,10 +289,10 @@ describe('getRule', () => { objectID: 'id1', }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/rules/id1', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/indexes/indexName/rules/id1'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -312,10 +303,10 @@ describe('getSynonym', () => { objectID: 'id1', }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/synonyms/id1', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/indexes/indexName/synonyms/id1'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -323,23 +314,21 @@ describe('listApiKeys', () => { test('listApiKeys', async () => { const req = await client.listApiKeys(); - expect(req).toMatchObject({ - path: '/1/keys', - method: 'GET', - }); + expect((req as any).path).toEqual('/1/keys'); + expect((req as any).method).toEqual('GET'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); describe('restoreApiKey', () => { test('restoreApiKey', async () => { - const req = await client.restoreApiKey({ - key: 'myApiKey', - }); + const req = await client.restoreApiKey({ key: 'myApiKey' }); - expect(req).toMatchObject({ - path: '/1/keys/myApiKey/restore', - method: 'POST', - }); + expect((req as any).path).toEqual('/1/keys/myApiKey/restore'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -356,15 +345,14 @@ describe('saveRule', () => { forwardToReplicas: true, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/rules/id1', - method: 'PUT', - data: { - objectID: 'id1', - conditions: [{ pattern: 'apple', anchoring: 'contains' }], - consequence: { params: { filters: 'brand:apple' } }, - }, + expect((req as any).path).toEqual('/1/indexes/indexName/rules/id1'); + expect((req as any).method).toEqual('PUT'); + expect((req as any).data).toEqual({ + objectID: 'id1', + conditions: [{ pattern: 'apple', anchoring: 'contains' }], + consequence: { params: { filters: 'brand:apple' } }, }); + expect((req as any).searchParams).toEqual({ forwardToReplicas: 'true' }); }); }); @@ -381,15 +369,14 @@ describe('saveSynonym', () => { forwardToReplicas: true, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/synonyms/id1', - method: 'PUT', - data: { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }, + expect((req as any).path).toEqual('/1/indexes/indexName/synonyms/id1'); + expect((req as any).method).toEqual('PUT'); + expect((req as any).data).toEqual({ + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], }); + expect((req as any).searchParams).toEqual({ forwardToReplicas: 'true' }); }); }); @@ -414,22 +401,24 @@ describe('saveSynonyms', () => { replaceExistingSynonyms: false, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/synonyms/batch', - method: 'POST', - data: [ - { - objectID: 'id1', - type: 'synonym', - synonyms: ['car', 'vehicule', 'auto'], - }, - { - objectID: 'id2', - type: 'onewaysynonym', - input: 'iphone', - synonyms: ['ephone', 'aphone', 'yphone'], - }, - ], + expect((req as any).path).toEqual('/1/indexes/indexName/synonyms/batch'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual([ + { + objectID: 'id1', + type: 'synonym', + synonyms: ['car', 'vehicule', 'auto'], + }, + { + objectID: 'id2', + type: 'onewaysynonym', + input: 'iphone', + synonyms: ['ephone', 'aphone', 'yphone'], + }, + ]); + expect((req as any).searchParams).toEqual({ + forwardToReplicas: 'true', + replaceExistingSynonyms: 'false', }); }); }); @@ -441,11 +430,10 @@ describe('search', () => { searchParams: { query: 'myQuery' }, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/query', - method: 'POST', - data: { query: 'myQuery' }, - }); + expect((req as any).path).toEqual('/1/indexes/indexName/query'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ query: 'myQuery' }); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -456,11 +444,10 @@ describe('searchDictionaryEntries', () => { searchDictionaryEntries: { query: 'foo' }, }); - expect(req).toMatchObject({ - path: '/1/dictionaries/compounds/search', - method: 'POST', - data: { query: 'foo' }, - }); + expect((req as any).path).toEqual('/1/dictionaries/compounds/search'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ query: 'foo' }); + expect((req as any).searchParams).toEqual(undefined); }); test('get searchDictionaryEntries results with all parameters', async () => { @@ -474,11 +461,15 @@ describe('searchDictionaryEntries', () => { }, }); - expect(req).toMatchObject({ - path: '/1/dictionaries/compounds/search', - method: 'POST', - data: { query: 'foo', page: 4, hitsPerPage: 2, language: 'fr' }, + expect((req as any).path).toEqual('/1/dictionaries/compounds/search'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + query: 'foo', + page: 4, + hitsPerPage: 2, + language: 'fr', }); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -489,10 +480,12 @@ describe('searchForFacetValues', () => { facetName: 'facetName', }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/facets/facetName/query', - method: 'POST', - }); + expect((req as any).path).toEqual( + '/1/indexes/indexName/facets/facetName/query' + ); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual(undefined); }); test('get searchForFacetValues results with all parameters', async () => { @@ -506,15 +499,16 @@ describe('searchForFacetValues', () => { }, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/facets/facetName/query', - method: 'POST', - data: { - params: "query=foo&facetFilters=['bar']", - facetQuery: 'foo', - maxFacetHits: 42, - }, + expect((req as any).path).toEqual( + '/1/indexes/indexName/facets/facetName/query' + ); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ + params: "query=foo&facetFilters=['bar']", + facetQuery: 'foo', + maxFacetHits: 42, }); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -525,11 +519,10 @@ describe('searchRules', () => { searchRulesParams: { query: 'something' }, }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/rules/search', - method: 'POST', - data: { query: 'something' }, - }); + expect((req as any).path).toEqual('/1/indexes/indexName/rules/search'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual({ query: 'something' }); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -541,9 +534,12 @@ describe('searchSynonyms', () => { type: 'onewaysynonym', }); - expect(req).toMatchObject({ - path: '/1/indexes/indexName/synonyms/search', - method: 'POST', + expect((req as any).path).toEqual('/1/indexes/indexName/synonyms/search'); + expect((req as any).method).toEqual('POST'); + expect((req as any).data).toEqual(undefined); + expect((req as any).searchParams).toEqual({ + query: 'queryString', + type: 'onewaysynonym', }); }); }); @@ -556,13 +552,12 @@ describe('setDictionarySettings', () => { }, }); - expect(req).toMatchObject({ - path: '/1/dictionaries/*/settings', - method: 'PUT', - data: { - disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, - }, + expect((req as any).path).toEqual('/1/dictionaries/*/settings'); + expect((req as any).method).toEqual('PUT'); + expect((req as any).data).toEqual({ + disableStandardEntries: { plurals: { fr: false, en: false, ru: true } }, }); + expect((req as any).searchParams).toEqual(undefined); }); test('get setDictionarySettings results with all parameters', async () => { @@ -576,17 +571,16 @@ describe('setDictionarySettings', () => { }, }); - expect(req).toMatchObject({ - path: '/1/dictionaries/*/settings', - method: 'PUT', - data: { - disableStandardEntries: { - plurals: { fr: false, en: false, ru: true }, - stopwords: { fr: false }, - compounds: { ru: true }, - }, + expect((req as any).path).toEqual('/1/dictionaries/*/settings'); + expect((req as any).method).toEqual('PUT'); + expect((req as any).data).toEqual({ + disableStandardEntries: { + plurals: { fr: false, en: false, ru: true }, + stopwords: { fr: false }, + compounds: { ru: true }, }, }); + expect((req as any).searchParams).toEqual(undefined); }); }); @@ -602,15 +596,14 @@ describe('updateApiKey', () => { }, }); - expect(req).toMatchObject({ - path: '/1/keys/myApiKey', - method: 'PUT', - data: { - acl: ['search', 'addObject'], - validity: 300, - maxQueriesPerIPPerHour: 100, - maxHitsPerQuery: 20, - }, + expect((req as any).path).toEqual('/1/keys/myApiKey'); + expect((req as any).method).toEqual('PUT'); + expect((req as any).data).toEqual({ + acl: ['search', 'addObject'], + validity: 300, + maxQueriesPerIPPerHour: 100, + maxHitsPerQuery: 20, }); + expect((req as any).searchParams).toEqual(undefined); }); });