feat(storage): add storage provider registration hook (SF-15)#551
Merged
Conversation
createStorageProvider now resolves a provider type through a registry instead of a hardcoded switch that only built 'local' and threw for everything else. 'local' is registered as a built-in default so existing behaviour is unchanged; hosts opt into the optional s3/vercel-blob packages or a custom provider by calling registerStorageProvider(type, factory). @opensaas/stack-storage gains no dependency on the provider packages — keeping the AWS/Vercel SDKs off every storage user. The read path (assembleImageMetadata) is unchanged: it only stamps the provider name and never constructs a provider. Unregistered types throw a clear error. Implements ADR-0009. Fixes #549 https://claude.ai/code/session_01ULd2HCT8dUve9aa9gKi6sX
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 0a61241 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
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 |
Contributor
Coverage Report for Core Package Coverage (./packages/core)
File CoverageNo changed files found. |
Contributor
Coverage Report for UI Package Coverage (./packages/ui)
File CoverageNo changed files found. |
Contributor
Coverage Report for CLI Package Coverage (./packages/cli)
File CoverageNo changed files found. |
Contributor
Coverage Report for Auth Package Coverage (./packages/auth)
File CoverageNo changed files found. |
Contributor
Coverage Report for Storage Package Coverage (./packages/storage)
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||
Contributor
Coverage Report for RAG Package Coverage (./packages/rag)
File CoverageNo changed files found. |
Contributor
Coverage Report for Storage S3 Package Coverage (./packages/storage-s3)
File CoverageNo changed files found. |
Contributor
Coverage Report for Storage Vercel Package Coverage (./packages/storage-vercel)
File CoverageNo changed files found. |
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.
What
Adds a provider-registration hook to the storage runtime so non-
localand custom providers are constructable. Implements ADR-0009.createStorageProvider(packages/storage/src/runtime/index.ts) previously used a hardcodedswitchthat only built'local'and threwUnknown storage provider type: …for everything else — so the published@opensaas/stack-storage-s3/-vercelproviders (and any custom provider) could not be constructed for uploads.It now resolves a provider
typethrough a registry:registerStorageProvider(type, factory)— exported from@opensaas/stack-storage/runtime. The host registers the optional provider it uses (or a custom one).createStorageProviderlooks thetypeup in the registry instead of a closedswitch.'local'is registered as a built-in default (on module load), so existing behaviour is unchanged with no registration step.registerStorageProvider.getStorageProviderFactory,hasStorageProvider,resetStorageProviderRegistry(test isolation), and theStorageProviderFactory<TConfig>type.No new runtime dependency
@opensaas/stack-storagedoes not depend on@opensaas/stack-storage-s3/-vercel—package.jsonis unchanged. The host opts into the optional provider it uses, avoiding the eager-dep problem (ADR-0008) of forcing the AWS/Vercel SDKs onto every storage user. Tests register a local fake/custom provider rather than pulling in a provider package.Read path unchanged
assembleImageMetadata(packages/storage/src/utils/multi-column.ts) still stamps only the provider name and never constructs a provider — left untouched and covered by a test.Type safety
The public API is strongly typed (
registerStorageProvider<TConfig extends BaseStorageConfig>,StorageProviderFactory<TConfig>) with noany/casts exposed. The single internal config-widening cast lives inside the package with an explanatory comment. The oldas unknown as LocalStorageConfigcast was removed.Docs
Completed the storage
CLAUDE.md"Custom Storage Provider" section (which dead-ended at "ExtendcreateStorageProviderto support…") with the real registration recipe: registering an optional provider package (s3,vercel-blob), registering a custom provider, and referencing it bytypein config.Tests
New
packages/storage/tests/provider-registry.test.ts(9 tests):'local'builds by default via the registrycreateStorageProviderbuild ithasStorageProvider/getStorageProviderFactoryreflect registrationassembleImageMetadata(read path) stamps the provider name without constructing a providerAll 123 storage tests pass.
pnpm lint(0 errors),pnpm format:check, andpnpm --filter @opensaas/stack-storage buildall pass. Changeset included (minor).Fixes #549
https://claude.ai/code/session_01ULd2HCT8dUve9aa9gKi6sX
Generated by Claude Code