@sgedda/mockifyer-fetch 1.8.38 → 1.8.40
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.js +14 -0
- package/package.json +2 -2
- package/src/index.ts +19 -0
package/dist/index.js
CHANGED
|
@@ -41,10 +41,23 @@ const fetch_client_1 = require("./clients/fetch-client");
|
|
|
41
41
|
class MockifyerClass {
|
|
42
42
|
/** Best-effort dashboard network log (skipped when traffic goes through `proxy.baseUrl`). */
|
|
43
43
|
logNetworkEvent(partial, correlation) {
|
|
44
|
+
// Dashboard proxy hops are recorded in performDashboardProxyRequest (shared axios/fetch path).
|
|
44
45
|
if (this.config.proxy?.baseUrl)
|
|
45
46
|
return;
|
|
46
47
|
const scenario = this.config.proxy?.scenario?.trim() ||
|
|
47
48
|
(0, mockifyer_core_1.getCurrentScenario)(this.config.mockDataPath);
|
|
49
|
+
(0, mockifyer_core_1.recordInlineTraceHopFromExchange)({
|
|
50
|
+
method: partial.method,
|
|
51
|
+
url: partial.url,
|
|
52
|
+
status: partial.status,
|
|
53
|
+
source: partial.source,
|
|
54
|
+
transport: partial.transport ?? 'fetch',
|
|
55
|
+
requestId: correlation?.requestId ?? partial.requestId ?? null,
|
|
56
|
+
parentRequestId: correlation?.parentRequestId ?? partial.parentRequestId ?? null,
|
|
57
|
+
durationMs: partial.durationMs,
|
|
58
|
+
clientId: this.config.clientId ?? partial.clientId ?? null,
|
|
59
|
+
errorMessage: partial.errorMessage,
|
|
60
|
+
});
|
|
48
61
|
(0, mockifyer_core_1.emitMockifyerNetworkEvent)({
|
|
49
62
|
config: this.config,
|
|
50
63
|
scenario,
|
|
@@ -1342,6 +1355,7 @@ function setupMockifyer(config) {
|
|
|
1342
1355
|
throw error;
|
|
1343
1356
|
}
|
|
1344
1357
|
};
|
|
1358
|
+
mockifyer_core_2.logger.info('[Mockifyer] ✅ Patched global fetch (useGlobalFetch: true)');
|
|
1345
1359
|
}
|
|
1346
1360
|
const extendedClient = httpClient;
|
|
1347
1361
|
extendedClient.reloadMockData = async (syncFromProject) => await mockifyer.reloadMockData(syncFromProject);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sgedda/mockifyer-fetch",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.40",
|
|
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",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"license": "MIT",
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@sgedda/mockifyer-core": "^1.10.
|
|
52
|
+
"@sgedda/mockifyer-core": "^1.10.17"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^20.11.24",
|
package/src/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ import {
|
|
|
68
68
|
type MockifyerActivationMode,
|
|
69
69
|
emitMockifyerNetworkEvent,
|
|
70
70
|
networkEventHashFromRequestKey,
|
|
71
|
+
recordInlineTraceHopFromExchange,
|
|
71
72
|
resolveRecordResponses,
|
|
72
73
|
applyOutboundRequestCorrelation,
|
|
73
74
|
type RequestCorrelationContext,
|
|
@@ -116,10 +117,26 @@ class MockifyerClass {
|
|
|
116
117
|
partial: Parameters<typeof emitMockifyerNetworkEvent>[0]['event'] & { transport?: 'fetch' },
|
|
117
118
|
correlation?: RequestCorrelationContext
|
|
118
119
|
): void {
|
|
120
|
+
// Dashboard proxy hops are recorded in performDashboardProxyRequest (shared axios/fetch path).
|
|
119
121
|
if (this.config.proxy?.baseUrl) return;
|
|
122
|
+
|
|
120
123
|
const scenario =
|
|
121
124
|
this.config.proxy?.scenario?.trim() ||
|
|
122
125
|
getCurrentScenario(this.config.mockDataPath);
|
|
126
|
+
|
|
127
|
+
recordInlineTraceHopFromExchange({
|
|
128
|
+
method: partial.method,
|
|
129
|
+
url: partial.url,
|
|
130
|
+
status: partial.status,
|
|
131
|
+
source: partial.source,
|
|
132
|
+
transport: partial.transport ?? 'fetch',
|
|
133
|
+
requestId: correlation?.requestId ?? partial.requestId ?? null,
|
|
134
|
+
parentRequestId: correlation?.parentRequestId ?? partial.parentRequestId ?? null,
|
|
135
|
+
durationMs: partial.durationMs,
|
|
136
|
+
clientId: this.config.clientId ?? partial.clientId ?? null,
|
|
137
|
+
errorMessage: partial.errorMessage,
|
|
138
|
+
});
|
|
139
|
+
|
|
123
140
|
emitMockifyerNetworkEvent({
|
|
124
141
|
config: this.config,
|
|
125
142
|
scenario,
|
|
@@ -1661,6 +1678,8 @@ export function setupMockifyer(config: MockifyerConfig): MockifyerInstance {
|
|
|
1661
1678
|
throw error;
|
|
1662
1679
|
}
|
|
1663
1680
|
} as typeof fetch;
|
|
1681
|
+
|
|
1682
|
+
logger.info('[Mockifyer] ✅ Patched global fetch (useGlobalFetch: true)');
|
|
1664
1683
|
}
|
|
1665
1684
|
|
|
1666
1685
|
const extendedClient = httpClient as MockifyerInstance;
|