From 5223b7114053e23654efaa5039b7a0a12b586892 Mon Sep 17 00:00:00 2001 From: Kevin He Date: Mon, 3 Nov 2025 13:40:49 -0800 Subject: [PATCH 1/4] log bundle size --- .github/workflows/test.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 49efa438..1c323903 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,4 +30,19 @@ jobs: if: ${{ steps.cache-nodemodules.outputs.cache-hit != 'true' }} - run: yarn run renderTemplates - run: yarn build:lib + - name: Log bundle sizes + run: | + echo "::group::Bundle sizes for lib/ directory" + echo "Individual file sizes:" + ls -lh lib/*.js | awk '{printf " %-50s %10s\n", $9, $5}' + echo "" + echo "Summary by file type:" + echo " ESM files:" + du -ch lib/*.js | grep -v '\.cjs\.js' | tail -1 | awk '{printf " Total: %s\n", $1}' + echo " CJS files:" + du -ch lib/*.cjs.js 2>/dev/null | tail -1 | awk '{printf " Total: %s\n", $1}' || echo " Total: 0" + echo "" + echo "Total lib/ directory size:" + du -sh lib | awk '{printf " %s\n", $1}' + echo "::endgroup::" - run: yarn test From 60ad7ead6f35bace3ee8be5746383adf59c40cd8 Mon Sep 17 00:00:00 2001 From: Kevin He Date: Mon, 3 Nov 2025 13:57:37 -0800 Subject: [PATCH 2/4] remove parameter looping logic --- templatesOas/apis.endpoint.mustache | 41 +++------------------- templatesOas/apis.mustache | 53 ----------------------------- 2 files changed, 4 insertions(+), 90 deletions(-) diff --git a/templatesOas/apis.endpoint.mustache b/templatesOas/apis.endpoint.mustache index 303adc44..821723e2 100644 --- a/templatesOas/apis.endpoint.mustache +++ b/templatesOas/apis.endpoint.mustache @@ -185,45 +185,12 @@ const pathParams: {{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}PathParameters & Required = { shortCode: configParams.shortCode, + ...optionParams }; - {{#pathParams}} - if (optionParams["{{paramName}}"] !== undefined) { - pathParams["{{paramName}}"] = optionParams["{{paramName}}"]; - } else if (configParams["{{paramName}}"] !== undefined) { - pathParams["{{paramName}}"] = configParams["{{paramName}}"]; - } - {{#required}} - else { - throw new Error('Missing required path parameter: {{paramName}}'); - } - {{/required}} - {{/pathParams}} - - const queryParams: Partial<{{nickname}}QueryParameters> & QueryParameters = {}; - - {{#queryParams}} - if (optionParams["{{paramName}}"] !== undefined) { - queryParams["{{paramName}}"] = optionParams["{{paramName}}"]; - } else if (configParams["{{paramName}}"] !== undefined) { - queryParams["{{paramName}}"] = configParams["{{paramName}}"]; - } - {{#required}} - else { - throw new Error('Missing required query parameter: {{paramName}}'); - } - {{/required}} - {{/queryParams}} - - Object.keys(optionParams).forEach((key) => { - const paramValue = optionParams[key as keyof typeof optionParams]; - if(paramValue !== undefined && (key.startsWith('c_') || !((key in queryParams) || (key in pathParams)))) { - if(!key.startsWith('c_')) { - console.warn(`Found unknown parameter for {{{nickname}}}: ${key}, adding as query parameter anyway`); - } - queryParams[key as keyof typeof queryParams] = paramValue; - } - }) + const queryParams: Partial<{{nickname}}QueryParameters> & QueryParameters = { + ...optionParams + }; const url = new TemplateURL( "{{{path}}}", diff --git a/templatesOas/apis.mustache b/templatesOas/apis.mustache index 3e4baa93..05a2c771 100644 --- a/templatesOas/apis.mustache +++ b/templatesOas/apis.mustache @@ -145,59 +145,6 @@ export class {{#vendorExtensions}}{{#x-sdk-classname}}{{{ . }}}{{/x-sdk-classnam this.clientConfig = new ClientConfig(cfg) as ClientConfig & { baseUri: string }; } - static readonly paramKeys = { - {{#operations}} - {{#operation}} - {{#vendorExtensions}} - {{^x-scapi-internal}} - {{nickname}}: [ - {{#allParams}} - {{^isBodyParam}} - {{^isHeaderParam}} - '{{paramName}}', - {{/isHeaderParam}} - {{/isBodyParam}} - {{/allParams}} - ], - {{nickname}}Required: [ - {{#allParams}} - {{^isBodyParam}} - {{^isHeaderParam}} - {{#required}} - '{{paramName}}', - {{/required}} - {{/isHeaderParam}} - {{/isBodyParam}} - {{/allParams}} - ], - {{/x-scapi-internal}} - {{/vendorExtensions}} - {{^vendorExtensions}} - {{nickname}}: [ - {{#allParams}} - {{^isBodyParam}} - {{^isHeaderParam}} - '{{paramName}}', - {{/isHeaderParam}} - {{/isBodyParam}} - {{/allParams}} - ], - {{nickname}}Required: [ - {{#allParams}} - {{^isBodyParam}} - {{^isHeaderParam}} - {{#required}} - '{{paramName}}', - {{/required}} - {{/isHeaderParam}} - {{/isBodyParam}} - {{/allParams}} - ], - {{/vendorExtensions}} - {{/operation}} - {{/operations}} - } as const; - {{#operations}} {{#operation}} {{#vendorExtensions}} From 17ae3847dab4954e61248d41c7a0954bc25063f0 Mon Sep 17 00:00:00 2001 From: Kevin He Date: Mon, 3 Nov 2025 14:04:34 -0800 Subject: [PATCH 3/4] add ts comments --- templatesOas/apis.endpoint.mustache | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templatesOas/apis.endpoint.mustache b/templatesOas/apis.endpoint.mustache index 821723e2..07a1053d 100644 --- a/templatesOas/apis.endpoint.mustache +++ b/templatesOas/apis.endpoint.mustache @@ -182,12 +182,14 @@ ): Promise { const optionParams = options?.parameters || ({} as Partial["parameters"]>>); const configParams = this.clientConfig.parameters; - + + // @ts-expect-error - Simplified parameter handling for bundle size reduction const pathParams: {{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}PathParameters & Required = { shortCode: configParams.shortCode, ...optionParams }; + // @ts-expect-error - Simplified parameter handling for bundle size reduction const queryParams: Partial<{{nickname}}QueryParameters> & QueryParameters = { ...optionParams }; From f51ab6223be80c3d28936d50b9b172b3aedf4c17 Mon Sep 17 00:00:00 2001 From: Kevin He Date: Mon, 3 Nov 2025 14:09:28 -0800 Subject: [PATCH 4/4] add comments --- templatesOas/apis.endpoint.mustache | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/templatesOas/apis.endpoint.mustache b/templatesOas/apis.endpoint.mustache index 07a1053d..8d8d3096 100644 --- a/templatesOas/apis.endpoint.mustache +++ b/templatesOas/apis.endpoint.mustache @@ -183,14 +183,17 @@ const optionParams = options?.parameters || ({} as Partial["parameters"]>>); const configParams = this.clientConfig.parameters; - // @ts-expect-error - Simplified parameter handling for bundle size reduction + // @ts-ignore - Simplified parameter handling for bundle size reduction const pathParams: {{#lambda.titlecase}}{{#lambda.camelcase}}{{appName}}{{/lambda.camelcase}}{{/lambda.titlecase}}PathParameters & Required = { + // @ts-ignore - Simplified parameter handling for bundle size reduction shortCode: configParams.shortCode, + // @ts-ignore - Simplified parameter handling for bundle size reduction ...optionParams }; - // @ts-expect-error - Simplified parameter handling for bundle size reduction + // @ts-ignore - Simplified parameter handling for bundle size reduction const queryParams: Partial<{{nickname}}QueryParameters> & QueryParameters = { + // @ts-ignore - Simplified parameter handling for bundle size reduction ...optionParams };