|
| 1 | +// Event metadata for webhook events |
| 2 | +// Maps technical event names to human-friendly names and descriptions |
| 3 | + |
| 4 | +export interface EventMetadata { |
| 5 | + displayName: string; |
| 6 | + description: string; |
| 7 | +} |
| 8 | + |
| 9 | +export const EVENT_METADATA: Record<string, EventMetadata> = { |
| 10 | + // Simulator Events |
| 11 | + 'TPS.Simulator.ChangePlayer': { |
| 12 | + displayName: 'Change Player', |
| 13 | + description: 'Player has been switched or changed in the simulator session', |
| 14 | + }, |
| 15 | + 'TPS.Simulator.HoleCompleted': { |
| 16 | + displayName: 'Hole Completed', |
| 17 | + description: 'Player has finished playing the current hole', |
| 18 | + }, |
| 19 | + 'TPS.Simulator.ShotStarting': { |
| 20 | + displayName: 'Shot Starting', |
| 21 | + description: 'A shot is about to be taken', |
| 22 | + }, |
| 23 | + 'TPS.Simulator.ShotFinish': { |
| 24 | + displayName: 'Shot Finished', |
| 25 | + description: 'Shot has been completed with final trajectory data', |
| 26 | + }, |
| 27 | + 'TPS.Simulator.SessionStarted': { |
| 28 | + displayName: 'Session Started', |
| 29 | + description: 'New simulator session has been initiated', |
| 30 | + }, |
| 31 | + 'TPS.Simulator.SessionEnded': { |
| 32 | + displayName: 'Session Ended', |
| 33 | + description: 'Simulator session has been terminated', |
| 34 | + }, |
| 35 | + |
| 36 | + // Live Events |
| 37 | + 'TPS.Live.OnStrokeCompletedEvent': { |
| 38 | + displayName: 'Stroke Completed', |
| 39 | + description: 'Ball strike has been detected and measured', |
| 40 | + }, |
| 41 | + 'TPS.Live.OnStrokeConditionChanged': { |
| 42 | + displayName: 'Stroke Condition Changed', |
| 43 | + description: 'Shot condition or state has been modified', |
| 44 | + }, |
| 45 | + 'TPS.Live.OnBallLandedEvent': { |
| 46 | + displayName: 'Ball Landed', |
| 47 | + description: 'Ball has landed and final position recorded', |
| 48 | + }, |
| 49 | + 'TPS.Live.OnCameraImageReceivedEvent': { |
| 50 | + displayName: 'Camera Image Received', |
| 51 | + description: 'Image captured from camera system', |
| 52 | + }, |
| 53 | + |
| 54 | + // Session Events |
| 55 | + 'TPS.SessionInfo': { |
| 56 | + displayName: 'Session Info', |
| 57 | + description: 'Session information and configuration data', |
| 58 | + }, |
| 59 | + 'TPS.SessionStarted': { |
| 60 | + displayName: 'Session Started', |
| 61 | + description: 'New practice or play session has begun', |
| 62 | + }, |
| 63 | + 'TPS.SessionEnded': { |
| 64 | + displayName: 'Session Ended', |
| 65 | + description: 'Session has been completed or terminated', |
| 66 | + }, |
| 67 | + |
| 68 | + // Device Events |
| 69 | + 'TPS.Device.Connected': { |
| 70 | + displayName: 'Device Connected', |
| 71 | + description: 'Device has successfully connected to the system', |
| 72 | + }, |
| 73 | + 'TPS.Device.Disconnected': { |
| 74 | + displayName: 'Device Disconnected', |
| 75 | + description: 'Device has been disconnected from the system', |
| 76 | + }, |
| 77 | + 'TPS.Device.StatusUpdate': { |
| 78 | + displayName: 'Device Status', |
| 79 | + description: 'Device status information has been updated', |
| 80 | + }, |
| 81 | + |
| 82 | + // Club Events |
| 83 | + 'TPS.ClubRecognized': { |
| 84 | + displayName: 'Club Recognized', |
| 85 | + description: 'Golf club type has been identified', |
| 86 | + }, |
| 87 | + 'TPS.ClubChanged': { |
| 88 | + displayName: 'Club Changed', |
| 89 | + description: 'Player has switched to a different club', |
| 90 | + }, |
| 91 | + |
| 92 | + // Course Events |
| 93 | + 'TPS.CourseLoaded': { |
| 94 | + displayName: 'Course Loaded', |
| 95 | + description: 'Golf course data has been loaded into the system', |
| 96 | + }, |
| 97 | + 'TPS.HoleChanged': { |
| 98 | + displayName: 'Hole Changed', |
| 99 | + description: 'Player has moved to a different hole', |
| 100 | + }, |
| 101 | + |
| 102 | + // Error Events |
| 103 | + 'TPS.Error': { |
| 104 | + displayName: 'Error', |
| 105 | + description: 'An error has occurred in the system', |
| 106 | + }, |
| 107 | + 'TPS.Warning': { |
| 108 | + displayName: 'Warning', |
| 109 | + description: 'A warning condition has been detected', |
| 110 | + }, |
| 111 | +}; |
| 112 | + |
| 113 | +/** |
| 114 | + * Get friendly display name for an event type |
| 115 | + * Falls back to original name if not found in metadata |
| 116 | + */ |
| 117 | +export function getEventDisplayName(eventType: string): string { |
| 118 | + return EVENT_METADATA[eventType]?.displayName || eventType; |
| 119 | +} |
| 120 | + |
| 121 | +/** |
| 122 | + * Get description for an event type |
| 123 | + * Returns null if not found |
| 124 | + */ |
| 125 | +export function getEventDescription(eventType: string): string | null { |
| 126 | + return EVENT_METADATA[eventType]?.description || null; |
| 127 | +} |
| 128 | + |
| 129 | +/** |
| 130 | + * Check if an event has metadata |
| 131 | + */ |
| 132 | +export function hasEventMetadata(eventType: string): boolean { |
| 133 | + return eventType in EVENT_METADATA; |
| 134 | +} |
0 commit comments