Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
millotp committed Jan 12, 2022
2 parents 6020cfa + 9592e77 commit 39f2862
Show file tree
Hide file tree
Showing 65 changed files with 2,252 additions and 37 deletions.
7 changes: 7 additions & 0 deletions .github/actions/cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ runs:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/recommend/dist
key: ${{ runner.os }}-js-client-recommend-${{ hashFiles('clients/algoliasearch-client-javascript/recommend/**') }}

- name: Restore built JavaScript query-suggestions client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
with:
path: /home/runner/work/api-clients-automation/api-clients-automation/clients/algoliasearch-client-javascript/client-query-suggestions/dist
key: ${{ runner.os }}-js-client-query-suggestions-${{ hashFiles('clients/algoliasearch-client-javascript/client-query-suggestions/**') }}

- name: Restore built JavaScript personalization client
if: ${{ inputs.job == 'cts' }}
uses: actions/cache@v2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
dist
.openapi-generator
.env
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
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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Error.
*/
export type ErrorBase = {
message?: string;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type IndexName = {
/**
* Index name to target.
*/
indexName: string;
};
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';
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
)}`;
}
}
}
}
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[];
};
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[];
};
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;
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[];
};
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;
};
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[];
};
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;
};
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;
};
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"
}
}
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];
Loading

0 comments on commit 39f2862

Please sign in to comment.