Documentation
¶
Index ¶
- type Service
- func (s *Service) CheckImportConflicts(ctx context.Context, vaultID uuid.UUID, destPath string, zipData []byte) ([]string, error)
- func (s *Service) CommitImport(ctx context.Context, vaultID uuid.UUID, destPath string, zipData []byte, ...) (imported int, skipped int, err error)
- func (s *Service) DeleteFolder(ctx context.Context, vaultID uuid.UUID, folderPath string) (deletedCount int, failedPaths []string, err error)
- func (s *Service) ExportFolder(ctx context.Context, vaultID uuid.UUID, folderPath string) ([]byte, error)
- func (s *Service) GetNote(ctx context.Context, vaultID uuid.UUID, path string) (couchdb.NoteDoc, error)
- func (s *Service) ListFolders(ctx context.Context, vaultID uuid.UUID) ([]string, error)
- func (s *Service) ListNotes(ctx context.Context, vaultID uuid.UUID) ([]couchdb.NoteEntry, error)
- func (s *Service) ListTags(ctx context.Context, vaultID uuid.UUID) ([]string, error)
- func (s *Service) MoveFolder(ctx context.Context, vaultID uuid.UUID, oldFolderPath, newFolderPath string) (movedCount int, err error)
- func (s *Service) MoveNote(ctx context.Context, vaultID uuid.UUID, oldPath, newPath string) error
- func (s *Service) SaveNote(ctx context.Context, vaultID uuid.UUID, path, content string) error
- func (s *Service) SyncFromWorkbench(ctx context.Context, vaultID uuid.UUID, files map[string][]byte, ...) (conflicts []string, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(repo repository.Repo, subscriptions service.SubscriptionService) *Service
func (*Service) CheckImportConflicts ¶
func (s *Service) CheckImportConflicts(ctx context.Context, vaultID uuid.UUID, destPath string, zipData []byte) ([]string, error)
CheckImportConflicts is a dry run over an uploaded zip: it reports which of its entries would collide with an existing note/file at destPath, without writing anything. The caller re-submits the same zip to CommitImport along with a resolution per conflicting path.
func (*Service) CommitImport ¶
func (s *Service) CommitImport( ctx context.Context, vaultID uuid.UUID, destPath string, zipData []byte, resolutions []domain.ImportResolution, ) (imported int, skipped int, err error)
CommitImport writes an uploaded zip's entries under destPath, applying resolutions for any path CheckImportConflicts previously reported as conflicting. Entries with no resolution and no conflict are written directly. Binary entries are skipped (not failed) when the vault has no bucket, matching the best-effort semantics of DeleteFolder.
func (*Service) DeleteFolder ¶
func (s *Service) DeleteFolder(ctx context.Context, vaultID uuid.UUID, folderPath string) (deletedCount int, failedPaths []string, err error)
DeleteFolder best-effort deletes every note and file under folderPath. CouchDB has no cross-document transactions here, so this cannot be all-or-nothing: it keeps going past individual failures and reports them in failedPaths rather than aborting.
func (*Service) ExportFolder ¶
func (s *Service) ExportFolder(ctx context.Context, vaultID uuid.UUID, folderPath string) ([]byte, error)
ExportFolder zips every note and binary file under folderPath (empty means the whole vault), with entries relative to folderPath, so re-importing the zip elsewhere lands its contents directly under whatever destination path the user picks.
func (*Service) ListFolders ¶
func (*Service) MoveFolder ¶
func (s *Service) MoveFolder(ctx context.Context, vaultID uuid.UUID, oldFolderPath, newFolderPath string) (movedCount int, err error)
MoveFolder renames folderPath to newFolderPath by moving every note and binary file whose path is folderPath itself or lives under it. Unlike DeleteFolder, this is all-or-nothing: every destination path is checked for conflicts against everything NOT being moved before anything is touched, and the whole move is rejected with user_errors.AlreadyExists if any collide, rather than partially applying and reporting failures.
func (*Service) MoveNote ¶
MoveNote renames/moves a single note. A move onto an already-occupied destination is rejected with user_errors.AlreadyExists rather than silently overwriting (client.MoveNote upserts on write, so without this check a move onto an existing path would clobber it).
func (*Service) SyncFromWorkbench ¶ added in v1.0.25
func (s *Service) SyncFromWorkbench( ctx context.Context, vaultID uuid.UUID, files map[string][]byte, snapshot map[string]int64, ) (conflicts []string, err error)
SyncFromWorkbench pushes markdown files edited inside a stopped workbench container's workspace back into vaultID's CouchDB notes. This is a snapshot sync, not continuous/live sync: snapshot is the path→mtime baseline captured when the vault was last materialized into the workbench (internal/service/v1/workbench/workbench.go's materializeVault), used to tell an untouched vault-side note apart from one edited elsewhere (e.g. the Obsidian app) while the workbench was running. Binary/bucket files are explicitly out of scope for this stage (see ExportFolder's bucket half) — non-markdown paths in files are silently skipped, never treated as conflicts.
Only a failure resolving the vault or listing its current notes aborts the whole call early; a single path's write/read failure doesn't abort the rest (best-effort, mirrors DeleteFolder) — since the only return values are the conflicts slice and an overall error, such a path is folded into conflicts too, so the caller still knows it wasn't safely synced.