Skip to content

Commit 38ba8d0

Browse files
committed
refactor: lint
1 parent 1924569 commit 38ba8d0

File tree

9 files changed

+184
-109
lines changed

9 files changed

+184
-109
lines changed

lib/config/TrotskyConfig.ts

Lines changed: 79 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313
* @public
1414
*/
1515
export 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
*/
2932
export 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
*/
4349
export 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
*/
6375
export 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
*/
7995
export 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
*/
95115
export 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
*/
124149
export 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
}

lib/errors/AuthenticationError.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import { TrotskyError } from "./TrotskyError"
2020

2121
export class AuthenticationError extends TrotskyError {
22+
2223
/**
2324
* Creates a new AuthenticationError.
2425
*
@@ -44,14 +45,19 @@ export class AuthenticationError extends TrotskyError {
4445
* @public
4546
*/
4647
export const AuthenticationErrorCode = {
48+
4749
/** Authentication is required but not provided */
48-
AUTH_REQUIRED: "AUTH_REQUIRED",
50+
"AUTH_REQUIRED": "AUTH_REQUIRED",
51+
4952
/** Provided credentials are invalid */
50-
INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
53+
"INVALID_CREDENTIALS": "INVALID_CREDENTIALS",
54+
5155
/** Session has expired */
52-
SESSION_EXPIRED: "SESSION_EXPIRED",
56+
"SESSION_EXPIRED": "SESSION_EXPIRED",
57+
5358
/** User lacks permission for this operation */
54-
FORBIDDEN: "FORBIDDEN",
59+
"FORBIDDEN": "FORBIDDEN",
60+
5561
/** Agent is not authenticated */
56-
NOT_AUTHENTICATED: "NOT_AUTHENTICATED"
62+
"NOT_AUTHENTICATED": "NOT_AUTHENTICATED"
5763
} as const

lib/errors/PaginationError.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import { TrotskyError } from "./TrotskyError"
2020

2121
export class PaginationError extends TrotskyError {
22+
2223
/**
2324
* Creates a new PaginationError.
2425
*
@@ -44,14 +45,19 @@ export class PaginationError extends TrotskyError {
4445
* @public
4546
*/
4647
export const PaginationErrorCode = {
48+
4749
/** Cursor is invalid or malformed */
48-
INVALID_CURSOR: "INVALID_CURSOR",
50+
"INVALID_CURSOR": "INVALID_CURSOR",
51+
4952
/** Cursor has expired */
50-
CURSOR_EXPIRED: "CURSOR_EXPIRED",
53+
"CURSOR_EXPIRED": "CURSOR_EXPIRED",
54+
5155
/** Failed to fetch next page */
52-
FETCH_FAILED: "FETCH_FAILED",
56+
"FETCH_FAILED": "FETCH_FAILED",
57+
5358
/** Limit parameter is invalid */
54-
INVALID_LIMIT: "INVALID_LIMIT",
59+
"INVALID_LIMIT": "INVALID_LIMIT",
60+
5561
/** No more pages available */
56-
NO_MORE_PAGES: "NO_MORE_PAGES"
62+
"NO_MORE_PAGES": "NO_MORE_PAGES"
5763
} as const

lib/errors/RateLimitError.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import { TrotskyError } from "./TrotskyError"
2121

2222
export class RateLimitError extends TrotskyError {
23+
2324
/**
2425
* Number of seconds until rate limit resets (if known).
2526
*/
@@ -65,12 +66,16 @@ export class RateLimitError extends TrotskyError {
6566
* @public
6667
*/
6768
export const RateLimitErrorCode = {
69+
6870
/** API rate limit exceeded */
69-
RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED",
71+
"RATE_LIMIT_EXCEEDED": "RATE_LIMIT_EXCEEDED",
72+
7073
/** Too many requests */
71-
TOO_MANY_REQUESTS: "TOO_MANY_REQUESTS",
74+
"TOO_MANY_REQUESTS": "TOO_MANY_REQUESTS",
75+
7276
/** Daily quota exceeded */
73-
QUOTA_EXCEEDED: "QUOTA_EXCEEDED",
77+
"QUOTA_EXCEEDED": "QUOTA_EXCEEDED",
78+
7479
/** Concurrent request limit exceeded */
75-
CONCURRENT_LIMIT: "CONCURRENT_LIMIT"
80+
"CONCURRENT_LIMIT": "CONCURRENT_LIMIT"
7681
} as const

lib/errors/TrotskyError.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @public
1717
*/
1818
export class TrotskyError extends Error {
19+
1920
/**
2021
* Error code for programmatic handling.
2122
*/

lib/errors/ValidationError.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import { TrotskyError } from "./TrotskyError"
2121

2222
export class ValidationError extends TrotskyError {
23+
2324
/**
2425
* Additional validation details (field names, values, etc.).
2526
*/
@@ -65,16 +66,22 @@ export class ValidationError extends TrotskyError {
6566
* @public
6667
*/
6768
export const ValidationErrorCode = {
69+
6870
/** URI is invalid or malformed */
69-
INVALID_URI: "INVALID_URI",
71+
"INVALID_URI": "INVALID_URI",
72+
7073
/** Parameter is missing */
71-
MISSING_PARAM: "MISSING_PARAM",
74+
"MISSING_PARAM": "MISSING_PARAM",
75+
7276
/** Parameter value is invalid */
73-
INVALID_PARAM: "INVALID_PARAM",
77+
"INVALID_PARAM": "INVALID_PARAM",
78+
7479
/** Parameter type is incorrect */
75-
INVALID_TYPE: "INVALID_TYPE",
80+
"INVALID_TYPE": "INVALID_TYPE",
81+
7682
/** Parameter value is out of range */
77-
OUT_OF_RANGE: "OUT_OF_RANGE",
83+
"OUT_OF_RANGE": "OUT_OF_RANGE",
84+
7885
/** Required field is missing */
79-
REQUIRED_FIELD: "REQUIRED_FIELD"
86+
"REQUIRED_FIELD": "REQUIRED_FIELD"
8087
} as const

0 commit comments

Comments
 (0)