Skip to content

Commit 632827b

Browse files
feat(javascript): legacy getRecommendations signature (#3241)
1 parent f0ed2ea commit 632827b

File tree

8 files changed

+29
-2
lines changed

8 files changed

+29
-2
lines changed

specs/recommend/paths/getRecommendations.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ post:
66
x-cacheable: true
77
x-acl:
88
- search
9+
x-legacy-signature-recommend: true
910
summary: Retrieve recommendations
1011
description: |
1112
Retrieves recommendations from selected AI models.

templates/javascript/clients/api-single.mustache

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export function create{{#lambda.titlecase}}{{apiName}}{{/lambda.titlecase}}({
8585
{{> client/api/operation/legacySearchCompatible/implementation}}
8686
{{/vendorExtensions.x-legacy-signature}}
8787

88+
{{#vendorExtensions.x-legacy-signature-recommend}}
89+
{{> client/api/operation/legacyGetRecommendationsCompatible/implementation}}
90+
{{/vendorExtensions.x-legacy-signature-recommend}}
91+
8892
{{#allParams}}
8993
{{#required}}
9094
if ({{#isBoolean}}{{paramName}} === null || {{paramName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}{{/isBoolean}}) {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ import type {
4343
{{#x-legacy-signature}}
4444
LegacySearchMethodProps,
4545
{{/x-legacy-signature}}
46+
{{#x-legacy-signature-recommend}}
47+
LegacyGetRecommendationsParams,
48+
{{/x-legacy-signature-recommend}}
4649
{{/vendorExtensions}}
4750
{{/operation}}
4851
} from '../model/clientMethodProps';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
if (getRecommendationsParams && Array.isArray(getRecommendationsParams)) {
2+
const newSignatureRequest: GetRecommendationsParams = {
3+
requests: getRecommendationsParams,
4+
};
5+
6+
// eslint-disable-next-line no-param-reassign
7+
getRecommendationsParams = newSignatureRequest;
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import type { RecommendationsRequest } from './recommendationsRequest';
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Recommend method signature compatible with the `algoliasearch` v4 package. When using this signature, extra computation will be required to make it match the new signature.
3+
*
4+
* @deprecated This signature will be removed from the next major version, we recommend using the `GetRecommendationsParams` type for performances and future proof reasons.
5+
*/
6+
export type LegacyGetRecommendationsParams = RecommendationsRequest[];

templates/javascript/clients/client/api/operation/parameters.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{/x-create-wrapping-object}}
99
{{#x-is-single-body-param}}
1010
{{#bodyParams}}
11-
{{paramName}}: {{{dataType}}} {{#x-legacy-signature}} | LegacySearchMethodProps{{/x-legacy-signature}},
11+
{{paramName}}: {{{dataType}}} {{#x-legacy-signature}} | LegacySearchMethodProps{{/x-legacy-signature}} {{#x-legacy-signature-recommend}} | LegacyGetRecommendationsParams{{/x-legacy-signature-recommend}},
1212
{{/bodyParams}}
1313
{{/x-is-single-body-param}}
1414
{{/vendorExtensions}}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { {{classname}} } from '{{filename}}';
77
{{/imports}}
88

99
{{! Imports for the legacy search method signature }}
10-
{{#operations}}{{#operation}}{{#vendorExtensions.x-legacy-signature}}{{> client/api/operation/legacySearchCompatible/imports}}{{/vendorExtensions.x-legacy-signature}}{{/operation}}{{/operations}}
10+
{{#operations}}
11+
{{#operation}}{{#vendorExtensions.x-legacy-signature}}{{> client/api/operation/legacySearchCompatible/imports}}{{/vendorExtensions.x-legacy-signature}}{{/operation}}
12+
{{#operation}}{{#vendorExtensions.x-legacy-signature-recommend}}{{> client/api/operation/legacyGetRecommendationsCompatible/imports}}{{/vendorExtensions.x-legacy-signature-recommend}}{{/operation}}
13+
{{/operations}}
1114

1215
{{! Imports for the helpers method of the search client }}
1316
{{#isSearchClient}}
@@ -36,6 +39,7 @@ export type {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props = {
3639
{{/x-create-wrapping-object}}
3740

3841
{{#x-legacy-signature}}{{> client/api/operation/legacySearchCompatible/model}}{{/x-legacy-signature}}
42+
{{#x-legacy-signature-recommend}}{{> client/api/operation/legacyGetRecommendationsCompatible/model}}{{/x-legacy-signature-recommend}}
3943

4044
{{/vendorExtensions}}
4145

0 commit comments

Comments
 (0)