Skip to content

Commit 134a386

Browse files
committed
feat: wrap parameters for all methods
1 parent 84fe5bd commit 134a386

File tree

12 files changed

+898
-502
lines changed

12 files changed

+898
-502
lines changed

clients/algoliasearch-client-javascript/client-analytics/src/analyticsApi.ts

Lines changed: 312 additions & 213 deletions
Large diffs are not rendered by default.

clients/algoliasearch-client-javascript/client-personalization/src/personalizationApi.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ export class PersonalizationApi {
8585
* Returns, as part of the response, a date until which the data can safely be considered as deleted for the given user. This means that if you send events for the given user before this date, they will be ignored. Any data received after the deletedUntil date will start building a new user profile. It might take a couple hours before for the deletion request to be fully processed.
8686
*
8787
* @summary Delete the user profile and all its associated data.
88-
* @param userToken - UserToken representing the user for which to fetch the Personalization profile.
88+
* @param deleteUserProfile - The deleteUserProfile parameters.
89+
* @param deleteUserProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
8990
*/
90-
deleteUserProfile(userToken: string): Promise<DeleteUserProfileResponse> {
91+
deleteUserProfile({
92+
userToken,
93+
}: DeleteUserProfileProps): Promise<DeleteUserProfileResponse> {
9194
const path = '/1/profiles/{userToken}'.replace(
9295
'{userToken}',
9396
encodeURIComponent(String(userToken))
@@ -117,6 +120,7 @@ export class PersonalizationApi {
117120
* The strategy contains information on the events and facets that impact user profiles and personalized search results.
118121
*
119122
* @summary Get the current personalization strategy.
123+
* @param getPersonalizationStrategy - The getPersonalizationStrategy parameters.
120124
*/
121125
getPersonalizationStrategy(): Promise<PersonalizationStrategyObject> {
122126
const path = '/1/strategies/personalization';
@@ -139,9 +143,12 @@ export class PersonalizationApi {
139143
* The profile is structured by facet name used in the strategy. Each facet value is mapped to its score. Each score represents the user affinity for a specific facet value given the userToken past events and the Personalization strategy defined. Scores are bounded to 20. The last processed event timestamp is provided using the ISO 8601 format for debugging purposes.
140144
*
141145
* @summary Get the user profile built from Personalization strategy.
142-
* @param userToken - UserToken representing the user for which to fetch the Personalization profile.
146+
* @param getUserTokenProfile - The getUserTokenProfile parameters.
147+
* @param getUserTokenProfile.userToken - UserToken representing the user for which to fetch the Personalization profile.
143148
*/
144-
getUserTokenProfile(userToken: string): Promise<GetUserTokenResponse> {
149+
getUserTokenProfile({
150+
userToken,
151+
}: GetUserTokenProfileProps): Promise<GetUserTokenResponse> {
145152
const path = '/1/profiles/personalization/{userToken}'.replace(
146153
'{userToken}',
147154
encodeURIComponent(String(userToken))
@@ -171,11 +178,12 @@ export class PersonalizationApi {
171178
* A strategy defines the events and facets that impact user profiles and personalized search results.
172179
*
173180
* @summary Set a new personalization strategy.
174-
* @param personalizationStrategyObject - The personalizationStrategyObject.
181+
* @param setPersonalizationStrategy - The setPersonalizationStrategy parameters.
182+
* @param setPersonalizationStrategy.personalizationStrategyObject - The personalizationStrategyObject.
175183
*/
176-
setPersonalizationStrategy(
177-
personalizationStrategyObject: PersonalizationStrategyObject
178-
): Promise<SetPersonalizationStrategyResponse> {
184+
setPersonalizationStrategy({
185+
personalizationStrategyObject,
186+
}: SetPersonalizationStrategyProps): Promise<SetPersonalizationStrategyResponse> {
179187
const path = '/1/strategies/personalization';
180188
const headers: Headers = { Accept: 'application/json' };
181189
const queryParameters: Record<string, string> = {};
@@ -203,3 +211,15 @@ export class PersonalizationApi {
203211
return this.sendRequest(request, requestOptions);
204212
}
205213
}
214+
215+
export type DeleteUserProfileProps = {
216+
userToken: string;
217+
};
218+
219+
export type GetUserTokenProfileProps = {
220+
userToken: string;
221+
};
222+
223+
export type SetPersonalizationStrategyProps = {
224+
personalizationStrategyObject: PersonalizationStrategyObject;
225+
};

clients/algoliasearch-client-javascript/client-search/src/searchApi.ts

Lines changed: 494 additions & 226 deletions
Large diffs are not rendered by default.

clients/algoliasearch-client-javascript/recommend/model/baseSearchParams.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export type BaseSearchParams = {
6464
*/
6565
aroundLatLng?: string;
6666
/**
67-
* Search for entries around a given location automatically computed from the requesters IP address.
67+
* Search for entries around a given location automatically computed from the requester\'s IP address.
6868
*/
6969
aroundLatLngViaIP?: boolean;
7070
/**

clients/algoliasearch-client-javascript/recommend/model/baseSearchResponse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export type BaseSearchResponse = {
4646
*/
4747
index?: string;
4848
/**
49-
* Index name used for the query. In the case of an A/B test, the targeted index isnt always the index used by the query.
49+
* Index name used for the query. In the case of an A/B test, the targeted index isn\'t always the index used by the query.
5050
*/
5151
indexUsed?: string;
5252
/**

clients/algoliasearch-client-javascript/recommend/model/indexSettingsAsSearchParams.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type IndexSettingsAsSearchParams = {
88
*/
99
attributesForFaceting?: string[];
1010
/**
11-
* List of attributes that cant be retrieved at query time.
11+
* List of attributes that can\'t be retrieved at query time.
1212
*/
1313
unretrievableAttributes?: string[];
1414
/**
@@ -28,7 +28,7 @@ export type IndexSettingsAsSearchParams = {
2828
*/
2929
customRanking?: string[];
3030
/**
31-
* Controls the relevancy threshold below which less relevant results arent included in the results.
31+
* Controls the relevancy threshold below which less relevant results aren\'t included in the results.
3232
*/
3333
relevancyStrictness?: number;
3434
/**
@@ -72,7 +72,7 @@ export type IndexSettingsAsSearchParams = {
7272
*/
7373
typoTolerance?: IndexSettingsAsSearchParams.TypoToleranceEnum;
7474
/**
75-
* Whether to allow typos on numbers (numeric tokens) in the query string.
75+
* Whether to allow typos on numbers (\"numeric tokens\") in the query string.
7676
*/
7777
allowTyposOnNumericTokens?: boolean;
7878
/**
@@ -92,7 +92,7 @@ export type IndexSettingsAsSearchParams = {
9292
*/
9393
removeStopWords?: string;
9494
/**
95-
* List of characters that the engine shouldnt automatically normalize.
95+
* List of characters that the engine shouldn\'t automatically normalize.
9696
*/
9797
keepDiacriticsOnCharacters?: string;
9898
/**
@@ -116,7 +116,7 @@ export type IndexSettingsAsSearchParams = {
116116
*/
117117
queryType?: IndexSettingsAsSearchParams.QueryTypeEnum;
118118
/**
119-
* Selects a strategy to remove words from the query when it doesnt match any hits.
119+
* Selects a strategy to remove words from the query when it doesn\'t match any hits.
120120
*/
121121
removeWordsIfNoResults?: IndexSettingsAsSearchParams.RemoveWordsIfNoResultsEnum;
122122
/**
@@ -140,15 +140,15 @@ export type IndexSettingsAsSearchParams = {
140140
*/
141141
alternativesAsExact?: IndexSettingsAsSearchParams.AlternativesAsExactEnum[];
142142
/**
143-
* Allows you to specify which advanced syntax features are active when ‘advancedSyntax is enabled.
143+
* Allows you to specify which advanced syntax features are active when ‘advancedSyntax\' is enabled.
144144
*/
145145
advancedSyntaxFeatures?: IndexSettingsAsSearchParams.AdvancedSyntaxFeaturesEnum[];
146146
/**
147147
* Enables de-duplication or grouping of results.
148148
*/
149149
distinct?: number;
150150
/**
151-
* Whether to take into account an indexs synonyms for a particular search.
151+
* Whether to take into account an index\'s synonyms for a particular search.
152152
*/
153153
synonyms?: boolean;
154154
/**
@@ -164,7 +164,7 @@ export type IndexSettingsAsSearchParams = {
164164
*/
165165
responseFields?: string[];
166166
/**
167-
* Maximum number of facet hits to return during a search for facet values.
167+
* Maximum number of facet hits to return during a search for facet values. For performance reasons, the maximum allowed number of returned values is 100.
168168
*/
169169
maxFacetHits?: number;
170170
/**

clients/algoliasearch-client-javascript/recommend/model/recommendationRequest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export type RecommendationRequest = {
1919
*/
2020
threshold: number;
2121
/**
22-
* The max number of recommendations to retrieve. If its set to 0, all the recommendations of the objectID may be returned.
22+
* The max number of recommendations to retrieve. If it\'s set to 0, all the recommendations of the objectID may be returned.
2323
*/
2424
maxRecommendations?: number;
2525
/**

clients/algoliasearch-client-javascript/recommend/src/recommendApi.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,12 @@ export class RecommendApi {
9999
/**
100100
* Returns recommendations for a specific model and objectID.
101101
*
102-
* @param getRecommendations - The getRecommendations.
102+
* @param getRecommendations - The getRecommendations parameters.
103+
* @param getRecommendations.getRecommendations - The getRecommendations.
103104
*/
104-
getRecommendations(
105-
getRecommendations: GetRecommendations
106-
): Promise<GetRecommendationsResponse> {
105+
getRecommendations({
106+
getRecommendations,
107+
}: GetRecommendationsProps): Promise<GetRecommendationsResponse> {
107108
const path = '/1/indexes/*/recommendations';
108109
const headers: Headers = { Accept: 'application/json' };
109110
const queryParameters: Record<string, string> = {};
@@ -128,3 +129,7 @@ export class RecommendApi {
128129
return this.sendRequest(request, requestOptions);
129130
}
130131
}
132+
133+
export type GetRecommendationsProps = {
134+
getRecommendations: GetRecommendations;
135+
};

playground/javascript/analytics.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ const client = new AnalyticsApi(appId, apiKey, 'de');
1414

1515
async function testAnalytics() {
1616
try {
17-
const res = await client.getSearchesNoResults({ index: analyticsIndex });
17+
const res = await client.getSearchesNoResults({
18+
index: analyticsIndex,
19+
});
1820

1921
console.log(`[OK]`, res);
2022
} catch (e) {

playground/javascript/recommend.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { RecommendApi, ApiError, RecommendationRequest } from '@algolia/recommend';
1+
import {
2+
RecommendApi,
3+
ApiError,
4+
RecommendationRequest,
5+
} from '@algolia/recommend';
26
import dotenv from 'dotenv';
37

48
dotenv.config({ path: '../.env' });
@@ -15,14 +19,16 @@ const client = new RecommendApi(appId, apiKey);
1519
async function testRecommend() {
1620
try {
1721
const res = await client.getRecommendations({
18-
requests: [
19-
{
20-
indexName: searchIndex,
21-
model: RecommendationRequest.ModelEnum['BoughtTogether'],
22-
objectID: searchQuery,
23-
threshold: 0,
24-
},
25-
],
22+
getRecommendations: {
23+
requests: [
24+
{
25+
indexName: searchIndex,
26+
model: RecommendationRequest.ModelEnum['BoughtTogether'],
27+
objectID: searchQuery,
28+
threshold: 0,
29+
},
30+
],
31+
},
2632
});
2733

2834
console.log(`[OK]`, res);

playground/javascript/search.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ const client = new SearchApi(appId, apiKey);
1414

1515
async function testSearch() {
1616
try {
17-
const res = await client.search(searchIndex, { query: searchQuery });
17+
const res = await client.search({
18+
indexName: searchIndex,
19+
searchParamsAsStringSearchParams: { query: searchQuery },
20+
});
1821

1922
console.log(`[OK]`, res);
2023
} catch (e) {

templates/javascript/api-single.mustache

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ApiKeyAuth } from '../model/models';
1616
* {{&description}}
1717
*/
1818
{{/description}}
19+
1920
export enum {{classname}}Keys {
2021
{{#authMethods}}
2122
{{#isApiKey}}
@@ -132,39 +133,19 @@ export class {{classname}} {
132133
{{#summary}}
133134
* @summary {{&summary}}
134135
{{/summary}}
135-
{{! We group parameters under an object if there are more than 5}}
136-
{{^allParams.5}}
137-
{{#allParams}}
138-
* @param {{paramName}} {{^description}}The {{paramName}}{{/description}}{{#description}}{{{description}}}{{/description}}
139-
{{/allParams}}
140-
{{/allParams.5}}
141-
{{#allParams.5}}
142-
* @param {{nickname}} - The {{nickname}} parameters.
143-
{{#allParams}}
144-
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}}{{/description}}{{#description}}{{{description}}}{{/description}}
145-
{{/allParams}}
146-
{{/allParams.5}}
136+
* @param {{nickname}} - The {{nickname}} parameters.
137+
{{#allParams}}
138+
* @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}}{{/description}}{{#description}}{{{description}}}{{/description}}
139+
{{/allParams}}
147140
*/
148141
public {{nickname}} (
149-
{{! We group parameters under an object if there are more than 5}}
150-
{{^allParams.5}}
142+
{{#allParams.0}}
143+
{
151144
{{#allParams}}
152-
{{paramName}}{{^required}}?{{/required}}: {{{dataType}}},
145+
{{paramName}},
153146
{{/allParams}}
154-
{{/allParams.5}}
155-
156-
{{#allParams.5}}
157-
{
158-
{{#allParams}}
159-
{{paramName}},
160-
{{/allParams}}
161-
}:
162-
{
163-
{{#allParams}}
164-
{{paramName}}{{^required}}?{{/required}}: {{{dataType}}},
165-
{{/allParams}}
166-
}
167-
{{/allParams.5}}
147+
}: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props
148+
{{/allParams.0}}
168149
) : Promise<{{{returnType}}}> {
169150
const path = '{{{path}}}'{{#pathParams}}.replace(
170151
{{=<% %>=}}
@@ -210,4 +191,16 @@ export class {{classname}} {
210191
}
211192
{{/operation}}
212193
}
194+
195+
{{#operation}}
196+
{{#allParams.0}}
197+
export type {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props = {
198+
{{#allParams}}
199+
{{paramName}}{{^required}}?{{/required}}: {{{dataType}}};
200+
{{/allParams}}
201+
}
202+
{{/allParams.0}}
203+
204+
{{/operation}}
205+
213206
{{/operations}}

0 commit comments

Comments
 (0)