Skip to content

feat(sdk): add downloadStream and uploadStream to file api#1275

Merged
haru0017 merged 2 commits into
mainfrom
feat/file-stream-api
Jun 2, 2026
Merged

feat(sdk): add downloadStream and uploadStream to file api#1275
haru0017 merged 2 commits into
mainfrom
feat/file-stream-api

Conversation

@haru0017

@haru0017 haru0017 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add downloadStream and uploadStream methods to the file runtime wrapper and vitest mock
  • Mark openDownloadStream as deprecated

Mirrors tailor-platform/function#178.

@haru0017 haru0017 self-assigned this Jun 1, 2026
@changeset-bot

changeset-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ae02530

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@tailor-platform/sdk Minor
@tailor-platform/create-sdk Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

⚡ pkg.pr.new

@tailor-platform/sdk

pnpm add https://pkg.pr.new/@tailor-platform/sdk@ae02530
pnpm dlx https://pkg.pr.new/@tailor-platform/sdk@ae02530 --help

@tailor-platform/create-sdk

pnpm add https://pkg.pr.new/@tailor-platform/create-sdk@ae02530
pnpm dlx https://pkg.pr.new/@tailor-platform/create-sdk@ae02530 my-app

commit: ae02530

@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the SDK’s TailorDB file (BLOB) runtime wrapper and Vitest mock to support streaming uploads/downloads via uploadStream and downloadStream, and deprecates the older openDownloadStream iterator-based API. It also updates runtime/testing documentation and adds unit tests for the new wrapper methods.

Changes:

  • Add downloadStream / uploadStream to the runtime tailordb.file wrapper API and export helpers.
  • Extend the Vitest tailordb.file mock to support the new methods and update defaults.
  • Add runtime unit tests and update docs to document downloadStream and deprecate openDownloadStream.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/sdk/src/vitest/mock.ts Adds downloadStream/uploadStream mock methods and defaults for tailordb.file.
packages/sdk/src/runtime/file.ts Adds new stream types/options, adds methods to TailorDBFileAPI, and exports downloadStream/uploadStream; deprecates openDownloadStream.
packages/sdk/src/runtime/file.test.ts Adds wrapper forwarding tests for downloadStream and uploadStream.
packages/sdk/docs/testing.md Documents mocking downloadStream and clarifies openDownloadStream as deprecated.
packages/sdk/docs/runtime.md Updates exported runtime API list to include new stream methods and mark openDownloadStream deprecated.
.changeset/tangy-views-tie.md Adds a minor changeset entry for the new stream methods and deprecation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/sdk/src/vitest/mock.ts Outdated
Comment thread packages/sdk/src/vitest/mock.ts
Comment thread packages/sdk/src/vitest/mock.ts Outdated
Comment thread packages/sdk/src/vitest/mock.ts
@haru0017
haru0017 force-pushed the feat/file-stream-api branch from fa454ff to cc0cf29 Compare June 1, 2026 06:54
@github-actions

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@haru0017
haru0017 marked this pull request as ready for review June 1, 2026 07:33
@claude

claude Bot commented Jun 1, 2026

Copy link
Copy Markdown

📖 Docs Consistency Check

⚠️ Inconsistencies Found

File Issue Suggested Fix
packages/sdk/src/plugin/builtin/file-utils/generate-file-utils.ts Generator does not create helpers for new downloadStream and uploadStream methods Update generator to produce downloadFileStream and uploadFileStream helpers alongside the existing openFileDownloadStream

Details

File Utils Generator (packages/sdk/src/plugin/builtin/file-utils/generate-file-utils.ts:40-141)

The file utils plugin generates typed helper functions for file operations, but currently only includes the deprecated openDownloadStream method:

  1. Missing imports (lines 40-48): Should import FileDownloadStreamResponse and FileUploadStreamOptions types
  2. Missing downloadStream helper: Should generate a downloadFileStream function similar to openFileDownloadStream but calling the new file.downloadStream API
  3. Missing uploadStream helper: Should generate an uploadFileStream function that calls file.uploadStream

Current generated output (example/generated/files.ts):

  • Lines 1-7: Only imports FileStreamIterator (for deprecated API)
  • Lines 61-67: Only generates openFileDownloadStream helper
  • Missing: downloadFileStream and uploadFileStream helpers

Impact:
Users relying on the generated file utilities will not have typed helpers for the new stream APIs and will continue using the deprecated openDownloadStream method without awareness of the newer alternatives.

Recommended Actions

  1. Update packages/sdk/src/plugin/builtin/file-utils/generate-file-utils.ts:

    • Add FileDownloadStreamResponse and FileUploadStreamOptions to the import statement (line 42-47)
    • Generate downloadFileStream helper that calls file.downloadStream
    • Generate uploadFileStream helper that calls file.uploadStream
    • Consider marking openFileDownloadStream as @deprecated in generated JSDoc
  2. Run code generation to update example/generated/files.ts

  3. Update example/tests/fixtures/expected/files.ts to match the new generated output

Re-run this check by adding the docs-check label to the PR.


fieldName: string,
recordId: string,
readableStream: ReadableStream<Uint8Array | ArrayBuffer>,
options?: FileUploadStreamOptions,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] I do not quite understand the significance of this being optional.
What is the difference between when it is specified and when it is not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both contentType and fileSize have default values, so callers don't need to specify them unless they want to override.

@toiroakr toiroakr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (with 1 question.)

@toiroakr

toiroakr commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

@haru0017 It looks like the commits are not signed.

@haru0017
haru0017 force-pushed the feat/file-stream-api branch from cc0cf29 to ae02530 Compare June 2, 2026 00:53
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

Code Metrics Report (packages/sdk)

main (c4f5dd0) #1275 (928d66f) +/-
Coverage 64.3% 64.3% +0.0%
Code to Test Ratio 1:0.4 1:0.4 -0.1
Details
  |                    | main (c4f5dd0) | #1275 (928d66f) |  +/-  |
  |--------------------|----------------|-----------------|-------|
+ | Coverage           |          64.3% |           64.3% | +0.0% |
  |   Files            |            380 |             380 |     0 |
  |   Lines            |          13132 |           13142 |   +10 |
+ |   Covered          |           8447 |            8455 |    +8 |
- | Code to Test Ratio |          1:0.4 |           1:0.4 |  -0.1 |
  |   Code             |          87381 |           87484 |  +103 |
+ |   Test             |          37420 |           37461 |   +41 |

Code coverage of files in pull request scope (91.9% → 91.4%)

Files Coverage +/- Status
packages/sdk/src/runtime/file.ts 100.0% 0.0% modified
packages/sdk/src/vitest/mock.ts 91.0% -0.6% modified

SDK Configure Bundle Size

main (c4f5dd0) #1275 (928d66f) +/-
configure-index-size 18KB 18KB 0KB
dependency-chunks-size 34.47KB 34.47KB 0KB
total-bundle-size 52.47KB 52.47KB 0KB

Runtime Performance

main (c4f5dd0) #1275 (928d66f) +/-
Generate Median 2,833ms 2,714ms -119ms
Generate Max 2,852ms 2,749ms -103ms
Apply Build Median 2,857ms 2,754ms -103ms
Apply Build Max 2,895ms 2,778ms -117ms

Type Performance (instantiations)

main (c4f5dd0) #1275 (928d66f) +/-
tailordb-basic 35,147 35,147 0
tailordb-optional 3,841 3,841 0
tailordb-relation 7,428 7,428 0
tailordb-validate 2,566 2,566 0
tailordb-hooks 5,767 5,767 0
tailordb-object 12,136 12,136 0
tailordb-enum 2,462 2,462 0
resolver-basic 9,424 9,424 0
resolver-nested 26,111 26,111 0
resolver-array 18,187 18,187 0
executor-schedule 4,234 4,234 0
executor-webhook 873 873 0
executor-record 8,166 8,166 0
executor-resolver 4,369 4,369 0
executor-operation-function 868 868 0
executor-operation-gql 869 869 0
executor-operation-webhook 888 888 0
executor-operation-workflow 1,714 1,714 0

Reported by octocov

@haru0017
haru0017 merged commit 537d0ea into main Jun 2, 2026
54 checks passed
@haru0017
haru0017 deleted the feat/file-stream-api branch June 2, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants