refactor: consolidate packages - move output to cmd, config/session to store, rename Store to GraphStore

This commit is contained in:
2026-04-02 00:18:33 +02:00
parent 2bcc310c6d
commit 03a896d23f
25 changed files with 190 additions and 239 deletions
+13 -13
View File
@@ -12,7 +12,7 @@ import (
)
type nodeServiceImpl struct {
store store.Store
store store.GraphStore
userID string
}
@@ -303,7 +303,7 @@ func (s *nodeServiceImpl) Add(input AddInput) (*models.Node, error) {
return nil, err
}
err = s.store.Transaction(func(st store.Store) error {
err = s.store.Transaction(func(st store.GraphStore) error {
now := time.Now().UTC().Format(time.RFC3339)
if err := st.AddNode(id, input.Title, input.Content, input.DueDate, now, now); err != nil {
return err
@@ -489,7 +489,7 @@ func (s *nodeServiceImpl) Update(id string, input UpdateInput) (*models.Node, er
}
}
err = s.store.Transaction(func(st store.Store) error {
err = s.store.Transaction(func(st store.GraphStore) error {
current, err := st.GetNode(id)
if err != nil {
return err
@@ -609,14 +609,14 @@ func (s *nodeServiceImpl) Delete(id string) error {
if !pc.canWrite(id) {
return fmt.Errorf("permission denied: no write access to node %s", id)
}
return s.store.Transaction(func(st store.Store) error {
return s.store.Transaction(func(st store.GraphStore) error {
return s.cascadeDelete(st, id, make(map[string]bool))
})
}
// cascadeDelete deletes id and all nodes it owns (recursively).
// visited prevents infinite loops from ownership cycles.
func (s *nodeServiceImpl) cascadeDelete(st store.Store, id string, visited map[string]bool) error {
func (s *nodeServiceImpl) cascadeDelete(st store.GraphStore, id string, visited map[string]bool) error {
if visited[id] {
return nil
}
@@ -644,7 +644,7 @@ func (s *nodeServiceImpl) cascadeDelete(st store.Store, id string, visited map[s
func (s *nodeServiceImpl) AddUser(name string) (*models.Node, error) {
var id string
err := s.store.Transaction(func(st store.Store) error {
err := s.store.Transaction(func(st store.GraphStore) error {
var err error
id, err = s.ensureUser(st, name)
return err
@@ -678,7 +678,7 @@ func (s *nodeServiceImpl) checkBlockers(id string) error {
return nil
}
func (s *nodeServiceImpl) syncMentions(st store.Store, id string, current *models.Node, newTitle, newContent string) error {
func (s *nodeServiceImpl) syncMentions(st store.GraphStore, id string, current *models.Node, newTitle, newContent string) error {
existingMentionIDs := make(map[string]bool)
for _, uid := range current.Relations[string(models.RelMentions)] {
existingMentionIDs[uid] = true
@@ -708,7 +708,7 @@ func (s *nodeServiceImpl) syncMentions(st store.Store, id string, current *model
// resolveRelTarget resolves a RelInput target to a node ID, auto-creating users
// and namespaces as needed. Use only inside a transaction.
func (s *nodeServiceImpl) resolveRelTarget(st store.Store, ri RelInput) (string, error) {
func (s *nodeServiceImpl) resolveRelTarget(st store.GraphStore, ri RelInput) (string, error) {
switch ri.Type {
case models.RelAssignee, models.RelCreated, models.RelMentions:
return s.resolveUserRef(st, ri.Target)
@@ -744,7 +744,7 @@ func (s *nodeServiceImpl) lookupRelTarget(relType models.RelType, target string)
}
// resolveIDByNameAndType finds a node by title and _type property without creating it.
func (s *nodeServiceImpl) resolveIDByNameAndType(st store.Store, title, nodeType string) (string, error) {
func (s *nodeServiceImpl) resolveIDByNameAndType(st store.GraphStore, title, nodeType string) (string, error) {
nodes, err := st.FindNodes([]*models.Rel{{Type: models.RelType("_type::" + nodeType), Target: ""}})
if err != nil {
return "", err
@@ -757,14 +757,14 @@ func (s *nodeServiceImpl) resolveIDByNameAndType(st store.Store, title, nodeType
return "", nil
}
func (s *nodeServiceImpl) resolveUserRef(st store.Store, ref string) (string, error) {
func (s *nodeServiceImpl) resolveUserRef(st store.GraphStore, ref string) (string, error) {
if exists, _ := st.NodeExists(ref); exists {
return ref, nil
}
return s.ensureUser(st, ref)
}
func (s *nodeServiceImpl) ensureUser(st store.Store, username string) (string, error) {
func (s *nodeServiceImpl) ensureUser(st store.GraphStore, username string) (string, error) {
userID, err := s.resolveIDByNameAndType(st, username, "user")
if err != nil {
return "", err
@@ -790,14 +790,14 @@ func (s *nodeServiceImpl) ensureUser(st store.Store, username string) (string, e
return id, nil
}
func (s *nodeServiceImpl) resolveNamespaceRef(st store.Store, ref string) (string, error) {
func (s *nodeServiceImpl) resolveNamespaceRef(st store.GraphStore, ref string) (string, error) {
if exists, _ := st.NodeExists(ref); exists {
return ref, nil
}
return s.ensureNamespace(st, ref)
}
func (s *nodeServiceImpl) ensureNamespace(st store.Store, name string) (string, error) {
func (s *nodeServiceImpl) ensureNamespace(st store.GraphStore, name string) (string, error) {
nsID, err := s.resolveIDByNameAndType(st, name, "namespace")
if err != nil {
return "", err