-
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.
- Loading branch information
Showing
65 changed files
with
2,252 additions
and
37 deletions.
There are no files selected for viewing
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
4 changes: 4 additions & 0 deletions
4
clients/algoliasearch-client-javascript/client-query-suggestions/.gitignore
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,4 @@ | ||
node_modules | ||
dist | ||
.openapi-generator | ||
.env |
4 changes: 4 additions & 0 deletions
4
clients/algoliasearch-client-javascript/client-query-suggestions/.openapi-generator-ignore
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,4 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
git_push.sh |
3 changes: 3 additions & 0 deletions
3
clients/algoliasearch-client-javascript/client-query-suggestions/api.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,3 @@ | ||
// This is the entrypoint for the package | ||
export * from './src/apis'; | ||
export * from './model/models'; |
6 changes: 6 additions & 0 deletions
6
clients/algoliasearch-client-javascript/client-query-suggestions/model/errorBase.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,6 @@ | ||
/** | ||
* Error. | ||
*/ | ||
export type ErrorBase = { | ||
message?: string; | ||
}; |
6 changes: 6 additions & 0 deletions
6
clients/algoliasearch-client-javascript/client-query-suggestions/model/indexName.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,6 @@ | ||
export type IndexName = { | ||
/** | ||
* Index name to target. | ||
*/ | ||
indexName: string; | ||
}; |
20 changes: 20 additions & 0 deletions
20
clients/algoliasearch-client-javascript/client-query-suggestions/model/logFile.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 @@ | ||
export type LogFile = { | ||
/** | ||
* Date and time of creation of the record. | ||
*/ | ||
timestamp: Date; | ||
/** | ||
* Type of the record, can be one of three values (INFO, SKIP or ERROR). | ||
*/ | ||
level: LogFileLevel; | ||
/** | ||
* Detailed description of what happened. | ||
*/ | ||
message: string; | ||
/** | ||
* Indicates the hierarchy of the records. For example, a record with contextLevel=1 belongs to a preceding record with contextLevel=0. | ||
*/ | ||
contextLevel: number; | ||
}; | ||
|
||
export type LogFileLevel = 'ERROR' | 'INFO' | 'SKIP'; |
53 changes: 53 additions & 0 deletions
53
clients/algoliasearch-client-javascript/client-query-suggestions/model/models.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,53 @@ | ||
/* eslint-disable no-param-reassign */ | ||
import type { RequestOptions } from '../utils/types'; | ||
|
||
export * from './errorBase'; | ||
export * from './indexName'; | ||
export * from './logFile'; | ||
export * from './querySuggestionsIndex'; | ||
export * from './querySuggestionsIndexParam'; | ||
export * from './querySuggestionsIndexWithIndexParam'; | ||
export * from './sourceIndex'; | ||
export * from './sourceIndexExternal'; | ||
export * from './sourceIndexWithReplicas'; | ||
export * from './status'; | ||
export * from './sucessResponse'; | ||
|
||
export interface Authentication { | ||
/** | ||
* Apply authentication settings to header and query params. | ||
*/ | ||
applyToRequest: (requestOptions: RequestOptions) => Promise<void> | void; | ||
} | ||
|
||
export class ApiKeyAuth implements Authentication { | ||
apiKey: string = ''; | ||
|
||
constructor(private location: string, private paramName: string) {} | ||
|
||
applyToRequest(requestOptions: RequestOptions): void { | ||
if (this.location === 'query') { | ||
requestOptions.queryParameters[this.paramName] = this.apiKey; | ||
} else if ( | ||
this.location === 'header' && | ||
requestOptions && | ||
requestOptions.headers | ||
) { | ||
requestOptions.headers[this.paramName] = this.apiKey; | ||
} else if ( | ||
this.location === 'cookie' && | ||
requestOptions && | ||
requestOptions.headers | ||
) { | ||
if (requestOptions.headers.Cookie) { | ||
requestOptions.headers.Cookie += `; ${ | ||
this.paramName | ||
}=${encodeURIComponent(this.apiKey)}`; | ||
} else { | ||
requestOptions.headers.Cookie = `${this.paramName}=${encodeURIComponent( | ||
this.apiKey | ||
)}`; | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...s/algoliasearch-client-javascript/client-query-suggestions/model/querySuggestionsIndex.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 { SourceIndexWithReplicas } from './sourceIndexWithReplicas'; | ||
|
||
export type QuerySuggestionsIndex = { | ||
/** | ||
* Index name to target. | ||
*/ | ||
indexName: string; | ||
/** | ||
* List of source indices used to generate a Query Suggestions index. | ||
*/ | ||
sourceIndices: SourceIndexWithReplicas[]; | ||
/** | ||
* De-duplicate singular and plural suggestions. For example, let\'s say your index contains English content, and that two suggestions “shoe” and “shoes” end up in your Query Suggestions index. If the English language is configured, only the most popular of those two suggestions would remain. | ||
*/ | ||
languages: string[]; | ||
/** | ||
* List of words and patterns to exclude from the Query Suggestions index. | ||
*/ | ||
exclude: string[]; | ||
}; |
16 changes: 16 additions & 0 deletions
16
...oliasearch-client-javascript/client-query-suggestions/model/querySuggestionsIndexParam.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,16 @@ | ||
import type { SourceIndex } from './sourceIndex'; | ||
|
||
export type QuerySuggestionsIndexParam = { | ||
/** | ||
* List of source indices used to generate a Query Suggestions index. | ||
*/ | ||
sourceIndices: SourceIndex[]; | ||
/** | ||
* De-duplicate singular and plural suggestions. For example, let\'s say your index contains English content, and that two suggestions “shoe” and “shoes” end up in your Query Suggestions index. If the English language is configured, only the most popular of those two suggestions would remain. | ||
*/ | ||
languages?: string[]; | ||
/** | ||
* List of words and patterns to exclude from the Query Suggestions index. | ||
*/ | ||
exclude?: string[]; | ||
}; |
5 changes: 5 additions & 0 deletions
5
...h-client-javascript/client-query-suggestions/model/querySuggestionsIndexWithIndexParam.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,5 @@ | ||
import type { IndexName } from './indexName'; | ||
import type { QuerySuggestionsIndexParam } from './querySuggestionsIndexParam'; | ||
|
||
export type QuerySuggestionsIndexWithIndexParam = IndexName & | ||
QuerySuggestionsIndexParam; |
32 changes: 32 additions & 0 deletions
32
clients/algoliasearch-client-javascript/client-query-suggestions/model/sourceIndex.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 { SourceIndexExternal } from './sourceIndexExternal'; | ||
|
||
export type SourceIndex = { | ||
/** | ||
* Source index name. | ||
*/ | ||
indexName: string; | ||
/** | ||
* List of analytics tags to filter the popular searches per tag. | ||
*/ | ||
analyticsTags?: string[]; | ||
/** | ||
* List of facets to define as categories for the query suggestions. | ||
*/ | ||
facets?: Array<Record<string, any>>; | ||
/** | ||
* Minimum number of hits (e.g., matching records in the source index) to generate a suggestions. | ||
*/ | ||
minHits?: number; | ||
/** | ||
* Minimum number of required letters for a suggestion to remain. | ||
*/ | ||
minLetters?: number; | ||
/** | ||
* List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC). | ||
*/ | ||
generate?: string[][]; | ||
/** | ||
* List of external indices to use to generate custom Query Suggestions. | ||
*/ | ||
external?: SourceIndexExternal[]; | ||
}; |
10 changes: 10 additions & 0 deletions
10
...nts/algoliasearch-client-javascript/client-query-suggestions/model/sourceIndexExternal.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 SourceIndexExternal = { | ||
/** | ||
* The suggestion you would like to add. | ||
*/ | ||
query: string; | ||
/** | ||
* The measure of the suggestion relative popularity. | ||
*/ | ||
count: number; | ||
}; |
36 changes: 36 additions & 0 deletions
36
...algoliasearch-client-javascript/client-query-suggestions/model/sourceIndexWithReplicas.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,36 @@ | ||
import type { SourceIndexExternal } from './sourceIndexExternal'; | ||
|
||
export type SourceIndexWithReplicas = { | ||
/** | ||
* Source index name. | ||
*/ | ||
indexName: string; | ||
/** | ||
* True if the Query Suggestions index is a replicas. | ||
*/ | ||
replicas: boolean; | ||
/** | ||
* List of analytics tags to filter the popular searches per tag. | ||
*/ | ||
analyticsTags: string[]; | ||
/** | ||
* List of facets to define as categories for the query suggestions. | ||
*/ | ||
facets: Array<Record<string, any>>; | ||
/** | ||
* Minimum number of hits (e.g., matching records in the source index) to generate a suggestions. | ||
*/ | ||
minHits: number; | ||
/** | ||
* Minimum number of required letters for a suggestion to remain. | ||
*/ | ||
minLetters: number; | ||
/** | ||
* List of facet attributes used to generate Query Suggestions. The resulting suggestions are every combination of the facets in the nested list (e.g., (facetA and facetB) and facetC). | ||
*/ | ||
generate: string[][]; | ||
/** | ||
* List of external indices to use to generate custom Query Suggestions. | ||
*/ | ||
external: SourceIndexExternal[]; | ||
}; |
14 changes: 14 additions & 0 deletions
14
clients/algoliasearch-client-javascript/client-query-suggestions/model/status.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 Status = { | ||
/** | ||
* The targeted index name. | ||
*/ | ||
indexName: string; | ||
/** | ||
* True if the Query Suggestions index is running. | ||
*/ | ||
isRunning: boolean; | ||
/** | ||
* Date and time of the last build. | ||
*/ | ||
lastBuiltAt: string; | ||
}; |
10 changes: 10 additions & 0 deletions
10
clients/algoliasearch-client-javascript/client-query-suggestions/model/sucessResponse.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 SucessResponse = { | ||
/** | ||
* The status code. | ||
*/ | ||
status: number; | ||
/** | ||
* Message of the response. | ||
*/ | ||
message: string; | ||
}; |
24 changes: 24 additions & 0 deletions
24
clients/algoliasearch-client-javascript/client-query-suggestions/package.json
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,24 @@ | ||
{ | ||
"name": "@algolia/client-query-suggestions", | ||
"version": "5.0.0", | ||
"description": "JavaScript client for @algolia/client-query-suggestions", | ||
"repository": "algolia/algoliasearch-client-javascript", | ||
"author": "Algolia", | ||
"private": true, | ||
"license": "MIT", | ||
"main": "dist/api.js", | ||
"types": "dist/api.d.ts", | ||
"scripts": { | ||
"clean": "rm -Rf node_modules/ *.js", | ||
"build": "tsc", | ||
"test": "yarn build && node dist/client.js" | ||
}, | ||
"engines": { | ||
"node": "^16.0.0", | ||
"yarn": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "16.11.11", | ||
"typescript": "4.5.4" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
clients/algoliasearch-client-javascript/client-query-suggestions/src/apis.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,7 @@ | ||
import { QuerySuggestionsApi } from './querySuggestionsApi'; | ||
|
||
export * from './querySuggestionsApi'; | ||
export * from '../utils/errors'; | ||
export { EchoRequester } from '../utils/requester/EchoRequester'; | ||
|
||
export const APIS = [QuerySuggestionsApi]; |
Oops, something went wrong.