-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Rules endpoints for search client (#48)
- Loading branch information
Showing
34 changed files
with
1,207 additions
and
11 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
clients/algoliasearch-client-javascript/client-search/model/anchoring.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* 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', | ||
EndsWith = 'endsWith', | ||
Contains = 'contains', | ||
} |
17 changes: 17 additions & 0 deletions
17
clients/algoliasearch-client-javascript/client-search/model/automaticFacetFilter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
17 changes: 17 additions & 0 deletions
17
clients/algoliasearch-client-javascript/client-search/model/condition.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
26 changes: 26 additions & 0 deletions
26
clients/algoliasearch-client-javascript/client-search/model/consequence.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string, any> }; | ||
}; |
9 changes: 9 additions & 0 deletions
9
clients/algoliasearch-client-javascript/client-search/model/consequenceHide.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Unique identifier of the object to hide. | ||
*/ | ||
export type ConsequenceHide = { | ||
/** | ||
* Unique identifier of the object. | ||
*/ | ||
objectID: string; | ||
}; |
10 changes: 10 additions & 0 deletions
10
clients/algoliasearch-client-javascript/client-search/model/deletedRule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
clients/algoliasearch-client-javascript/client-search/model/params.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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[]; | ||
}; |
17 changes: 17 additions & 0 deletions
17
clients/algoliasearch-client-javascript/client-search/model/promote.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
30 changes: 30 additions & 0 deletions
30
clients/algoliasearch-client-javascript/client-search/model/rule.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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[]; | ||
}; |
32 changes: 32 additions & 0 deletions
32
clients/algoliasearch-client-javascript/client-search/model/searchRulesParams.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string, any> }>; | ||
}; |
20 changes: 20 additions & 0 deletions
20
clients/algoliasearch-client-javascript/client-search/model/searchRulesResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
clients/algoliasearch-client-javascript/client-search/model/timeRange.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
14 changes: 14 additions & 0 deletions
14
clients/algoliasearch-client-javascript/client-search/model/updatedRuleResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
10 changes: 10 additions & 0 deletions
10
...algoliasearch-client-javascript/client-search/model/updatedRuleResponseWithoutObjectID.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
Oops, something went wrong.