diff --git a/clients/algoliasearch-client-javascript/bundlesize.config.json b/clients/algoliasearch-client-javascript/bundlesize.config.json index b917f4a485..b73ae954b6 100644 --- a/clients/algoliasearch-client-javascript/bundlesize.config.json +++ b/clients/algoliasearch-client-javascript/bundlesize.config.json @@ -38,15 +38,15 @@ }, { "path": "packages/client-common/dist/client-common.esm.node.js", - "maxSize": "3.80KB" + "maxSize": "5.25KB" }, { "path": "packages/requester-browser-xhr/dist/requester-browser-xhr.esm.node.js", - "maxSize": "825B" + "maxSize": "900B" }, { "path": "packages/requester-node-http/dist/requester-node-http.esm.node.js", - "maxSize": "1.10KB" + "maxSize": "1.15KB" } ] } diff --git a/clients/algoliasearch-client-javascript/rollup.config.js b/clients/algoliasearch-client-javascript/rollup.config.js index 2b68794b3a..8b0d582e85 100644 --- a/clients/algoliasearch-client-javascript/rollup.config.js +++ b/clients/algoliasearch-client-javascript/rollup.config.js @@ -183,7 +183,7 @@ packagesConfig.forEach((packageConfig) => { packageConfig.formats.forEach((format) => { // Avoid generating types multiple times. - let isTypesGenerated = false; + let areTypesGenerated = false; const output = bundlers[format]; const isUmdBuild = format === 'umd-browser'; const isEsmBrowserBuild = format === 'esm-browser'; @@ -244,12 +244,12 @@ packagesConfig.forEach((packageConfig) => { }), nodeResolve(), ts({ - check: !isTypesGenerated, + check: !areTypesGenerated, tsconfig: path.resolve(clientPath, 'tsconfig.json'), tsconfigOverride: { compilerOptions: { - declaration: !isTypesGenerated, - declarationMap: !isTypesGenerated, + declaration: !areTypesGenerated, + declarationMap: !areTypesGenerated, }, }, }), @@ -269,7 +269,7 @@ packagesConfig.forEach((packageConfig) => { }, }); - isTypesGenerated = true; + areTypesGenerated = true; }); }); diff --git a/clients/algoliasearch-client-javascript/tsconfig.json b/clients/algoliasearch-client-javascript/tsconfig.json index 08473f19f4..fb70913461 100644 --- a/clients/algoliasearch-client-javascript/tsconfig.json +++ b/clients/algoliasearch-client-javascript/tsconfig.json @@ -7,12 +7,12 @@ "lib": ["dom", "esnext", "dom.iterable", "scripthost"], "module": "esnext", "moduleResolution": "node", - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, "noLib": false, "noUnusedLocals": true, "outDir": "dist", - "removeComments": true, + "removeComments": false, "sourceMap": true, "strict": true, "suppressImplicitAnyIndexErrors": true, diff --git a/templates/javascript/api-all.mustache b/templates/javascript/api-all.mustache index c0c1ad47b8..b89289ccec 100644 --- a/templates/javascript/api-all.mustache +++ b/templates/javascript/api-all.mustache @@ -12,7 +12,6 @@ import type { Region } from '../src/{{apiName}}Api'; export * from '../src/{{apiName}}Api'; -// eslint-disable-next-line @typescript-eslint/explicit-function-return-type export function {{apiName}}Api( appId: string, apiKey: string,{{#hasRegionalHost}}region{{#fallbackToAliasHost}}?{{/fallbackToAliasHost}}: Region,{{/hasRegionalHost}} diff --git a/templates/javascript/api-single.mustache b/templates/javascript/api-single.mustache index f987d4bda3..140366c126 100644 --- a/templates/javascript/api-single.mustache +++ b/templates/javascript/api-single.mustache @@ -108,150 +108,151 @@ export function create{{capitalizedApiName}}Api(options: CreateClientOptions{{#h transporter.userAgent.add({ segment, version }); } - {{#operation}} - /** - {{#notes}} - * {{¬es}} - {{/notes}} - {{#summary}} - * @summary {{&summary}} - {{/summary}} - {{#allParams.0}} - {{^bodyParams.0}} - * @param {{nickname}} - The {{nickname}} object. - {{#allParams}} - * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} - {{/allParams}} - {{/bodyParams.0}} - {{#bodyParams.0}} - {{^queryParams.0}} - {{^pathParams.0}} - {{#bodyParams.0.isArray}} - {{^bodyParams.1}} - * @param {{nickname}} - The {{nickname}} object. - {{#allParams}} - * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} - {{/allParams}} - {{/bodyParams.1}} - {{/bodyParams.0.isArray}} - {{^bodyParams.0.isArray}} - * @param {{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} - {{/bodyParams.0.isArray}} - {{/pathParams.0}} - {{#pathParams.0}} - * @param {{nickname}} - The {{nickname}} object. - {{#allParams}} - * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} - {{/allParams}} - {{/pathParams.0}} - {{/queryParams.0}} - {{#queryParams.0}} - * @param {{nickname}} - The {{nickname}} object. - {{#allParams}} - * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} - {{/allParams}} - {{/queryParams.0}} - {{/bodyParams.0}} - {{/allParams.0}} - */ - function {{nickname}}( + return { + addUserAgent, + {{#operation}} + /** + {{#notes}} + * {{¬es}} + {{/notes}} + {{#summary}} + * @summary {{&summary}} + {{/summary}} {{#allParams.0}} {{^bodyParams.0}} - { + * @param {{nickname}} - The {{nickname}} object. {{#allParams}} - {{paramName}}, + * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} {{/allParams}} - }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, {{/bodyParams.0}} {{#bodyParams.0}} {{^queryParams.0}} {{^pathParams.0}} {{#bodyParams.0.isArray}} {{^bodyParams.1}} - { - {{#allParams}} - {{paramName}}, - {{/allParams}} - }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, + * @param {{nickname}} - The {{nickname}} object. + {{#allParams}} + * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} + {{/allParams}} {{/bodyParams.1}} {{/bodyParams.0.isArray}} {{^bodyParams.0.isArray}} - {{#bodyParams}} - {{paramName}}: {{{dataType}}}, - {{/bodyParams}} + * @param {{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} {{/bodyParams.0.isArray}} {{/pathParams.0}} {{#pathParams.0}} - { + * @param {{nickname}} - The {{nickname}} object. {{#allParams}} - {{paramName}}, + * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} {{/allParams}} - }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, {{/pathParams.0}} {{/queryParams.0}} {{#queryParams.0}} - { + * @param {{nickname}} - The {{nickname}} object. {{#allParams}} - {{paramName}}, + * @param {{nickname}}.{{paramName}} {{^description}}The {{paramName}} object.{{/description}}{{#description}}{{{description}}}{{/description}} {{/allParams}} - }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, {{/queryParams.0}} {{/bodyParams.0}} {{/allParams.0}} - requestOptions?: RequestOptions - ) : Promise<{{{returnType}}}> { - const requestPath = '{{{path}}}'{{#pathParams}}.replace( - {{=<% %>=}} - '{<%baseName%>}', - <%={{ }}=%> - encodeURIComponent(String({{paramName}})) - ){{/pathParams}}; - const headers: Headers = {}; - const queryParameters: QueryParameters = {}; - - {{#allParams}} - {{#required}} - if ({{#isBoolean}}{{paramName}} === null || {{paramName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}{{/isBoolean}}) { - throw new Error('Parameter `{{paramName}}` is required when calling `{{nickname}}`.'); - } + */ + {{nickname}}( + {{#allParams.0}} + {{^bodyParams.0}} + { + {{#allParams}} + {{paramName}}, + {{/allParams}} + }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, + {{/bodyParams.0}} + {{#bodyParams.0}} + {{^queryParams.0}} + {{^pathParams.0}} + {{#bodyParams.0.isArray}} + {{^bodyParams.1}} + { + {{#allParams}} + {{paramName}}, + {{/allParams}} + }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, + {{/bodyParams.1}} + {{/bodyParams.0.isArray}} + {{^bodyParams.0.isArray}} + {{#bodyParams}} + {{paramName}}: {{{dataType}}}, + {{/bodyParams}} + {{/bodyParams.0.isArray}} + {{/pathParams.0}} + {{#pathParams.0}} + { + {{#allParams}} + {{paramName}}, + {{/allParams}} + }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, + {{/pathParams.0}} + {{/queryParams.0}} + {{#queryParams.0}} + { + {{#allParams}} + {{paramName}}, + {{/allParams}} + }: {{#lambda.titlecase}}{{nickname}}{{/lambda.titlecase}}Props, + {{/queryParams.0}} + {{/bodyParams.0}} + {{/allParams.0}} + requestOptions?: RequestOptions + ) : Promise<{{{returnType}}}> { + const requestPath = '{{{path}}}'{{#pathParams}}.replace( + {{=<% %>=}} + '{<%baseName%>}', + <%={{ }}=%> + encodeURIComponent(String({{paramName}})) + ){{/pathParams}}; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; - {{#vars}} - {{#required}} - if ({{#isBoolean}}{{paramName}}.{{baseName}} === null || {{paramName}}.{{baseName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}.{{baseName}}{{/isBoolean}}) { - throw new Error('Parameter `{{paramName}}.{{baseName}}` is required when calling `{{nickname}}`.'); - } - {{/required}} - {{/vars}} + {{#allParams}} + {{#required}} + if ({{#isBoolean}}{{paramName}} === null || {{paramName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}{{/isBoolean}}) { + throw new Error('Parameter `{{paramName}}` is required when calling `{{nickname}}`.'); + } - {{/required}} - {{/allParams}} - {{#queryParams}} - if ({{paramName}} !== undefined) { - queryParameters['{{baseName}}'] = {{paramName}}.toString(); - } + {{#vars}} + {{#required}} + if ({{#isBoolean}}{{paramName}}.{{baseName}} === null || {{paramName}}.{{baseName}} === undefined{{/isBoolean}}{{^isBoolean}}!{{paramName}}.{{baseName}}{{/isBoolean}}) { + throw new Error('Parameter `{{paramName}}.{{baseName}}` is required when calling `{{nickname}}`.'); + } + {{/required}} + {{/vars}} - {{/queryParams}} - {{#headerParams}} - headers['{{baseName}}'] = {{paramName}}; - {{/headerParams}} + {{/required}} + {{/allParams}} + {{#queryParams}} + if ({{paramName}} !== undefined) { + queryParameters['{{baseName}}'] = {{paramName}}.toString(); + } - const request: Request = { - method: '{{httpMethod}}', - path: requestPath, - {{#bodyParam}} - data: {{paramName}}, - {{/bodyParam}} - }; + {{/queryParams}} + {{#headerParams}} + headers['{{baseName}}'] = {{paramName}}; + {{/headerParams}} - return transporter.request(request, { - queryParameters, - headers, - }, requestOptions); - } + const request: Request = { + method: '{{httpMethod}}', + path: requestPath, + {{#bodyParam}} + data: {{paramName}}, + {{/bodyParam}} + }; - {{/operation}} + return transporter.request(request, { + queryParameters, + headers, + }, requestOptions); + }, - return { addUserAgent, {{#operation}}{{nickname}},{{/operation}} }; + {{/operation}} + }; } export type {{capitalizedApiName}}Api = ReturnType; diff --git a/templates/javascript/model.mustache b/templates/javascript/model.mustache index 6abed90791..84a53980f1 100644 --- a/templates/javascript/model.mustache +++ b/templates/javascript/model.mustache @@ -16,9 +16,6 @@ export type {{classname}} = {{#oneOf}}{{.}} {{^-last}}|{{/-last}} {{/oneOf}}{{#a */ {{/description}} {{^isEnum}} -{{#parent}} -{{! TODO: Add back 'extends parent' when we understand where parent come from, but for now it's breaking the code}} -{{/parent}} export type {{classname}} = { {{#vars}} {{#description}}