merge-api / merge-node-client

The Node SDK for accessing various Merge Unified APIs
Other
11 stars 6 forks source link

File Storage API downloadRetrieve method returns ReadableStream #46

Open pandektes-braedon opened 1 week ago

pandektes-braedon commented 1 week ago

Problem

The downloadRetrieve method is typed as returning a Readable node stream: https://github.com/merge-api/merge-node-client/blob/ffa041c31abef86cb4e059ba2616cf62c0598f88/src/api/resources/filestorage/resources/files/client/Client.ts#L330

The api does not return a node stream, it returns a ReadableStream

Steps to Reproduce

    import { PassThrough, Readable } from 'node:stream'

    const readable = await merge.filestorage.files.downloadRetrieve(fileId)

    const isReadable = readable instanceof Readable // returns false
    const isReadableStream = readable instanceof ReadableStream // returns true

Would it be possible to update the API to return a node stream instead of the web stream?

dsinghvi commented 1 week ago

@pandektes-braedon we'll take a look here, did you notice this after upgrading the SDK to latest?

pandektes-braedon commented 1 week ago

@dsinghvi I'm currently running v1.0.11. I installed the SDK last week, however, it looks like the api is the same in latest.

Could you also confirm if the file is actually being streamed? Based on current current usage, it looks like your API is buffering the whole file in before returning it to me which defeats the purpose of the stream. I could be wrong but that's currently what it looks like while testing.