// Package todos: todo lists and items with assignment. package todos import ( "context" "errors" "atlas9.dev/c/core" "atlas9.dev/c/core/iam" ) // List groups items. An item can belong to any number of lists // within its tenant. type List struct { ID core.ID Tenant core.ID Name string } type Item struct { ID core.ID Tenant core.ID Title string Notes string Status Status // Assignee is the user assigned to the item. Empty means unassigned. // Assignees must be members of the item's tenant. Assignee core.ID } type Status string const ( StatusOpen Status = "open" StatusInProgress Status = "in_progress" StatusDone Status = "done" ) func (s Status) Valid() bool { switch s { case StatusOpen, StatusInProgress, StatusDone: return true } return false } var ( Cap_Todos_CreateList = iam.NewCap("Todos_CreateList") Cap_Todos_UpdateList = iam.NewCap("Todos_UpdateList") Cap_Todos_ReadList = iam.NewCap("Todos_ReadList") Cap_Todos_DeleteList = iam.NewCap("Todos_DeleteList") Cap_Todos_AddToList = iam.NewCap("Todos_AddToList") Cap_Todos_RemoveFromList = iam.NewCap("Todos_RemoveFromList") Cap_Todos_CreateItem = iam.NewCap("Todos_CreateItem") Cap_Todos_UpdateItem = iam.NewCap("Todos_UpdateItem") Cap_Todos_ReadItem = iam.NewCap("Todos_ReadItem") Cap_Todos_DeleteItem = iam.NewCap("Todos_DeleteItem") ) var ErrAssigneeNotMember = errors.New("assignee is not a member of the tenant") type Store interface { CreateList(ctx context.Context, list *List) error UpdateList(ctx context.Context, list *List) error GetList(ctx context.Context, tenant core.ID, id core.ID, out *List) error ListLists(ctx context.Context, tenant core.ID, page core.PageReq, out *core.Page[List]) error DeleteList(ctx context.Context, tenant core.ID, id core.ID) error AddToList(ctx context.Context, tenant core.ID, list core.ID, item core.ID) error RemoveFromList(ctx context.Context, tenant core.ID, list core.ID, item core.ID) error CreateItem(ctx context.Context, item *Item) error UpdateItem(ctx context.Context, item *Item) error GetItem(ctx context.Context, tenant core.ID, id core.ID, out *Item) error // ListItems lists items in the tenant. When list is non-empty, only // items belonging to that list are returned. ListItems(ctx context.Context, tenant core.ID, list core.ID, page core.PageReq, out *core.Page[Item]) error DeleteItem(ctx context.Context, tenant core.ID, id core.ID) error }