export type ResultSuccess = { success: true; data: T; }; export type ResultFailure = { success: false; error: string; context?: any; }; export type Result = ResultSuccess | ResultFailure; export function isSuccess(result: Result): result is ResultSuccess { return result.success; } export function isError(result: Result): result is ResultFailure { return !result.success; }