@sgedda/mockifyer-fetch 1.8.13 → 1.8.14

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.
@@ -82,6 +82,19 @@ class FetchHTTPClient extends mockifyer_core_1.BaseHTTPClient {
82
82
  throw new Error(`[FetchHTTPClient] Proxy error: ${proxyResponse.status} ${txt}`);
83
83
  }
84
84
  const payload = await proxyResponse.json();
85
+ try {
86
+ const source = String(payload?.source || '');
87
+ const hash = typeof payload?.hash === 'string' ? payload.hash : '';
88
+ if (source) {
89
+ const hashShort = hash ? `${hash.slice(0, 8)}…` : '';
90
+ const lane = this.clientId ? this.clientId : '—';
91
+ const kind = source === 'redis' ? 'mock hit' : 'upstream';
92
+ console.log(`[Mockifyer-Fetch] Proxy ${kind}: ${requestConfig.method} ${url} ${hashShort ? `(hash=${hashShort}) ` : ''}(lane=${lane})`);
93
+ }
94
+ }
95
+ catch {
96
+ // ignore logging failures
97
+ }
85
98
  const data = payload?.response?.data;
86
99
  const status = payload?.response?.status ?? 200;
87
100
  const responseHeaders = payload?.response?.headers ?? {};
package/dist/index.js CHANGED
@@ -84,6 +84,7 @@ class MockifyerClass {
84
84
  this.config = { ...config }; // Create a copy to avoid mutations
85
85
  // Resolve client lane id (env/config/fallback); used for Redis per-client scenario overrides and proxy headers.
86
86
  this.config.clientId = (0, mockifyer_core_1.resolveClientId)(this.config);
87
+ mockifyer_core_2.logger.info(`[Mockifyer-Fetch] clientId: ${this.config.clientId}`);
87
88
  // Initialize test generator if test generation is enabled
88
89
  if (config.generateTests?.enabled) {
89
90
  this.testGenerator = new mockifyer_core_1.TestGenerator();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sgedda/mockifyer-fetch",
3
- "version": "1.8.13",
3
+ "version": "1.8.14",
4
4
  "description": "Mockifyer for Fetch - API mocking and logging utility for storing and replaying API responses",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -99,6 +99,22 @@ export class FetchHTTPClient extends BaseHTTPClient<any, HTTPResponse<any>> {
99
99
  throw new Error(`[FetchHTTPClient] Proxy error: ${proxyResponse.status} ${txt}`);
100
100
  }
101
101
  const payload = await proxyResponse.json();
102
+ try {
103
+ const source = String(payload?.source || '');
104
+ const hash = typeof payload?.hash === 'string' ? payload.hash : '';
105
+ if (source) {
106
+ const hashShort = hash ? `${hash.slice(0, 8)}…` : '';
107
+ const lane = this.clientId ? this.clientId : '—';
108
+ const kind = source === 'redis' ? 'mock hit' : 'upstream';
109
+ console.log(
110
+ `[Mockifyer-Fetch] Proxy ${kind}: ${requestConfig.method} ${url} ${
111
+ hashShort ? `(hash=${hashShort}) ` : ''
112
+ }(lane=${lane})`
113
+ );
114
+ }
115
+ } catch {
116
+ // ignore logging failures
117
+ }
102
118
  const data = payload?.response?.data;
103
119
  const status = payload?.response?.status ?? 200;
104
120
  const responseHeaders: Record<string, string> = payload?.response?.headers ?? {};
package/src/index.ts CHANGED
@@ -111,6 +111,7 @@ class MockifyerClass {
111
111
 
112
112
  // Resolve client lane id (env/config/fallback); used for Redis per-client scenario overrides and proxy headers.
113
113
  this.config.clientId = resolveClientId(this.config);
114
+ logger.info(`[Mockifyer-Fetch] clientId: ${this.config.clientId}`);
114
115
 
115
116
  // Initialize test generator if test generation is enabled
116
117
  if (config.generateTests?.enabled) {