Skip to content

Commit 9753e2d

Browse files
authored
fix(javascript): helpers type options (#895)
1 parent 529f4e0 commit 9753e2d

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

playground/javascript/node/search.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ client.addAlgoliaAgent('Node playground', '0.0.1');
1717

1818
async function testSearch() {
1919
try {
20-
const res = await client.search<{ name: string }>({ requests: [{ indexName: searchIndex, query: searchQuery }] });
20+
const res = await client.search<{ name: string }>({
21+
requests: [{ indexName: searchIndex, query: searchQuery }],
22+
});
2123

2224
console.log(`[OK]`, res.results[0].hits![0].name);
2325
} catch (e: any) {

templates/javascript/clients/client/api/helpers.mustache

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ waitForApiKey(
114114
* @param browseObjects - The browseObjects object.
115115
* @param browseObjects.indexName - The index in which to perform the request.
116116
* @param browseObjects.browseRequest - The `browse` method parameters.
117-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
117+
* @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.
118118
* @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`.
119119
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `browse` method and merged with the transporter requestOptions.
120120
*/
@@ -151,7 +151,7 @@ browseObjects<T>(
151151
* @param browseObjects - The browseObjects object.
152152
* @param browseObjects.indexName - The index in which to perform the request.
153153
* @param browseObjects.searchRulesParams - The `searchRules` method parameters.
154-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
154+
* @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).
155155
* @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`.
156156
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchRules` method and merged with the transporter requestOptions.
157157
*/
@@ -194,7 +194,7 @@ browseRules(
194194
* @summary Helper method that iterates on the `searchSynonyms` method.
195195
* @param browseObjects - The browseObjects object.
196196
* @param browseObjects.indexName - The index in which to perform the request.
197-
* @param browseObjects.validate - The validator function. It receive the resolved return of the API call.
197+
* @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).
198198
* @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`.
199199
* @param requestOptions - The requestOptions to send along with the query, they will be forwarded to the `searchSynonyms` method and merged with the transporter requestOptions.
200200
*/

templates/javascript/clients/client/model/clientMethodProps.mustache

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ export type BrowseOptions<T> = Partial<
4848
> &
4949
Required<Pick<CreateIterablePromise<T>, 'aggregator'>>;
5050

51-
type WaitForOptions<T> = Omit<
52-
CreateIterablePromise<T>,
53-
'func' | 'timeout' | 'validate'
54-
> & {
51+
type WaitForOptions = Partial<{
5552
/**
5653
* The maximum number of retries. 50 by default.
5754
*/
@@ -61,9 +58,9 @@ type WaitForOptions<T> = Omit<
6158
* The function to decide how long to wait between retries.
6259
*/
6360
timeout: (retryCount: number) => number;
64-
};
61+
}>;
6562

66-
export type WaitForTaskOptions = WaitForOptions<GetTaskResponse> & {
63+
export type WaitForTaskOptions = WaitForOptions & {
6764
/**
6865
* The `indexName` where the operation was performed.
6966
*/
@@ -74,7 +71,7 @@ export type WaitForTaskOptions = WaitForOptions<GetTaskResponse> & {
7471
taskID: number;
7572
};
7673

77-
export type WaitForApiKeyOptions = WaitForOptions<GetApiKeyResponse> & {
74+
export type WaitForApiKeyOptions = WaitForOptions & {
7875
/**
7976
* The API Key.
8077
*/

website/docs/clients/installation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ To get started, you first need to install `algoliasearch` (or any other availabl
1919
All of our clients comes with type definition, and are available for both `browser` and `node` environments.
2020

2121
```bash
22-
yarn add algoliasearch
22+
yarn add algoliasearch@alpha
2323
# or
24-
npm install algoliasearch
24+
npm install algoliasearch@alpha
2525
```
2626

2727
Or use a specific package:
2828

2929
```bash
30-
yarn add @algolia/client-search
30+
yarn add @algolia/client-search@alpha
3131
# or
32-
npm install @algolia/client-search
32+
npm install @algolia/client-search@alpha
3333
```
3434

3535
**Without a package manager**

website/docs/clients/migration-guides/javascript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ title: JavaScript
1212
To get started, first install the `algoliasearch` client.
1313

1414
```bash
15-
yarn add algoliasearch
15+
yarn add algoliasearch@alpha
1616
# or
17-
npm install algoliasearch
17+
npm install algoliasearch@alpha
1818
```
1919

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

0 commit comments

Comments
 (0)