Skip to content

fix(javascript): helpers type options #895

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 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion playground/javascript/node/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ client.addAlgoliaAgent('Node playground', '0.0.1');

async function testSearch() {
try {
const res = await client.search<{ name: string }>({ requests: [{ indexName: searchIndex, query: searchQuery }] });
const res = await client.search<{ name: string }>({
requests: [{ indexName: searchIndex, query: searchQuery }],
});

console.log(`[OK]`, res.results[0].hits![0].name);
} catch (e: any) {
Expand Down
6 changes: 3 additions & 3 deletions templates/javascript/clients/client/api/helpers.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ waitForApiKey(
* @param browseObjects - The browseObjects object.
* @param browseObjects.indexName - The index in which to perform the request.
* @param browseObjects.browseRequest - The `browse` method parameters.
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is no `cursor` in the response.
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
*/
Expand Down Expand Up @@ -151,7 +151,7 @@ browseObjects<T>(
* @param browseObjects - The browseObjects object.
* @param browseObjects.indexName - The index in which to perform the request.
* @param browseObjects.searchRulesParams - The `searchRules` method parameters.
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
*/
Expand Down Expand Up @@ -194,7 +194,7 @@ browseRules(
* @summary Helper method that iterates on the `searchSynonyms` method.
* @param browseObjects - The browseObjects object.
* @param browseObjects.indexName - The index in which to perform the request.
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call. By default, stops when there is less hits returned than the number of maximum hits (1000).
* @param browseObjects.aggregator - The function that runs right after the API call has been resolved, allows you to do anything with the response before `validate`.
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ export type BrowseOptions<T> = Partial<
> &
Required<Pick<CreateIterablePromise<T>, 'aggregator'>>;

type WaitForOptions<T> = Omit<
CreateIterablePromise<T>,
'func' | 'timeout' | 'validate'
> & {
type WaitForOptions = Partial<{
/**
* The maximum number of retries. 50 by default.
*/
Expand All @@ -61,9 +58,9 @@ type WaitForOptions<T> = Omit<
* The function to decide how long to wait between retries.
*/
timeout: (retryCount: number) => number;
};
}>;

export type WaitForTaskOptions = WaitForOptions<GetTaskResponse> & {
export type WaitForTaskOptions = WaitForOptions & {
/**
* The `indexName` where the operation was performed.
*/
Expand All @@ -74,7 +71,7 @@ export type WaitForTaskOptions = WaitForOptions<GetTaskResponse> & {
taskID: number;
};

export type WaitForApiKeyOptions = WaitForOptions<GetApiKeyResponse> & {
export type WaitForApiKeyOptions = WaitForOptions & {
/**
* The API Key.
*/
Expand Down
8 changes: 4 additions & 4 deletions website/docs/clients/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ To get started, you first need to install `algoliasearch` (or any other availabl
All of our clients comes with type definition, and are available for both `browser` and `node` environments.

```bash
yarn add algoliasearch
yarn add algoliasearch@alpha
# or
npm install algoliasearch
npm install algoliasearch@alpha
```

Or use a specific package:

```bash
yarn add @algolia/client-search
yarn add @algolia/client-search@alpha
# or
npm install @algolia/client-search
npm install @algolia/client-search@alpha
```

**Without a package manager**
Expand Down
4 changes: 2 additions & 2 deletions website/docs/clients/migration-guides/javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ title: JavaScript
To get started, first install the `algoliasearch` client.

```bash
yarn add algoliasearch
yarn add algoliasearch@alpha
# or
npm install algoliasearch
npm install algoliasearch@alpha
```

You can continue this guide on [our installation page](/docs/clients/installation).
Expand Down