@ritas-inc/hanaqueryapi-client
Version:
TypeScript client for HANA Query API with full type safety and error handling
46 lines • 1.67 kB
TypeScript
/**
* Response Helper Functions
*
* Utility functions for safely handling API responses
*/
import type { APIResponse, SuccessResponse, ErrorResponse } from './types.ts';
/**
* Safely extract data from an API response
* Returns the data if successful, or null if error
*/
export declare function safeExtractData<T, M>(response: APIResponse<T, M>): T | null;
/**
* Safely extract metadata from an API response
* Returns the metadata if successful, or null if error
*/
export declare function safeExtractMetadata<T, M>(response: APIResponse<T, M>): M | null;
/**
* Get error details from a response
* Returns error details if it's an error response, null otherwise
*/
export declare function getErrorDetails(response: APIResponse): ErrorResponse['problem'] | null;
/**
* Check if response indicates success
*/
export declare function isSuccess<T, M>(response: APIResponse<T, M>): response is SuccessResponse<T, M>;
/**
* Check if response indicates error
*/
export declare function isError(response: APIResponse): response is ErrorResponse;
/**
* Transform response data safely
* Applies transform function only if response is successful
*/
export declare function transformResponseData<T, R, M>(response: APIResponse<T, M>, transform: (data: T) => R): APIResponse<R, M>;
/**
* Combine multiple responses into a single result
* All responses must be successful for the result to be successful
*/
export declare function combineResponses<T1, T2, M1, M2>(response1: APIResponse<T1, M1>, response2: APIResponse<T2, M2>): APIResponse<{
first: T1;
second: T2;
}, {
first: M1;
second: M2;
}>;
//# sourceMappingURL=response-helpers.d.ts.map