test-proxy-recorder 0.2.0 → 0.3.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.cts CHANGED
@@ -1,5 +1,6 @@
1
+ export { RECORDING_ID_HEADER, createHeadersWithRecordingId, getRecordingId, setNextProxyHeaders } from './nextjs/index.cjs';
1
2
  import http from 'node:http';
2
- export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-nmNRt1WE.cjs';
3
+ export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-CVuiglPk.cjs';
3
4
  import '@playwright/test';
4
5
 
5
6
  declare class ProxyServer {
@@ -13,13 +14,14 @@ declare class ProxyServer {
13
14
  private currentSession;
14
15
  private recordingsDir;
15
16
  private recordingIdCounter;
17
+ private sequenceCounterByKey;
16
18
  private replaySessions;
19
+ private recordingPromises;
17
20
  constructor(targets: string[], recordingsDir: string);
18
21
  init(): Promise<void>;
19
22
  listen(port: number): http.Server;
20
23
  private setupProxyEventHandlers;
21
24
  private handleProxyError;
22
- private handleProxyResponse;
23
25
  /**
24
26
  * Get CORS headers for a given request
25
27
  * @param req The incoming HTTP request
@@ -28,13 +30,26 @@ declare class ProxyServer {
28
30
  private getCorsHeaders;
29
31
  private addCorsHeaders;
30
32
  private getTarget;
33
+ /**
34
+ * Extract recording ID from custom HTTP header
35
+ * Used for concurrent replay session routing, especially with Next.js
36
+ * @param req The incoming HTTP request
37
+ * @returns The recording ID from header, or null if not found
38
+ */
39
+ private getRecordingIdFromHeader;
31
40
  /**
32
41
  * Extract recording ID from request cookie
33
- * Used for concurrent replay session routing
42
+ * Used for concurrent replay session routing (fallback method)
34
43
  * @param req The incoming HTTP request
35
44
  * @returns The recording ID from cookie, or null if not found
36
45
  */
37
46
  private getRecordingIdFromCookie;
47
+ /**
48
+ * Extract recording ID from request using custom header (preferred) or cookie (fallback)
49
+ * @param req The incoming HTTP request
50
+ * @returns The recording ID, or null if not found
51
+ */
52
+ private getRecordingIdFromRequest;
38
53
  /**
39
54
  * Get or create a replay session state for a given recording ID
40
55
  * @param recordingId The recording ID to get/create session for
@@ -42,6 +57,7 @@ declare class ProxyServer {
42
57
  */
43
58
  private getOrCreateReplaySession;
44
59
  private parseGetParams;
60
+ private parseControlRequest;
45
61
  private handleControlRequest;
46
62
  private clearModeTimeout;
47
63
  private switchMode;
@@ -49,17 +65,18 @@ declare class ProxyServer {
49
65
  private switchToRecordMode;
50
66
  private switchToReplayMode;
51
67
  private setupModeTimeout;
68
+ private flushPendingRecordings;
52
69
  private saveCurrentSession;
53
- private saveRequestRecordSync;
54
- private updateRequestBodySync;
55
- private recordResponse;
56
- private recordResponseData;
70
+ private getRecordingIdOrError;
71
+ private ensureSessionLoaded;
72
+ private getServedTracker;
73
+ private selectReplayRecord;
57
74
  private handleReplayRequest;
58
75
  private handleReplayError;
59
76
  private handleRequest;
60
77
  private handleCorsPreflightRequest;
61
78
  private handleProxyRequest;
62
- private bufferAndProxyRequest;
79
+ private recordAndProxyRequest;
63
80
  private handleUpgrade;
64
81
  private handleRecordWebSocket;
65
82
  private handleReplayWebSocket;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
+ export { RECORDING_ID_HEADER, createHeadersWithRecordingId, getRecordingId, setNextProxyHeaders } from './nextjs/index.js';
1
2
  import http from 'node:http';
2
- export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-nmNRt1WE.js';
3
+ export { C as ControlRequest, M as Mode, P as PlaywrightTestInfo, R as Recording, a as RecordingSession, W as WebSocketRecording, g as generateSessionId, p as playwrightProxy, s as setProxyMode, b as startRecording, c as startReplay, d as stopProxy } from './index-CVuiglPk.js';
3
4
  import '@playwright/test';
4
5
 
5
6
  declare class ProxyServer {
@@ -13,13 +14,14 @@ declare class ProxyServer {
13
14
  private currentSession;
14
15
  private recordingsDir;
15
16
  private recordingIdCounter;
17
+ private sequenceCounterByKey;
16
18
  private replaySessions;
19
+ private recordingPromises;
17
20
  constructor(targets: string[], recordingsDir: string);
18
21
  init(): Promise<void>;
19
22
  listen(port: number): http.Server;
20
23
  private setupProxyEventHandlers;
21
24
  private handleProxyError;
22
- private handleProxyResponse;
23
25
  /**
24
26
  * Get CORS headers for a given request
25
27
  * @param req The incoming HTTP request
@@ -28,13 +30,26 @@ declare class ProxyServer {
28
30
  private getCorsHeaders;
29
31
  private addCorsHeaders;
30
32
  private getTarget;
33
+ /**
34
+ * Extract recording ID from custom HTTP header
35
+ * Used for concurrent replay session routing, especially with Next.js
36
+ * @param req The incoming HTTP request
37
+ * @returns The recording ID from header, or null if not found
38
+ */
39
+ private getRecordingIdFromHeader;
31
40
  /**
32
41
  * Extract recording ID from request cookie
33
- * Used for concurrent replay session routing
42
+ * Used for concurrent replay session routing (fallback method)
34
43
  * @param req The incoming HTTP request
35
44
  * @returns The recording ID from cookie, or null if not found
36
45
  */
37
46
  private getRecordingIdFromCookie;
47
+ /**
48
+ * Extract recording ID from request using custom header (preferred) or cookie (fallback)
49
+ * @param req The incoming HTTP request
50
+ * @returns The recording ID, or null if not found
51
+ */
52
+ private getRecordingIdFromRequest;
38
53
  /**
39
54
  * Get or create a replay session state for a given recording ID
40
55
  * @param recordingId The recording ID to get/create session for
@@ -42,6 +57,7 @@ declare class ProxyServer {
42
57
  */
43
58
  private getOrCreateReplaySession;
44
59
  private parseGetParams;
60
+ private parseControlRequest;
45
61
  private handleControlRequest;
46
62
  private clearModeTimeout;
47
63
  private switchMode;
@@ -49,17 +65,18 @@ declare class ProxyServer {
49
65
  private switchToRecordMode;
50
66
  private switchToReplayMode;
51
67
  private setupModeTimeout;
68
+ private flushPendingRecordings;
52
69
  private saveCurrentSession;
53
- private saveRequestRecordSync;
54
- private updateRequestBodySync;
55
- private recordResponse;
56
- private recordResponseData;
70
+ private getRecordingIdOrError;
71
+ private ensureSessionLoaded;
72
+ private getServedTracker;
73
+ private selectReplayRecord;
57
74
  private handleReplayRequest;
58
75
  private handleReplayError;
59
76
  private handleRequest;
60
77
  private handleCorsPreflightRequest;
61
78
  private handleProxyRequest;
62
- private bufferAndProxyRequest;
79
+ private recordAndProxyRequest;
63
80
  private handleUpgrade;
64
81
  private handleRecordWebSocket;
65
82
  private handleReplayWebSocket;