"""
ToDoWrite Core Type Definitions.
This module contains shared type definitions and utility classes used
throughout the ToDoWrite package.
Key Concepts:
- LayerType: The 12 hierarchical layers from Goal to Command
- StatusType: Workflow states for task tracking
- Metadata: Extensible metadata system
- Command: Executable command definitions
Example:
>>> from todowrite.core.models import Goal
>>> from todowrite.core.types import LayerType, Metadata
>>>
>>> goal = Goal(
... title="Launch Product",
... description="Successfully launch the new product",
... owner="product-team",
... severity="high"
... )
"""
from __future__ import annotations
from typing import Literal
# Define the 12 hierarchical layers in the ToDoWrite system
LayerType = Literal[
"Goal",
"Concept",
"Context",
"Constraints",
"Requirements",
"AcceptanceCriteria",
"InterfaceContract",
"Phase",
"Step",
"Task",
"SubTask",
"Command",
]
# Define workflow status types
StatusType = Literal[
"planned", "in_progress", "completed", "blocked", "cancelled"
]
# ToDoWrite Core Type Definitions
#
# This module contains shared type definitions and utility classes used
# throughout the ToDoWrite package.
#
# SQLAlchemy model classes are in todowrite.core.models
#
# Available exports:
__all__ = [
"AcceptanceCriteriaCollection",
"CommandCollection",
"LayerType",
"Metadata",
"PhaseCollection",
"StatusType",
"StepCollection",
"SubTaskCollection",
"TaskCollection",
"ToDoWriteCollection",
]
[docs]
class ToDoWriteCollection:
"""Base collection class for ToDoWrite models."""
[docs]
def __init__(self, items: list[str] | None = None) -> None:
self.items = items or []
[docs]
def all(self) -> list[str]:
"""Get all items in the collection."""
return self.items
[docs]
def size(self) -> int:
"""Get the size of the collection."""
return len(self.items)
[docs]
def empty(self) -> bool:
"""Check if the collection is empty."""
return len(self.items) == 0
[docs]
def exists(self) -> bool:
"""Check if any items exist in the collection."""
return len(self.items) > 0
[docs]
class PhaseCollection(ToDoWriteCollection):
"""Collection for Phase items."""
pass
[docs]
class TaskCollection(ToDoWriteCollection):
"""Collection for Task items."""
pass
[docs]
class AcceptanceCriteriaCollection(ToDoWriteCollection):
"""Collection for AcceptanceCriteria items."""
pass
[docs]
class StepCollection(ToDoWriteCollection):
"""Collection for Step items."""
pass
[docs]
class SubTaskCollection(ToDoWriteCollection):
"""Collection for SubTask items."""
pass
[docs]
class CommandCollection(ToDoWriteCollection):
"""Collection for Command items."""
pass