Refactor/storage adapter complexity - #117
Open
saabdullcmuq wants to merge 2 commits into
Open
saabdullcmuq wants to merge 2 commits into
saabdullcmuq wants to merge 2 commits into
Conversation
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #97
Type of change
[ yes] Refactor / code improvement
What does this PR do?
Refactors storage.ts inside the enterprise package to take care of the smell issue of too much complexity with the adaptor selection and list filtering. The adapter is now a plain createAdapter(client, endpoint, bucket) factory exposed through Storage.forClient(...), which makes the module directly testable without real R2/S3 credentials or a configured OPENCODE_STORAGE_ADAPTER env var.
How did you verify your code works?
did a bun test test/core/storage.test.ts: 10 pass / 0 fail (read 200/404/500, write 200/500, remove 200/404, list parse, list before strict-<, list 500)
also did bun test --coverage test/core/storage.test.ts: storage.ts at 67.86% funcs / 66.09% lines (the uncovered lines are the lazy/env-var init path, intentionally left for integration)
checked bun run typecheck and it gave us clean
Screenshots / recordings
Qlty Smell Before:

Qlty Smell After:

Test Before:

Test After:

Checklist
If you do not follow this template your PR will be automatically rejected.