@ritas-inc/hanaqueryapi-client
Version:
TypeScript client for HANA Query API with full type safety and error handling
187 lines • 6.28 kB
TypeScript
/**
* 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 ITEMS_QTY_PER_TAG: "/items/qty-per-tag";
readonly SALES: "/sales";
readonly PRODUCTION_SECTORS: "/production-sectors";
readonly DATABASE_COMPANIES: "/database-companies";
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 PLAN_TAGS: "/plans/{planId}/tags";
readonly USER: "/users/{username}";
readonly TAG: "/tags/{tagEntry}";
readonly WORK_ORDER_TAGS: "/work-orders/{workOrderEntry}/tags";
readonly INJECTION_MACHINES: "/injection-machines";
readonly INJECTION_MACHINE: "/injection-machines/{machineCode}";
readonly MOLDS: "/molds";
readonly MOLD: "/molds/{moldCode}";
readonly BUSINESS_PARTNERS: "/business-partners";
readonly BUSINESS_PARTNERS_SEARCH: "/business-partners/search";
readonly BUSINESS_PARTNER_CONTACTS: "/business-partners/{cardCode}/contacts";
readonly CONTACTS: "/contacts";
readonly CONTACTS_SEARCH: "/contacts/search";
};
/**
* 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 "/plans/{planId}/tags": 10000;
readonly "/users/{username}": 10000;
readonly "/database-companies": 5000;
readonly "/production-sectors": 5000;
readonly "/tags/{tagEntry}": 10000;
readonly "/work-orders/{workOrderEntry}/tags": 15000;
readonly "/injection-machines": 10000;
readonly "/injection-machines/{machineCode}": 10000;
readonly "/molds": 10000;
readonly "/molds/{moldCode}": 10000;
readonly "/items": 60000;
readonly "/sales": 60000;
readonly "/items/hierarchies": 90000;
readonly "/items/trees": 90000;
readonly "/items/qty-per-tag": 30000;
readonly "/business-partners": 60000;
readonly "/business-partners/search": 90000;
readonly "/business-partners/{cardCode}/contacts": 15000;
readonly "/contacts": 60000;
readonly "/contacts/search": 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