fix: preserve Blob values with files preserve#79
Conversation
Treat Blob values like File values during plain-object encoding so callers can opt into preserving binary fields with files: preserve. Update the preserved entry type, docs, regression tests, and changeset for issue #66.
Greptile SummaryThis PR fixes issue #66 by extending the
Confidence Score: 5/5Safe to merge - the change is additive and well-scoped with no impact on existing encode/decode behavior for non-Blob inputs. The Blob preservation path follows the exact same pattern as the pre-existing File preservation path, the type widening is correct in both directions, and the only gap is a minor decode error-message inconsistency that does not affect runtime behavior. No files require special attention beyond the minor error-message inconsistency in src/decode.ts.
|
| Filename | Overview |
|---|---|
| src/encode.ts | Widens PreservedFileEntry to include Blob, updates isFileValue to detect Blob, updates error message, and broadens encodeStringEntries parameter type - all changes are correct and consistent. |
| src/decode.ts | Adds DecodableEntry/DecodableEntryValue types and widens the decode parameter to accept Blob entries; the thrown error message still reads 'File entries are not supported' instead of 'File and Blob entries'. |
| test/roundtrip.test.ts | Adds encode-side tests for Blob preserve and throw cases. |
| test/types.test.ts | Adds a compile-time assertion verifying encode output with Blob entries is assignable to the decode parameter type. |
| src/core.ts | Re-exports the new DecodableEntry and DecodableEntryValue types - straightforward additive change. |
| src/index.ts | Adds DecodableEntry and DecodableEntryValue to the public API surface. |
| README.md | Updates docs to mention Blob alongside File throughout and corrects the API signature table. |
Reviews (2): Last reviewed commit: "fix: accept blob entries in decode types" | Re-trigger Greptile
Widen the public decode input type so encode output containing preserved Blob values can be passed directly to decode. Export the new entry aliases and add type coverage for the Blob encode-to-decode path.
Summary
Fixes #66.
This updates plain-object encoding so
Blobvalues are handled consistently withFilevalues:Blobvalues when{ files: "preserve" }is passedFileandBlobvalues unless preservation is enabled[string, string | File | Blob][]Verification
bun fmtbun lint:fixbun testbun typecheck