@dbs-portal/tool-mock
Version:
API mocking toolkit using MSW for DBS Portal development workflows
59 lines • 1.95 kB
TypeScript
/**
* Error simulation utilities
*/
import { HttpResponse } from 'msw';
import type { ErrorSimulationConfig } from '../core/types';
/**
* Simulate errors based on configuration
*/
export declare function simulateError(url: string, method: string, config?: ErrorSimulationConfig): Response | null;
/**
* Create custom error responses
*/
export declare const errorResponses: {
/**
* Create a validation error
*/
validation: (errors: string[] | Record<string, string[]>, message?: string) => HttpResponse<import("msw").JsonBodyType>;
/**
* Create an unauthorized error
*/
unauthorized: (message?: string) => HttpResponse<import("msw").JsonBodyType>;
/**
* Create a forbidden error
*/
forbidden: (message?: string) => HttpResponse<import("msw").JsonBodyType>;
/**
* Create a not found error
*/
notFound: (message?: string) => HttpResponse<import("msw").JsonBodyType>;
/**
* Create a conflict error
*/
conflict: (message?: string) => HttpResponse<import("msw").JsonBodyType>;
/**
* Create a rate limit error
*/
rateLimit: (message?: string, retryAfter?: number) => HttpResponse<import("msw").JsonBodyType>;
/**
* Create a server error
*/
serverError: (message?: string) => HttpResponse<import("msw").JsonBodyType>;
/**
* Create a custom error
*/
custom: (code: string, message: string, status: number, details?: any) => HttpResponse<import("msw").JsonBodyType>;
};
/**
* Error probability calculator
*/
export declare function calculateErrorProbability(baseRate: number, factors?: {
timeOfDay?: number;
dayOfWeek?: number;
load?: number;
}): number;
/**
* Create error simulation based on environment
*/
export declare function createEnvironmentErrorSimulation(environment: 'development' | 'testing' | 'staging' | 'production'): ErrorSimulationConfig;
//# sourceMappingURL=error.d.ts.map