vfsservice

package
v0.9.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package vfsservice exposes the local filesystem to chains. Steps read files, inspect repos, and write outputs through this.

Index

Constants

View Source
const (
	// MaxUploadSize is the maximum allowed size for a single file upload (100 MiB).
	MaxUploadSize    = 100 * 1024 * 1024
	MaxFilesRowCount = 50000
)

Variables

View Source
var (
	ErrUnknownPath    = fmt.Errorf("unable to resolve path")
	ErrFolderNotEmpty = fmt.Errorf("folder is not empty")
	ErrNotSupported   = errors.New("operation not supported")
)

Functions

This section is empty.

Types

type Callbacks

type Callbacks struct {
	BeforeRead  func(ctx context.Context, resourceID string) error
	BeforeWrite func(ctx context.Context, resourceID string) error
	OnCreate    func(ctx context.Context, file *File) error
	OnUpdate    func(ctx context.Context, file *File) error
	OnDelete    func(ctx context.Context, resourceID string) error
}

Callbacks holds optional lifecycle hooks called around VFS operations. Any nil field is silently skipped.

type File

type File struct {
	ID          string    `json:"id"`
	Path        string    `json:"path"`
	Name        string    `json:"name"`
	ParentID    string    `json:"parentId"`
	Size        int64     `json:"size"`
	ContentType string    `json:"contentType"`
	Data        []byte    `json:"data"`
	CreatedAt   time.Time `json:"createdAt"`
	UpdatedAt   time.Time `json:"updatedAt"`
	// IsDirectory is set for directory entries returned by GetFilesByPath; omitted for normal files.
	IsDirectory bool `json:"isDirectory,omitempty"`
}

File represents a file in the VFS.

type Folder

type Folder struct {
	ID        string    `json:"id"`
	Path      string    `json:"path"`
	Name      string    `json:"name"`
	ParentID  string    `json:"parentId"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Folder represents a directory in the VFS.

type Metadata

type Metadata struct {
	SpecVersion string `json:"specVersion"`
	Path        string `json:"path"`
	Hash        string `json:"hash"`
	Size        int64  `json:"size"`
	FileID      string `json:"fileId"`
}

Metadata holds file content metadata stored alongside blob data.

type Service

type Service interface {
	CreateFile(ctx context.Context, file *File) (*File, error)
	GetFileByID(ctx context.Context, id string) (*File, error)
	GetFolderByID(ctx context.Context, id string) (*Folder, error)
	GetFilesByPath(ctx context.Context, path string) ([]File, error)
	UpdateFile(ctx context.Context, file *File) (*File, error)
	DeleteFile(ctx context.Context, id string) error
	CreateFolder(ctx context.Context, parentID, name string) (*Folder, error)
	RenameFile(ctx context.Context, fileID, newName string) (*File, error)
	RenameFolder(ctx context.Context, folderID, newName string) (*Folder, error)
	DeleteFolder(ctx context.Context, folderID string) error
	MoveFile(ctx context.Context, fileID, newParentID string) (*File, error)
	MoveFolder(ctx context.Context, folderID, newParentID string) (*Folder, error)
}

Service defines all VFS operations.

func New

func New(db libdb.DBManager, cb Callbacks) Service

New creates a DB-backed VFS service. Pass Callbacks{} for pure storage.

func NewLocalFS

func NewLocalFS(root string) Service

NewLocalFS returns a Service backed by the local filesystem rooted at root. Intended for the CLI and TUI.

func WithActivityTracker

func WithActivityTracker(svc Service, tracker libtracker.ActivityTracker) Service

WithActivityTracker wraps a Service with activity logging.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL