@fatagnus/convex-filesystem
v0.1.0
Published
Convex component for collaborative filesystem management with folders, file uploads, granular sharing permissions, Google Drive link integration, and AI-powered semantic search
Maintainers
Readme
@fatagnus/convex-filesystem
A standalone Convex component that provides collaborative filesystem management with folders, file uploads, granular sharing permissions, Google Drive link integration, and AI-powered semantic search.
Features
- Folder Management: Create, rename, move, and delete folders with unlimited nesting
- File Storage: Upload files to Convex storage with CDN support
- File Versioning: Automatic version history with configurable retention
- Sharing & Permissions: Granular permissions (view, comment, edit, admin) with inheritance
- Google Drive Integration: Link Google Drive documents with content caching
- Semantic Search: AI-powered search using embeddings for content discovery
- Comments: Threaded comments on files for collaboration
- React Components: Ready-to-use UI components built with Mantine
Installation
npm install @fatagnus/convex-filesystemPeer Dependencies
Required:
npm install convex @convex-dev/agentOptional (for React components):
npm install react @mantine/core @mantine/hooks @tabler/icons-reactSetup
1. Mount the Component
In your convex/convex.config.ts:
import { defineApp } from "convex/server";
import filesystem from "@fatagnus/convex-filesystem/convex.config";
const app = defineApp();
app.use(filesystem);
export default app;2. Configure API Keys (Optional)
For semantic search and Google Drive content fetching, set environment variables:
# For semantic search embeddings
OPENROUTER_API_KEY=your_openrouter_key
# For Google Drive content fetching
GOOGLE_API_KEY=your_google_api_keyUsage
Convex Functions
import { api } from "./_generated/api";
// Create a folder
await ctx.runMutation(api.filesystem.folders.create, {
name: "Documents",
organizationId: "org_123",
});
// Upload a file
const uploadUrl = await ctx.runMutation(api.filesystem.files.generateUploadUrl);
// ... upload file to URL ...
await ctx.runMutation(api.filesystem.files.create, {
name: "report.pdf",
folderId: folderId,
storageId: storageId,
size: fileSize,
mimeType: "application/pdf",
});
// Share a folder
await ctx.runMutation(api.filesystem.sharing.share, {
resourceType: "folder",
resourceId: folderId,
shareType: "organization",
targetId: "org_456",
permission: "view",
});React Components
import { FileManager } from "@fatagnus/convex-filesystem/react";
function App() {
return (
<FileManager
organizationId="org_123"
userId="user_456"
/>
);
}React Hooks
import { useFiles, useFolders, useSharing } from "@fatagnus/convex-filesystem/react";
function MyFileList({ folderId }) {
const { files, isLoading, upload, deleteFile } = useFiles(folderId);
const { folders, createFolder } = useFolders(folderId);
const { shares, permission, canEdit } = useSharing("folder", folderId);
// ... your UI
}API Reference
Folders
folders.create- Create a new folderfolders.rename- Rename a folderfolders.move- Move a folder to a new parentfolders.delete- Soft delete a folder and its contentsfolders.list- List folders in a parentfolders.get- Get a folder by IDfolders.getPath- Get folder ancestors for breadcrumbs
Files
files.generateUploadUrl- Get a signed upload URLfiles.create- Create file record after uploadfiles.getDownloadUrl- Get a signed download URLfiles.rename- Rename a filefiles.move- Move a file to a new folderfiles.delete- Soft delete a filefiles.restore- Restore a soft-deleted filefiles.permanentDelete- Permanently delete a filefiles.list- List files in a folderfiles.listDeleted- List soft-deleted files (trash)files.listVersions- List file versionsfiles.restoreVersion- Restore a previous version
Sharing
sharing.share- Share a resource with a user or organizationsharing.unshare- Remove a sharesharing.updatePermission- Update share permission levelsharing.listShares- List shares for a resourcesharing.getEffectivePermission- Get user's effective permission
Comments
comments.create- Add a comment to a filecomments.update- Update own commentcomments.delete- Delete a commentcomments.list- List comments on a file
Google Drive
googleDrive.create- Link a Google Drive documentgoogleDrive.delete- Remove a linkgoogleDrive.list- List links in a foldergoogleDrive.fetchContent- Fetch and cache document content
Search
search.searchByName- Search files by namesearch.semanticSearch- AI-powered semantic search
License
Apache-2.0
