UNPKG

@ritas-inc/hanaqueryapi-client

Version:

TypeScript client for HANA Query API with full type safety and error handling

158 lines 4.87 kB
/** * HANA Query API Client - Configuration * * Default configuration and environment-specific settings for the API client. */ import type { ClientConfig } from './types.ts'; /** * Default client configuration (excluding baseUrl which is required) */ export declare const DEFAULT_CONFIG: { timeout: number; retries: number; retryDelay: number; enableLogging: boolean; logLevel: "info"; headers: { 'Content-Type': string; Accept: string; }; }; /** * Environment-specific configurations */ export declare const ENVIRONMENT_CONFIGS: Record<string, ClientConfig>; /** * API version and paths */ export declare const API_VERSION = "v1"; export declare const API_BASE_PATH = "/api/v1"; /** * Endpoint paths */ export declare const ENDPOINTS: { readonly HEALTH: "/health"; readonly DOCS: "/docs"; readonly ITEMS: "/items"; readonly ITEMS_GROUPS: "/items/groups"; readonly ITEMS_HIERARCHIES: "/items/hierarchies"; readonly ITEMS_TREES: "/items/trees"; readonly SALES: "/sales"; readonly PRODUCTION_SECTORS: "/production-sectors"; readonly PLANS: "/plans"; readonly ALL_PLANS_SECTORS: "/plans/sectors"; readonly PLAN_DETAIL: "/plans/{planId}"; readonly PLAN_PRODUCTS: "/plans/{planId}/products"; readonly PLAN_WORK_ORDERS: "/plans/{planId}/work-orders"; readonly PLAN_SECTORS: "/plans/{planId}/sectors"; readonly USER: "/users/{username}"; }; /** * HTTP status codes */ export declare const HTTP_STATUS: { readonly OK: 200; readonly BAD_REQUEST: 400; readonly UNAUTHORIZED: 401; readonly FORBIDDEN: 403; readonly NOT_FOUND: 404; readonly INTERNAL_SERVER_ERROR: 500; readonly BAD_GATEWAY: 502; readonly SERVICE_UNAVAILABLE: 503; readonly GATEWAY_TIMEOUT: 504; }; /** * Request timeout configuration for different endpoint types */ export declare const ENDPOINT_TIMEOUTS: { readonly "/health": 5000; readonly "/docs": 5000; readonly "/plans": 15000; readonly "/plans/sectors": 30000; readonly "/plans/{planId}": 10000; readonly "/plans/{planId}/products": 10000; readonly "/plans/{planId}/work-orders": 10000; readonly "/plans/{planId}/sectors": 15000; readonly "/users/{username}": 10000; readonly "/items": 60000; readonly "/sales": 60000; readonly "/items/hierarchies": 90000; readonly "/items/trees": 90000; }; /** * Retry configuration for different error types */ export declare const RETRY_CONFIG: { readonly network: { readonly enabled: true; readonly maxAttempts: 3; readonly baseDelay: 1000; readonly maxDelay: 10000; readonly backoffMultiplier: 2; }; readonly timeout: { readonly enabled: true; readonly maxAttempts: 2; readonly baseDelay: 2000; readonly maxDelay: 15000; readonly backoffMultiplier: 2; }; readonly server: { readonly enabled: true; readonly maxAttempts: 2; readonly baseDelay: 3000; readonly maxDelay: 20000; readonly backoffMultiplier: 2; }; readonly client: { readonly enabled: false; readonly maxAttempts: 1; readonly baseDelay: 0; readonly maxDelay: 0; readonly backoffMultiplier: 1; }; }; /** * Header names used by the API */ export declare const HEADERS: { readonly RESPONSE_TIME: "x-response-time"; readonly AUTHORIZATION_RESPONSE: "x-authorization-response"; readonly CONTENT_TYPE: "content-type"; }; /** * Authorization response values */ export declare const AUTH_STATUS: { readonly OK: "ok"; readonly UNAUTHORIZED: "unauthorized"; }; /** * Create a configuration by merging defaults with environment-specific and custom options */ export declare function createConfig(baseConfig: ClientConfig, customConfig?: Partial<Omit<ClientConfig, 'baseUrl'>>): Required<ClientConfig>; /** * Create a configuration from environment and custom options */ export declare function createConfigFromEnvironment(environment: string, customConfig?: Partial<ClientConfig>): Required<ClientConfig>; /** * Get timeout for a specific endpoint */ export declare function getEndpointTimeout(endpoint: string, defaultTimeout: number): number; /** * Validate configuration */ export declare function validateConfig(config: ClientConfig): string[]; /** * Get the full API URL for an endpoint */ export declare function getApiUrl(baseUrl: string, endpoint: string): string; /** * Replace path parameters in endpoint URLs */ export declare function replacePathParams(endpoint: string, params: Record<string, string | number>): string; /** * Build query string from parameters */ export declare function buildQueryString(params: Record<string, string | number | boolean | undefined>): string; //# sourceMappingURL=config.d.ts.map