(entry)
| 64 | } |
| 65 | |
| 66 | function validateHookTimingEvent(entry) { |
| 67 | const errors = []; |
| 68 | |
| 69 | if (!entry || typeof entry !== 'object') { |
| 70 | return { valid: false, errors: ['entry must be an object'] }; |
| 71 | } |
| 72 | |
| 73 | if (typeof entry.timestamp !== 'string' || !entry.timestamp) { |
| 74 | errors.push('timestamp must be a non-empty string (ISO 8601)'); |
| 75 | } |
| 76 | |
| 77 | if (typeof entry.hook !== 'string' || !entry.hook) { |
| 78 | errors.push('hook must be a non-empty string'); |
| 79 | } |
| 80 | |
| 81 | if (entry.event !== undefined && !HOOK_TIMING_EVENT_TYPES.includes(entry.event)) { |
| 82 | errors.push(`event must be one of: ${HOOK_TIMING_EVENT_TYPES.join(', ')} — got: ${entry.event}`); |
| 83 | } |
| 84 | |
| 85 | if (entry.metric !== null && entry.metric !== undefined && typeof entry.metric !== 'string') { |
| 86 | errors.push('metric must be a string or null'); |
| 87 | } |
| 88 | |
| 89 | if (entry.duration_ms !== null && entry.duration_ms !== undefined && typeof entry.duration_ms !== 'number') { |
| 90 | errors.push('duration_ms must be a number or null'); |
| 91 | } |
| 92 | |
| 93 | return { valid: errors.length === 0, errors }; |
| 94 | } |
| 95 | |
| 96 | function validateSessionCostEvent(entry) { |
| 97 | const errors = []; |
no outgoing calls
no test coverage detected