UNPKG

@sudowealth/schwab-api

Version:

TypeScript client for Charles Schwab API with OAuth support, market data, trading functionality, and complete type safety

74 lines (73 loc) 1.99 kB
/** * Metadata structure for communication between middleware components * This information is carried along with requests and responses to coordinate actions */ interface MiddlewareMetadata { /** * Rate limit information */ rateLimit?: { /** * Whether the request has been queued by rate limit middleware */ wasQueued?: boolean; /** * Remaining requests in the current window */ remaining?: number; /** * When the rate limit window will reset (epoch ms) */ resetAt?: number; /** * Maximum requests allowed per window */ limit?: number; }; /** * Retry information */ retry?: { /** * Whether this is a retry attempt */ isRetry?: boolean; /** * Current attempt number (1-based) */ attemptNumber?: number; /** * Maximum number of attempts (including the initial attempt) */ maxAttempts?: number; /** * Whether the rate limit middleware should be skipped for this retry * Used to avoid double-queueing when retrying rate-limited requests */ skipRateLimit?: boolean; }; /** * Authentication information */ auth?: { /** * Whether the token was refreshed for this request */ tokenRefreshed?: boolean; }; /** * Custom metadata for extension middleware */ [key: string]: any; } /** * Gets middleware metadata from a Request or Response * Creates an empty object if no metadata exists yet */ export declare function getMetadata(obj: Request | Response): MiddlewareMetadata; /** * Creates a new Request with the metadata from the original * Useful when you need to clone a request but maintain its metadata */ export declare function cloneRequestWithMetadata(req: Request): Request; export {};