@stanfordspezi/spezi-web-design-system
Version:
Stanford Biodesign Digital Health Spezi Web Design System
44 lines (43 loc) • 1.3 kB
TypeScript
/**
* Minimal representation of a query state. Matches Tanstack Query result.
*/
export interface Query {
isLoading?: boolean;
isError?: boolean;
isSuccess?: boolean;
}
/**
* Combines multiple query states into a single aggregated state.
*
* @returns Combined query state where:
* - `isLoading` is true if any query is loading
* - `isError` is true if any query has an error
* - `isSuccess` is true only if all queries are successful
*
* @example
* ```ts
* const combinedState = combineQueries([
* { isLoading: true },
* { isSuccess: true }
* ]);
* // Result: { isLoading: true, isError: false, isSuccess: false }
* ```
*/
export declare const combineQueries: (queries: Query[]) => {
isLoading: boolean;
isError: boolean;
isSuccess: boolean;
};
/**
* Parses an unknown error into a string message.
* Handles various error formats including Error objects and plain strings.
*
* @example
* ```ts
* parseUnknownError(new Error("Something went wrong")); // "Something went wrong"
* parseUnknownError("Custom error message"); // "Custom error message"
* parseUnknownError({ message: "Object error" }); // "Object error"
* parseUnknownError({}); // "Unknown error happened"
* ```
*/
export declare const parseUnknownError: (error: unknown) => string;