Alokai

Integration

interface Integration<CONFIG extends TObject = any, API extends ApiMethods = {}, CONTEXT extends TObject = any> {
	circuitBreaker?: {
    granularity?: CircuitBreakerGranularity;
    methods?: string[];
    preset: CircuitBreakerPreset;
  };
	configuration: CONFIG;
	customQueries?: Record<string, CustomQueryFunction>;
	errorHandler?: ErrorHandler;
	extensions?: (extensions: ApiClientExtension<API, CONTEXT, CONFIG>[]) => ApiClientExtension<API, CONTEXT, CONFIG>[];
	initConfig?: TObject;
	location: string;
	logger?: LoggerOptions;
	retry?: boolean | RetryConfig;
}

Properties

NameRequiredTypeDescription
circuitBreakerOptional{ granularity?: CircuitBreakerGranularity; methods?: string[]; preset: CircuitBreakerPreset; }Circuit breaker configuration for this integration. When to use: Define this when you need to customize circuit breaker behavior for this specific integration. The CB_<INTEGRATION>_PRESET and CB_PRESET environment variables take priority over preset. Available presets: - BALANCED - Moderate settings for most backends, 20s timeout (default) - AGGRESSIVE - Strict settings for fast failure detection, 5s timeout - FAST_FAILURE - Short timeout for latency-sensitive flows, 3s timeout - HARD_FAIL - Trips after very few failures, 2s timeout - TOLERANT - Lenient settings for legacy or slow backends, 60s timeout - RELAXED_DEBUG - High tolerance for debugging, 30s timeout - EXTREME_DEBUG - Almost never trips, 120s timeout (blocked in production)
configurationRequiredCONFIG
customQueriesOptionalRecord<string, CustomQueryFunction>
errorHandlerOptionalErrorHandlerIntegration-specific error handler. When to use: Define this when you need custom error handling for this specific integration only. This handler has the highest priority and will override any global error handler defined in middleware.config.ts. Priority: Integration-specific > Global > Built-in default
extensionsOptional(extensions: ApiClientExtension<API, CONTEXT, CONFIG>[]) => ApiClientExtension<API, CONTEXT, CONFIG>[]
initConfigOptionalTObject
locationRequiredstring
loggerOptionalLoggerOptions
retryOptionalboolean | RetryConfigRetry transient failures (502/503/504/408/429 and normalized network errors). Off by default. - true - enable with the default policy (2 retries, randomized exponential backoff). - object - override retries, retryCondition, and/or retryDelay. - false / omitted - no retries.

Referenced Types

On this page