@sgedda/mockifyer-fetch 1.8.87 → 1.8.92
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 +33 -16
- package/dist/metro-atlas-key-handlers.d.ts +19 -8
- package/dist/metro-atlas-key-handlers.js +49 -12
- package/dist/metro-config.d.ts +1 -1
- package/dist/metro-config.js +1 -1
- package/dist/metro-sync-middleware.d.ts +8 -3
- package/dist/metro-sync-middleware.js +532 -61
- package/package.json +2 -2
- package/src/index.ts +45 -16
- package/src/metro-atlas-key-handlers.ts +65 -19
- package/src/metro-config.ts +1 -1
- package/src/metro-sync-middleware.ts +682 -86
package/dist/index.js
CHANGED
|
@@ -70,15 +70,28 @@ class MockifyerClass {
|
|
|
70
70
|
transport: this.usesDashboardProxy() ? 'proxy' : 'fetch',
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
applyOutboundCorrelation(config) {
|
|
74
|
-
return (0, mockifyer_core_1.applyOutboundRequestCorrelation)(config, (0, mockifyer_core_1.
|
|
73
|
+
async applyOutboundCorrelation(config) {
|
|
74
|
+
return (0, mockifyer_core_1.applyOutboundRequestCorrelation)(config, await (0, mockifyer_core_1.resolveNetworkLogIncludeTraceOptionsAsync)(this.config));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Full outbound URL including `params` — hop logs / Atlas curl / include-trace
|
|
78
|
+
* must not drop the query string (fetch splits search into `config.params`).
|
|
79
|
+
*/
|
|
80
|
+
resolveLoggedRequestUrl(config, fallbackUrl) {
|
|
81
|
+
const raw = (fallbackUrl || config?.url || '').trim();
|
|
82
|
+
if (!raw)
|
|
83
|
+
return '';
|
|
84
|
+
return (0, mockifyer_core_1.appendParamsToUrl)(raw, config?.params);
|
|
75
85
|
}
|
|
76
86
|
/** Best-effort dashboard network log. */
|
|
77
|
-
logNetworkEvent(partial, correlation
|
|
87
|
+
logNetworkEvent(partial, correlation,
|
|
88
|
+
/** Final outbound header bag (after auth interceptors). */
|
|
89
|
+
requestHeadersSource) {
|
|
78
90
|
const scenario = this.config.proxy?.scenario?.trim() ||
|
|
79
91
|
(0, mockifyer_core_1.getCurrentScenario)(this.config.mockDataPath);
|
|
80
92
|
const { requestBody, responseBody, ...eventPartial } = partial;
|
|
81
93
|
const businessResponseBody = (0, mockifyer_core_1.getInlineTraceEnvelopeBusinessBody)(responseBody);
|
|
94
|
+
const requestHeaders = eventPartial.requestHeaders ?? (0, mockifyer_core_1.outboundHeadersToRecord)(requestHeadersSource);
|
|
82
95
|
if (!this.config.proxy?.baseUrl) {
|
|
83
96
|
(0, mockifyer_core_1.recordInlineTraceHopFromExchange)({
|
|
84
97
|
method: eventPartial.method,
|
|
@@ -107,6 +120,7 @@ class MockifyerClass {
|
|
|
107
120
|
transport: eventPartial.transport ?? 'fetch',
|
|
108
121
|
requestId: correlation?.requestId ?? eventPartial.requestId,
|
|
109
122
|
parentRequestId: correlation?.parentRequestId ?? eventPartial.parentRequestId,
|
|
123
|
+
requestHeaders,
|
|
110
124
|
requestBodyPreview: eventPartial.requestBodyPreview,
|
|
111
125
|
responseBodyPreview: eventPartial.responseBodyPreview,
|
|
112
126
|
},
|
|
@@ -619,7 +633,7 @@ class MockifyerClass {
|
|
|
619
633
|
if (!(0, mockifyer_core_1.shouldApplyMockifyer)(this.activationMode, config.headers, {
|
|
620
634
|
useProxyLane: { proxyBaseUrl: this.config.proxy?.baseUrl, resolvedClientId: this.config.clientId },
|
|
621
635
|
})) {
|
|
622
|
-
this.applyOutboundCorrelation(config);
|
|
636
|
+
await this.applyOutboundCorrelation(config);
|
|
623
637
|
config.__mockifyer_bypass = true;
|
|
624
638
|
return config;
|
|
625
639
|
}
|
|
@@ -628,7 +642,7 @@ class MockifyerClass {
|
|
|
628
642
|
config.__mockifyer_bypass = true;
|
|
629
643
|
return config;
|
|
630
644
|
}
|
|
631
|
-
let correlation = this.applyOutboundCorrelation(config);
|
|
645
|
+
let correlation = await this.applyOutboundCorrelation(config);
|
|
632
646
|
this.stashRequestCorrelation(config, correlation);
|
|
633
647
|
// Normalize empty params: treat {} the same as undefined for consistent matching
|
|
634
648
|
const rawParams = config.params || {};
|
|
@@ -678,13 +692,13 @@ class MockifyerClass {
|
|
|
678
692
|
const mockResponseBody = this.prepareStoredResponseBody(mockData, filename, hitScenarioPath);
|
|
679
693
|
this.logNetworkEvent({
|
|
680
694
|
method: (request.method || 'GET').toUpperCase(),
|
|
681
|
-
url: request.url,
|
|
695
|
+
url: this.resolveLoggedRequestUrl(config, request.url),
|
|
682
696
|
source: 'mock-hit',
|
|
683
697
|
status: mockData.response.status,
|
|
684
698
|
requestHash: (0, mockifyer_core_1.networkEventHashFromRequestKey)(requestKey),
|
|
685
699
|
requestBody: request.data,
|
|
686
700
|
responseBody: mockResponseBody,
|
|
687
|
-
}, correlation);
|
|
701
|
+
}, correlation, request.headers ?? config.headers);
|
|
688
702
|
const responseHeaders = {
|
|
689
703
|
...mockData.response.headers,
|
|
690
704
|
'x-mockifyer': 'true',
|
|
@@ -820,7 +834,7 @@ class MockifyerClass {
|
|
|
820
834
|
// be recorded here before early return (otherwise flight recorder stays empty).
|
|
821
835
|
const shouldLogMockOrLimit = isLimitReached || (isMocked && this.usesDashboardProxy());
|
|
822
836
|
if (shouldLogMockOrLimit) {
|
|
823
|
-
const reqUrl = response.config
|
|
837
|
+
const reqUrl = this.resolveLoggedRequestUrl(response.config, url);
|
|
824
838
|
const reqMethod = (response.config?.method || 'GET').toUpperCase();
|
|
825
839
|
const startTime = response.config.__mockifyer_startTime;
|
|
826
840
|
const durationMs = startTime ? Date.now() - startTime : undefined;
|
|
@@ -842,8 +856,11 @@ class MockifyerClass {
|
|
|
842
856
|
: 'Request limit reached',
|
|
843
857
|
}
|
|
844
858
|
: {}),
|
|
845
|
-
}, this.readRequestCorrelation(response.config));
|
|
859
|
+
}, this.readRequestCorrelation(response.config), response.config?.headers);
|
|
846
860
|
}
|
|
861
|
+
// Mock hits return before the upstream path. Still emit nested service
|
|
862
|
+
// hops and strip mockifyerTrace so the caller sees the business body.
|
|
863
|
+
this.unwrapResponseInlineTrace(response);
|
|
847
864
|
return response;
|
|
848
865
|
}
|
|
849
866
|
if (this.config.proxy?.baseUrl && this.config.proxy?.mirrorRecordedMocksToClient) {
|
|
@@ -853,9 +870,9 @@ class MockifyerClass {
|
|
|
853
870
|
if (matchedMock) {
|
|
854
871
|
const startTime = response.config.__mockifyer_startTime;
|
|
855
872
|
const durationMs = startTime ? Date.now() - startTime : undefined;
|
|
856
|
-
const reqUrl = response.config
|
|
873
|
+
const reqUrl = this.resolveLoggedRequestUrl(response.config, url);
|
|
857
874
|
const reqMethod = (response.config?.method || 'GET').toUpperCase();
|
|
858
|
-
// Parent hop first, then unwrap nested
|
|
875
|
+
// Parent hop first, then unwrap nested service hops from downstream services.
|
|
859
876
|
this.logNetworkEvent({
|
|
860
877
|
method: reqMethod,
|
|
861
878
|
url: reqUrl,
|
|
@@ -864,7 +881,7 @@ class MockifyerClass {
|
|
|
864
881
|
durationMs,
|
|
865
882
|
requestBody: response.config?.data,
|
|
866
883
|
responseBody: response.data,
|
|
867
|
-
}, this.readRequestCorrelation(response.config));
|
|
884
|
+
}, this.readRequestCorrelation(response.config), response.config?.headers);
|
|
868
885
|
this.unwrapResponseInlineTrace(response);
|
|
869
886
|
const capturedResponse = {
|
|
870
887
|
status: response.status,
|
|
@@ -886,7 +903,7 @@ class MockifyerClass {
|
|
|
886
903
|
delete response.config.__mockifyer_matchedMock;
|
|
887
904
|
return response;
|
|
888
905
|
}
|
|
889
|
-
const reqUrl = response.config
|
|
906
|
+
const reqUrl = this.resolveLoggedRequestUrl(response.config, url);
|
|
890
907
|
const reqMethod = (response.config?.method || 'GET').toUpperCase();
|
|
891
908
|
this.logNetworkEvent({
|
|
892
909
|
method: reqMethod,
|
|
@@ -898,7 +915,7 @@ class MockifyerClass {
|
|
|
898
915
|
: undefined,
|
|
899
916
|
requestBody: response.config?.data,
|
|
900
917
|
responseBody: response.data,
|
|
901
|
-
}, this.readRequestCorrelation(response.config));
|
|
918
|
+
}, this.readRequestCorrelation(response.config), response.config?.headers);
|
|
902
919
|
this.unwrapResponseInlineTrace(response);
|
|
903
920
|
// Only save locally if recordMode is enabled AND we're not proxying upstream calls.
|
|
904
921
|
// When proxy is configured, recording should happen on the proxy (e.g. dashboard → Redis).
|
|
@@ -911,7 +928,7 @@ class MockifyerClass {
|
|
|
911
928
|
if (requestKey) {
|
|
912
929
|
this.processingRequests.delete(requestKey);
|
|
913
930
|
}
|
|
914
|
-
const reqUrl = error.config
|
|
931
|
+
const reqUrl = this.resolveLoggedRequestUrl(error.config);
|
|
915
932
|
if (reqUrl) {
|
|
916
933
|
this.logNetworkEvent({
|
|
917
934
|
method: (error.config?.method || 'GET').toUpperCase(),
|
|
@@ -921,7 +938,7 @@ class MockifyerClass {
|
|
|
921
938
|
errorMessage: error?.message ?? String(error),
|
|
922
939
|
requestBody: error.config?.data,
|
|
923
940
|
responseBody: error.response?.data,
|
|
924
|
-
}, this.readRequestCorrelation(error.config));
|
|
941
|
+
}, this.readRequestCorrelation(error.config), error.config?.headers);
|
|
925
942
|
}
|
|
926
943
|
this.throwWithMockifyerRequestId(error);
|
|
927
944
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Metro terminal keys for Mockifyer:
|
|
3
|
-
* - `t` (default): start/stop Atlas capture (
|
|
3
|
+
* - `t` (default): start/stop Atlas capture (start opens the live stream page;
|
|
4
|
+
* stop ends capture — generate HTML from the live page “Render docs” button)
|
|
4
5
|
* - `m` (default): open the Mockifyer dashboard in the browser
|
|
5
6
|
*
|
|
6
|
-
* Opening `mockifyer-atlas` (SSE `/mockifyer-network-events/stream`)
|
|
7
|
-
* capture when idle — then press `t` once to stop
|
|
7
|
+
* Opening `mockifyer-atlas` (SSE `/mockifyer-network-events/stream`) or the live
|
|
8
|
+
* page auto-starts capture when idle — then press `t` once to stop, or use
|
|
9
|
+
* Render docs on the live page without stopping.
|
|
8
10
|
*
|
|
9
11
|
* `a` is reserved by Metro for Android (`i` iOS, `r` reload, `d` Dev Menu, `j` DevTools).
|
|
10
12
|
* Disable Atlas with `atlasKey: false`, dashboard with `dashboardKey: false`.
|
|
@@ -33,9 +35,9 @@ export interface AttachMetroAtlasKeyHandlerOptions {
|
|
|
33
35
|
* Mount prefix from `MOCKIFYER_DASHBOARD_BASE` is appended when set.
|
|
34
36
|
*/
|
|
35
37
|
dashboardUrl?: string;
|
|
36
|
-
/** Called on session start
|
|
37
|
-
onSessionStart?: () => void;
|
|
38
|
-
/** Called on session stop —
|
|
38
|
+
/** Called on session start. `reason` is `key` (Metro `t`) or `stream` (live page connected). */
|
|
39
|
+
onSessionStart?: (reason: MetroAtlasSessionStartReason) => void;
|
|
40
|
+
/** Called on session stop — end capture (HTML is rendered from the live page). */
|
|
39
41
|
onSessionStop?: () => void | Promise<void>;
|
|
40
42
|
/** Override stdin (tests). */
|
|
41
43
|
stdin?: NodeJS.ReadStream;
|
|
@@ -51,6 +53,8 @@ export interface AttachedMetroAtlasKeyHandler {
|
|
|
51
53
|
dashboardKey: string | null;
|
|
52
54
|
/** Resolved dashboard browse URL. */
|
|
53
55
|
dashboardUrl: string | null;
|
|
56
|
+
/** Live Atlas stream page opened when capture starts via the Atlas key. */
|
|
57
|
+
liveUrl: string | null;
|
|
54
58
|
/** Detach listener and clear module attach flag. */
|
|
55
59
|
detach: () => void;
|
|
56
60
|
}
|
|
@@ -72,6 +76,11 @@ export declare function resolveDashboardKeyOption(dashboardKey?: AtlasKeyOption)
|
|
|
72
76
|
* then append `MOCKIFYER_DASHBOARD_BASE` when set.
|
|
73
77
|
*/
|
|
74
78
|
export declare function resolveMetroDashboardUrl(explicit?: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* Browser URL for the Metro live Atlas hop stream page.
|
|
81
|
+
* Uses `MOCKIFYER_METRO_URL` when set, otherwise `http://localhost:<METRO_PORT|8081>`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveMetroAtlasLiveUrl(explicitBase?: string): string;
|
|
75
84
|
/**
|
|
76
85
|
* Open a URL with the OS default handler (browser / file).
|
|
77
86
|
*/
|
|
@@ -89,9 +98,11 @@ export declare function getMetroAtlasStreamSubscriberCount(): number;
|
|
|
89
98
|
* @returns true if a new session was started
|
|
90
99
|
*/
|
|
91
100
|
export declare function startMetroAtlasSession(reason?: MetroAtlasSessionStartReason): boolean;
|
|
101
|
+
/** Open the live hop stream page in the browser (Atlas key start). */
|
|
102
|
+
export declare function openMetroAtlasLivePage(): boolean;
|
|
92
103
|
/**
|
|
93
|
-
* Stop capture
|
|
94
|
-
* @returns true if stop
|
|
104
|
+
* Stop capture when capturing (does not write Atlas HTML — use live page Render docs).
|
|
105
|
+
* @returns true if stop was kicked off
|
|
95
106
|
*/
|
|
96
107
|
export declare function stopMetroAtlasSession(): boolean;
|
|
97
108
|
/** Open the dashboard URL when the dashboard key is enabled. */
|
|
@@ -38,11 +38,13 @@ exports.resolveKeyOption = resolveKeyOption;
|
|
|
38
38
|
exports.resolveAtlasKeyOption = resolveAtlasKeyOption;
|
|
39
39
|
exports.resolveDashboardKeyOption = resolveDashboardKeyOption;
|
|
40
40
|
exports.resolveMetroDashboardUrl = resolveMetroDashboardUrl;
|
|
41
|
+
exports.resolveMetroAtlasLiveUrl = resolveMetroAtlasLiveUrl;
|
|
41
42
|
exports.openMetroBrowseUrl = openMetroBrowseUrl;
|
|
42
43
|
exports.matchesAtlasKey = matchesAtlasKey;
|
|
43
44
|
exports.getMetroAtlasSessionPhase = getMetroAtlasSessionPhase;
|
|
44
45
|
exports.getMetroAtlasStreamSubscriberCount = getMetroAtlasStreamSubscriberCount;
|
|
45
46
|
exports.startMetroAtlasSession = startMetroAtlasSession;
|
|
47
|
+
exports.openMetroAtlasLivePage = openMetroAtlasLivePage;
|
|
46
48
|
exports.stopMetroAtlasSession = stopMetroAtlasSession;
|
|
47
49
|
exports.openMetroDashboard = openMetroDashboard;
|
|
48
50
|
exports.notifyMetroAtlasStreamClientConnected = notifyMetroAtlasStreamClientConnected;
|
|
@@ -51,11 +53,13 @@ exports.detachMetroAtlasKeyHandler = detachMetroAtlasKeyHandler;
|
|
|
51
53
|
exports.attachMetroAtlasKeyHandler = attachMetroAtlasKeyHandler;
|
|
52
54
|
/**
|
|
53
55
|
* Metro terminal keys for Mockifyer:
|
|
54
|
-
* - `t` (default): start/stop Atlas capture (
|
|
56
|
+
* - `t` (default): start/stop Atlas capture (start opens the live stream page;
|
|
57
|
+
* stop ends capture — generate HTML from the live page “Render docs” button)
|
|
55
58
|
* - `m` (default): open the Mockifyer dashboard in the browser
|
|
56
59
|
*
|
|
57
|
-
* Opening `mockifyer-atlas` (SSE `/mockifyer-network-events/stream`)
|
|
58
|
-
* capture when idle — then press `t` once to stop
|
|
60
|
+
* Opening `mockifyer-atlas` (SSE `/mockifyer-network-events/stream`) or the live
|
|
61
|
+
* page auto-starts capture when idle — then press `t` once to stop, or use
|
|
62
|
+
* Render docs on the live page without stopping.
|
|
59
63
|
*
|
|
60
64
|
* `a` is reserved by Metro for Android (`i` iOS, `r` reload, `d` Dev Menu, `j` DevTools).
|
|
61
65
|
* Disable Atlas with `atlasKey: false`, dashboard with `dashboardKey: false`.
|
|
@@ -134,6 +138,16 @@ function resolveMetroDashboardUrl(explicit) {
|
|
|
134
138
|
return base;
|
|
135
139
|
return `${base}${mount.startsWith("/") ? mount : `/${mount}`}`;
|
|
136
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Browser URL for the Metro live Atlas hop stream page.
|
|
143
|
+
* Uses `MOCKIFYER_METRO_URL` when set, otherwise `http://localhost:<METRO_PORT|8081>`.
|
|
144
|
+
*/
|
|
145
|
+
function resolveMetroAtlasLiveUrl(explicitBase) {
|
|
146
|
+
const fromExplicit = typeof explicitBase === "string" ? explicitBase.trim() : "";
|
|
147
|
+
const fromEnv = typeof process !== "undefined" ? process.env.MOCKIFYER_METRO_URL?.trim() : "";
|
|
148
|
+
const base = (fromExplicit || fromEnv || `http://localhost:${(0, mockifyer_core_1.resolveMetroNetworkStreamPort)()}`).replace(/\/+$/, "");
|
|
149
|
+
return `${base}${mockifyer_core_1.ATLAS_LIVE_STREAM_PATH}`;
|
|
150
|
+
}
|
|
137
151
|
/**
|
|
138
152
|
* Open a URL with the OS default handler (browser / file).
|
|
139
153
|
*/
|
|
@@ -200,7 +214,7 @@ function startMetroAtlasSession(reason = "key") {
|
|
|
200
214
|
sessionPhase = "capturing";
|
|
201
215
|
sessionStartedAt = Date.now();
|
|
202
216
|
try {
|
|
203
|
-
onSessionStart();
|
|
217
|
+
onSessionStart(reason);
|
|
204
218
|
}
|
|
205
219
|
catch (err) {
|
|
206
220
|
sessionPhase = "idle";
|
|
@@ -210,16 +224,34 @@ function startMetroAtlasSession(reason = "key") {
|
|
|
210
224
|
return false;
|
|
211
225
|
}
|
|
212
226
|
if (reason === "stream") {
|
|
213
|
-
console.log(`[Mockifyer] Atlas capture started (stream connected) — press ${key} to stop
|
|
227
|
+
console.log(`[Mockifyer] Atlas capture started (stream connected) — press ${key} to stop, or Render docs on the live page.`);
|
|
214
228
|
}
|
|
215
229
|
else {
|
|
216
|
-
console.log(`[Mockifyer] Atlas capture started — press ${key} again to stop
|
|
230
|
+
console.log(`[Mockifyer] Atlas capture started — press ${key} again to stop, or Render docs on the live page.`);
|
|
231
|
+
openMetroAtlasLivePage();
|
|
232
|
+
}
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
/** Open the live hop stream page in the browser (Atlas key start). */
|
|
236
|
+
function openMetroAtlasLivePage() {
|
|
237
|
+
const url = sessionCallbacks?.liveUrl;
|
|
238
|
+
if (!url || !sessionCallbacks?.openUrl) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
console.log(`[Mockifyer] Opening Atlas live stream → ${url}`);
|
|
242
|
+
try {
|
|
243
|
+
sessionCallbacks.openUrl(url);
|
|
244
|
+
}
|
|
245
|
+
catch (err) {
|
|
246
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
247
|
+
console.error(`[Mockifyer] Could not open Atlas live stream: ${message}`);
|
|
248
|
+
return false;
|
|
217
249
|
}
|
|
218
250
|
return true;
|
|
219
251
|
}
|
|
220
252
|
/**
|
|
221
|
-
* Stop capture
|
|
222
|
-
* @returns true if stop
|
|
253
|
+
* Stop capture when capturing (does not write Atlas HTML — use live page Render docs).
|
|
254
|
+
* @returns true if stop was kicked off
|
|
223
255
|
*/
|
|
224
256
|
function stopMetroAtlasSession() {
|
|
225
257
|
if (!sessionCallbacks?.onSessionStop)
|
|
@@ -230,12 +262,12 @@ function stopMetroAtlasSession() {
|
|
|
230
262
|
const startedAt = sessionStartedAt ?? Date.now();
|
|
231
263
|
const duration = formatSessionDuration(startedAt);
|
|
232
264
|
sessionPhase = "rendering";
|
|
233
|
-
console.log(`[Mockifyer] Atlas capture stopped (${duration})
|
|
265
|
+
console.log(`[Mockifyer] Atlas capture stopped (${duration}).`);
|
|
234
266
|
Promise.resolve()
|
|
235
267
|
.then(() => onSessionStop())
|
|
236
268
|
.catch((err) => {
|
|
237
269
|
const message = err instanceof Error ? err.message : String(err);
|
|
238
|
-
console.error(`[Mockifyer] Atlas
|
|
270
|
+
console.error(`[Mockifyer] Atlas session stop failed: ${message}`);
|
|
239
271
|
})
|
|
240
272
|
.finally(() => {
|
|
241
273
|
sessionPhase = "idle";
|
|
@@ -327,6 +359,7 @@ function attachMetroAtlasKeyHandler(options) {
|
|
|
327
359
|
key: null,
|
|
328
360
|
dashboardKey: null,
|
|
329
361
|
dashboardUrl: null,
|
|
362
|
+
liveUrl: null,
|
|
330
363
|
detach: () => undefined,
|
|
331
364
|
};
|
|
332
365
|
}
|
|
@@ -340,10 +373,12 @@ function attachMetroAtlasKeyHandler(options) {
|
|
|
340
373
|
mockifyer_core_1.logger.warn(`[Mockifyer] atlasKey and dashboardKey are both "${atlasKey}" — dashboard key ignored`);
|
|
341
374
|
}
|
|
342
375
|
const effectiveDashboardKey = atlasKey != null && dashboardKey === atlasKey ? null : dashboardKey;
|
|
376
|
+
const liveUrl = atlasKey != null ? resolveMetroAtlasLiveUrl() : null;
|
|
343
377
|
sessionCallbacks = {
|
|
344
378
|
key: atlasKey,
|
|
345
379
|
dashboardKey: effectiveDashboardKey,
|
|
346
380
|
dashboardUrl: effectiveDashboardKey != null ? dashboardUrl : null,
|
|
381
|
+
liveUrl,
|
|
347
382
|
onSessionStart: options.onSessionStart,
|
|
348
383
|
onSessionStop: options.onSessionStop,
|
|
349
384
|
openUrl: options.openUrl ?? openMetroBrowseUrl,
|
|
@@ -353,6 +388,7 @@ function attachMetroAtlasKeyHandler(options) {
|
|
|
353
388
|
key: atlasKey,
|
|
354
389
|
dashboardKey: effectiveDashboardKey,
|
|
355
390
|
dashboardUrl: sessionCallbacks.dashboardUrl,
|
|
391
|
+
liveUrl,
|
|
356
392
|
detach: detachMetroAtlasKeyHandler,
|
|
357
393
|
};
|
|
358
394
|
}
|
|
@@ -380,7 +416,7 @@ function attachMetroAtlasKeyHandler(options) {
|
|
|
380
416
|
if (!atlasKey || !matchesAtlasKey(str, keyObj, atlasKey))
|
|
381
417
|
return;
|
|
382
418
|
if (sessionPhase === "rendering") {
|
|
383
|
-
console.log("[Mockifyer] Atlas
|
|
419
|
+
console.log("[Mockifyer] Atlas stop already in progress…");
|
|
384
420
|
return;
|
|
385
421
|
}
|
|
386
422
|
if (sessionPhase === "idle") {
|
|
@@ -416,7 +452,7 @@ function attachMetroAtlasKeyHandler(options) {
|
|
|
416
452
|
attached = true;
|
|
417
453
|
const parts = [];
|
|
418
454
|
if (atlasKey) {
|
|
419
|
-
parts.push(`Press ${atlasKey} to start/stop Atlas capture (
|
|
455
|
+
parts.push(`Press ${atlasKey} to start/stop Atlas capture (start opens live stream; Render docs on the page writes HTML)`);
|
|
420
456
|
}
|
|
421
457
|
if (effectiveDashboardKey && dashboardUrl) {
|
|
422
458
|
parts.push(`Press ${effectiveDashboardKey} to open dashboard (${dashboardUrl})`);
|
|
@@ -443,6 +479,7 @@ function attachMetroAtlasKeyHandler(options) {
|
|
|
443
479
|
key: atlasKey,
|
|
444
480
|
dashboardKey: effectiveDashboardKey,
|
|
445
481
|
dashboardUrl: sessionCallbacks.dashboardUrl,
|
|
482
|
+
liveUrl,
|
|
446
483
|
detach: detachMetroAtlasKeyHandler,
|
|
447
484
|
};
|
|
448
485
|
}
|
package/dist/metro-config.d.ts
CHANGED
|
@@ -108,7 +108,7 @@ export interface ConfigureMetroOptions {
|
|
|
108
108
|
* syncMiddleware: {
|
|
109
109
|
* projectRoot: __dirname,
|
|
110
110
|
* mockDataPath: './mock-data',
|
|
111
|
-
* // atlasKey: 't' (default) — Metro terminal: start/stop Atlas
|
|
111
|
+
* // atlasKey: 't' (default) — Metro terminal: start/stop Atlas (start opens live stream; stop → HTML). `a` is Android.
|
|
112
112
|
* // dashboardKey: 'm' (default) — open dashboard in browser
|
|
113
113
|
* // dashboardUrl: 'http://localhost:3002' — or MOCKIFYER_DASHBOARD_URL
|
|
114
114
|
* },
|
package/dist/metro-config.js
CHANGED
|
@@ -127,7 +127,7 @@ function resolveMockifyerCoreReactNativeEntry(moduleName, platform) {
|
|
|
127
127
|
* syncMiddleware: {
|
|
128
128
|
* projectRoot: __dirname,
|
|
129
129
|
* mockDataPath: './mock-data',
|
|
130
|
-
* // atlasKey: 't' (default) — Metro terminal: start/stop Atlas
|
|
130
|
+
* // atlasKey: 't' (default) — Metro terminal: start/stop Atlas (start opens live stream; stop → HTML). `a` is Android.
|
|
131
131
|
* // dashboardKey: 'm' (default) — open dashboard in browser
|
|
132
132
|
* // dashboardUrl: 'http://localhost:3002' — or MOCKIFYER_DASHBOARD_URL
|
|
133
133
|
* },
|
|
@@ -19,8 +19,12 @@
|
|
|
19
19
|
* 15. POST /mockifyer-network-events/snapshot — write hops JSON/NDJSON under atlas-html/
|
|
20
20
|
* 16. POST /mockifyer-network-events/render — render Atlas HTML from buffer hops
|
|
21
21
|
* 17. POST /mockifyer-network-events/clear — clear ring buffer
|
|
22
|
-
* 18.
|
|
23
|
-
* 19.
|
|
22
|
+
* 18. GET /mockifyer-atlas-live — live hop stream web page (SSE + expand/collapse)
|
|
23
|
+
* 19. GET /mockifyer-atlas-trace?id= — re-call a hop with X-Mockifyer-Include-Trace (`&format=html` opens a result tab)
|
|
24
|
+
* 20. GET /mockifyer-atlas-capture — Atlas `t` capture session active flag
|
|
25
|
+
* 21. Metro terminal key `t` — start/stop Atlas capture (start opens live stream; stop ends capture; Render docs on the live page writes HTML; stream auto-starts; `atlasKey: false` to disable). `a` is reserved for Android.
|
|
26
|
+
* 22. Metro terminal key `m` — open Mockifyer dashboard in the browser (`dashboardKey: false` to disable)
|
|
27
|
+
* 23. On hop ingest / Atlas render — pull nested hops from dashboard `/api/network-events/trace` (remote BFF → dashboard → Atlas)
|
|
24
28
|
*
|
|
25
29
|
* The Hybrid Provider (recommended) uses POST /mockifyer-save for instant file sync.
|
|
26
30
|
* Legacy polling-based sync is still available for backward compatibility.
|
|
@@ -35,7 +39,8 @@ export interface MetroSyncMiddlewareOptions {
|
|
|
35
39
|
mockDataPath?: string;
|
|
36
40
|
/**
|
|
37
41
|
* Metro terminal key that starts/stops Atlas capture (default `"t"`).
|
|
38
|
-
* Start clears the hop buffer; stop
|
|
42
|
+
* Start clears the hop buffer; stop ends capture. Write HTML via live page
|
|
43
|
+
* “Render docs” (`POST /mockifyer-network-events/render`) or the CLI.
|
|
39
44
|
* Pass `false` to disable. `a` is reserved by Metro for Android.
|
|
40
45
|
*/
|
|
41
46
|
atlasKey?: AtlasKeyOption;
|