Skip to content

feat(storage): add storage provider registration hook (SF-15)#551

Merged
borisno2 merged 1 commit into
mainfrom
claude/issue-549-storage-provider-registry
Jun 6, 2026
Merged

feat(storage): add storage provider registration hook (SF-15)#551
borisno2 merged 1 commit into
mainfrom
claude/issue-549-storage-provider-registry

Conversation

@borisno2

@borisno2 borisno2 commented Jun 6, 2026

Copy link
Copy Markdown
Member

What

Adds a provider-registration hook to the storage runtime so non-local and custom providers are constructable. Implements ADR-0009.

createStorageProvider (packages/storage/src/runtime/index.ts) previously used a hardcoded switch that only built 'local' and threw Unknown storage provider type: … for everything else — so the published @opensaas/stack-storage-s3 / -vercel providers (and any custom provider) could not be constructed for uploads.

It now resolves a provider type through a registry:

  • registerStorageProvider(type, factory) — exported from @opensaas/stack-storage/runtime. The host registers the optional provider it uses (or a custom one).
  • createStorageProvider looks the type up in the registry instead of a closed switch.
  • 'local' is registered as a built-in default (on module load), so existing behaviour is unchanged with no registration step.
  • An unregistered type still throws a clear error that points at registerStorageProvider.
  • Also exported: getStorageProviderFactory, hasStorageProvider, resetStorageProviderRegistry (test isolation), and the StorageProviderFactory<TConfig> type.

No new runtime dependency

@opensaas/stack-storage does not depend on @opensaas/stack-storage-s3 / -vercelpackage.json is 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 no any/casts exposed. The single internal config-widening cast lives inside the package with an explanatory comment. The old as unknown as LocalStorageConfig cast was removed.

Docs

Completed the storage CLAUDE.md "Custom Storage Provider" section (which dead-ended at "Extend createStorageProvider to support…") with the real registration recipe: registering an optional provider package (s3, vercel-blob), registering a custom provider, and referencing it by type in config.

Tests

New packages/storage/tests/provider-registry.test.ts (9 tests):

  • 'local' builds by default via the registry
  • registering a custom provider lets createStorageProvider build it
  • config is passed through to the factory; re-registration overwrites
  • hasStorageProvider / getStorageProviderFactory reflect registration
  • unregistered type throws a clear error; missing-name still throws
  • assembleImageMetadata (read path) stamps the provider name without constructing a provider

All 123 storage tests pass. pnpm lint (0 errors), pnpm format:check, and pnpm --filter @opensaas/stack-storage build all pass. Changeset included (minor).

Fixes #549

https://claude.ai/code/session_01ULd2HCT8dUve9aa9gKi6sX


Generated by Claude Code

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
@vercel

vercel Bot commented Jun 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-docs Ready Ready Preview, Comment Jun 6, 2026 4:59am

@changeset-bot

changeset-bot Bot commented Jun 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0a61241

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

This PR includes changesets to release 9 packages
Name Type
@opensaas/stack-storage Minor
@opensaas/stack-storage-s3 Minor
@opensaas/stack-storage-vercel Minor
@opensaas/stack-auth Minor
@opensaas/stack-cli Minor
@opensaas/stack-core Minor
@opensaas/stack-rag Minor
@opensaas/stack-tiptap Minor
@opensaas/stack-ui 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 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for Core Package Coverage (./packages/core)

Status Category Percentage Covered / Total
🔵 Lines 89.64% (🎯 65%) 580 / 647
🔵 Statements 88.85% (🎯 65%) 590 / 664
🔵 Functions 98.09% (🎯 62%) 103 / 105
🔵 Branches 77.17% (🎯 50%) 382 / 495
File CoverageNo changed files found.
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for UI Package Coverage (./packages/ui)

Status Category Percentage Covered / Total
🔵 Lines 76.03% 92 / 121
🔵 Statements 75.39% 95 / 126
🔵 Functions 75.6% 31 / 41
🔵 Branches 65.78% 75 / 114
File CoverageNo changed files found.
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for CLI Package Coverage (./packages/cli)

Status Category Percentage Covered / Total
🔵 Lines 75.15% 1295 / 1723
🔵 Statements 74.93% 1342 / 1791
🔵 Functions 83.64% 179 / 214
🔵 Branches 64.36% 569 / 884
File CoverageNo changed files found.
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for Auth Package Coverage (./packages/auth)

Status Category Percentage Covered / Total
🔵 Lines 74.64% 159 / 213
🔵 Statements 69.74% 166 / 238
🔵 Functions 83.11% 64 / 77
🔵 Branches 70.67% 94 / 133
File CoverageNo changed files found.
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for Storage Package Coverage (./packages/storage)

Status Category Percentage Covered / Total
🔵 Lines 73.22% 186 / 254
🔵 Statements 75% 207 / 276
🔵 Functions 83.33% 65 / 78
🔵 Branches 70.73% 174 / 246
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/storage/src/runtime/index.ts 18.91% 25% 20% 18.91% 89-250
packages/storage/src/runtime/registry.ts 100% 100% 100% 100%
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for RAG Package Coverage (./packages/rag)

Status Category Percentage Covered / Total
🔵 Lines 47.97% 355 / 740
🔵 Statements 48.14% 377 / 783
🔵 Functions 54.26% 70 / 129
🔵 Branches 42.55% 180 / 423
File CoverageNo changed files found.
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for Storage S3 Package Coverage (./packages/storage-s3)

Status Category Percentage Covered / Total
🔵 Lines 100% 40 / 40
🔵 Statements 100% 40 / 40
🔵 Functions 100% 9 / 9
🔵 Branches 100% 19 / 19
File CoverageNo changed files found.
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for Storage Vercel Package Coverage (./packages/storage-vercel)

Status Category Percentage Covered / Total
🔵 Lines 100% 38 / 38
🔵 Statements 100% 38 / 38
🔵 Functions 100% 8 / 8
🔵 Branches 100% 22 / 22
File CoverageNo changed files found.
Generated in workflow #1149 for commit 0a61241 by the Vitest Coverage Report Action

@borisno2 borisno2 merged commit fb979b8 into main Jun 6, 2026
6 checks passed
@borisno2 borisno2 deleted the claude/issue-549-storage-provider-registry branch June 6, 2026 05:07
@github-actions github-actions Bot mentioned this pull request Jun 6, 2026
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.

Storage: createStorageProvider only builds 'local' — add a provider registration hook (SF-15)

2 participants