Skip to content

feat: Generic file storage abstraction layer#13

Draft
falfaddaghi wants to merge 6 commits intoadw/feature-workspace-recent-changes-panel-857b7bc9from
adw/feature-generic-file-storage-b8dbb4a6
Draft

feat: Generic file storage abstraction layer#13
falfaddaghi wants to merge 6 commits intoadw/feature-workspace-recent-changes-panel-857b7bc9from
adw/feature-generic-file-storage-b8dbb4a6

Conversation

@falfaddaghi
Copy link
Copy Markdown
Member

Summary

Introduces a pluggable StorageProvider abstraction layer for all server-side file I/O in Nexus Workflow Studio. The current tight coupling to node:fs/promises in workspace, brain, snapshot, and collaboration modules is replaced by a single interface with a LocalFilesystemProvider default. Adding new storage backends (S3, Azure Blob, SharePoint) will require only implementing the interface and registering the provider — no changes to any consumer.

Implementation plan: docs/tasks/feature-generic-file-storage-b8dbb4a6/plan-feature-generic-file-storage-b8dbb4a6.md

ADW tracking ID: b8dbb4a6

Checklist

  • Define StorageProvider interface and supporting types (StorageMetadata, StorageProviderType) in src/lib/storage/types.ts
  • Create storage configuration with NEXUS_STORAGE_PROVIDER and NEXUS_STORAGE_ROOT env var support
  • Implement LocalFilesystemProvider wrapping current fs behavior with path traversal guard
  • Build provider factory with caching, reset, and registerStorageProvider() for extensibility
  • Create barrel export at src/lib/storage/index.ts
  • Write unit tests for LocalFilesystemProvider (all interface methods + edge cases)
  • Write unit tests for factory (selection, caching, reset, custom registration)
  • Migrate workspace/server.ts to use StorageProvider (remove direct fs imports)
  • Migrate workspace/snapshots.ts to use StorageProvider
  • Migrate brain/server.ts to use StorageProvider
  • Migrate collaboration/object-store.ts to accept a StorageProvider
  • Update config files to document new env vars
  • Create E2E test specification
  • Validate: bun run typecheck, bun run lint, bun run build all pass

Key Changes

  • New src/lib/storage/ module with types.ts, local-provider.ts, factory.ts, config.ts, index.ts
  • All server-side consumers (workspace/server.ts, workspace/snapshots.ts, brain/server.ts, collaboration/object-store.ts) migrated off direct node:fs/promises imports
  • registerStorageProvider() API enables third-party storage backends with zero core changes
  • writeAtomic() method preserves crash-safe temp-file-then-rename behavior used by snapshots and collab state
  • Binary data (Uint8Array) supported via readBytes()/writeBytes() for collaboration state

@falfaddaghi falfaddaghi force-pushed the adw/feature-workspace-recent-changes-panel-857b7bc9 branch from d8622a3 to 76a90b1 Compare April 27, 2026 13:49
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.

1 participant