fix: correct GetProperty bug, init to use .ax/, add default aliases, split e2e tests, add due date tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,21 @@ type nodeServiceImpl struct {
|
||||
|
||||
var mentionRegex = regexp.MustCompile(`@([a-z0-9_]+)`)
|
||||
|
||||
// parseDueDate converts a user-supplied date string to *time.Time.
|
||||
// Returns nil, nil for an empty string (clear/unset). Accepts "YYYY-MM-DD" or RFC3339.
|
||||
func parseDueDate(s string) (*time.Time, error) {
|
||||
if s == "" {
|
||||
return nil, nil
|
||||
}
|
||||
for _, layout := range []string{"2006-01-02", time.RFC3339} {
|
||||
if t, err := time.Parse(layout, s); err == nil {
|
||||
ut := t.UTC()
|
||||
return &ut, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("invalid due date %q: expected YYYY-MM-DD", s)
|
||||
}
|
||||
|
||||
func mentions(t string) []string {
|
||||
seen := make(map[string]bool)
|
||||
for _, m := range mentionRegex.FindAllStringSubmatch(t, -1) {
|
||||
@@ -295,6 +310,11 @@ func (s *nodeServiceImpl) Add(input AddInput) (*models.Node, error) {
|
||||
}
|
||||
}
|
||||
|
||||
dueDate, err := parseDueDate(input.DueDate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
id, err := s.store.GenerateID()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -302,7 +322,7 @@ func (s *nodeServiceImpl) Add(input AddInput) (*models.Node, 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 {
|
||||
if err := st.AddNode(id, input.Title, input.Content, dueDate, now, now); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -492,7 +512,12 @@ func (s *nodeServiceImpl) Update(id string, input UpdateInput) (*models.Node, er
|
||||
return err
|
||||
}
|
||||
|
||||
title, content, dueDate := current.Title, current.Content, current.DueDate
|
||||
title, content := current.Title, current.Content
|
||||
var dueDate *time.Time
|
||||
if current.DueDate != nil {
|
||||
t := current.DueDate.Time
|
||||
dueDate = &t
|
||||
}
|
||||
if input.Title != nil {
|
||||
title = *input.Title
|
||||
}
|
||||
@@ -500,7 +525,11 @@ func (s *nodeServiceImpl) Update(id string, input UpdateInput) (*models.Node, er
|
||||
content = *input.Content
|
||||
}
|
||||
if input.DueDate != nil {
|
||||
dueDate = *input.DueDate
|
||||
parsed, err := parseDueDate(*input.DueDate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dueDate = parsed
|
||||
}
|
||||
|
||||
now := time.Now().UTC().Format(time.RFC3339)
|
||||
@@ -774,7 +803,7 @@ func (s *nodeServiceImpl) ensureUser(st store.GraphStore, username string) (stri
|
||||
return "", err
|
||||
}
|
||||
now := time.Now().UTC().Format(time.RFC3339)
|
||||
if err := st.AddNode(id, username, "", "", now, now); err != nil {
|
||||
if err := st.AddNode(id, username, "", nil, now, now); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := st.AddRel(id, "_type::user", ""); err != nil {
|
||||
@@ -807,7 +836,7 @@ func (s *nodeServiceImpl) ensureNamespace(st store.GraphStore, name string) (str
|
||||
return "", err
|
||||
}
|
||||
now := time.Now().UTC().Format(time.RFC3339)
|
||||
if err := st.AddNode(id, name, "", "", now, now); err != nil {
|
||||
if err := st.AddNode(id, name, "", nil, now, now); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := st.AddRel(id, "_type::namespace", ""); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user