1313 * @public
1414 */
1515export interface LoggingConfig {
16+
1617 /** Enable or disable logging */
17- enabled : boolean
18+ "enabled" : boolean ;
19+
1820 /** Minimum log level to output */
19- level : "debug" | "info" | "warn" | "error"
21+ "level" : "debug" | "info" | "warn" | "error" ;
22+
2023 /** Custom logger function (optional) */
21- logger ?: ( level : string , message : string , meta ?: Record < string , unknown > ) => void
24+ " logger" ?: ( level : string , message : string , meta ?: Record < string , unknown > ) => void ;
2225}
2326
2427/**
@@ -27,12 +30,15 @@ export interface LoggingConfig {
2730 * @public
2831 */
2932export interface PaginationConfig {
33+
3034 /** Default page size for paginated requests */
31- defaultLimit : number
35+ "defaultLimit" : number ;
36+
3237 /** Maximum page size allowed */
33- maxLimit : number
38+ "maxLimit" : number ;
39+
3440 /** Enable automatic pagination */
35- autoPaginate : boolean
41+ " autoPaginate" : boolean ;
3642}
3743
3844/**
@@ -41,18 +47,24 @@ export interface PaginationConfig {
4147 * @public
4248 */
4349export interface RetryConfig {
50+
4451 /** Enable automatic retries on failure */
45- enabled : boolean
52+ "enabled" : boolean ;
53+
4654 /** Maximum number of retry attempts */
47- maxAttempts : number
55+ "maxAttempts" : number ;
56+
4857 /** Backoff strategy for retries */
49- backoff : "linear" | "exponential"
58+ "backoff" : "linear" | "exponential" ;
59+
5060 /** Initial delay between retries (milliseconds) */
51- initialDelay : number
61+ "initialDelay" : number ;
62+
5263 /** Maximum delay between retries (milliseconds) */
53- maxDelay : number
64+ "maxDelay" : number ;
65+
5466 /** HTTP status codes that should trigger a retry */
55- retryableStatusCodes : number [ ]
67+ " retryableStatusCodes" : number [ ] ;
5668}
5769
5870/**
@@ -61,14 +73,18 @@ export interface RetryConfig {
6173 * @public
6274 */
6375export interface RateLimitConfig {
76+
6477 /** Enable built-in rate limiting */
65- enabled : boolean
78+ "enabled" : boolean ;
79+
6680 /** Maximum requests per minute */
67- requestsPerMinute : number
81+ "requestsPerMinute" : number ;
82+
6883 /** Maximum concurrent requests */
69- concurrentRequests : number
84+ "concurrentRequests" : number ;
85+
7086 /** Behavior when rate limit is hit */
71- onLimitReached : "throw" | "queue" | "drop"
87+ " onLimitReached" : "throw" | "queue" | "drop" ;
7288}
7389
7490/**
@@ -77,14 +93,18 @@ export interface RateLimitConfig {
7793 * @public
7894 */
7995export interface CacheConfig {
96+
8097 /** Enable caching */
81- enabled : boolean
98+ "enabled" : boolean ;
99+
82100 /** Default cache TTL in milliseconds */
83- defaultTTL : number
101+ "defaultTTL" : number ;
102+
84103 /** Maximum cache size (number of entries) */
85- maxSize : number
104+ "maxSize" : number ;
105+
86106 /** Cache key prefix */
87- keyPrefix : string
107+ " keyPrefix" : string ;
88108}
89109
90110/**
@@ -93,16 +113,21 @@ export interface CacheConfig {
93113 * @public
94114 */
95115export interface TrotskyConfig {
116+
96117 /** Logging configuration */
97- logging : LoggingConfig
118+ "logging" : LoggingConfig ;
119+
98120 /** Pagination configuration */
99- pagination : PaginationConfig
121+ "pagination" : PaginationConfig ;
122+
100123 /** Retry configuration */
101- retry : RetryConfig
124+ "retry" : RetryConfig ;
125+
102126 /** Rate limiting configuration */
103- rateLimit : RateLimitConfig
127+ "rateLimit" : RateLimitConfig ;
128+
104129 /** Caching configuration */
105- cache : CacheConfig
130+ " cache" : CacheConfig ;
106131}
107132
108133/**
@@ -122,34 +147,34 @@ export type PartialTrotskyConfig = {
122147 * @public
123148 */
124149export const defaultConfig : TrotskyConfig = {
125- logging : {
126- enabled : false ,
127- level : "info"
150+ " logging" : {
151+ " enabled" : false ,
152+ " level" : "info"
128153 } ,
129- pagination : {
130- defaultLimit : 50 ,
131- maxLimit : 100 ,
132- autoPaginate : true
154+ " pagination" : {
155+ " defaultLimit" : 50 ,
156+ " maxLimit" : 100 ,
157+ " autoPaginate" : true
133158 } ,
134- retry : {
135- enabled : true ,
136- maxAttempts : 3 ,
137- backoff : "exponential" ,
138- initialDelay : 1000 ,
139- maxDelay : 30000 ,
140- retryableStatusCodes : [ 408 , 429 , 500 , 502 , 503 , 504 ]
159+ " retry" : {
160+ " enabled" : true ,
161+ " maxAttempts" : 3 ,
162+ " backoff" : "exponential" ,
163+ " initialDelay" : 1000 ,
164+ " maxDelay" : 30000 ,
165+ " retryableStatusCodes" : [ 408 , 429 , 500 , 502 , 503 , 504 ]
141166 } ,
142- rateLimit : {
143- enabled : false ,
144- requestsPerMinute : 60 ,
145- concurrentRequests : 10 ,
146- onLimitReached : "queue"
167+ " rateLimit" : {
168+ " enabled" : false ,
169+ " requestsPerMinute" : 60 ,
170+ " concurrentRequests" : 10 ,
171+ " onLimitReached" : "queue"
147172 } ,
148- cache : {
149- enabled : false ,
150- defaultTTL : 60000 , // 1 minute
151- maxSize : 1000 ,
152- keyPrefix : "trotsky:"
173+ " cache" : {
174+ " enabled" : false ,
175+ " defaultTTL" : 60000 , // 1 minute
176+ " maxSize" : 1000 ,
177+ " keyPrefix" : "trotsky:"
153178 }
154179}
155180
@@ -174,10 +199,10 @@ export function mergeConfig (config?: PartialTrotskyConfig): TrotskyConfig {
174199 }
175200
176201 return {
177- logging : { ...defaultConfig . logging , ...config . logging } ,
178- pagination : { ...defaultConfig . pagination , ...config . pagination } ,
179- retry : { ...defaultConfig . retry , ...config . retry } ,
180- rateLimit : { ...defaultConfig . rateLimit , ...config . rateLimit } ,
181- cache : { ...defaultConfig . cache , ...config . cache }
202+ " logging" : { ...defaultConfig . logging , ...config . logging } ,
203+ " pagination" : { ...defaultConfig . pagination , ...config . pagination } ,
204+ " retry" : { ...defaultConfig . retry , ...config . retry } ,
205+ " rateLimit" : { ...defaultConfig . rateLimit , ...config . rateLimit } ,
206+ " cache" : { ...defaultConfig . cache , ...config . cache }
182207 }
183208}
0 commit comments