From 31e9dc6bc525eac3d84a174f636dab4b299344b5 Mon Sep 17 00:00:00 2001 From: Deep Singhvi Date: Tue, 1 Oct 2024 15:25:49 -0400 Subject: [PATCH] fix(typescript): file arrays call appendFile (#4787) --- generators/typescript/sdk/CHANGELOG.md | 5 +++++ generators/typescript/sdk/VERSION | 2 +- .../src/endpoints/utils/appendPropertyToFormData.ts | 2 +- pnpm-lock.yaml | 4 ++++ .../src/api/resources/service/client/Client.ts | 4 ++-- .../src/api/resources/service/client/Client.ts | 4 ++-- 6 files changed, 15 insertions(+), 6 deletions(-) diff --git a/generators/typescript/sdk/CHANGELOG.md b/generators/typescript/sdk/CHANGELOG.md index 0ffec774d58..497c462e5b5 100644 --- a/generators/typescript/sdk/CHANGELOG.md +++ b/generators/typescript/sdk/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.40.8] - 2024-09-28 + +- Fix: File array uploads now call `request.appendFile` instead of `request.append` which + was causing form data to be in a corrupted state. + ## [0.40.7] - 2024-09-28 - Fix: The generated README will now have a section that links to the generated diff --git a/generators/typescript/sdk/VERSION b/generators/typescript/sdk/VERSION index 7754b3ee7fd..e374d018191 100644 --- a/generators/typescript/sdk/VERSION +++ b/generators/typescript/sdk/VERSION @@ -1 +1 @@ -0.40.7 +0.40.8 diff --git a/generators/typescript/sdk/client-class-generator/src/endpoints/utils/appendPropertyToFormData.ts b/generators/typescript/sdk/client-class-generator/src/endpoints/utils/appendPropertyToFormData.ts index 2a62757e1a9..38cfe41fcdf 100644 --- a/generators/typescript/sdk/client-class-generator/src/endpoints/utils/appendPropertyToFormData.ts +++ b/generators/typescript/sdk/client-class-generator/src/endpoints/utils/appendPropertyToFormData.ts @@ -60,7 +60,7 @@ export function appendPropertyToFormData({ ), ts.factory.createBlock( [ - context.coreUtilities.formDataUtils.append({ + context.coreUtilities.formDataUtils.appendFile({ referencetoFormData: referenceToFormData, key: property.key.wireValue, value: ts.factory.createIdentifier(FOR_LOOP_ITEM_VARIABLE_NAME) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e6b5240fb52..fdae32e9512 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3331,6 +3331,10 @@ importers: specifier: ^2.0.5 version: 2.0.5(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) + packages/cli/cli/dist/dev: {} + + packages/cli/cli/dist/prod: {} + packages/cli/configuration: dependencies: '@fern-api/core-utils': diff --git a/seed/ts-sdk/file-upload/no-custom-config/src/api/resources/service/client/Client.ts b/seed/ts-sdk/file-upload/no-custom-config/src/api/resources/service/client/Client.ts index c93359af6d0..7ccfbf75359 100644 --- a/seed/ts-sdk/file-upload/no-custom-config/src/api/resources/service/client/Client.ts +++ b/seed/ts-sdk/file-upload/no-custom-config/src/api/resources/service/client/Client.ts @@ -54,7 +54,7 @@ export class Service { await _request.append("integer", request.integer.toString()); await _request.appendFile("file", file); for (const _file of fileList) { - await _request.append("fileList", _file); + await _request.appendFile("fileList", _file); } if (maybeFile != null) { @@ -63,7 +63,7 @@ export class Service { if (maybeFileList != null) { for (const _file of maybeFileList) { - await _request.append("maybeFileList", _file); + await _request.appendFile("maybeFileList", _file); } } diff --git a/seed/ts-sdk/file-upload/wrap-file-properties/src/api/resources/service/client/Client.ts b/seed/ts-sdk/file-upload/wrap-file-properties/src/api/resources/service/client/Client.ts index fdcf7355512..ba5d0251d5b 100644 --- a/seed/ts-sdk/file-upload/wrap-file-properties/src/api/resources/service/client/Client.ts +++ b/seed/ts-sdk/file-upload/wrap-file-properties/src/api/resources/service/client/Client.ts @@ -45,7 +45,7 @@ export class Service { await _request.append("integer", request.integer.toString()); await _request.appendFile("file", request.file); for (const _file of request.fileList) { - await _request.append("fileList", _file); + await _request.appendFile("fileList", _file); } if (request.maybeFile != null) { @@ -54,7 +54,7 @@ export class Service { if (request.maybeFileList != null) { for (const _file of request.maybeFileList) { - await _request.append("maybeFileList", _file); + await _request.appendFile("maybeFileList", _file); } }