@coderule/clients 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,12 @@
1
+ interface Logger {
2
+ error(message: string, ...meta: unknown[]): void;
3
+ warn(message: string, ...meta: unknown[]): void;
4
+ info(message: string, ...meta: unknown[]): void;
5
+ debug(message: string, ...meta: unknown[]): void;
6
+ }
7
+ declare const nullLogger: Logger;
8
+ declare const consoleLogger: Logger;
9
+
1
10
  interface AuthResponse {
2
11
  jwt: string;
3
12
  expires_at: string;
@@ -10,7 +19,8 @@ interface HealthResponse$2 {
10
19
  declare class AuthHttpClient {
11
20
  private baseUrl;
12
21
  private timeout;
13
- constructor(baseUrl: string, timeout?: number);
22
+ private readonly logger;
23
+ constructor(baseUrl: string, timeout?: number, logger?: Logger);
14
24
  authenticate(token: string): Promise<AuthResponse>;
15
25
  health(): Promise<HealthResponse$2>;
16
26
  close(): void;
@@ -21,7 +31,7 @@ interface JWTPayload {
21
31
  iat?: number;
22
32
  nbf?: number;
23
33
  }
24
- declare function decodeJWT(jwtToken: string): JWTPayload | null;
34
+ declare function decodeJWT(jwtToken: string, logger?: Logger): JWTPayload | null;
25
35
 
26
36
  interface JWTProvider {
27
37
  getJWT(forceRefresh?: boolean): Promise<string>;
@@ -34,6 +44,7 @@ interface TokenRefreshInfo {
34
44
  interface JWTFactoryOptions {
35
45
  minTtlMs?: number;
36
46
  onTokenRefreshed?: (info: TokenRefreshInfo) => void;
47
+ logger?: Logger;
37
48
  }
38
49
  declare class JWTFactory implements JWTProvider {
39
50
  private readonly authClient;
@@ -43,6 +54,7 @@ declare class JWTFactory implements JWTProvider {
43
54
  private readonly minTtlMs;
44
55
  private readonly onTokenRefreshed?;
45
56
  private currentServerUrl?;
57
+ private readonly logger;
46
58
  constructor(authClient: AuthHttpClient, sourceToken: string, options?: JWTFactoryOptions);
47
59
  setSourceToken(token: string): void;
48
60
  invalidate(): void;
@@ -55,16 +67,27 @@ declare class JWTFactory implements JWTProvider {
55
67
  getServerUrl(): string | undefined;
56
68
  }
57
69
 
70
+ interface SnapshotTimingMetrics {
71
+ pass1?: number;
72
+ pass2?: number;
73
+ gap?: number;
74
+ pass2db?: number;
75
+ total_files?: number;
76
+ total_chunks?: number;
77
+ total_classes?: number;
78
+ total_methods?: number;
79
+ }
58
80
  interface SnapshotStatus$1 {
59
81
  status: 'NOT_FOUND' | 'READY' | 'INDEXING' | 'PENDING' | 'FAILED' | 'MISSING_CONTENT';
60
82
  snapshot_hash?: string;
61
83
  created_at?: string;
62
- indexed_at?: string;
63
- total_files?: number;
84
+ updated_at?: string;
85
+ timing?: SnapshotTimingMetrics;
64
86
  missing_files?: Array<{
65
87
  file_path: string;
66
88
  file_hash: string;
67
89
  }>;
90
+ message?: string;
68
91
  [key: string]: any;
69
92
  }
70
93
  interface FileInfo {
@@ -86,13 +109,15 @@ interface SyncClientConfig {
86
109
  baseUrl?: string;
87
110
  timeout?: number;
88
111
  jwtProvider: JWTProvider;
112
+ logger?: Logger;
89
113
  }
90
114
  declare class SyncHttpClient {
91
115
  private baseUrl;
92
116
  private timeout;
93
117
  private apiBase;
94
118
  private readonly jwtProvider;
95
- constructor({ baseUrl, timeout, jwtProvider, }: SyncClientConfig);
119
+ private readonly logger;
120
+ constructor({ baseUrl, timeout, jwtProvider, logger, }: SyncClientConfig);
96
121
  updateBaseUrl(baseUrl: string): void;
97
122
  private configureBase;
98
123
  checkSnapshotStatus(snapshotHash: string): Promise<SnapshotStatus$1>;
@@ -145,13 +170,15 @@ interface RetrievalClientConfig {
145
170
  baseUrl?: string;
146
171
  timeout?: number;
147
172
  jwtProvider: JWTProvider;
173
+ logger?: Logger;
148
174
  }
149
175
  declare class RetrievalHttpClient {
150
176
  private baseUrl;
151
177
  private timeout;
152
178
  private apiBase;
153
179
  private readonly jwtProvider;
154
- constructor({ baseUrl, timeout, jwtProvider, }: RetrievalClientConfig);
180
+ private readonly logger;
181
+ constructor({ baseUrl, timeout, jwtProvider, logger, }: RetrievalClientConfig);
155
182
  updateBaseUrl(baseUrl: string): void;
156
183
  private configureBase;
157
184
  healthCheck(): Promise<HealthResponse>;
@@ -179,13 +206,15 @@ interface ASTClientConfig {
179
206
  baseUrl?: string;
180
207
  timeout?: number;
181
208
  jwtProvider: JWTProvider;
209
+ logger?: Logger;
182
210
  }
183
211
  declare class ASTHttpClient {
184
212
  private baseUrl;
185
213
  private timeout;
186
214
  private apiBase;
187
215
  private readonly jwtProvider;
188
- constructor({ baseUrl, timeout, jwtProvider, }: ASTClientConfig);
216
+ private readonly logger;
217
+ constructor({ baseUrl, timeout, jwtProvider, logger, }: ASTClientConfig);
189
218
  updateBaseUrl(baseUrl: string): void;
190
219
  private configureBase;
191
220
  getVisitorRulesV2(): Promise<VisitorRulesV2>;
@@ -213,6 +242,7 @@ interface CoderuleClientOptions {
213
242
  retrieval?: ServiceConfig;
214
243
  sync?: ServiceConfig;
215
244
  jwtFactory?: JWTFactoryOptions;
245
+ logger?: Logger;
216
246
  }
217
247
  declare class CoderuleClients {
218
248
  readonly auth: AuthHttpClient;
@@ -222,6 +252,7 @@ declare class CoderuleClients {
222
252
  readonly jwtFactory: JWTFactory;
223
253
  private readonly serviceBaseLocked;
224
254
  private lastServerUrl?;
255
+ private readonly logger;
225
256
  constructor(options: CoderuleClientOptions);
226
257
  get jwt(): JWTProvider;
227
258
  getJWT(forceRefresh?: boolean): Promise<string>;
@@ -232,4 +263,4 @@ declare class CoderuleClients {
232
263
 
233
264
  declare const fetch: typeof globalThis.fetch;
234
265
 
235
- export { type ASTClientConfig, ASTHttpClient, AuthHttpClient, type CoderuleClientOptions, CoderuleClients, type HealthStatus, JWTFactory, type JWTFactoryOptions, type JWTProvider, type RetrievalClientConfig, RetrievalHttpClient, type ServiceConfig, type ServiceKey, type SyncClientConfig, SyncHttpClient, type TokenRefreshInfo, type VisitorRulesV2, decodeJWT, fetch };
266
+ export { type ASTClientConfig, ASTHttpClient, AuthHttpClient, type CoderuleClientOptions, CoderuleClients, type HealthStatus, JWTFactory, type JWTFactoryOptions, type JWTProvider, type Logger, type RetrievalClientConfig, RetrievalHttpClient, type ServiceConfig, type ServiceKey, type SnapshotStatus$1 as SnapshotStatus, type SnapshotTimingMetrics, type SyncClientConfig, SyncHttpClient, type TokenRefreshInfo, type VisitorRulesV2, consoleLogger, decodeJWT, fetch, nullLogger };
package/dist/index.js CHANGED
@@ -119,16 +119,37 @@ var FormData2 = fetchModule.FormData;
119
119
  var AbortController2 = fetchModule.AbortController;
120
120
  var fetch_wrapper_default = fetch2;
121
121
 
122
+ // src/utils/logger.ts
123
+ init_esm_shims();
124
+ var nullLogger = {
125
+ error: () => {
126
+ },
127
+ warn: () => {
128
+ },
129
+ info: () => {
130
+ },
131
+ debug: () => {
132
+ }
133
+ };
134
+ var consoleLogger = {
135
+ error: (message, ...meta) => console.error(message, ...meta),
136
+ warn: (message, ...meta) => console.warn(message, ...meta),
137
+ info: (message, ...meta) => console.info(message, ...meta),
138
+ debug: (message, ...meta) => console.debug(message, ...meta)
139
+ };
140
+
122
141
  // src/clients/auth-client.ts
123
142
  var AuthHttpClient = class {
124
143
  /**
125
144
  * Initialize the Auth HTTP client
126
145
  * @param baseUrl - Base URL of the Auth service (e.g., "http://localhost:8001")
127
146
  * @param timeout - Request timeout in milliseconds (default: 30000)
147
+ * @param logger - Optional logger instance (defaults to nullLogger)
128
148
  */
129
- constructor(baseUrl, timeout = 3e4) {
149
+ constructor(baseUrl, timeout = 3e4, logger) {
130
150
  this.baseUrl = baseUrl.replace(/\/$/, "");
131
151
  this.timeout = timeout;
152
+ this.logger = logger ?? nullLogger;
132
153
  }
133
154
  /**
134
155
  * Authenticate a token and receive a JWT
@@ -157,7 +178,7 @@ var AuthHttpClient = class {
157
178
  );
158
179
  }
159
180
  const data = await response.json();
160
- console.debug(
181
+ this.logger.debug(
161
182
  `Authentication successful, JWT expires at ${data.expires_at}`
162
183
  );
163
184
  return data;
@@ -165,7 +186,7 @@ var AuthHttpClient = class {
165
186
  if (error.name === "AbortError") {
166
187
  throw new Error(`Request timeout after ${this.timeout}ms`);
167
188
  }
168
- console.error(`Authentication request failed: ${error.message}`);
189
+ this.logger.error(`Authentication request failed: ${error.message}`);
169
190
  throw error;
170
191
  }
171
192
  }
@@ -191,13 +212,13 @@ var AuthHttpClient = class {
191
212
  );
192
213
  }
193
214
  const data = await response.json();
194
- console.debug(`Health check: ${data.status}`);
215
+ this.logger.debug(`Health check: ${data.status}`);
195
216
  return data;
196
217
  } catch (error) {
197
218
  if (error.name === "AbortError") {
198
219
  throw new Error(`Request timeout after ${this.timeout}ms`);
199
220
  }
200
- console.error(`Health check request failed: ${error.message}`);
221
+ this.logger.error(`Health check request failed: ${error.message}`);
201
222
  throw error;
202
223
  }
203
224
  }
@@ -207,7 +228,7 @@ var AuthHttpClient = class {
207
228
  close() {
208
229
  }
209
230
  };
210
- function decodeJWT(jwtToken) {
231
+ function decodeJWT(jwtToken, logger) {
211
232
  try {
212
233
  const parts = jwtToken.split(".");
213
234
  if (parts.length !== 3) {
@@ -221,13 +242,13 @@ function decodeJWT(jwtToken) {
221
242
  if (payloadObj.exp) {
222
243
  const now = Math.floor(Date.now() / 1e3);
223
244
  if (payloadObj.exp < now) {
224
- console.debug("JWT token is expired");
245
+ if (logger) logger.debug("JWT token is expired");
225
246
  return null;
226
247
  }
227
248
  }
228
249
  return payloadObj;
229
250
  } catch (error) {
230
- console.error("Failed to decode JWT:", error);
251
+ if (logger) logger.error("Failed to decode JWT:", error);
231
252
  return null;
232
253
  }
233
254
  }
@@ -240,17 +261,20 @@ var SyncHttpClient = class {
240
261
  * @param config.baseUrl - URI/URL for connecting to the HTTP server (e.g., "http://localhost:8002")
241
262
  * @param config.timeout - Request timeout in milliseconds (default: 60000)
242
263
  * @param config.jwtProvider - Provider for obtaining JWT tokens
264
+ * @param config.logger - Optional logger instance (defaults to nullLogger)
243
265
  */
244
266
  constructor({
245
267
  baseUrl = "http://localhost:8002",
246
268
  timeout = 6e4,
247
- jwtProvider
269
+ jwtProvider,
270
+ logger
248
271
  }) {
249
272
  if (!jwtProvider) {
250
273
  throw new Error("SyncHttpClient requires a JWT provider");
251
274
  }
252
275
  this.timeout = timeout;
253
276
  this.jwtProvider = jwtProvider;
277
+ this.logger = logger ?? nullLogger;
254
278
  this.configureBase(baseUrl);
255
279
  }
256
280
  updateBaseUrl(baseUrl) {
@@ -313,7 +337,7 @@ var SyncHttpClient = class {
313
337
  if (error.name === "AbortError") {
314
338
  throw new Error(`Request timeout after ${this.timeout}ms`);
315
339
  }
316
- console.error(`Request failed: ${error.message}`);
340
+ this.logger.error(`Request failed: ${error.message}`);
317
341
  throw error;
318
342
  }
319
343
  }
@@ -348,7 +372,7 @@ var SyncHttpClient = class {
348
372
  clearTimeout(timeoutId);
349
373
  if (response.status === 422) {
350
374
  const data2 = await response.json();
351
- console.info(
375
+ this.logger.info(
352
376
  `Snapshot ${snapshotHash.substring(0, 8)}... missing ${data2.missing_files?.length || 0} files`
353
377
  );
354
378
  return data2;
@@ -360,7 +384,7 @@ var SyncHttpClient = class {
360
384
  );
361
385
  }
362
386
  const data = await response.json();
363
- console.info(
387
+ this.logger.info(
364
388
  `Snapshot ${snapshotHash.substring(0, 8)}... status: ${data.status}`
365
389
  );
366
390
  return data;
@@ -368,7 +392,7 @@ var SyncHttpClient = class {
368
392
  if (error.name === "AbortError") {
369
393
  throw new Error(`Request timeout after ${this.timeout}ms`);
370
394
  }
371
- console.error(`Request failed: ${error.message}`);
395
+ this.logger.error(`Request failed: ${error.message}`);
372
396
  throw error;
373
397
  }
374
398
  }
@@ -407,7 +431,7 @@ var SyncHttpClient = class {
407
431
  );
408
432
  }
409
433
  const data = await response.json();
410
- console.info(
434
+ this.logger.info(
411
435
  `Uploaded ${data.uploaded_count || 0} files, ${data.failed_count || 0} failed`
412
436
  );
413
437
  return data;
@@ -415,7 +439,7 @@ var SyncHttpClient = class {
415
439
  if (error.name === "AbortError") {
416
440
  throw new Error(`Request timeout after ${this.timeout}ms`);
417
441
  }
418
- console.error(`Request failed: ${error.message}`);
442
+ this.logger.error(`Request failed: ${error.message}`);
419
443
  throw error;
420
444
  }
421
445
  }
@@ -471,7 +495,7 @@ var SyncHttpClient = class {
471
495
  if (error.name === "AbortError") {
472
496
  throw new Error(`Request timeout after ${this.timeout}ms`);
473
497
  }
474
- console.error(`Request failed: ${error.message}`);
498
+ this.logger.error(`Request failed: ${error.message}`);
475
499
  throw error;
476
500
  }
477
501
  }
@@ -490,20 +514,23 @@ var RetrievalHttpClient = class {
490
514
  * @param config.baseUrl - URI/URL for connecting to the HTTP server (e.g., "http://localhost:8004")
491
515
  * @param config.timeout - Request timeout in milliseconds (default: 60000)
492
516
  * @param config.jwtProvider - Provider for obtaining JWT tokens
517
+ * @param config.logger - Optional logger instance (defaults to nullLogger)
493
518
  */
494
519
  constructor({
495
520
  baseUrl = "http://localhost:8004",
496
521
  timeout = 6e4,
497
- jwtProvider
522
+ jwtProvider,
523
+ logger
498
524
  }) {
499
525
  if (!jwtProvider) {
500
526
  throw new Error("RetrievalHttpClient requires a JWT provider");
501
527
  }
502
528
  this.timeout = timeout;
503
529
  this.jwtProvider = jwtProvider;
530
+ this.logger = logger ?? nullLogger;
504
531
  this.configureBase(baseUrl);
505
- console.debug(`Initialized HTTP client for ${this.baseUrl}`);
506
- console.debug(`API base: ${this.apiBase}`);
532
+ this.logger.debug(`Initialized HTTP client for ${this.baseUrl}`);
533
+ this.logger.debug(`API base: ${this.apiBase}`);
507
534
  }
508
535
  updateBaseUrl(baseUrl) {
509
536
  this.configureBase(baseUrl);
@@ -532,7 +559,7 @@ var RetrievalHttpClient = class {
532
559
  */
533
560
  async healthCheck() {
534
561
  const healthEndpoint = `${this.apiBase}health`;
535
- console.debug(`Checking server health: ${healthEndpoint}`);
562
+ this.logger.debug(`Checking server health: ${healthEndpoint}`);
536
563
  try {
537
564
  const controller = new AbortController2();
538
565
  const timeoutId = setTimeout(() => controller.abort(), this.timeout);
@@ -548,7 +575,7 @@ var RetrievalHttpClient = class {
548
575
  );
549
576
  }
550
577
  const healthInfo = await response.json();
551
- console.debug(`HTTP retrieval server status:`, healthInfo);
578
+ this.logger.debug(`HTTP retrieval server status:`, healthInfo);
552
579
  return {
553
580
  status: healthInfo.status || "UNKNOWN",
554
581
  database: healthInfo.database || "UNKNOWN",
@@ -561,7 +588,7 @@ var RetrievalHttpClient = class {
561
588
  if (error.name === "AbortError") {
562
589
  throw new Error(`Request timeout after ${this.timeout}ms`);
563
590
  }
564
- console.error(`Error checking HTTP server health: ${error.message}`);
591
+ this.logger.error(`Error checking HTTP server health: ${error.message}`);
565
592
  throw new Error(
566
593
  `Unable to connect to HTTP server ${this.baseUrl}: ${error.message}`
567
594
  );
@@ -625,7 +652,7 @@ var RetrievalHttpClient = class {
625
652
  const result = await response.json();
626
653
  const elapsedTime = (Date.now() - startTime) / 1e3;
627
654
  const formatter = options?.formatter || "standard";
628
- console.debug(
655
+ this.logger.debug(
629
656
  `Retrieval query completed for snapshot ${snapshotHash.substring(0, 8)}... Formatter: ${formatter}. Total time: ${elapsedTime.toFixed(2)}s`
630
657
  );
631
658
  return result;
@@ -633,7 +660,7 @@ var RetrievalHttpClient = class {
633
660
  if (error.name === "AbortError") {
634
661
  throw new Error(`Request timeout after ${this.timeout}ms`);
635
662
  }
636
- console.error(`Error executing retrieval query: ${error.message}`);
663
+ this.logger.error(`Error executing retrieval query: ${error.message}`);
637
664
  throw new Error(`Failed to execute retrieval query: ${error.message}`);
638
665
  }
639
666
  }
@@ -675,7 +702,7 @@ var RetrievalHttpClient = class {
675
702
  );
676
703
  }
677
704
  const statusInfo = await response.json();
678
- console.debug(
705
+ this.logger.debug(
679
706
  `Snapshot ${snapshotHash.substring(0, 8)}... status: ${statusInfo.status}`
680
707
  );
681
708
  return statusInfo;
@@ -683,7 +710,7 @@ var RetrievalHttpClient = class {
683
710
  if (error.name === "AbortError") {
684
711
  throw new Error(`Request timeout after ${this.timeout}ms`);
685
712
  }
686
- console.error(`Error checking snapshot status: ${error.message}`);
713
+ this.logger.error(`Error checking snapshot status: ${error.message}`);
687
714
  throw new Error(`Failed to check snapshot status: ${error.message}`);
688
715
  }
689
716
  }
@@ -713,13 +740,13 @@ var RetrievalHttpClient = class {
713
740
  `Cache clear failed with status ${response.status}: ${errorText}`
714
741
  );
715
742
  }
716
- console.info("Graph cache cleared successfully");
743
+ this.logger.info("Graph cache cleared successfully");
717
744
  return true;
718
745
  } catch (error) {
719
746
  if (error.name === "AbortError") {
720
747
  throw new Error(`Request timeout after ${this.timeout}ms`);
721
748
  }
722
- console.error(`Error clearing cache: ${error.message}`);
749
+ this.logger.error(`Error clearing cache: ${error.message}`);
723
750
  throw new Error(`Failed to clear cache: ${error.message}`);
724
751
  }
725
752
  }
@@ -750,7 +777,7 @@ var RetrievalHttpClient = class {
750
777
  );
751
778
  }
752
779
  const stats = await response.json();
753
- console.debug(
780
+ this.logger.debug(
754
781
  `Cache stats: ${stats.cached_snapshots || 0} snapshots cached`
755
782
  );
756
783
  return stats;
@@ -758,7 +785,7 @@ var RetrievalHttpClient = class {
758
785
  if (error.name === "AbortError") {
759
786
  throw new Error(`Request timeout after ${this.timeout}ms`);
760
787
  }
761
- console.error(`Error getting cache stats: ${error.message}`);
788
+ this.logger.error(`Error getting cache stats: ${error.message}`);
762
789
  throw new Error(`Failed to get cache stats: ${error.message}`);
763
790
  }
764
791
  }
@@ -802,17 +829,20 @@ var ASTHttpClient = class {
802
829
  * @param config.baseUrl - URI/URL for connecting to the HTTP server (e.g., "http://localhost:8003")
803
830
  * @param config.timeout - Request timeout in milliseconds (default: 60000)
804
831
  * @param config.jwtProvider - Provider for obtaining JWT tokens
832
+ * @param config.logger - Optional logger instance (defaults to nullLogger)
805
833
  */
806
834
  constructor({
807
835
  baseUrl = "http://localhost:8003",
808
836
  timeout = 6e4,
809
- jwtProvider
837
+ jwtProvider,
838
+ logger
810
839
  }) {
811
840
  if (!jwtProvider) {
812
841
  throw new Error("ASTHttpClient requires a JWT provider");
813
842
  }
814
843
  this.timeout = timeout;
815
844
  this.jwtProvider = jwtProvider;
845
+ this.logger = logger ?? nullLogger;
816
846
  this.configureBase(baseUrl);
817
847
  }
818
848
  updateBaseUrl(baseUrl) {
@@ -869,7 +899,7 @@ var ASTHttpClient = class {
869
899
  if (error.name === "AbortError") {
870
900
  throw new Error(`Request timeout after ${this.timeout}ms`);
871
901
  }
872
- console.error(`Failed to get visitor rules v2: ${error.message}`);
902
+ this.logger.error(`Failed to get visitor rules v2: ${error.message}`);
873
903
  throw error;
874
904
  }
875
905
  }
@@ -901,7 +931,7 @@ var ASTHttpClient = class {
901
931
  if (error.name === "AbortError") {
902
932
  throw new Error(`Request timeout after ${this.timeout}ms`);
903
933
  }
904
- console.error(`Health check failed: ${error.message}`);
934
+ this.logger.error(`Health check failed: ${error.message}`);
905
935
  throw error;
906
936
  }
907
937
  }
@@ -974,6 +1004,7 @@ var JWTFactory = class {
974
1004
  }
975
1005
  this.minTtlMs = options.minTtlMs ?? DEFAULT_MIN_TTL_MS;
976
1006
  this.onTokenRefreshed = options.onTokenRefreshed;
1007
+ this.logger = options.logger ?? nullLogger;
977
1008
  }
978
1009
  setSourceToken(token) {
979
1010
  if (!token) {
@@ -1012,7 +1043,7 @@ var JWTFactory = class {
1012
1043
  return await this.refreshPromise;
1013
1044
  } catch (error) {
1014
1045
  if (!forceRefresh && this.cache && now < this.cache.expiresAt) {
1015
- console.warn(
1046
+ this.logger.warn(
1016
1047
  "Failed to refresh JWT, using cached token until expiry. Reason:",
1017
1048
  error
1018
1049
  );
@@ -1055,7 +1086,7 @@ var JWTFactory = class {
1055
1086
  return parsed;
1056
1087
  }
1057
1088
  }
1058
- const decoded = decodeJWT(jwt);
1089
+ const decoded = decodeJWT(jwt, this.logger);
1059
1090
  if (decoded?.exp) {
1060
1091
  const expMs = decoded.exp * 1e3;
1061
1092
  if (expMs > referenceTime + this.minTtlMs) {
@@ -1076,7 +1107,7 @@ var JWTFactory = class {
1076
1107
  try {
1077
1108
  this.onTokenRefreshed(info);
1078
1109
  } catch (error) {
1079
- console.warn("JWTFactory onTokenRefreshed callback failed:", error);
1110
+ this.logger.warn("JWTFactory onTokenRefreshed callback failed:", error);
1080
1111
  }
1081
1112
  }
1082
1113
  }
@@ -1111,14 +1142,16 @@ var CoderuleClients = class {
1111
1142
  if (!options?.token) {
1112
1143
  throw new Error("CoderuleClients requires a non-empty token");
1113
1144
  }
1145
+ this.logger = options.logger ?? nullLogger;
1114
1146
  const overrides = resolveOverrides(options);
1115
1147
  const baseUrl = options.baseUrl;
1116
1148
  const authBase = overrides.auth?.baseUrl ?? baseUrl ?? DEFAULT_AUTH_BASE_URL;
1117
1149
  const authTimeout = resolveTimeout("auth", overrides);
1118
- this.auth = new AuthHttpClient(authBase, authTimeout);
1150
+ this.auth = new AuthHttpClient(authBase, authTimeout, this.logger);
1119
1151
  const userTokenCallback = options.jwtFactory?.onTokenRefreshed;
1120
1152
  const jwtOptions = {
1121
1153
  ...options.jwtFactory,
1154
+ logger: this.logger,
1122
1155
  onTokenRefreshed: (info) => {
1123
1156
  userTokenCallback?.(info);
1124
1157
  if (info.serverUrl) {
@@ -1136,17 +1169,20 @@ var CoderuleClients = class {
1136
1169
  this.ast = new ASTHttpClient({
1137
1170
  baseUrl: overrides.ast?.baseUrl ?? defaultServiceBase,
1138
1171
  timeout: resolveTimeout("ast", overrides),
1139
- jwtProvider: this.jwtFactory
1172
+ jwtProvider: this.jwtFactory,
1173
+ logger: this.logger
1140
1174
  });
1141
1175
  this.retrieval = new RetrievalHttpClient({
1142
1176
  baseUrl: overrides.retrieval?.baseUrl ?? defaultServiceBase,
1143
1177
  timeout: resolveTimeout("retrieval", overrides),
1144
- jwtProvider: this.jwtFactory
1178
+ jwtProvider: this.jwtFactory,
1179
+ logger: this.logger
1145
1180
  });
1146
1181
  this.sync = new SyncHttpClient({
1147
1182
  baseUrl: overrides.sync?.baseUrl ?? defaultServiceBase,
1148
1183
  timeout: resolveTimeout("sync", overrides),
1149
- jwtProvider: this.jwtFactory
1184
+ jwtProvider: this.jwtFactory,
1185
+ logger: this.logger
1150
1186
  });
1151
1187
  const initialServerUrl = this.jwtFactory.getServerUrl();
1152
1188
  if (initialServerUrl) {
@@ -1179,25 +1215,25 @@ var CoderuleClients = class {
1179
1215
  this.ast.updateBaseUrl(trimmed);
1180
1216
  }
1181
1217
  } catch (error) {
1182
- console.warn("Failed to update AST client base URL:", error);
1218
+ this.logger.warn("Failed to update AST client base URL:", error);
1183
1219
  }
1184
1220
  try {
1185
1221
  if (!this.serviceBaseLocked.retrieval) {
1186
1222
  this.retrieval.updateBaseUrl(trimmed);
1187
1223
  }
1188
1224
  } catch (error) {
1189
- console.warn("Failed to update Retrieval client base URL:", error);
1225
+ this.logger.warn("Failed to update Retrieval client base URL:", error);
1190
1226
  }
1191
1227
  try {
1192
1228
  if (!this.serviceBaseLocked.sync) {
1193
1229
  this.sync.updateBaseUrl(trimmed);
1194
1230
  }
1195
1231
  } catch (error) {
1196
- console.warn("Failed to update Sync client base URL:", error);
1232
+ this.logger.warn("Failed to update Sync client base URL:", error);
1197
1233
  }
1198
1234
  }
1199
1235
  };
1200
1236
 
1201
- export { ASTHttpClient, AuthHttpClient, CoderuleClients, JWTFactory, RetrievalHttpClient, SyncHttpClient, decodeJWT, fetch_wrapper_default as fetch };
1237
+ export { ASTHttpClient, AuthHttpClient, CoderuleClients, JWTFactory, RetrievalHttpClient, SyncHttpClient, consoleLogger, decodeJWT, fetch_wrapper_default as fetch, nullLogger };
1202
1238
  //# sourceMappingURL=index.js.map
1203
1239
  //# sourceMappingURL=index.js.map