@sudowealth/schwab-api
Version:
TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety
63 lines (62 loc) • 2.13 kB
TypeScript
import { type EnhancedTokenManager } from '../auth/enhanced-token-manager';
import { type Middleware } from './compose';
import { type RateLimitOptions } from './with-rate-limit';
import { type RetryOptions } from './with-retry';
import { type TokenAuthOptions } from './with-token-auth';
/**
* Configuration options for the middleware pipeline
*/
export interface MiddlewarePipelineOptions {
/**
* Configuration for authentication middleware
* Only used if token is provided
*/
auth?: Omit<TokenAuthOptions, 'tokenManager'>;
/**
* Configuration for rate limit middleware
* Set to false to disable rate limiting
*/
rateLimit?: Partial<RateLimitOptions> | false;
/**
* Configuration for retry middleware
* Set to false to disable retry
*/
retry?: Partial<RetryOptions> | false;
/**
* List of middleware types to disable
* Example: ['rateLimit', 'retry']
*/
disable?: Array<'auth' | 'rateLimit' | 'retry'>;
/**
* Custom middleware to add at the end of the pipeline
* These will be executed in the order provided
*/
custom?: Middleware[];
/**
* Custom middleware to add at the beginning of the pipeline
* These will be executed in the order provided
*/
before?: Middleware[];
/**
* Custom middleware to add between specific middleware types
* Use this for more precise placement in the pipeline
*/
between?: {
/**
* Middleware to add after auth and before rate limiting
*/
authAndRateLimit?: Middleware[];
/**
* Middleware to add after rate limiting and before retry
*/
rateLimitAndRetry?: Middleware[];
};
}
/**
* Builds a middleware pipeline from the provided options and token
*
* @param options Pipeline configuration options
* @param token Authentication token or token manager
* @returns Array of middleware functions in execution order
*/
export declare function buildMiddlewarePipeline(options?: MiddlewarePipelineOptions, tokenManagerInstance?: EnhancedTokenManager): Middleware[];