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
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.