-
Notifications
You must be signed in to change notification settings - Fork 21
feat: add Rules endpoints for search client #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
364c943
feat: add first endpoints
damcou 25229f7
Merge branch 'main' into feat/APIC-193/rules-endpoints
damcou 7eed249
feat: Add rules endpoints
damcou f9f48bf
feat: add tests
damcou d9bdf06
Merge branch 'main' into feat/APIC-193/rules-endpoints
damcou 0965b4f
feat: regenerate after merge
damcou 4dae177
fix: handle feedbacks
damcou 0c796ab
Merge branch 'main' into feat/APIC-193/rules-endpoints
damcou 1368f9f
fix: broken CI
damcou 1c8fc35
Merge branch 'main' into feat/APIC-193/rules-endpoints
damcou b491b2c
fix: after merge
damcou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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; | ||
}; |
2 changes: 1 addition & 1 deletion
2
clients/algoliasearch-client-javascript/client-search/model/baseSearchParams.ts
This file contains hidden or 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
This file contains hidden or 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
17 changes: 17 additions & 0 deletions
17
clients/algoliasearch-client-javascript/client-search/model/condition.ts
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
damcou marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* 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 hidden or 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 hidden or 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
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.