@alwaysmeticulous/sdk-bundles-api 2.163.0 → 2.165.0
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/record/middleware.d.ts +42 -26
- package/package.json +3 -3
|
@@ -59,41 +59,50 @@ export interface RecorderMiddleware {
|
|
|
59
59
|
/**
|
|
60
60
|
* Transforms network requests before they are sent to Meticulous's servers.
|
|
61
61
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* your middleware
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
62
|
+
* If you are only transforming headers, and nothing else then set {@link applyRequestTransformationAtReplayTime}
|
|
63
|
+
* to false.
|
|
64
|
+
*
|
|
65
|
+
* If you are transforming URLs, query strings or request bodies, or sometimes returning null, then:
|
|
66
|
+
*
|
|
67
|
+
* 1. Please ensure you call tryLoadAndStartRecorder with your middleware, or set
|
|
68
|
+
* `window.METICULOUS_RECORDER_MIDDLEWARE_V1`, when Meticulous is replaying sessions at test time
|
|
69
|
+
* ('replay time'), and not just when you want to record. This allows Meticulous to auto-detect your
|
|
70
|
+
* middleware and transform the requests at replay time when finding an appropiate request to match
|
|
71
|
+
* with. This enables correctly matching requests with the corresponding saved responses even if the
|
|
72
|
+
* requests have been substantially transformed by your middleware.
|
|
73
|
+
*
|
|
74
|
+
* 2. Please avoid changing the transformations applied based on context that may differ at replay time.
|
|
75
|
+
* For example, if you change whether you apply transformNetworkRequest based on whether the current URL contains
|
|
76
|
+
* 'staging', then when replaying the recorded session that network request transformer would not be applied
|
|
77
|
+
* (URL does not contain 'staging', even if the original session was recorded on a staging environment), and
|
|
78
|
+
* so the request may not be able to be matched correctly.
|
|
79
|
+
*
|
|
80
|
+
* 3. Enough unique information must still be preserved in the redacted network request to allow Meticulous
|
|
81
|
+
* to correctly match a request that is performed at replay time by your application with
|
|
82
|
+
* the correct corresponding saved request stored in the recording / recorded session.
|
|
83
|
+
*
|
|
84
|
+
* For example: if you replace all query string values with "[REDACTED]", and there are multiple distinct
|
|
85
|
+
* requests with identical paths but different query string values then Meticulous will not have enough
|
|
86
|
+
* information to match them correctly. However if instead you md5 hash all query string values then
|
|
87
|
+
* Meticulous would have enough information to match the requests correctly.
|
|
88
|
+
*
|
|
89
|
+
* 4. Returning null will cause the request and the corresponding response to be dropped from the payload.
|
|
90
|
+
* At replay time if there is no exact match for a request that is transformed to null then the request
|
|
91
|
+
* will be failed with 'net::ERR_FAILED'/'Failed to fetch' rather than automatically trying to find a
|
|
92
|
+
* 'closest match' in the recorded session.
|
|
82
93
|
*
|
|
83
94
|
* See JSDoc for {@link RecorderMiddleware} before implementing.
|
|
84
95
|
*/
|
|
85
96
|
transformNetworkRequest?: (request: Omit<HarRequest, "queryString">, metadata: NetworkRequestMetadata) => Omit<HarRequest, "queryString"> | null;
|
|
86
97
|
/**
|
|
87
|
-
* Transforms network
|
|
98
|
+
* Transforms network responses before they are sent to Meticulous's servers.
|
|
88
99
|
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* the request then Meticulous will look for another closely matching recorded request, and replay that,
|
|
92
|
-
* or if none can be found it will fail the request with 'net::ERR_FAILED'/'Failed to fetch'.
|
|
100
|
+
* If you wish to drop a network response entirely please implement transformNetworkRequest
|
|
101
|
+
* instead and return null for the corresponding request.
|
|
93
102
|
*
|
|
94
103
|
* See JSDoc for {@link RecorderMiddleware} before implementing.
|
|
95
104
|
*/
|
|
96
|
-
transformNetworkResponse?: (response: HarResponse, metadata: NetworkResponseMetadata) => HarResponse
|
|
105
|
+
transformNetworkResponse?: (response: HarResponse, metadata: NetworkResponseMetadata) => HarResponse;
|
|
97
106
|
/**
|
|
98
107
|
* Transforms WebSocket messages before they are sent to Meticulous's servers.
|
|
99
108
|
*
|
|
@@ -107,6 +116,13 @@ export interface RecorderMiddleware {
|
|
|
107
116
|
* See JSDoc for {@link RecorderMiddleware} before implementing.
|
|
108
117
|
*/
|
|
109
118
|
transformWebSocketConnectionData?: (entry: Omit<WebSocketConnectionData, "id">) => Omit<WebSocketConnectionData, "id"> | null;
|
|
119
|
+
/**
|
|
120
|
+
* Defaults to true. Set to false if transformNetworkRequest only transforms the headers and not the URL or body of the request,
|
|
121
|
+
* and transformNetworkRequest never returns null. Setting to false when not required improves replay performance.
|
|
122
|
+
*
|
|
123
|
+
* See {@link transformNetworkRequest} for more details.
|
|
124
|
+
*/
|
|
125
|
+
applyRequestTransformationAtReplayTime?: boolean;
|
|
110
126
|
}
|
|
111
127
|
export interface IndexedDBStoreEntries {
|
|
112
128
|
databaseName: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alwaysmeticulous/sdk-bundles-api",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.165.0",
|
|
4
4
|
"description": "Meticulous common types",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"depcheck": "depcheck --ignore-patterns=dist"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@alwaysmeticulous/api": "^2.
|
|
22
|
+
"@alwaysmeticulous/api": "^2.164.0"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"loglevel": "^1.8.0"
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"bugs": {
|
|
47
47
|
"url": "https://github.com/alwaysmeticulous/meticulous-sdk/issues"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "fb42f552b9ae0d56218c531977db13fb14e94205"
|
|
50
50
|
}
|