This repository was archived by the owner on Mar 13, 2025. It is now read-only.
[Miniflare 3] Implement more of R2 and add tests#524
Merged
Conversation
|
0b6fa4a to
c72c983
Compare
penalosa
reviewed
Mar 6, 2023
| v4Code: number; | ||
| object?: R2Object; | ||
|
|
||
| constructor(status: number, message: string, v4Code: number) { |
Contributor
There was a problem hiding this comment.
status: number should probably also be renamed to code
penalosa
approved these changes
Mar 10, 2023
We'll need this for R2 too
We made a similar change in Miniflare 2 recently
Validate incoming R2 requests from `workerd` with `zod`, increasing type safety. This removes some implicit `any`s from `JSON.parse`, and allows us to use `method` as a type-level union discriminator. Validation of types has also been removed from the `Validator` class, as we don't need to duplicate this. `workerd` will handle validating user input here.
Calling `head()` should return the full-range here
Note this is returning slightly different, but still correct, results to the real implementation. This is due a restriction of Miniflare's storage abstraction, see the comment in `list()` for more details. We're planning to replace this very soon though, so this shouldn't be a problem for long.
This restriction no longer seems to apply
ace5152 to
851c479
Compare
851c479 to
66cf2ec
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR brings over some of the improvements from #470, and adds tests for the R2 implementation.
Specifically we now: (see commit descriptions for more details)
workerdusingzodto ensure type safety in the rest of the implementation (chunky)R2Bucket#delete()Rangeheader inR2Bucket#get()rangeinformation fromR2Bucket#head()R2Bucket#list()startAfteroptionsha*checksums inR2Bucket#put()and return these fromR2Bucket#{get,head}R2Bucket#put()secondsGranularityoption inR2ConditionalsR2Object#versiona hex string to match the real implementationcustomMetadatasizeBest reviewed commit-by-commit... 😅