From 364c943427f708c9f87966c4f4e429c40eb262c3 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 10:47:55 +0100 Subject: [PATCH 1/7] feat: add first endpoints --- specs/search/paths/rules/common/schemas.yml | 169 ++++++++++++++++++++ specs/search/paths/rules/rule.yml | 79 +++++++++ specs/search/spec.yml | 16 +- 3 files changed, 256 insertions(+), 8 deletions(-) create mode 100644 specs/search/paths/rules/common/schemas.yml diff --git a/specs/search/paths/rules/common/schemas.yml b/specs/search/paths/rules/common/schemas.yml new file mode 100644 index 0000000000..4f8d6638d5 --- /dev/null +++ b/specs/search/paths/rules/common/schemas.yml @@ -0,0 +1,169 @@ +rule: + type: object + description: Rule object. + additionalProperties: false + properties: + objectID: + $ref: '../../../../common/parameters.yml#/objectID' + conditions: + type: array + description: A list of conditions that should apply to activate a Rule. You can use up to 25 conditions per Rule. + items: + $ref: '#/condition' + consequence: + $ref: '#/consequence' + description: + type: string + description: This field is intended for Rule management purposes, in particular to ease searching for Rules and presenting them to human readers. It’s not interpreted by the API. + enabled: + type: boolean + default: true + description: Whether the Rule is enabled. Disabled Rules remain in the index, but aren’t applied at query time. + validity: + type: array + description: By default, Rules are permanently valid. When validity periods are specified, the Rule applies only during those periods; it’s ignored the rest of the time. The list must not be empty. + items: + $ref: '#/timeRange' + required: + - objectID + - consequence + +condition: + type: object + additionalProperties: false + properties: + pattern: + type: string + description: Query pattern syntax + anchoring: + type: string + description: Whether the pattern parameter must match the beginning or the end of the query string, or both, or none. + enum: + [ + 'is', + 'startsWith', + 'endsWith', + 'contains', + ] + alternatives: + type: boolean + description: Whether the pattern matches on plurals, synonyms, and typos. + default: false + context: + type: string + description: 'Rule context format: [A-Za-z0-9_-]+).' + + +consequence: + type: object + description: Consequence of the Rule. + additionalProperties: false + properties: + params: + $ref: '#/params' + promote: + type: array + description: Objects to promote as hits. + items: + $ref: '#/promote' + filterPromotes: + hide: + userData: + +promote: + type: object + description: Object to promote as hits. + additionalProperties: false + properties: + objectID: FIXME + objectIDs: + position: + required: + - objectID + - objectIDs + - position + +params: + type: object + description: Additional search parameters. Any valid search parameter is allowed. + additionalProperties: false + properties: + query: + type: string + description: Query string. + automaticFacetFilters: + $ref: '#/automaticFacetFilters' + automaticOptionalFacetFilters: + $ref: '#/automaticOptionalFacetFilters' + +automaticFacetFilters: + type: array + description: Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern. + items: + $ref: '#/automaticFacetFilter' + +automaticOptionalFacetFilters: + type: object + description: Same syntax as automaticFacetFilters, but the engine treats the filters as optional. + items: + $ref: '#/automaticFacetFilter' + +automaticFacetFilter: + type: object + description: Automatic facet Filter. + additionalProperties: false + properties: + facet: + type: string + description: Attribute to filter on. This must match a facet placeholder in the Rule’s pattern. + score: + type: integer + default: 1 + description: Score for the filter. Typically used for optional or disjunctive filters. + disjunctive: + type: boolean + default: false + description: Whether the filter is disjunctive (true) or conjunctive (false). + required: + - facet + +timeRange: + type: object + additionalProperties: false + properties: + from: + type: integer + description: Lower bound of the time range (Unix timestamp). + until: + type: until + description: Upper bound of the time range (Unix timestamp). + required: + - from + - until + +updatedRuleResponse: + type: object + additionalProperties: false + properties: + objectID: + $ref: '../../../../common/parameters.yml#/objectID' + updatedAt: + $ref: '../../../../common/parameters.yml#/updatedAt' + taskID: + $ref: '../../../../common/parameters.yml#/taskID' + required: + - objectID + - updatedAt + - taskID + +deletedRule: + type: object + additionalProperties: false + properties: + updatedAt: + $ref: '../../../../common/parameters.yml#/updatedAt' + taskID: + $ref: '../../../../common/parameters.yml#/taskID' + required: + - updatedAt + - taskID diff --git a/specs/search/paths/rules/rule.yml b/specs/search/paths/rules/rule.yml index 9157e5af9a..9e05d67a37 100644 --- a/specs/search/paths/rules/rule.yml +++ b/specs/search/paths/rules/rule.yml @@ -1,3 +1,82 @@ put: + tags: + - search + operationId: saveRule + summary: Save/Update a rule. + description: Create or update the Rule with the specified objectID. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ObjectID' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + requestBody: + required: true + content: + application/json: + schema: + $ref: 'common/schemas.yml#/rule' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/updatedRuleResponse' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' + get: + tags: + - search + operationId: getRule + summary: Get a rule. + description: Retrieve the Rule with the specified objectID. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ObjectID' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/rule' + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' + delete: + tags: + - search + operationId: deleteRule + summary: Delete a rule. + description: Delete the Rule with the specified objectID.. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ObjectID' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/deletedRule' + '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/search/spec.yml b/specs/search/spec.yml index 8c5b6c25ad..035976a609 100644 --- a/specs/search/spec.yml +++ b/specs/search/spec.yml @@ -78,14 +78,14 @@ paths: # ####################### # ### Rules Endpoints ### # ####################### - # /1/indexes/{indexName}/rules/{objectID}: - # $ref: './paths/rules/rule.yml' - # /1/indexes/{indexName}/rules/batch: - # $ref: './paths/rules/batchRules.yml' - # /1/indexes/{indexName}/rules/clear: - # $ref: './paths/rules/clearRules.yml' - # /1/indexes/{indexName}/rules/search: - # $ref: './paths/rules/searchRules.yml' + /1/indexes/{indexName}/rules/{objectID}: + $ref: './paths/rules/rule.yml' + /1/indexes/{indexName}/rules/batch: + $ref: './paths/rules/batchRules.yml' + /1/indexes/{indexName}/rules/clear: + $ref: './paths/rules/clearRules.yml' + /1/indexes/{indexName}/rules/search: + $ref: './paths/rules/searchRules.yml' # ############################## # ### Dictionaries Endpoints ### From 7eed24944db2367e1ddb815d33c62df561a6e462 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 16:19:07 +0100 Subject: [PATCH 2/7] feat: Add rules endpoints --- .../client-search/model/anchoring.ts | 6 + .../model/automaticFacetFilter.ts | 17 ++ .../client-search/model/condition.ts | 17 ++ .../client-search/model/consequence.ts | 26 ++ .../client-search/model/consequenceHide.ts | 9 + .../client-search/model/deletedRule.ts | 10 + .../client-search/model/models.ts | 13 + .../client-search/model/params.ts | 19 ++ .../client-search/model/promote.ts | 17 ++ .../client-search/model/rule.ts | 30 ++ .../client-search/model/searchRulesParams.ts | 32 ++ .../model/searchRulesResponse.ts | 20 ++ .../client-search/model/timeRange.ts | 10 + .../model/updatedRuleResponse.ts | 14 + .../updatedRuleResponseWithoutObjectID.ts | 10 + .../client-search/src/searchApi.ts | 284 ++++++++++++++++++ openapitools.json | 2 +- specs/common/parameters.yml | 5 + specs/search/paths/rules/batchRules.yml | 33 ++ specs/search/paths/rules/clearRules.yml | 23 ++ .../search/paths/rules/common/parameters.yml | 7 + specs/search/paths/rules/common/schemas.yml | 75 +++-- specs/search/paths/rules/rule.yml | 2 +- specs/search/paths/rules/searchRules.yml | 80 +++++ 24 files changed, 728 insertions(+), 33 deletions(-) create mode 100644 clients/algoliasearch-client-javascript/client-search/model/anchoring.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/automaticFacetFilter.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/condition.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/consequence.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/consequenceHide.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/deletedRule.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/params.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/promote.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/rule.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/searchRulesParams.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/searchRulesResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/timeRange.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponse.ts create mode 100644 clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponseWithoutObjectID.ts create mode 100644 specs/search/paths/rules/common/parameters.yml diff --git a/clients/algoliasearch-client-javascript/client-search/model/anchoring.ts b/clients/algoliasearch-client-javascript/client-search/model/anchoring.ts new file mode 100644 index 0000000000..bf861b13c3 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/anchoring.ts @@ -0,0 +1,6 @@ +export enum Anchoring { + Is = 'is', + StartsWith = 'startsWith', + EndsWith = 'endsWith', + Contains = 'contains', +} diff --git a/clients/algoliasearch-client-javascript/client-search/model/automaticFacetFilter.ts b/clients/algoliasearch-client-javascript/client-search/model/automaticFacetFilter.ts new file mode 100644 index 0000000000..9db0524583 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/automaticFacetFilter.ts @@ -0,0 +1,17 @@ +/** + * Automatic facet Filter. + */ +export type AutomaticFacetFilter = { + /** + * Attribute to filter on. This must match a facet placeholder in the Rule’s pattern. + */ + facet: string; + /** + * Score for the filter. Typically used for optional or disjunctive filters. + */ + score?: number; + /** + * Whether the filter is disjunctive (true) or conjunctive (false). + */ + disjunctive?: boolean; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/condition.ts b/clients/algoliasearch-client-javascript/client-search/model/condition.ts new file mode 100644 index 0000000000..41db9a3cc1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/condition.ts @@ -0,0 +1,17 @@ +import type { Anchoring } from './anchoring'; + +export type Condition = { + /** + * Query pattern syntax. + */ + pattern?: string; + anchoring?: Anchoring; + /** + * Whether the pattern matches on plurals, synonyms, and typos. + */ + alternatives?: boolean; + /** + * Rule context format: [A-Za-z0-9_-]+). + */ + context?: string; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/consequence.ts b/clients/algoliasearch-client-javascript/client-search/model/consequence.ts new file mode 100644 index 0000000000..b41a4583d2 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/consequence.ts @@ -0,0 +1,26 @@ +import type { ConsequenceHide } from './consequenceHide'; +import type { Params } from './params'; +import type { Promote } from './promote'; + +/** + * Consequence of the Rule. + */ +export type Consequence = { + params?: Params; + /** + * Objects to promote as hits. + */ + promote?: Promote[]; + /** + * Only use in combination with the promote consequence. When true, promoted results will be restricted to match the filters of the current search. When false, the promoted results will show up regardless of the filters. + */ + filterPromotes?: boolean; + /** + * Objects to hide from hits. Each object must contain an objectID field. By default, you can hide up to 50 items per rule. + */ + hide?: ConsequenceHide[]; + /** + * Custom JSON object that will be appended to the userData array in the response. This object isn’t interpreted by the API. It’s limited to 1kB of minified JSON. + */ + userData?: { [key: string]: Record }; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/consequenceHide.ts b/clients/algoliasearch-client-javascript/client-search/model/consequenceHide.ts new file mode 100644 index 0000000000..28f87c9c0c --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/consequenceHide.ts @@ -0,0 +1,9 @@ +/** + * Unique identifier of the object to hide. + */ +export type ConsequenceHide = { + /** + * Unique identifier of the object. + */ + objectID: string; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/deletedRule.ts b/clients/algoliasearch-client-javascript/client-search/model/deletedRule.ts new file mode 100644 index 0000000000..d25b854ac5 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/deletedRule.ts @@ -0,0 +1,10 @@ +export type DeletedRule = { + /** + * Date of last update (ISO-8601 format). + */ + updatedAt: Date; + /** + * TaskID of the indexing task to wait for. + */ + taskID: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index 0f55a5fb4f..ec426f4e1f 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -2,7 +2,9 @@ import type { RequestOptions } from '../utils/types'; export * from './addApiKeyResponse'; +export * from './anchoring'; export * from './apiKey'; +export * from './automaticFacetFilter'; export * from './baseIndexSettings'; export * from './baseSearchParams'; export * from './baseSearchResponse'; @@ -10,6 +12,9 @@ export * from './baseSearchResponseFacetsStats'; export * from './batchObject'; export * from './batchResponse'; export * from './clearAllSynonymsResponse'; +export * from './condition'; +export * from './consequence'; +export * from './consequenceHide'; export * from './createdAtObject'; export * from './deleteApiKeyResponse'; export * from './deleteIndexResponse'; @@ -32,9 +37,12 @@ export * from './multipleQueriesResponse'; export * from './operation'; export * from './operationIndexObject'; export * from './operationIndexResponse'; +export * from './params'; +export * from './promote'; export * from './rankingInfo'; export * from './rankingInfoMatchedGeoLocation'; export * from './record'; +export * from './rule'; export * from './saveObjectResponse'; export * from './saveSynonymResponse'; export * from './saveSynonymsResponse'; @@ -42,12 +50,17 @@ export * from './searchHits'; export * from './searchParams'; export * from './searchParamsAsString'; export * from './searchResponse'; +export * from './searchRulesParams'; +export * from './searchRulesResponse'; export * from './searchSynonymsResponse'; export * from './setSettingsResponse'; export * from './snippetResult'; export * from './synonymHit'; export * from './synonymHitHighlightResult'; +export * from './timeRange'; export * from './updateApiKeyResponse'; +export * from './updatedRuleResponse'; +export * from './updatedRuleResponseWithoutObjectID'; export interface Authentication { /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/params.ts b/clients/algoliasearch-client-javascript/client-search/model/params.ts new file mode 100644 index 0000000000..59c91f2bc1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/params.ts @@ -0,0 +1,19 @@ +import type { AutomaticFacetFilter } from './automaticFacetFilter'; + +/** + * Additional search parameters. Any valid search parameter is allowed. + */ +export type Params = { + /** + * Query string. + */ + query?: string; + /** + * Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern. + */ + automaticFacetFilters?: AutomaticFacetFilter[]; + /** + * Same syntax as automaticFacetFilters, but the engine treats the filters as optional. + */ + automaticOptionalFacetFilters?: AutomaticFacetFilter[]; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/promote.ts b/clients/algoliasearch-client-javascript/client-search/model/promote.ts new file mode 100644 index 0000000000..915ad295da --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/promote.ts @@ -0,0 +1,17 @@ +/** + * Object to promote as hits. + */ +export type Promote = { + /** + * Unique identifier of the object to promote. + */ + objectID?: string; + /** + * Array of unique identifiers of the objects to promote. + */ + objectIDs?: string[]; + /** + * The position to promote the objects to (zero-based). If you pass objectIDs, the objects are placed at this position as a group. For example, if you pass four objectIDs to position 0, the objects take the first four positions. + */ + position: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/rule.ts b/clients/algoliasearch-client-javascript/client-search/model/rule.ts new file mode 100644 index 0000000000..5c606d79d1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/rule.ts @@ -0,0 +1,30 @@ +import type { Condition } from './condition'; +import type { Consequence } from './consequence'; +import type { TimeRange } from './timeRange'; + +/** + * Rule object. + */ +export type Rule = { + /** + * Unique identifier of the object. + */ + objectID: string; + /** + * A list of conditions that should apply to activate a Rule. You can use up to 25 conditions per Rule. + */ + conditions?: Condition[]; + consequence: Consequence; + /** + * This field is intended for Rule management purposes, in particular to ease searching for Rules and presenting them to human readers. It’s not interpreted by the API. + */ + description?: string; + /** + * Whether the Rule is enabled. Disabled Rules remain in the index, but aren’t applied at query time. + */ + enabled?: boolean; + /** + * By default, Rules are permanently valid. When validity periods are specified, the Rule applies only during those periods; it’s ignored the rest of the time. The list must not be empty. + */ + validity?: TimeRange[]; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchRulesParams.ts b/clients/algoliasearch-client-javascript/client-search/model/searchRulesParams.ts new file mode 100644 index 0000000000..164b30ba4d --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/searchRulesParams.ts @@ -0,0 +1,32 @@ +import type { Anchoring } from './anchoring'; + +/** + * Parameters for the search. + */ +export type SearchRulesParams = { + /** + * Full text query. + */ + query?: string; + anchoring?: Anchoring; + /** + * Restricts matches to contextual rules with a specific context (exact match). + */ + context?: string; + /** + * Requested page (zero-based). + */ + page?: number; + /** + * Maximum number of hits in a page. Minimum is 1, maximum is 1000. + */ + hitsPerPage?: number; + /** + * When specified, restricts matches to rules with a specific enabled status. When absent (default), all rules are retrieved, regardless of their enabled status. + */ + enabled?: boolean; + /** + * A mapping of requestOptions to send along with the request. + */ + requestOptions?: Array<{ [key: string]: Record }>; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchRulesResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/searchRulesResponse.ts new file mode 100644 index 0000000000..ce4f100e43 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/searchRulesResponse.ts @@ -0,0 +1,20 @@ +import type { Rule } from './rule'; + +export type SearchRulesResponse = { + /** + * Fetched rules. + */ + hits: Rule[]; + /** + * Number of fetched rules. + */ + nbHits: number; + /** + * Current page. + */ + page: number; + /** + * Number of pages. + */ + nbPages: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/timeRange.ts b/clients/algoliasearch-client-javascript/client-search/model/timeRange.ts new file mode 100644 index 0000000000..2c0a2444fd --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/timeRange.ts @@ -0,0 +1,10 @@ +export type TimeRange = { + /** + * Lower bound of the time range (Unix timestamp). + */ + from: number; + /** + * Upper bound of the time range (Unix timestamp). + */ + until: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponse.ts new file mode 100644 index 0000000000..6abeef1c93 --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponse.ts @@ -0,0 +1,14 @@ +export type UpdatedRuleResponse = { + /** + * Unique identifier of the object. + */ + objectID: string; + /** + * Date of last update (ISO-8601 format). + */ + updatedAt: Date; + /** + * TaskID of the indexing task to wait for. + */ + taskID: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponseWithoutObjectID.ts b/clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponseWithoutObjectID.ts new file mode 100644 index 0000000000..cb245abbdf --- /dev/null +++ b/clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponseWithoutObjectID.ts @@ -0,0 +1,10 @@ +export type UpdatedRuleResponseWithoutObjectID = { + /** + * Date of last update (ISO-8601 format). + */ + updatedAt: Date; + /** + * TaskID of the indexing task to wait for. + */ + taskID: number; +}; diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index 87d4ff7eba..c587ab849e 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -17,16 +17,21 @@ import type { MultipleQueriesObject } from '../model/multipleQueriesObject'; import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse'; import type { OperationIndexObject } from '../model/operationIndexObject'; import type { OperationIndexResponse } from '../model/operationIndexResponse'; +import type { Rule } from '../model/rule'; import type { SaveObjectResponse } from '../model/saveObjectResponse'; import type { SaveSynonymResponse } from '../model/saveSynonymResponse'; import type { SaveSynonymsResponse } from '../model/saveSynonymsResponse'; import type { SearchParams } from '../model/searchParams'; import type { SearchParamsAsString } from '../model/searchParamsAsString'; import type { SearchResponse } from '../model/searchResponse'; +import type { SearchRulesParams } from '../model/searchRulesParams'; +import type { SearchRulesResponse } from '../model/searchRulesResponse'; import type { SearchSynonymsResponse } from '../model/searchSynonymsResponse'; import type { SetSettingsResponse } from '../model/setSettingsResponse'; import type { SynonymHit } from '../model/synonymHit'; import type { UpdateApiKeyResponse } from '../model/updateApiKeyResponse'; +import type { UpdatedRuleResponse } from '../model/updatedRuleResponse'; +import type { UpdatedRuleResponseWithoutObjectID } from '../model/updatedRuleResponseWithoutObjectID'; import { Transporter } from '../utils/Transporter'; import { shuffle } from '../utils/helpers'; import type { Requester } from '../utils/requester/Requester'; @@ -191,6 +196,61 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Create or update a batch of Rules. + * + * @summary Batch Rules. + * @param indexName - The index in which to perform the request. + * @param rule - The rule. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + * @param clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept. + */ + batchRules( + indexName: string, + rule: Rule[], + forwardToReplicas?: boolean, + clearExistingRules?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/rules/batch'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling batchRules.' + ); + } + + if (rule === null || rule === undefined) { + throw new Error( + 'Required parameter rule was null or undefined when calling batchRules.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + if (clearExistingRules !== undefined) { + queryParameters.clearExistingRules = clearExistingRules.toString(); + } + + const request: Request = { + method: 'POST', + path, + data: rule, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Remove all synonyms from an index. * @@ -231,6 +291,46 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Delete all Rules in the index. + * + * @summary Clear Rules. + * @param indexName - The index in which to perform the request. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + */ + clearRules( + indexName: string, + forwardToReplicas?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/rules/clear'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling clearRules.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + const request: Request = { + method: 'POST', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Delete an existing API Key. * @@ -295,6 +395,53 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Delete the Rule with the specified objectID.. + * + * @summary Delete a rule. + * @param indexName - The index in which to perform the request. + * @param objectID - Unique identifier of an object. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + */ + deleteRule( + indexName: string, + objectID: string, + forwardToReplicas?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/rules/{objectID}' + .replace('{indexName}', encodeURIComponent(String(indexName))) + .replace('{objectID}', encodeURIComponent(String(objectID))); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling deleteRule.' + ); + } + + if (objectID === null || objectID === undefined) { + throw new Error( + 'Required parameter objectID was null or undefined when calling deleteRule.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + const request: Request = { + method: 'DELETE', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Delete a single synonyms set, identified by the given objectID. * @@ -420,6 +567,44 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Retrieve the Rule with the specified objectID. + * + * @summary Get a rule. + * @param indexName - The index in which to perform the request. + * @param objectID - Unique identifier of an object. + */ + getRule(indexName: string, objectID: string): Promise { + const path = '/1/indexes/{indexName}/rules/{objectID}' + .replace('{indexName}', encodeURIComponent(String(indexName))) + .replace('{objectID}', encodeURIComponent(String(objectID))); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling getRule.' + ); + } + + if (objectID === null || objectID === undefined) { + throw new Error( + 'Required parameter objectID was null or undefined when calling getRule.' + ); + } + + const request: Request = { + method: 'GET', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Retrieve settings of a given indexName. * @@ -723,6 +908,62 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Create or update the Rule with the specified objectID. + * + * @summary Save/Update a rule. + * @param indexName - The index in which to perform the request. + * @param objectID - Unique identifier of an object. + * @param rule - The rule. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + */ + saveRule( + indexName: string, + objectID: string, + rule: Rule, + forwardToReplicas?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/rules/{objectID}' + .replace('{indexName}', encodeURIComponent(String(indexName))) + .replace('{objectID}', encodeURIComponent(String(objectID))); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling saveRule.' + ); + } + + if (objectID === null || objectID === undefined) { + throw new Error( + 'Required parameter objectID was null or undefined when calling saveRule.' + ); + } + + if (rule === null || rule === undefined) { + throw new Error( + 'Required parameter rule was null or undefined when calling saveRule.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + const request: Request = { + method: 'PUT', + path, + data: rule, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Create a new synonym object or update the existing synonym object with the given object ID. * @@ -880,6 +1121,49 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Search for rules matching various criteria. + * + * @summary Search for rules. + * @param indexName - The index in which to perform the request. + * @param searchRulesParams - The searchRulesParams. + */ + searchRules( + indexName: string, + searchRulesParams: SearchRulesParams + ): Promise { + const path = '/1/indexes/{indexName}/rules/search'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling searchRules.' + ); + } + + if (searchRulesParams === null || searchRulesParams === undefined) { + throw new Error( + 'Required parameter searchRulesParams was null or undefined when calling searchRules.' + ); + } + + const request: Request = { + method: 'POST', + path, + data: searchRulesParams, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Search or browse all synonyms, optionally filtering them by type. * diff --git a/openapitools.json b/openapitools.json index d7b749c8c7..06cf00c585 100644 --- a/openapitools.json +++ b/openapitools.json @@ -13,7 +13,7 @@ "gitHost": "algolia", "gitUserId": "algolia", "gitRepoId": "algoliasearch-client-javascript", - "reservedWordsMappings": "queryParameters=queryParameters", + "reservedWordsMappings": "queryParameters=queryParameters,requestOptions=requestOptions", "additionalProperties": { "modelPropertyNaming": "original", "supportsES6": true, diff --git a/specs/common/parameters.yml b/specs/common/parameters.yml index 7b4c9bffd9..6b3fed2c22 100644 --- a/specs/common/parameters.yml +++ b/specs/common/parameters.yml @@ -126,3 +126,8 @@ indexName: type: string example: products description: The Algolia index name. + +hitsPerPage: + type: integer + default: 20 + description: Maximum number of hits in a page. Minimum is 1, maximum is 1000. diff --git a/specs/search/paths/rules/batchRules.yml b/specs/search/paths/rules/batchRules.yml index 6adb517bf4..3e66e882ce 100644 --- a/specs/search/paths/rules/batchRules.yml +++ b/specs/search/paths/rules/batchRules.yml @@ -1 +1,34 @@ post: + tags: + - search + operationId: batchRules + summary: Batch Rules. + description: Create or update a batch of Rules. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + - $ref: 'common/parameters.yml#/ClearExistingRules' + requestBody: + required: true + content: + application/json: + schema: + type: array + description: Rules to add. + items: + $ref: 'common/schemas.yml#/rule' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/updatedRuleResponseWithoutObjectID' + '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/search/paths/rules/clearRules.yml b/specs/search/paths/rules/clearRules.yml index 6adb517bf4..a6b1d3255c 100644 --- a/specs/search/paths/rules/clearRules.yml +++ b/specs/search/paths/rules/clearRules.yml @@ -1 +1,24 @@ post: + tags: + - search + operationId: clearRules + summary: Clear Rules. + description: Delete all Rules in the index. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + - $ref: '../../../common/parameters.yml#/ForwardToReplicas' + responses: + '200': + description: OK + content: + application/json: + schema: + $ref: './common/schemas.yml#/updatedRuleResponseWithoutObjectID' + '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/search/paths/rules/common/parameters.yml b/specs/search/paths/rules/common/parameters.yml new file mode 100644 index 0000000000..df87cba731 --- /dev/null +++ b/specs/search/paths/rules/common/parameters.yml @@ -0,0 +1,7 @@ +ClearExistingRules: + in: query + name: clearExistingRules + required: false + schema: + type: boolean + description: When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept. diff --git a/specs/search/paths/rules/common/schemas.yml b/specs/search/paths/rules/common/schemas.yml index 4f8d6638d5..9c9d0e2101 100644 --- a/specs/search/paths/rules/common/schemas.yml +++ b/specs/search/paths/rules/common/schemas.yml @@ -28,7 +28,7 @@ rule: - objectID - consequence -condition: +condition: type: object additionalProperties: false properties: @@ -36,15 +36,7 @@ condition: type: string description: Query pattern syntax anchoring: - type: string - description: Whether the pattern parameter must match the beginning or the end of the query string, or both, or none. - enum: - [ - 'is', - 'startsWith', - 'endsWith', - 'contains', - ] + $ref: '#/anchoring' alternatives: type: boolean description: Whether the pattern matches on plurals, synonyms, and typos. @@ -53,6 +45,10 @@ condition: type: string description: 'Rule context format: [A-Za-z0-9_-]+).' +anchoring: + type: string + description: Whether the pattern parameter must match the beginning or the end of the query string, or both, or none. + enum: ['is', 'startsWith', 'endsWith', 'contains'] consequence: type: object @@ -63,24 +59,47 @@ consequence: $ref: '#/params' promote: type: array - description: Objects to promote as hits. + description: Objects to promote as hits. items: $ref: '#/promote' filterPromotes: + type: boolean + default: false + description: Only use in combination with the promote consequence. When true, promoted results will be restricted to match the filters of the current search. When false, the promoted results will show up regardless of the filters. hide: + type: array + description: Objects to hide from hits. Each object must contain an objectID field. By default, you can hide up to 50 items per rule. + items: + type: object + description: Unique identifier of the object to hide. + additionalProperties: false + properties: + objectID: + $ref: '../../../../common/parameters.yml#/objectID' + required: + - objectID userData: + type: object + description: Custom JSON object that will be appended to the userData array in the response. This object isn’t interpreted by the API. It’s limited to 1kB of minified JSON. + additionalProperties: true promote: type: object - description: Object to promote as hits. + description: Object to promote as hits. additionalProperties: false properties: - objectID: FIXME + objectID: + type: string + description: Unique identifier of the object to promote. objectIDs: + type: array + description: Array of unique identifiers of the objects to promote. + items: + type: string position: + type: integer + description: The position to promote the objects to (zero-based). If you pass objectIDs, the objects are placed at this position as a group. For example, if you pass four objectIDs to position 0, the objects take the first four positions. required: - - objectID - - objectIDs - position params: @@ -92,21 +111,15 @@ params: type: string description: Query string. automaticFacetFilters: - $ref: '#/automaticFacetFilters' + type: array + description: Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern. + items: + $ref: '#/automaticFacetFilter' automaticOptionalFacetFilters: - $ref: '#/automaticOptionalFacetFilters' - -automaticFacetFilters: - type: array - description: Names of facets to which automatic filtering must be applied; they must match the facet name of a facet value placeholder in the query pattern. - items: - $ref: '#/automaticFacetFilter' - -automaticOptionalFacetFilters: - type: object - description: Same syntax as automaticFacetFilters, but the engine treats the filters as optional. - items: - $ref: '#/automaticFacetFilter' + type: object + description: Same syntax as automaticFacetFilters, but the engine treats the filters as optional. + items: + $ref: '#/automaticFacetFilter' automaticFacetFilter: type: object @@ -135,7 +148,7 @@ timeRange: type: integer description: Lower bound of the time range (Unix timestamp). until: - type: until + type: integer description: Upper bound of the time range (Unix timestamp). required: - from @@ -156,7 +169,7 @@ updatedRuleResponse: - updatedAt - taskID -deletedRule: +updatedRuleResponseWithoutObjectID: type: object additionalProperties: false properties: diff --git a/specs/search/paths/rules/rule.yml b/specs/search/paths/rules/rule.yml index 9e05d67a37..33d496255b 100644 --- a/specs/search/paths/rules/rule.yml +++ b/specs/search/paths/rules/rule.yml @@ -71,7 +71,7 @@ delete: content: application/json: schema: - $ref: './common/schemas.yml#/deletedRule' + $ref: './common/schemas.yml#/updatedRuleResponseWithoutObjectID' '400': $ref: '../../../common/responses/BadRequest.yml' '402': diff --git a/specs/search/paths/rules/searchRules.yml b/specs/search/paths/rules/searchRules.yml index 6adb517bf4..4168c01af4 100644 --- a/specs/search/paths/rules/searchRules.yml +++ b/specs/search/paths/rules/searchRules.yml @@ -1 +1,81 @@ post: + tags: + - search + operationId: searchRules + summary: Search for rules. + description: Search for rules matching various criteria. + parameters: + - $ref: '../../../common/parameters.yml#/IndexName' + requestBody: + required: true + content: + application/json: + schema: + type: object + title: searchRulesParams + description: Parameters for the search. + additionalProperties: false + properties: + query: + type: string + default: '' + description: Full text query. + anchoring: + $ref: './common/schemas.yml#/anchoring' + context: + type: string + description: Restricts matches to contextual rules with a specific context (exact match). + page: + type: integer + default: 0 + description: Requested page (zero-based). + hitsPerPage: + $ref: '../../../common/parameters.yml#/hitsPerPage' + enabled: + type: boolean + default: null + description: When specified, restricts matches to rules with a specific enabled status. When absent (default), all rules are retrieved, regardless of their enabled status. + requestOptions: + type: array + description: A mapping of requestOptions to send along with the request. + items: + type: object + description: Request Option. + additionalProperties: true + responses: + '200': + description: OK + content: + application/json: + schema: + title: searchRulesResponse + type: object + additionalProperties: false + required: + - hits + - nbHits + - page + - nbPages + properties: + hits: + type: array + description: Fetched rules. + items: + $ref: 'common/schemas.yml#/rule' + nbHits: + type: integer + description: Number of fetched rules. + page: + type: integer + description: Current page. + nbPages: + type: integer + description: Number of pages. + '400': + $ref: '../../../common/responses/BadRequest.yml' + '402': + $ref: '../../../common/responses/FeatureNotEnabled.yml' + '403': + $ref: '../../../common/responses/MethodNotAllowed.yml' + '404': + $ref: '../../../common/responses/IndexNotFound.yml' From f9f48bf6ad07cd0f20565ec610d18dff5e70c9fe Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 16:59:27 +0100 Subject: [PATCH 3/7] feat: add tests --- .../client-search/model/anchoring.ts | 3 + tests/CTS/clients/search/batchRules.json | 67 ++++++++++++++ tests/CTS/clients/search/clearRules.json | 11 +++ tests/CTS/clients/search/deleteRule.json | 11 +++ tests/CTS/clients/search/getRule.json | 11 +++ tests/CTS/clients/search/saveRule.json | 39 ++++++++ tests/CTS/clients/search/searchRules.json | 15 +++ tests/output/javascript/search.test.ts | 91 +++++++++++++++++++ 8 files changed, 248 insertions(+) create mode 100644 tests/CTS/clients/search/batchRules.json create mode 100644 tests/CTS/clients/search/clearRules.json create mode 100644 tests/CTS/clients/search/deleteRule.json create mode 100644 tests/CTS/clients/search/getRule.json create mode 100644 tests/CTS/clients/search/saveRule.json create mode 100644 tests/CTS/clients/search/searchRules.json diff --git a/clients/algoliasearch-client-javascript/client-search/model/anchoring.ts b/clients/algoliasearch-client-javascript/client-search/model/anchoring.ts index bf861b13c3..46fd248e5a 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/anchoring.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/anchoring.ts @@ -1,3 +1,6 @@ +/** + * Whether the pattern parameter must match the beginning or the end of the query string, or both, or none. + */ export enum Anchoring { Is = 'is', StartsWith = 'startsWith', diff --git a/tests/CTS/clients/search/batchRules.json b/tests/CTS/clients/search/batchRules.json new file mode 100644 index 0000000000..507de4d6e4 --- /dev/null +++ b/tests/CTS/clients/search/batchRules.json @@ -0,0 +1,67 @@ +[ + { + "method": "batchRules", + "parameters": [ + "indexName", + [ + { + "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" + } + } + } + ], + true, + true + ], + "request": { + "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" + } + } + } + ] + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/clearRules.json b/tests/CTS/clients/search/clearRules.json new file mode 100644 index 0000000000..0a205332e1 --- /dev/null +++ b/tests/CTS/clients/search/clearRules.json @@ -0,0 +1,11 @@ +[ + { + "method": "clearRules", + "parameters": ["indexName"], + "request": { + "path": "/1/indexes/indexName/rules/clear", + "method": "POST" + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/deleteRule.json b/tests/CTS/clients/search/deleteRule.json new file mode 100644 index 0000000000..36bf62d073 --- /dev/null +++ b/tests/CTS/clients/search/deleteRule.json @@ -0,0 +1,11 @@ +[ + { + "method": "deleteRule", + "parameters": ["indexName", "id1"], + "request": { + "path": "/1/indexes/indexName/rules/id1", + "method": "DELETE" + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/getRule.json b/tests/CTS/clients/search/getRule.json new file mode 100644 index 0000000000..93203a795f --- /dev/null +++ b/tests/CTS/clients/search/getRule.json @@ -0,0 +1,11 @@ +[ + { + "method": "getRule", + "parameters": ["indexName", "id1"], + "request": { + "path": "/1/indexes/indexName/rules/id1", + "method": "GET" + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/saveRule.json b/tests/CTS/clients/search/saveRule.json new file mode 100644 index 0000000000..68761da37d --- /dev/null +++ b/tests/CTS/clients/search/saveRule.json @@ -0,0 +1,39 @@ +[ + { + "method": "saveRule", + "parameters": [ + "indexName", + "id1", + { + "objectID": "id1", + "conditions": [{ + "pattern": "apple", + "anchoring": "contains" + }], + "consequence": { + "params": { + "filters": "brand:apple" + } + } + }, + true + ], + "request": { + "path": "/1/indexes/indexName/rules/id1", + "method": "PUT", + "data": { + "objectID": "id1", + "conditions": [{ + "pattern": "apple", + "anchoring": "contains" + }], + "consequence": { + "params": { + "filters": "brand:apple" + } + } + } + } + } +] + \ No newline at end of file diff --git a/tests/CTS/clients/search/searchRules.json b/tests/CTS/clients/search/searchRules.json new file mode 100644 index 0000000000..cb6e0c44b2 --- /dev/null +++ b/tests/CTS/clients/search/searchRules.json @@ -0,0 +1,15 @@ +[ + { + "method": "searchRules", + "parameters": [ + "indexName", + {"query": "something"} + ], + "request": { + "path": "/1/indexes/indexName/rules/search", + "method": "POST", + "data": {"query": "something"} + } + } +] + \ No newline at end of file diff --git a/tests/output/javascript/search.test.ts b/tests/output/javascript/search.test.ts index 2fd84d64a3..1e64e47e2e 100644 --- a/tests/output/javascript/search.test.ts +++ b/tests/output/javascript/search.test.ts @@ -58,6 +58,14 @@ describe('Common Test Suite', () => { }); }); + test('deleteRule', async () => { + const req = await client.deleteRule('indexName', 'id1'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/rules/id1', + method: 'DELETE', + }); + }); + test('getSynonym', async () => { const req = await client.getSynonym('indexName', 'id1'); expect(req).toMatchObject({ @@ -75,6 +83,50 @@ describe('Common Test Suite', () => { }); }); + test('getRule', async () => { + const req = await client.getRule('indexName', 'id1'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/rules/id1', + method: 'GET', + }); + }); + + test('batchRules', async () => { + const req = await client.batchRules( + 'indexName', + [ + { + 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' } }, + }, + ], + true, + 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' } }, + }, + ], + }); + }); + test('updateApiKey', async () => { const req = await client.updateApiKey('myApiKey', { acl: ['search', 'addObject'], @@ -102,6 +154,15 @@ describe('Common Test Suite', () => { }); }); + test('searchRules', async () => { + const req = await client.searchRules('indexName', { query: 'something' }); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/rules/search', + method: 'POST', + data: { query: 'something' }, + }); + }); + test('clearAllSynonyms', async () => { const req = await client.clearAllSynonyms('indexName'); expect(req).toMatchObject({ @@ -110,6 +171,28 @@ describe('Common Test Suite', () => { }); }); + test('saveRule', async () => { + const req = await client.saveRule( + 'indexName', + 'id1', + { + objectID: 'id1', + conditions: [{ pattern: 'apple', anchoring: 'contains' }], + consequence: { params: { filters: 'brand:apple' } }, + }, + 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' } }, + }, + }); + }); + test('addApiKey', async () => { const req = await client.addApiKey({ acl: ['search', 'addObject'], @@ -155,6 +238,14 @@ describe('Common Test Suite', () => { }); }); + test('clearRules', async () => { + const req = await client.clearRules('indexName'); + expect(req).toMatchObject({ + path: '/1/indexes/indexName/rules/clear', + method: 'POST', + }); + }); + test('listApiKeys', async () => { const req = await client.listApiKeys(); expect(req).toMatchObject({ From 0965b4f937dad63d9f5fa8d7fdde826d3bfa975b Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Thu, 16 Dec 2021 17:05:54 +0100 Subject: [PATCH 4/7] feat: regenerate after merge --- .../client-search/model/models.ts | 4 ++ .../client-search/src/searchApi.ts | 58 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/clients/algoliasearch-client-javascript/client-search/model/models.ts b/clients/algoliasearch-client-javascript/client-search/model/models.ts index f1ceefd44f..47a4ff164d 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/models.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/models.ts @@ -6,6 +6,7 @@ export * from './anchoring'; export * from './apiKey'; export * from './assignUserIdObject'; export * from './assignUserIdResponse'; +export * from './automaticFacetFilter'; export * from './baseIndexSettings'; export * from './baseSearchParams'; export * from './baseSearchResponse'; @@ -50,6 +51,7 @@ export * from './rankingInfo'; export * from './rankingInfoMatchedGeoLocation'; export * from './record'; export * from './removeUserIdResponse'; +export * from './rule'; export * from './saveObjectResponse'; export * from './saveSynonymResponse'; export * from './saveSynonymsResponse'; @@ -70,6 +72,8 @@ export * from './synonymHit'; export * from './synonymHitHighlightResult'; export * from './timeRange'; export * from './updateApiKeyResponse'; +export * from './updatedRuleResponse'; +export * from './updatedRuleResponseWithoutObjectID'; export * from './userId'; export interface Authentication { diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index e4660c21f8..1179b65af8 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -26,6 +26,7 @@ import type { MultipleQueriesResponse } from '../model/multipleQueriesResponse'; import type { OperationIndexObject } from '../model/operationIndexObject'; import type { OperationIndexResponse } from '../model/operationIndexResponse'; import type { RemoveUserIdResponse } from '../model/removeUserIdResponse'; +import type { Rule } from '../model/rule'; import type { SaveObjectResponse } from '../model/saveObjectResponse'; import type { SaveSynonymResponse } from '../model/saveSynonymResponse'; import type { SaveSynonymsResponse } from '../model/saveSynonymsResponse'; @@ -40,6 +41,8 @@ import type { SearchUserIdsResponse } from '../model/searchUserIdsResponse'; import type { SetSettingsResponse } from '../model/setSettingsResponse'; import type { SynonymHit } from '../model/synonymHit'; import type { UpdateApiKeyResponse } from '../model/updateApiKeyResponse'; +import type { UpdatedRuleResponse } from '../model/updatedRuleResponse'; +import type { UpdatedRuleResponseWithoutObjectID } from '../model/updatedRuleResponseWithoutObjectID'; import type { UserId } from '../model/userId'; import { Transporter } from '../utils/Transporter'; import { shuffle } from '../utils/helpers'; @@ -296,6 +299,61 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } + /** + * Create or update a batch of Rules. + * + * @summary Batch Rules. + * @param indexName - The index in which to perform the request. + * @param rule - The rule. + * @param forwardToReplicas - When true, changes are also propagated to replicas of the given indexName. + * @param clearExistingRules - When true, existing Rules are cleared before adding this batch. When false, existing Rules are kept. + */ + batchRules( + indexName: string, + rule: Rule[], + forwardToReplicas?: boolean, + clearExistingRules?: boolean + ): Promise { + const path = '/1/indexes/{indexName}/rules/batch'.replace( + '{indexName}', + encodeURIComponent(String(indexName)) + ); + const headers: Headers = { Accept: 'application/json' }; + const queryParameters: Record = {}; + + if (indexName === null || indexName === undefined) { + throw new Error( + 'Required parameter indexName was null or undefined when calling batchRules.' + ); + } + + if (rule === null || rule === undefined) { + throw new Error( + 'Required parameter rule was null or undefined when calling batchRules.' + ); + } + + if (forwardToReplicas !== undefined) { + queryParameters.forwardToReplicas = forwardToReplicas.toString(); + } + + if (clearExistingRules !== undefined) { + queryParameters.clearExistingRules = clearExistingRules.toString(); + } + + const request: Request = { + method: 'POST', + path, + data: rule, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + + return this.sendRequest(request, requestOptions); + } /** * Remove all synonyms from an index. * From 4dae1770adf1ff4df90ab83e3ad1d03ba3da3ea3 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Fri, 17 Dec 2021 14:37:43 +0100 Subject: [PATCH 5/7] fix: handle feedbacks --- .../client-search/model/baseSearchParams.ts | 2 +- .../client-search/model/baseSearchResponse.ts | 4 ++-- .../client-search/model/indexSettingsAsSearchParams.ts | 2 +- .../client-search/model/multipleQueries.ts | 2 +- .../client-search/model/searchUserIdsObject.ts | 2 +- .../client-search/model/searchUserIdsResponse.ts | 2 +- .../client-search/src/searchApi.ts | 2 +- specs/common/parameters.yml | 10 ++++++++++ specs/search/common/schemas/IndexSettings.yml | 4 +--- specs/search/common/schemas/SearchParams.yml | 4 +--- specs/search/common/schemas/SearchResponse.yml | 2 +- specs/search/paths/multiclusters/searchUserIds.yml | 2 +- specs/search/paths/rules/rule.yml | 2 +- specs/search/paths/rules/searchRules.yml | 8 ++------ tests/CTS/clients/search/searchRules.json | 1 - 15 files changed, 25 insertions(+), 24 deletions(-) diff --git a/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts b/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts index f23907fbe3..8cbd91ae7f 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts @@ -1,6 +1,6 @@ export type BaseSearchParams = { /** - * The text to search in the index. + * Full text query. */ query: string; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts index e66b56a7e3..07e0aa2364 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts @@ -38,7 +38,7 @@ export type BaseSearchResponse = { */ facets_stats?: { [key: string]: BaseSearchResponseFacetsStats }; /** - * Set the number of hits per page. + * Maximum number of hits in a page. Minimum is 1, maximum is 1000. */ hitsPerPage: number; /** @@ -82,7 +82,7 @@ export type BaseSearchResponse = { */ processingTimeMS: number; /** - * The text to search in the index. + * Full text query. */ query: string; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts b/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts index 937cd43c07..1bc043d6ab 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts @@ -56,7 +56,7 @@ export type IndexSettingsAsSearchParams = { */ restrictHighlightAndSnippetArrays?: boolean; /** - * Set the number of hits per page. + * Maximum number of hits in a page. Minimum is 1, maximum is 1000. */ hitsPerPage?: number; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts b/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts index 4e1db9f448..2d400faaa5 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts @@ -4,7 +4,7 @@ export type MultipleQueries = { */ indexName: string; /** - * The text to search in the index. + * Full text query. */ query?: string; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts b/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts index c0f5a2c483..2f41111edd 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts @@ -15,7 +15,7 @@ export type SearchUserIdsObject = { */ page?: number; /** - * Set the number of hits per page. + * Maximum number of hits in a page. Minimum is 1, maximum is 1000. */ hitsPerPage?: number; }; diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsResponse.ts index 521512b5f3..ffbfc31ee9 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsResponse.ts @@ -14,7 +14,7 @@ export type SearchUserIdsResponse = { */ page: number; /** - * Set the number of hits per page. + * Maximum number of hits in a page. Minimum is 1, maximum is 1000. */ hitsPerPage: number; /** diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index 1179b65af8..6d093f5b74 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -499,7 +499,7 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } /** - * Delete the Rule with the specified objectID.. + * Delete the Rule with the specified objectID. * * @summary Delete a rule. * @param indexName - The index in which to perform the request. diff --git a/specs/common/parameters.yml b/specs/common/parameters.yml index 52e0462021..38b93aff02 100644 --- a/specs/common/parameters.yml +++ b/specs/common/parameters.yml @@ -131,3 +131,13 @@ hitsPerPage: type: integer default: 20 description: Maximum number of hits in a page. Minimum is 1, maximum is 1000. + +query: + type: string + description: Full text query. + default: '' + +page: + type: integer + default: 0 + description: Requested page (zero-based). diff --git a/specs/search/common/schemas/IndexSettings.yml b/specs/search/common/schemas/IndexSettings.yml index 49dcf0bde5..9987f521bd 100644 --- a/specs/search/common/schemas/IndexSettings.yml +++ b/specs/search/common/schemas/IndexSettings.yml @@ -158,9 +158,7 @@ indexSettingsAsSearchParams: description: Restrict highlighting and snippeting to items that matched the query. default: false hitsPerPage: - type: integer - description: Set the number of hits per page. - default: 20 + $ref: '../../../common/parameters.yml#/hitsPerPage' minWordSizefor1Typo: type: integer description: Minimum number of characters a word in the query string must contain to accept matches with 1 typo. diff --git a/specs/search/common/schemas/SearchParams.yml b/specs/search/common/schemas/SearchParams.yml index 4a0af449cf..5ca2523a43 100644 --- a/specs/search/common/schemas/SearchParams.yml +++ b/specs/search/common/schemas/SearchParams.yml @@ -10,9 +10,7 @@ baseSearchParams: - query properties: query: - type: string - description: The text to search in the index. - default: '' + $ref: '../../../common/parameters.yml#/query' similarQuery: type: string description: Overrides the query parameter and performs a more generic search that can be used to find "similar" results. diff --git a/specs/search/common/schemas/SearchResponse.yml b/specs/search/common/schemas/SearchResponse.yml index 141c550947..b7def391d4 100644 --- a/specs/search/common/schemas/SearchResponse.yml +++ b/specs/search/common/schemas/SearchResponse.yml @@ -82,7 +82,7 @@ baseSearchResponse: type: integer description: The sum of all values in the result set. hitsPerPage: - $ref: 'IndexSettings.yml#/indexSettingsAsSearchParams/properties/hitsPerPage' + $ref: '../../../common/parameters.yml#/hitsPerPage' index: type: string example: indexName diff --git a/specs/search/paths/multiclusters/searchUserIds.yml b/specs/search/paths/multiclusters/searchUserIds.yml index ba8d8aab88..e0e40d8746 100644 --- a/specs/search/paths/multiclusters/searchUserIds.yml +++ b/specs/search/paths/multiclusters/searchUserIds.yml @@ -81,7 +81,7 @@ post: page: $ref: '../../common/schemas/SearchResponse.yml#/baseSearchResponse/properties/page' hitsPerPage: - $ref: '../../common/schemas/SearchResponse.yml#/baseSearchResponse/properties/hitsPerPage' + $ref: '../../../common/parameters.yml#/hitsPerPage' updatedAt: $ref: '../../../common/parameters.yml#/updatedAt' required: diff --git a/specs/search/paths/rules/rule.yml b/specs/search/paths/rules/rule.yml index 33d496255b..6060e1a22c 100644 --- a/specs/search/paths/rules/rule.yml +++ b/specs/search/paths/rules/rule.yml @@ -60,7 +60,7 @@ delete: - search operationId: deleteRule summary: Delete a rule. - description: Delete the Rule with the specified objectID.. + description: Delete the Rule with the specified objectID. parameters: - $ref: '../../../common/parameters.yml#/IndexName' - $ref: '../../../common/parameters.yml#/ObjectID' diff --git a/specs/search/paths/rules/searchRules.yml b/specs/search/paths/rules/searchRules.yml index 4168c01af4..25654a99fe 100644 --- a/specs/search/paths/rules/searchRules.yml +++ b/specs/search/paths/rules/searchRules.yml @@ -17,18 +17,14 @@ post: additionalProperties: false properties: query: - type: string - default: '' - description: Full text query. + $ref: '../../../common/parameters.yml#/query' anchoring: $ref: './common/schemas.yml#/anchoring' context: type: string description: Restricts matches to contextual rules with a specific context (exact match). page: - type: integer - default: 0 - description: Requested page (zero-based). + $ref: '../../../common/parameters.yml#/page' hitsPerPage: $ref: '../../../common/parameters.yml#/hitsPerPage' enabled: diff --git a/tests/CTS/clients/search/searchRules.json b/tests/CTS/clients/search/searchRules.json index cb6e0c44b2..8417218673 100644 --- a/tests/CTS/clients/search/searchRules.json +++ b/tests/CTS/clients/search/searchRules.json @@ -12,4 +12,3 @@ } } ] - \ No newline at end of file From 1368f9f5e406b37251831b834c4c8558c46091d4 Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Fri, 17 Dec 2021 15:23:40 +0100 Subject: [PATCH 6/7] fix: broken CI --- .../client-search/model/baseSearchParams.ts | 2 +- .../client-search/model/baseSearchResponse.ts | 4 ++-- .../client-search/model/indexSettingsAsSearchParams.ts | 2 +- .../client-search/model/multipleQueries.ts | 2 +- .../client-search/model/searchUserIdsObject.ts | 2 +- specs/search/common/schemas/IndexSettings.yml | 4 +++- specs/search/common/schemas/SearchParams.yml | 4 +++- specs/search/common/schemas/SearchResponse.yml | 2 +- 8 files changed, 13 insertions(+), 9 deletions(-) diff --git a/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts b/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts index 8cbd91ae7f..f23907fbe3 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts @@ -1,6 +1,6 @@ export type BaseSearchParams = { /** - * Full text query. + * The text to search in the index. */ query: string; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts b/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts index 07e0aa2364..e66b56a7e3 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/baseSearchResponse.ts @@ -38,7 +38,7 @@ export type BaseSearchResponse = { */ facets_stats?: { [key: string]: BaseSearchResponseFacetsStats }; /** - * Maximum number of hits in a page. Minimum is 1, maximum is 1000. + * Set the number of hits per page. */ hitsPerPage: number; /** @@ -82,7 +82,7 @@ export type BaseSearchResponse = { */ processingTimeMS: number; /** - * Full text query. + * The text to search in the index. */ query: string; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts b/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts index 1bc043d6ab..937cd43c07 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/indexSettingsAsSearchParams.ts @@ -56,7 +56,7 @@ export type IndexSettingsAsSearchParams = { */ restrictHighlightAndSnippetArrays?: boolean; /** - * Maximum number of hits in a page. Minimum is 1, maximum is 1000. + * Set the number of hits per page. */ hitsPerPage?: number; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts b/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts index 2d400faaa5..4e1db9f448 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/multipleQueries.ts @@ -4,7 +4,7 @@ export type MultipleQueries = { */ indexName: string; /** - * Full text query. + * The text to search in the index. */ query?: string; /** diff --git a/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts b/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts index 2f41111edd..c0f5a2c483 100644 --- a/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts +++ b/clients/algoliasearch-client-javascript/client-search/model/searchUserIdsObject.ts @@ -15,7 +15,7 @@ export type SearchUserIdsObject = { */ page?: number; /** - * Maximum number of hits in a page. Minimum is 1, maximum is 1000. + * Set the number of hits per page. */ hitsPerPage?: number; }; diff --git a/specs/search/common/schemas/IndexSettings.yml b/specs/search/common/schemas/IndexSettings.yml index 9987f521bd..49dcf0bde5 100644 --- a/specs/search/common/schemas/IndexSettings.yml +++ b/specs/search/common/schemas/IndexSettings.yml @@ -158,7 +158,9 @@ indexSettingsAsSearchParams: description: Restrict highlighting and snippeting to items that matched the query. default: false hitsPerPage: - $ref: '../../../common/parameters.yml#/hitsPerPage' + type: integer + description: Set the number of hits per page. + default: 20 minWordSizefor1Typo: type: integer description: Minimum number of characters a word in the query string must contain to accept matches with 1 typo. diff --git a/specs/search/common/schemas/SearchParams.yml b/specs/search/common/schemas/SearchParams.yml index 5ca2523a43..4a0af449cf 100644 --- a/specs/search/common/schemas/SearchParams.yml +++ b/specs/search/common/schemas/SearchParams.yml @@ -10,7 +10,9 @@ baseSearchParams: - query properties: query: - $ref: '../../../common/parameters.yml#/query' + type: string + description: The text to search in the index. + default: '' similarQuery: type: string description: Overrides the query parameter and performs a more generic search that can be used to find "similar" results. diff --git a/specs/search/common/schemas/SearchResponse.yml b/specs/search/common/schemas/SearchResponse.yml index b7def391d4..141c550947 100644 --- a/specs/search/common/schemas/SearchResponse.yml +++ b/specs/search/common/schemas/SearchResponse.yml @@ -82,7 +82,7 @@ baseSearchResponse: type: integer description: The sum of all values in the result set. hitsPerPage: - $ref: '../../../common/parameters.yml#/hitsPerPage' + $ref: 'IndexSettings.yml#/indexSettingsAsSearchParams/properties/hitsPerPage' index: type: string example: indexName From b491b2c8fb10799d30c548b276a79c710d8ae69e Mon Sep 17 00:00:00 2001 From: Damien Couchez Date: Fri, 17 Dec 2021 15:33:57 +0100 Subject: [PATCH 7/7] fix: after merge --- .../client-search/src/searchApi.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts index c78176c76f..dc63e00ad4 100644 --- a/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts +++ b/clients/algoliasearch-client-javascript/client-search/src/searchApi.ts @@ -532,7 +532,6 @@ export class SearchApi { return this.sendRequest(request, requestOptions); } /** - * Delete the Rule with the specified objectID. * * @summary Delete a rule. @@ -567,7 +566,19 @@ export class SearchApi { queryParameters.forwardToReplicas = forwardToReplicas.toString(); } + const request: Request = { + method: 'DELETE', + path, + }; + + const requestOptions: RequestOptions = { + headers, + queryParameters, + }; + return this.sendRequest(request, requestOptions); + } + /** * Remove a single source from the list of allowed sources. * * @param source - The IP range of the source. @@ -586,7 +597,6 @@ export class SearchApi { ); } - const request: Request = { method: 'DELETE', path,