Documentation
¶
Overview ¶
Package events defines the centralized event taxonomy for the td sync system.
The event taxonomy provides:
- Canonical entity and action types
- Backward-compatible normalization of singular/plural entity names
- Mapping of legacy td action types to canonical sync action types
- Validation of entity+action combinations
Backward Compatibility ¶
The taxonomy is designed to accept both singular and plural forms of entity type names:
- 'issue' and 'issues' both normalize to EntityIssues
- 'board' and 'boards' both normalize to EntityBoards
- And so on for all entity types
This ensures clients can send events using either old or new naming conventions without breaking. The API and sync engine internally normalize to the canonical plural forms.
Legacy action types used by the td action_log are automatically mapped to canonical sync types:
- 'handoff' → 'create'
- 'add_dependency' → 'create'
- 'link_file' → 'create'
- 'board_create', 'board_update', 'board_add_issue', 'board_set_position' → 'create'
- 'work_session_tag' → 'create'
- 'remove_dependency', 'unlink_file', 'board_delete', 'work_session_untag' → 'delete'
- 'delete', 'board_unposition', 'board_remove_issue', 'soft_delete' → 'soft_delete'
- 'restore' → 'restore'
- Others default to 'update'
This mapping ensures existing events in the events table with old action/entity types can be queried and processed correctly by the sync engine.
Index ¶
- func AllActionTypes() map[ActionType]bool
- func AllEntityTypes() map[EntityType]bool
- func IsValidActionType(at string) bool
- func IsValidEntityActionCombination(entity EntityType, action ActionType) bool
- func IsValidEntityType(et string) bool
- func ValidEntityActionCombinations() map[EntityType]map[ActionType]bool
- type ActionType
- type EntityType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllActionTypes ¶
func AllActionTypes() map[ActionType]bool
AllActionTypes returns all valid action types.
func AllEntityTypes ¶
func AllEntityTypes() map[EntityType]bool
AllEntityTypes returns all valid entity types.
func IsValidActionType ¶
IsValidActionType checks if the given action type string is valid.
func IsValidEntityActionCombination ¶
func IsValidEntityActionCombination(entity EntityType, action ActionType) bool
IsValidEntityActionCombination checks if an entity type can have a given action type.
func IsValidEntityType ¶
IsValidEntityType checks if the given entity type string is valid.
func ValidEntityActionCombinations ¶
func ValidEntityActionCombinations() map[EntityType]map[ActionType]bool
ValidEntityActionCombinations defines which entity types can have which action types. Used for validation and semantic checking.
Types ¶
type ActionType ¶
type ActionType string
ActionType represents the canonical action types for events.
const ( ActionCreate ActionType = "create" ActionUpdate ActionType = "update" ActionDelete ActionType = "delete" ActionSoftDelete ActionType = "soft_delete" ActionRestore ActionType = "restore" )
Canonical action types
func NormalizeActionType ¶
func NormalizeActionType(tdAction string) ActionType
NormalizeActionType normalizes an action type string to its canonical form. Maps td's internal action_log action types to canonical sync event action types. Provides backward compatibility for legacy action naming conventions.
type EntityType ¶
type EntityType string
EntityType represents the canonical entity types in the sync system.
const ( EntityIssues EntityType = "issues" EntityLogs EntityType = "logs" EntityHandoffs EntityType = "handoffs" EntityComments EntityType = "comments" EntitySessions EntityType = "sessions" EntityBoards EntityType = "boards" EntityBoardIssuePositions EntityType = "board_issue_positions" EntityWorkSessions EntityType = "work_sessions" EntityWorkSessionIssues EntityType = "work_session_issues" EntityIssueFiles EntityType = "issue_files" EntityIssueDependencies EntityType = "issue_dependencies" EntityGitSnapshots EntityType = "git_snapshots" EntityIssueSessionHistory EntityType = "issue_session_history" EntityNotes EntityType = "notes" )
Canonical entity types
func NormalizeEntityType ¶
func NormalizeEntityType(entityType string) (EntityType, bool)
NormalizeEntityType normalizes an entity type string to its canonical form. Returns the canonical entity type and true if valid, or empty string and false if invalid. Handles both singular and plural forms for backward compatibility.