Skip to content

refactor(file-input): extract storage providers into modular plugin packages#14

Open
OrangeGEProton wants to merge 2 commits intomasterfrom
file-input_modular_plugins
Open

refactor(file-input): extract storage providers into modular plugin packages#14
OrangeGEProton wants to merge 2 commits intomasterfrom
file-input_modular_plugins

Conversation

@OrangeGEProton
Copy link
Collaborator

Refactor file-input to Support Modular Provider Plugins

Closes #13

Problem

Storage providers (MongoDB, SQLite, Azure, S3) were hardcoded inside @startupjs-ui/file-input with if/else dynamic imports. SDK dependencies were listed as optional peers with "*" versions — leading to manual installs, version drift, and no extensibility.

Solution

Introduced a plugin registry pattern:

  • providers/registry.js — central registerProvider(name, provider) / getProvider(name) API
  • 4 separate plugin packages, each with pinned SDK versions:
    • @startupjs-ui/file-input-provider-mongo (mongodb@^6.12.0)
    • @startupjs-ui/file-input-provider-sqlite (built-in)
    • @startupjs-ui/file-input-provider-azure (@azure/storage-blob@^12.26.0)
    • @startupjs-ui/file-input-provider-s3 (@aws-sdk/client-s3@^3.600.0)

How it works

// Simply importing the package auto-registers the provider:
import '@startupjs-ui/file-input-provider-mongo'

The core providers/index.js resolves providers from the registry at runtime — no hardcoded imports.

Changes

File / Package Change
packages/file-input/providers/registry.js New — plugin registry module
packages/file-input/providers/index.js Rewritten to use registry instead of hardcoded import()
packages/file-input/package.json Removed optional peer deps (@aws-sdk/*, @azure/*, mongodb); added ./providers/registry export
packages/file-input/providers/{awsS3,azureblob,mongo,sqlite}.js Deleted — replaced by plugin packages
packages/file-input-provider-{mongo,sqlite,azure,s3}/ New — 4 plugin packages
packages/file-input/README.mdx Updated docs with plugin setup guide and custom provider API

Migration

# Before: manually install SDK with unknown version
- yarn add @azure/storage-blob

# After: install the plugin (SDK is bundled with a pinned version)
+ yarn add @startupjs-ui/file-input-provider-azure

# And import it in your server entry:
+ import '@startupjs-ui/file-input-provider-azure'

Checks

  • yarn install — all packages linked via workspaces
  • yarn eslint — no errors
  • yarn tsc --noEmit --skipLibCheck — no errors

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.

Refactor file-input to Support Modular Provider Plugins

2 participants