Replace axios and other dependencies with native counterparts, add type support for `stream`
This PR replaces NPM dependencies such asaxios and form-data with native counterparts, making the codebase lighter and available for different non-Node environments.
We are aware of the existing pull requests for this feature (see #10, thanks @gfortaine), but this PR aims to be a more lightweight implementation (no external dependencies needed) and with a similar API to reduce migration friction.
Additionally, we have added type support for streaming, which enables TypeScript to return correct types when stream: true. This makes it easier for developers to work with streams in a type-safe manner.
https://user-images.githubusercontent.com/1443449/220939140-70058c48-ae0b-47e0-a576-7f7d99fa723a.mp4
Changelog:
- Remove
axiosandform-datadependency with a simplified call tofetch(this is a breaking change, users w/out native Fetch support must polyfill/ponyfill) - Modify existing templates from
typescript-axiostemplate found here: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/typescript-axios (maybe we should just apply patches instead?) - Add an additional TypeScript source transformer using
ts-morphto add proper type support forstream: true
https://github.com/openai/openai-node/pull/45#issuecomment-1455258096
This PR is better suited for the openai-node repository. We are also working on a v4 version that adds support for streaming and other features. Please continue the discussion there: https://github.com/openai/openai-node/discussions/182.