Documentation
¶
Index ¶
- Variables
- func ConvertToDBFile(file mfile.File) gen.File
- func ConvertToModelFile(file gen.File) *mfile.File
- type FileService
- func (s *FileService) CheckWorkspaceID(ctx context.Context, fileID, workspaceID idwrap.IDWrap) (bool, error)
- func (s *FileService) CreateFile(ctx context.Context, file *mfile.File) error
- func (s *FileService) DeleteFile(ctx context.Context, id idwrap.IDWrap) error
- func (s *FileService) GetFile(ctx context.Context, id idwrap.IDWrap) (*mfile.File, error)
- func (s *FileService) GetFileByContentID(ctx context.Context, contentID idwrap.IDWrap) (*mfile.File, error)
- func (s *FileService) GetFileContentID(ctx context.Context, id idwrap.IDWrap) (*idwrap.IDWrap, mfile.ContentType, error)
- func (s *FileService) GetWorkspaceID(ctx context.Context, fileID idwrap.IDWrap) (idwrap.IDWrap, error)
- func (s *FileService) ListFilesByParent(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) ([]mfile.File, error)
- func (s *FileService) ListFilesByWorkspace(ctx context.Context, workspaceID idwrap.IDWrap) ([]mfile.File, error)
- func (s *FileService) MoveFile(ctx context.Context, fileID idwrap.IDWrap, newParentID *idwrap.IDWrap) error
- func (s *FileService) NextDisplayOrder(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) (float64, error)
- func (s *FileService) Reader() *Reader
- func (s *FileService) TX(tx *sql.Tx) *FileService
- func (s *FileService) UpdateFile(ctx context.Context, file *mfile.File) error
- func (s *FileService) UpsertFile(ctx context.Context, file *mfile.File) error
- type Reader
- func (r *Reader) CheckWorkspaceID(ctx context.Context, fileID, workspaceID idwrap.IDWrap) (bool, error)
- func (r *Reader) FindFileByPathHash(ctx context.Context, workspaceID idwrap.IDWrap, pathHash string) (idwrap.IDWrap, error)
- func (r *Reader) GetFile(ctx context.Context, id idwrap.IDWrap) (*mfile.File, error)
- func (r *Reader) GetFileByContentID(ctx context.Context, contentID idwrap.IDWrap) (*mfile.File, error)
- func (r *Reader) GetFileContentID(ctx context.Context, id idwrap.IDWrap) (*idwrap.IDWrap, mfile.ContentType, error)
- func (r *Reader) GetWorkspaceID(ctx context.Context, fileID idwrap.IDWrap) (idwrap.IDWrap, error)
- func (r *Reader) ListFilesByParent(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) ([]mfile.File, error)
- func (r *Reader) ListFilesByWorkspace(ctx context.Context, workspaceID idwrap.IDWrap) ([]mfile.File, error)
- type Writer
- func (w *Writer) CreateFile(ctx context.Context, file *mfile.File) error
- func (w *Writer) DeleteFile(ctx context.Context, id idwrap.IDWrap) error
- func (w *Writer) MoveFile(ctx context.Context, fileID idwrap.IDWrap, newParentID *idwrap.IDWrap) error
- func (w *Writer) NextDisplayOrder(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) (float64, error)
- func (w *Writer) UpdateFile(ctx context.Context, file *mfile.File) error
- func (w *Writer) UpsertFile(ctx context.Context, file *mfile.File) error
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileNotFound = fmt.Errorf("file not found") ErrContentNotFound = fmt.Errorf("content not found") ErrInvalidContentKind = fmt.Errorf("invalid content kind") ErrFolderIntoItself = fmt.Errorf("cannot move folder into itself") ErrWorkspaceMismatch = fmt.Errorf("workspace mismatch") )
Functions ¶
func ConvertToDBFile ¶
ConvertToDBFile converts model to DB representation
Types ¶
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
FileService provides operations for managing files in the unified file system Supports the union type content pattern with two-query approach for content retrieval
func New ¶
func New(queries *gen.Queries, logger *slog.Logger) *FileService
New creates a new FileService
func (*FileService) CheckWorkspaceID ¶
func (s *FileService) CheckWorkspaceID(ctx context.Context, fileID, workspaceID idwrap.IDWrap) (bool, error)
CheckWorkspaceID verifies if a file belongs to a specific workspace
func (*FileService) CreateFile ¶
CreateFile creates a new file
func (*FileService) DeleteFile ¶
DeleteFile deletes a file
func (*FileService) GetFileByContentID ¶
func (s *FileService) GetFileByContentID(ctx context.Context, contentID idwrap.IDWrap) (*mfile.File, error)
GetFileByContentID retrieves a file by its content ID
func (*FileService) GetFileContentID ¶
func (s *FileService) GetFileContentID(ctx context.Context, id idwrap.IDWrap) (*idwrap.IDWrap, mfile.ContentType, error)
GetFileContentID retrieves the content ID for a file
func (*FileService) GetWorkspaceID ¶
func (s *FileService) GetWorkspaceID(ctx context.Context, fileID idwrap.IDWrap) (idwrap.IDWrap, error)
GetWorkspaceID retrieves the workspace ID for a file
func (*FileService) ListFilesByParent ¶
func (s *FileService) ListFilesByParent(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) ([]mfile.File, error)
ListFilesByParent retrieves files directly under a parent
func (*FileService) ListFilesByWorkspace ¶
func (s *FileService) ListFilesByWorkspace(ctx context.Context, workspaceID idwrap.IDWrap) ([]mfile.File, error)
ListFilesByWorkspace retrieves all files for a workspace
func (*FileService) MoveFile ¶
func (s *FileService) MoveFile(ctx context.Context, fileID idwrap.IDWrap, newParentID *idwrap.IDWrap) error
MoveFile moves a file to a different parent
func (*FileService) NextDisplayOrder ¶
func (s *FileService) NextDisplayOrder(ctx context.Context, workspaceID idwrap.IDWrap, parentID *idwrap.IDWrap) (float64, error)
NextDisplayOrder calculates the next order value for a file in a workspace/parent
func (*FileService) Reader ¶
func (s *FileService) Reader() *Reader
func (*FileService) TX ¶
func (s *FileService) TX(tx *sql.Tx) *FileService
TX returns a new service instance with transaction support
func (*FileService) UpdateFile ¶
UpdateFile updates an existing file
func (*FileService) UpsertFile ¶
UpsertFile creates or updates a file
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func NewReaderFromQueries ¶
func (*Reader) CheckWorkspaceID ¶
func (*Reader) FindFileByPathHash ¶
func (*Reader) GetFileByContentID ¶
func (r *Reader) GetFileByContentID(ctx context.Context, contentID idwrap.IDWrap) (*mfile.File, error)
GetFileByContentID retrieves a file by its content ID
func (*Reader) GetFileContentID ¶
func (*Reader) GetWorkspaceID ¶
func (*Reader) ListFilesByParent ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}