UNPKG

@dbs-portal/core-api

Version:

HTTP client and API utilities for DBS Portal

88 lines 2.67 kB
/** * MSW response building utilities */ import type { ApiResponse, ApiError } from '@dbs-portal/core-shared'; import type { MockResponseBuilder } from '../types'; /** * Create a mock HTTP response from API response data */ export declare function createMockResponse<T = any>(apiResponse: ApiResponse<T>, options?: { status?: number; headers?: Record<string, string>; }): Response; /** * Create a success response */ export declare function createSuccessResponse<T = any>(data: T, message?: string, options?: { status?: number; headers?: Record<string, string>; meta?: Record<string, any>; }): Response; /** * Create an error response */ export declare function createErrorResponse(error: ApiError | string, options?: { status?: number; headers?: Record<string, string>; meta?: Record<string, any>; }): Response; /** * Create a validation error response */ export declare function createValidationErrorResponse(errors: Array<{ field: string; message: string; code?: string; }>, options?: { status?: number; headers?: Record<string, string>; meta?: Record<string, any>; }): Response; /** * Create a not found response */ export declare function createNotFoundResponse(resource?: string, options?: { headers?: Record<string, string>; meta?: Record<string, any>; }): Response; /** * Create an unauthorized response */ export declare function createUnauthorizedResponse(message?: string, options?: { headers?: Record<string, string>; meta?: Record<string, any>; }): Response; /** * Create a forbidden response */ export declare function createForbiddenResponse(message?: string, options?: { headers?: Record<string, string>; meta?: Record<string, any>; }): Response; /** * Create a server error response */ export declare function createServerErrorResponse(message?: string, options?: { headers?: Record<string, string>; meta?: Record<string, any>; }): Response; /** * Mock response builder class */ export declare class MockResponseBuilderImpl<T = any> implements MockResponseBuilder<T> { private responseData; private statusCode; private responseHeaders; private responseError; data(data: T): MockResponseBuilder<T>; status(code: number): MockResponseBuilder<T>; headers(headers: Record<string, string>): MockResponseBuilder<T>; delay(_ms: number | [number, number]): MockResponseBuilder<T>; error(error: ApiError): MockResponseBuilder<T>; build(): Response; } /** * Create a response builder */ export declare function createResponseBuilder<T = any>(): MockResponseBuilder<T>; //# sourceMappingURL=response-builder.d.ts.map