1
- import {
2
- createAuth,
3
- createTransporter,
4
- getAlgoliaAgent,
5
- shuffle,
6
- {{#isSearchClient} }
7
- createRetryablePromise,
8
- { {/isSearchClient} }
9
- } from '@experimental-api-clients-automation/client-common';
10
- import type {
11
- CreateClientOptions,
12
- Headers,
13
- Host,
14
- Request,
15
- RequestOptions,
16
- QueryParameters,
17
- {{#isSearchClient} }
18
- CreateRetryablePromiseOptions,
19
- { {/isSearchClient} }
20
- } from '@experimental-api-clients-automation/client-common';
21
-
22
- { {#imports} }
23
- import { {{classname} } } from '{ {filename} }';
24
- { {/imports} }
25
-
26
- { {#operations} }
27
- import type {
28
- {{#operation} }
29
- { {#vendorExtensions.x-create-wrapping-object} }
30
- { {#lambda.titlecase} }{ {nickname} }{ {/lambda.titlecase} }Props,
31
- { {/vendorExtensions.x-create-wrapping-object} }
32
- { {/operation} }
33
- } from '../model/clientMethodProps';
34
- { {/operations} }
1
+ { {> api/imports} }
35
2
36
3
export const apiClientVersion = '{ {packageVersion} }';
37
4
38
5
{ {#operations} }
39
- { {#hasRegionalHost} }
40
- export const REGIONS = [{ {#allowedRegions} }'{ {.} }'{ {^-last} },{ {/-last} }{ {/allowedRegions} }] as const;
41
- export type Region = typeof REGIONS[number];
42
- { {/hasRegionalHost} }
43
-
44
- { {^hasRegionalHost} }
45
- function getDefaultHosts(appId: string): Host[] {
46
- return (
47
- [
48
- {
49
- url: `${appId} -dsn.algolia.net`,
50
- accept: 'read',
51
- protocol: 'https',
52
- },
53
- {
54
- url: `${appId} .algolia.net`,
55
- accept: 'write',
56
- protocol: 'https',
57
- },
58
- ] as Host[]
59
- ).concat(
60
- shuffle([
61
- {
62
- url: `${appId} -1.algolianet.com`,
63
- accept: 'readWrite',
64
- protocol: 'https',
65
- },
66
- {
67
- url: `${appId} -2.algolianet.com`,
68
- accept: 'readWrite',
69
- protocol: 'https',
70
- },
71
- {
72
- url: `${appId} -3.algolianet.com`,
73
- accept: 'readWrite',
74
- protocol: 'https',
75
- },
76
- ])
77
- );
78
- }
79
- { {/hasRegionalHost} }
80
-
81
- { {#hasRegionalHost} }
82
- function getDefaultHosts(region{ {#fallbackToAliasHost} }?{ {/fallbackToAliasHost} }: Region): Host[] {
83
- const url = {{#fallbackToAliasHost} }!region ? '{ {{hostWithFallback} }}' : { {/fallbackToAliasHost} } '{ {{host} }}'.replace('{ region} ', region);
84
-
85
- return [{ url, accept: ' readWrite' , protocol: ' https' } ];
86
- }
87
- { {/hasRegionalHost} }
6
+ { {> api/hosts} }
88
7
89
8
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
90
9
export function create{ {capitalizedApiName} }({
@@ -147,45 +66,8 @@ export function create{{capitalizedApiName}}({
147
66
},
148
67
{ {/isSearchClient} }
149
68
{ {#operation} }
150
- /**
151
- { {#notes} }
152
- * { {¬es} }
153
- { {/notes} }
154
- { {#summary} }
155
- * @summary { {&summary} }
156
- { {/summary} }
157
- { {#vendorExtensions} }
158
- { {#x-create-wrapping-object} }
159
- * @param { {nickname} } - The { {nickname} } object.
160
- { {#allParams} }
161
- * @param { {nickname} }.{ {paramName} } - { {^description} }The { {paramName} } object.{ {/description} }{ {#description} }{ {{description} }}{ {/description} }
162
- { {/allParams} }
163
- { {/x-create-wrapping-object} }
164
- { {#x-is-single-body-param} }
165
- { {#bodyParams} }
166
- * @param { {paramName} } - { {^description} }The { {paramName} } object.{ {/description} }{ {#description} }{ {{description} }}{ {/description} }
167
- { {/bodyParams} }
168
- { {/x-is-single-body-param} }
169
- { {/vendorExtensions} }
170
- * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
171
- */
172
- { {nickname} }(
173
- { {#vendorExtensions} }
174
- { {#x-create-wrapping-object} }
175
- {
176
- {{#allParams} }
177
- { {paramName} },
178
- { {/allParams} }
179
- }: { {#lambda.titlecase} }{ {nickname} }{ {/lambda.titlecase} }Props,
180
- { {/x-create-wrapping-object} }
181
- { {#x-is-single-body-param} }
182
- { {#bodyParams} }
183
- { {paramName} }: { {{dataType} }},
184
- { {/bodyParams} }
185
- { {/x-is-single-body-param} }
186
- { {/vendorExtensions} }
187
- requestOptions?: RequestOptions
188
- ) : Promise<{ {{returnType} }}> {
69
+ { {> api/operation/jsdoc} }
70
+ { {nickname} }( { {> api/operation/parameters} } ) : Promise<{ {{returnType} }}> {
189
71
{{#allParams} }
190
72
{ {#required} }
191
73
if ({ {#isBoolean} }{ {paramName} } === null || { {paramName} } === undefined{ {/isBoolean} }{ {^isBoolean} }!{ {paramName} }{ {/isBoolean} }) {
@@ -203,9 +85,16 @@ export function create{{capitalizedApiName}}({
203
85
{ {/required} }
204
86
{ {/allParams} }
205
87
206
- const requestPath = '{ {{path} }}'{ {#vendorExtensions} }{ {#pathParams} }.replace(
207
- { {=<% %>= } }'{ <% baseName%> } '<%={ { } }=%>,{ {#x-is-custom-request} }{ {paramName} }{ {/x-is-custom-request} }{ {^x-is-custom-request} }encodeURIComponent({ {paramName} }){ {/x-is-custom-request} }
208
- ){ {/pathParams} }{ {/vendorExtensions} };
88
+ { {#vendorExtensions} }
89
+ const requestPath = '{ {{path} }}'{ {#pathParams} }.replace({ {=<% %>= } }'{ <% baseName%> } '<%={ { } }=%>,
90
+ { {#x-is-custom-request} }
91
+ { {paramName} }
92
+ { {/x-is-custom-request} }
93
+ { {^x-is-custom-request} }
94
+ encodeURIComponent({ {paramName} })
95
+ { {/x-is-custom-request} }
96
+ ){ {/pathParams} };
97
+ { {/vendorExtensions} }
209
98
const headers: Headers = { } ;
210
99
const queryParameters: QueryParameters = { {#vendorExtensions.x-is-custom-request} }parameters || { {/vendorExtensions.x-is-custom-request} }{ } ;
211
100
@@ -230,12 +119,14 @@ export function create{{capitalizedApiName}}({
230
119
{{#bodyParam} }
231
120
data: { {paramName} },
232
121
{ {/bodyParam} }
233
- { {#vendorExtensions.x-use-read-transporter} }
234
- useReadTransporter: true,
235
- { {/vendorExtensions.x-use-read-transporter} }
236
- { {#vendorExtensions.x-cacheable} }
237
- cacheable: true,
238
- { {/vendorExtensions.x-cacheable} }
122
+ { {#vendorExtensions} }
123
+ { {#x-use-read-transporter} }
124
+ useReadTransporter: true,
125
+ { {/x-use-read-transporter} }
126
+ { {#x-cacheable} }
127
+ cacheable: true,
128
+ { {/x-cacheable} }
129
+ { {/vendorExtensions} }
239
130
};
240
131
241
132
return transporter.request(request, requestOptions);
0 commit comments