msw 0.35.0 → 0.36.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/lib/esm/RequestHandler-deps.js +379 -65
- package/lib/esm/errors-deps.js +15 -1
- package/lib/esm/fetch-deps.js +9 -5
- package/lib/esm/graphql-deps.js +14 -9
- package/lib/esm/graphql.js +1 -0
- package/lib/esm/index-deps.js +2 -1
- package/lib/esm/index.js +47 -4238
- package/lib/esm/index2.js +1 -1
- package/lib/esm/mockServiceWorker.js +5 -5
- package/lib/esm/rest-deps.js +8 -15
- package/lib/esm/rest.js +1 -0
- package/lib/iife/index.js +3 -3
- package/lib/iife/mockServiceWorker.js +5 -5
- package/lib/types/context/data.d.ts +2 -3
- package/lib/types/context/extensions.d.ts +8 -0
- package/lib/types/context/index.d.ts +1 -0
- package/lib/types/graphql.d.ts +2 -1
- package/lib/types/handlers/GraphQLHandler.d.ts +5 -4
- package/lib/types/handlers/RequestHandler.d.ts +1 -1
- package/lib/types/handlers/RestHandler.d.ts +8 -10
- package/lib/types/index.d.ts +17 -7
- package/lib/types/node/index.d.ts +1 -1
- package/lib/types/rest.d.ts +10 -9
- package/lib/types/setupWorker/glossary.d.ts +12 -12
- package/lib/types/setupWorker/start/utils/prepareStartHandler.d.ts +3 -3
- package/lib/types/sharedOptions.d.ts +1 -1
- package/lib/types/typeUtils.d.ts +5 -3
- package/lib/types/utils/handleRequest.d.ts +4 -4
- package/lib/types/utils/internal/getCallFrame.d.ts +1 -1
- package/lib/types/utils/internal/jsonParse.d.ts +2 -2
- package/lib/types/utils/logging/prepareResponse.d.ts +1 -1
- package/lib/types/utils/matching/matchRequestUrl.d.ts +12 -2
- package/lib/types/utils/matching/normalizePath.d.ts +1 -1
- package/lib/types/utils/request/parseBody.d.ts +2 -2
- package/lib/types/utils/request/parseWorkerRequest.d.ts +2 -2
- package/lib/types/utils/worker/createFallbackRequestListener.d.ts +2 -1
- package/lib/types/utils/worker/createRequestListener.d.ts +2 -1
- package/lib/umd/index.js +524 -107
- package/lib/umd/mockServiceWorker.js +5 -5
- package/native/lib/index.js +450 -488
- package/node/lib/index.js +452 -490
- package/package.json +19 -19
package/lib/umd/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MockServiceWorker = {}));
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var statuses = {
|
|
8
8
|
"100": "Continue",
|
|
@@ -652,7 +652,7 @@
|
|
|
652
652
|
* @public
|
|
653
653
|
*/
|
|
654
654
|
|
|
655
|
-
var parse_1 = parse$
|
|
655
|
+
var parse_1 = parse$5;
|
|
656
656
|
var serialize_1 = serialize;
|
|
657
657
|
|
|
658
658
|
/**
|
|
@@ -686,7 +686,7 @@
|
|
|
686
686
|
* @public
|
|
687
687
|
*/
|
|
688
688
|
|
|
689
|
-
function parse$
|
|
689
|
+
function parse$5(str, options) {
|
|
690
690
|
if (typeof str !== 'string') {
|
|
691
691
|
throw new TypeError('argument str must be a string');
|
|
692
692
|
}
|
|
@@ -871,12 +871,12 @@
|
|
|
871
871
|
};
|
|
872
872
|
|
|
873
873
|
/**
|
|
874
|
-
* Parses a given
|
|
874
|
+
* Parses a given value into a JSON.
|
|
875
875
|
* Does not throw an exception on an invalid JSON string.
|
|
876
876
|
*/
|
|
877
|
-
function jsonParse(
|
|
877
|
+
function jsonParse(value) {
|
|
878
878
|
try {
|
|
879
|
-
return JSON.parse(
|
|
879
|
+
return JSON.parse(value);
|
|
880
880
|
}
|
|
881
881
|
catch (error) {
|
|
882
882
|
return undefined;
|
|
@@ -942,6 +942,20 @@
|
|
|
942
942
|
};
|
|
943
943
|
};
|
|
944
944
|
|
|
945
|
+
/**
|
|
946
|
+
* Sets the GraphQL extensions on a given response.
|
|
947
|
+
* @example
|
|
948
|
+
* res(ctx.extensions({ tracing: { version: 1 }}))
|
|
949
|
+
* @see {@link https://mswjs.io/docs/api/context/extensions `ctx.extensions()`}
|
|
950
|
+
*/
|
|
951
|
+
const extensions = (payload) => {
|
|
952
|
+
return (res) => {
|
|
953
|
+
const prevBody = jsonParse(res.body) || {};
|
|
954
|
+
const nextBody = mergeRight(prevBody, { extensions: payload });
|
|
955
|
+
return json(nextBody)(res);
|
|
956
|
+
};
|
|
957
|
+
};
|
|
958
|
+
|
|
945
959
|
var lib$5 = {exports: {}};
|
|
946
960
|
|
|
947
961
|
(function (module, exports) {
|
|
@@ -1051,8 +1065,12 @@
|
|
|
1051
1065
|
if (['GET', 'HEAD'].includes(method)) {
|
|
1052
1066
|
return requestParameters;
|
|
1053
1067
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
1068
|
+
if (typeof body === 'object' || typeof body === 'number') {
|
|
1069
|
+
requestParameters.body = JSON.stringify(body);
|
|
1070
|
+
}
|
|
1071
|
+
else {
|
|
1072
|
+
requestParameters.body = body;
|
|
1073
|
+
}
|
|
1056
1074
|
return requestParameters;
|
|
1057
1075
|
};
|
|
1058
1076
|
/**
|
|
@@ -1106,6 +1124,7 @@
|
|
|
1106
1124
|
cookie: cookie,
|
|
1107
1125
|
body: body,
|
|
1108
1126
|
data: data,
|
|
1127
|
+
extensions: extensions,
|
|
1109
1128
|
delay: delay,
|
|
1110
1129
|
errors: errors,
|
|
1111
1130
|
fetch: fetch$1,
|
|
@@ -2086,7 +2105,7 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
|
|
|
2086
2105
|
return cookie;
|
|
2087
2106
|
}
|
|
2088
2107
|
|
|
2089
|
-
function parse$
|
|
2108
|
+
function parse$4(input, options) {
|
|
2090
2109
|
options = options
|
|
2091
2110
|
? Object.assign({}, defaultParseOptions, options)
|
|
2092
2111
|
: defaultParseOptions;
|
|
@@ -2224,8 +2243,8 @@ Learn more about creating the Service Worker script: https://mswjs.io/docs/cli/i
|
|
|
2224
2243
|
return cookiesStrings;
|
|
2225
2244
|
}
|
|
2226
2245
|
|
|
2227
|
-
setCookie.exports = parse$
|
|
2228
|
-
setCookie.exports.parse = parse$
|
|
2246
|
+
setCookie.exports = parse$4;
|
|
2247
|
+
setCookie.exports.parse = parse$4;
|
|
2229
2248
|
setCookie.exports.parseString = parseString;
|
|
2230
2249
|
setCookie.exports.splitCookiesString = splitCookiesString;
|
|
2231
2250
|
|
|
@@ -2405,7 +2424,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
2405
2424
|
/**
|
|
2406
2425
|
* @note No cookies persist on the document in Node.js: no document.
|
|
2407
2426
|
*/
|
|
2408
|
-
if (typeof location === 'undefined') {
|
|
2427
|
+
if (typeof document === 'undefined' || typeof location === 'undefined') {
|
|
2409
2428
|
return {};
|
|
2410
2429
|
}
|
|
2411
2430
|
switch (request.credentials) {
|
|
@@ -2506,25 +2525,25 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
2506
2525
|
}
|
|
2507
2526
|
|
|
2508
2527
|
/**
|
|
2509
|
-
* Parses a given request/response body based on the
|
|
2528
|
+
* Parses a given request/response body based on the "Content-Type" header.
|
|
2510
2529
|
*/
|
|
2511
2530
|
function parseBody(body, headers) {
|
|
2512
2531
|
// Return whatever falsey body value is given.
|
|
2513
2532
|
if (!body) {
|
|
2514
2533
|
return body;
|
|
2515
2534
|
}
|
|
2516
|
-
const contentType = headers === null || headers === void 0 ? void 0 : headers.get('content-type');
|
|
2535
|
+
const contentType = (headers === null || headers === void 0 ? void 0 : headers.get('content-type')) || '';
|
|
2517
2536
|
// If the body has a Multipart Content-Type
|
|
2518
2537
|
// parse it into an object.
|
|
2519
|
-
const hasMultipartContent = contentType
|
|
2538
|
+
const hasMultipartContent = contentType.startsWith('multipart/form-data');
|
|
2520
2539
|
if (hasMultipartContent && typeof body !== 'object') {
|
|
2521
|
-
return parseMultipartData(body, headers) || body;
|
|
2540
|
+
return parseMultipartData(body.toString(), headers) || body;
|
|
2522
2541
|
}
|
|
2523
2542
|
// If the intercepted request's body has a JSON Content-Type
|
|
2524
2543
|
// parse it into an object.
|
|
2525
|
-
const hasJsonContent = contentType
|
|
2544
|
+
const hasJsonContent = contentType.includes('json');
|
|
2526
2545
|
if (hasJsonContent && typeof body !== 'object') {
|
|
2527
|
-
return jsonParse(body) || body;
|
|
2546
|
+
return jsonParse(body.toString()) || body;
|
|
2528
2547
|
}
|
|
2529
2548
|
// Otherwise leave as-is.
|
|
2530
2549
|
return body;
|
|
@@ -3826,7 +3845,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
3826
3845
|
|
|
3827
3846
|
directiveLocation.DirectiveLocation = DirectiveLocation;
|
|
3828
3847
|
|
|
3829
|
-
var lexer = {};
|
|
3848
|
+
var lexer$1 = {};
|
|
3830
3849
|
|
|
3831
3850
|
var blockString = {};
|
|
3832
3851
|
|
|
@@ -3963,11 +3982,11 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
3963
3982
|
return '"""' + result.replace(/"""/g, '\\"""') + '"""';
|
|
3964
3983
|
}
|
|
3965
3984
|
|
|
3966
|
-
Object.defineProperty(lexer, "__esModule", {
|
|
3985
|
+
Object.defineProperty(lexer$1, "__esModule", {
|
|
3967
3986
|
value: true
|
|
3968
3987
|
});
|
|
3969
|
-
lexer.isPunctuatorTokenKind = isPunctuatorTokenKind;
|
|
3970
|
-
lexer.Lexer = void 0;
|
|
3988
|
+
lexer$1.isPunctuatorTokenKind = isPunctuatorTokenKind;
|
|
3989
|
+
lexer$1.Lexer = void 0;
|
|
3971
3990
|
|
|
3972
3991
|
var _syntaxError$1 = syntaxError$1;
|
|
3973
3992
|
|
|
@@ -4049,7 +4068,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
4049
4068
|
*/
|
|
4050
4069
|
|
|
4051
4070
|
|
|
4052
|
-
lexer.Lexer = Lexer;
|
|
4071
|
+
lexer$1.Lexer = Lexer;
|
|
4053
4072
|
|
|
4054
4073
|
function isPunctuatorTokenKind(kind) {
|
|
4055
4074
|
return kind === _tokenKind$3.TokenKind.BANG || kind === _tokenKind$3.TokenKind.DOLLAR || kind === _tokenKind$3.TokenKind.AMP || kind === _tokenKind$3.TokenKind.PAREN_L || kind === _tokenKind$3.TokenKind.PAREN_R || kind === _tokenKind$3.TokenKind.SPREAD || kind === _tokenKind$3.TokenKind.COLON || kind === _tokenKind$3.TokenKind.EQUALS || kind === _tokenKind$3.TokenKind.AT || kind === _tokenKind$3.TokenKind.BRACKET_L || kind === _tokenKind$3.TokenKind.BRACKET_R || kind === _tokenKind$3.TokenKind.BRACE_L || kind === _tokenKind$3.TokenKind.PIPE || kind === _tokenKind$3.TokenKind.BRACE_R;
|
|
@@ -4655,7 +4674,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
4655
4674
|
Object.defineProperty(parser, "__esModule", {
|
|
4656
4675
|
value: true
|
|
4657
4676
|
});
|
|
4658
|
-
parser.parse = parse$
|
|
4677
|
+
parser.parse = parse$3;
|
|
4659
4678
|
parser.parseValue = parseValue;
|
|
4660
4679
|
parser.parseType = parseType;
|
|
4661
4680
|
parser.Parser = void 0;
|
|
@@ -4672,13 +4691,13 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
4672
4691
|
|
|
4673
4692
|
var _directiveLocation$3 = directiveLocation;
|
|
4674
4693
|
|
|
4675
|
-
var _lexer$1 = lexer;
|
|
4694
|
+
var _lexer$1 = lexer$1;
|
|
4676
4695
|
|
|
4677
4696
|
/**
|
|
4678
4697
|
* Given a GraphQL source, parses it into a Document.
|
|
4679
4698
|
* Throws GraphQLError if a syntax error is encountered.
|
|
4680
4699
|
*/
|
|
4681
|
-
function parse$
|
|
4700
|
+
function parse$3(source, options) {
|
|
4682
4701
|
var parser = new Parser(source, options);
|
|
4683
4702
|
return parser.parseDocument();
|
|
4684
4703
|
}
|
|
@@ -17337,7 +17356,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
17337
17356
|
|
|
17338
17357
|
var _tokenKind = tokenKind;
|
|
17339
17358
|
|
|
17340
|
-
var _lexer = lexer;
|
|
17359
|
+
var _lexer = lexer$1;
|
|
17341
17360
|
|
|
17342
17361
|
var _parser = parser;
|
|
17343
17362
|
|
|
@@ -20153,7 +20172,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
20153
20172
|
|
|
20154
20173
|
var _tokenKind = tokenKind;
|
|
20155
20174
|
|
|
20156
|
-
var _lexer = lexer;
|
|
20175
|
+
var _lexer = lexer$1;
|
|
20157
20176
|
|
|
20158
20177
|
var _blockString = blockString;
|
|
20159
20178
|
|
|
@@ -22433,51 +22452,414 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22433
22452
|
body: parseBody(res.body, responseHeaders) });
|
|
22434
22453
|
}
|
|
22435
22454
|
|
|
22436
|
-
var
|
|
22437
|
-
|
|
22438
|
-
Object.defineProperty(cjs, '__esModule', { value: true });
|
|
22455
|
+
var dist = {};
|
|
22439
22456
|
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
|
|
22443
|
-
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
|
|
22452
|
-
|
|
22453
|
-
|
|
22454
|
-
|
|
22455
|
-
|
|
22456
|
-
|
|
22457
|
-
|
|
22458
|
-
|
|
22459
|
-
|
|
22460
|
-
|
|
22461
|
-
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
|
|
22465
|
-
|
|
22466
|
-
|
|
22467
|
-
|
|
22468
|
-
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22457
|
+
Object.defineProperty(dist, "__esModule", { value: true });
|
|
22458
|
+
dist.pathToRegexp = dist.tokensToRegexp = dist.regexpToFunction = match_1 = dist.match = dist.tokensToFunction = dist.compile = dist.parse = void 0;
|
|
22459
|
+
/**
|
|
22460
|
+
* Tokenize input string.
|
|
22461
|
+
*/
|
|
22462
|
+
function lexer(str) {
|
|
22463
|
+
var tokens = [];
|
|
22464
|
+
var i = 0;
|
|
22465
|
+
while (i < str.length) {
|
|
22466
|
+
var char = str[i];
|
|
22467
|
+
if (char === "*" || char === "+" || char === "?") {
|
|
22468
|
+
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
|
22469
|
+
continue;
|
|
22470
|
+
}
|
|
22471
|
+
if (char === "\\") {
|
|
22472
|
+
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
|
22473
|
+
continue;
|
|
22474
|
+
}
|
|
22475
|
+
if (char === "{") {
|
|
22476
|
+
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
|
22477
|
+
continue;
|
|
22478
|
+
}
|
|
22479
|
+
if (char === "}") {
|
|
22480
|
+
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
|
22481
|
+
continue;
|
|
22482
|
+
}
|
|
22483
|
+
if (char === ":") {
|
|
22484
|
+
var name = "";
|
|
22485
|
+
var j = i + 1;
|
|
22486
|
+
while (j < str.length) {
|
|
22487
|
+
var code = str.charCodeAt(j);
|
|
22488
|
+
if (
|
|
22489
|
+
// `0-9`
|
|
22490
|
+
(code >= 48 && code <= 57) ||
|
|
22491
|
+
// `A-Z`
|
|
22492
|
+
(code >= 65 && code <= 90) ||
|
|
22493
|
+
// `a-z`
|
|
22494
|
+
(code >= 97 && code <= 122) ||
|
|
22495
|
+
// `_`
|
|
22496
|
+
code === 95) {
|
|
22497
|
+
name += str[j++];
|
|
22498
|
+
continue;
|
|
22499
|
+
}
|
|
22500
|
+
break;
|
|
22501
|
+
}
|
|
22502
|
+
if (!name)
|
|
22503
|
+
throw new TypeError("Missing parameter name at " + i);
|
|
22504
|
+
tokens.push({ type: "NAME", index: i, value: name });
|
|
22505
|
+
i = j;
|
|
22506
|
+
continue;
|
|
22507
|
+
}
|
|
22508
|
+
if (char === "(") {
|
|
22509
|
+
var count = 1;
|
|
22510
|
+
var pattern = "";
|
|
22511
|
+
var j = i + 1;
|
|
22512
|
+
if (str[j] === "?") {
|
|
22513
|
+
throw new TypeError("Pattern cannot start with \"?\" at " + j);
|
|
22514
|
+
}
|
|
22515
|
+
while (j < str.length) {
|
|
22516
|
+
if (str[j] === "\\") {
|
|
22517
|
+
pattern += str[j++] + str[j++];
|
|
22518
|
+
continue;
|
|
22519
|
+
}
|
|
22520
|
+
if (str[j] === ")") {
|
|
22521
|
+
count--;
|
|
22522
|
+
if (count === 0) {
|
|
22523
|
+
j++;
|
|
22524
|
+
break;
|
|
22525
|
+
}
|
|
22526
|
+
}
|
|
22527
|
+
else if (str[j] === "(") {
|
|
22528
|
+
count++;
|
|
22529
|
+
if (str[j + 1] !== "?") {
|
|
22530
|
+
throw new TypeError("Capturing groups are not allowed at " + j);
|
|
22531
|
+
}
|
|
22532
|
+
}
|
|
22533
|
+
pattern += str[j++];
|
|
22534
|
+
}
|
|
22535
|
+
if (count)
|
|
22536
|
+
throw new TypeError("Unbalanced pattern at " + i);
|
|
22537
|
+
if (!pattern)
|
|
22538
|
+
throw new TypeError("Missing pattern at " + i);
|
|
22539
|
+
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
|
22540
|
+
i = j;
|
|
22541
|
+
continue;
|
|
22542
|
+
}
|
|
22543
|
+
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
|
22544
|
+
}
|
|
22545
|
+
tokens.push({ type: "END", index: i, value: "" });
|
|
22546
|
+
return tokens;
|
|
22547
|
+
}
|
|
22548
|
+
/**
|
|
22549
|
+
* Parse a string for the raw tokens.
|
|
22550
|
+
*/
|
|
22551
|
+
function parse$2(str, options) {
|
|
22552
|
+
if (options === void 0) { options = {}; }
|
|
22553
|
+
var tokens = lexer(str);
|
|
22554
|
+
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
|
|
22555
|
+
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
|
|
22556
|
+
var result = [];
|
|
22557
|
+
var key = 0;
|
|
22558
|
+
var i = 0;
|
|
22559
|
+
var path = "";
|
|
22560
|
+
var tryConsume = function (type) {
|
|
22561
|
+
if (i < tokens.length && tokens[i].type === type)
|
|
22562
|
+
return tokens[i++].value;
|
|
22563
|
+
};
|
|
22564
|
+
var mustConsume = function (type) {
|
|
22565
|
+
var value = tryConsume(type);
|
|
22566
|
+
if (value !== undefined)
|
|
22567
|
+
return value;
|
|
22568
|
+
var _a = tokens[i], nextType = _a.type, index = _a.index;
|
|
22569
|
+
throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
|
|
22570
|
+
};
|
|
22571
|
+
var consumeText = function () {
|
|
22572
|
+
var result = "";
|
|
22573
|
+
var value;
|
|
22574
|
+
// tslint:disable-next-line
|
|
22575
|
+
while ((value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR"))) {
|
|
22576
|
+
result += value;
|
|
22577
|
+
}
|
|
22578
|
+
return result;
|
|
22579
|
+
};
|
|
22580
|
+
while (i < tokens.length) {
|
|
22581
|
+
var char = tryConsume("CHAR");
|
|
22582
|
+
var name = tryConsume("NAME");
|
|
22583
|
+
var pattern = tryConsume("PATTERN");
|
|
22584
|
+
if (name || pattern) {
|
|
22585
|
+
var prefix = char || "";
|
|
22586
|
+
if (prefixes.indexOf(prefix) === -1) {
|
|
22587
|
+
path += prefix;
|
|
22588
|
+
prefix = "";
|
|
22589
|
+
}
|
|
22590
|
+
if (path) {
|
|
22591
|
+
result.push(path);
|
|
22592
|
+
path = "";
|
|
22593
|
+
}
|
|
22594
|
+
result.push({
|
|
22595
|
+
name: name || key++,
|
|
22596
|
+
prefix: prefix,
|
|
22597
|
+
suffix: "",
|
|
22598
|
+
pattern: pattern || defaultPattern,
|
|
22599
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
22600
|
+
});
|
|
22601
|
+
continue;
|
|
22602
|
+
}
|
|
22603
|
+
var value = char || tryConsume("ESCAPED_CHAR");
|
|
22604
|
+
if (value) {
|
|
22605
|
+
path += value;
|
|
22606
|
+
continue;
|
|
22607
|
+
}
|
|
22608
|
+
if (path) {
|
|
22609
|
+
result.push(path);
|
|
22610
|
+
path = "";
|
|
22611
|
+
}
|
|
22612
|
+
var open = tryConsume("OPEN");
|
|
22613
|
+
if (open) {
|
|
22614
|
+
var prefix = consumeText();
|
|
22615
|
+
var name_1 = tryConsume("NAME") || "";
|
|
22616
|
+
var pattern_1 = tryConsume("PATTERN") || "";
|
|
22617
|
+
var suffix = consumeText();
|
|
22618
|
+
mustConsume("CLOSE");
|
|
22619
|
+
result.push({
|
|
22620
|
+
name: name_1 || (pattern_1 ? key++ : ""),
|
|
22621
|
+
pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
|
|
22622
|
+
prefix: prefix,
|
|
22623
|
+
suffix: suffix,
|
|
22624
|
+
modifier: tryConsume("MODIFIER") || ""
|
|
22625
|
+
});
|
|
22626
|
+
continue;
|
|
22627
|
+
}
|
|
22628
|
+
mustConsume("END");
|
|
22629
|
+
}
|
|
22630
|
+
return result;
|
|
22631
|
+
}
|
|
22632
|
+
dist.parse = parse$2;
|
|
22633
|
+
/**
|
|
22634
|
+
* Compile a string to a template function for the path.
|
|
22635
|
+
*/
|
|
22636
|
+
function compile(str, options) {
|
|
22637
|
+
return tokensToFunction(parse$2(str, options), options);
|
|
22638
|
+
}
|
|
22639
|
+
dist.compile = compile;
|
|
22640
|
+
/**
|
|
22641
|
+
* Expose a method for transforming tokens into the path function.
|
|
22642
|
+
*/
|
|
22643
|
+
function tokensToFunction(tokens, options) {
|
|
22644
|
+
if (options === void 0) { options = {}; }
|
|
22645
|
+
var reFlags = flags(options);
|
|
22646
|
+
var _a = options.encode, encode = _a === void 0 ? function (x) { return x; } : _a, _b = options.validate, validate = _b === void 0 ? true : _b;
|
|
22647
|
+
// Compile all the tokens into regexps.
|
|
22648
|
+
var matches = tokens.map(function (token) {
|
|
22649
|
+
if (typeof token === "object") {
|
|
22650
|
+
return new RegExp("^(?:" + token.pattern + ")$", reFlags);
|
|
22651
|
+
}
|
|
22652
|
+
});
|
|
22653
|
+
return function (data) {
|
|
22654
|
+
var path = "";
|
|
22655
|
+
for (var i = 0; i < tokens.length; i++) {
|
|
22656
|
+
var token = tokens[i];
|
|
22657
|
+
if (typeof token === "string") {
|
|
22658
|
+
path += token;
|
|
22659
|
+
continue;
|
|
22660
|
+
}
|
|
22661
|
+
var value = data ? data[token.name] : undefined;
|
|
22662
|
+
var optional = token.modifier === "?" || token.modifier === "*";
|
|
22663
|
+
var repeat = token.modifier === "*" || token.modifier === "+";
|
|
22664
|
+
if (Array.isArray(value)) {
|
|
22665
|
+
if (!repeat) {
|
|
22666
|
+
throw new TypeError("Expected \"" + token.name + "\" to not repeat, but got an array");
|
|
22667
|
+
}
|
|
22668
|
+
if (value.length === 0) {
|
|
22669
|
+
if (optional)
|
|
22670
|
+
continue;
|
|
22671
|
+
throw new TypeError("Expected \"" + token.name + "\" to not be empty");
|
|
22672
|
+
}
|
|
22673
|
+
for (var j = 0; j < value.length; j++) {
|
|
22674
|
+
var segment = encode(value[j], token);
|
|
22675
|
+
if (validate && !matches[i].test(segment)) {
|
|
22676
|
+
throw new TypeError("Expected all \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
|
|
22677
|
+
}
|
|
22678
|
+
path += token.prefix + segment + token.suffix;
|
|
22679
|
+
}
|
|
22680
|
+
continue;
|
|
22681
|
+
}
|
|
22682
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
22683
|
+
var segment = encode(String(value), token);
|
|
22684
|
+
if (validate && !matches[i].test(segment)) {
|
|
22685
|
+
throw new TypeError("Expected \"" + token.name + "\" to match \"" + token.pattern + "\", but got \"" + segment + "\"");
|
|
22686
|
+
}
|
|
22687
|
+
path += token.prefix + segment + token.suffix;
|
|
22688
|
+
continue;
|
|
22689
|
+
}
|
|
22690
|
+
if (optional)
|
|
22691
|
+
continue;
|
|
22692
|
+
var typeOfMessage = repeat ? "an array" : "a string";
|
|
22693
|
+
throw new TypeError("Expected \"" + token.name + "\" to be " + typeOfMessage);
|
|
22694
|
+
}
|
|
22695
|
+
return path;
|
|
22696
|
+
};
|
|
22697
|
+
}
|
|
22698
|
+
dist.tokensToFunction = tokensToFunction;
|
|
22699
|
+
/**
|
|
22700
|
+
* Create path match function from `path-to-regexp` spec.
|
|
22701
|
+
*/
|
|
22702
|
+
function match(str, options) {
|
|
22703
|
+
var keys = [];
|
|
22704
|
+
var re = pathToRegexp(str, keys, options);
|
|
22705
|
+
return regexpToFunction(re, keys, options);
|
|
22706
|
+
}
|
|
22707
|
+
var match_1 = dist.match = match;
|
|
22708
|
+
/**
|
|
22709
|
+
* Create a path match function from `path-to-regexp` output.
|
|
22710
|
+
*/
|
|
22711
|
+
function regexpToFunction(re, keys, options) {
|
|
22712
|
+
if (options === void 0) { options = {}; }
|
|
22713
|
+
var _a = options.decode, decode = _a === void 0 ? function (x) { return x; } : _a;
|
|
22714
|
+
return function (pathname) {
|
|
22715
|
+
var m = re.exec(pathname);
|
|
22716
|
+
if (!m)
|
|
22717
|
+
return false;
|
|
22718
|
+
var path = m[0], index = m.index;
|
|
22719
|
+
var params = Object.create(null);
|
|
22720
|
+
var _loop_1 = function (i) {
|
|
22721
|
+
// tslint:disable-next-line
|
|
22722
|
+
if (m[i] === undefined)
|
|
22723
|
+
return "continue";
|
|
22724
|
+
var key = keys[i - 1];
|
|
22725
|
+
if (key.modifier === "*" || key.modifier === "+") {
|
|
22726
|
+
params[key.name] = m[i].split(key.prefix + key.suffix).map(function (value) {
|
|
22727
|
+
return decode(value, key);
|
|
22728
|
+
});
|
|
22729
|
+
}
|
|
22730
|
+
else {
|
|
22731
|
+
params[key.name] = decode(m[i], key);
|
|
22732
|
+
}
|
|
22733
|
+
};
|
|
22734
|
+
for (var i = 1; i < m.length; i++) {
|
|
22735
|
+
_loop_1(i);
|
|
22736
|
+
}
|
|
22737
|
+
return { path: path, index: index, params: params };
|
|
22738
|
+
};
|
|
22739
|
+
}
|
|
22740
|
+
dist.regexpToFunction = regexpToFunction;
|
|
22741
|
+
/**
|
|
22742
|
+
* Escape a regular expression string.
|
|
22743
|
+
*/
|
|
22744
|
+
function escapeString(str) {
|
|
22745
|
+
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
|
22746
|
+
}
|
|
22747
|
+
/**
|
|
22748
|
+
* Get the flags for a regexp from the options.
|
|
22749
|
+
*/
|
|
22750
|
+
function flags(options) {
|
|
22751
|
+
return options && options.sensitive ? "" : "i";
|
|
22752
|
+
}
|
|
22753
|
+
/**
|
|
22754
|
+
* Pull out keys from a regexp.
|
|
22755
|
+
*/
|
|
22756
|
+
function regexpToRegexp(path, keys) {
|
|
22757
|
+
if (!keys)
|
|
22758
|
+
return path;
|
|
22759
|
+
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
|
|
22760
|
+
var index = 0;
|
|
22761
|
+
var execResult = groupsRegex.exec(path.source);
|
|
22762
|
+
while (execResult) {
|
|
22763
|
+
keys.push({
|
|
22764
|
+
// Use parenthesized substring match if available, index otherwise
|
|
22765
|
+
name: execResult[1] || index++,
|
|
22766
|
+
prefix: "",
|
|
22767
|
+
suffix: "",
|
|
22768
|
+
modifier: "",
|
|
22769
|
+
pattern: ""
|
|
22770
|
+
});
|
|
22771
|
+
execResult = groupsRegex.exec(path.source);
|
|
22772
|
+
}
|
|
22773
|
+
return path;
|
|
22774
|
+
}
|
|
22775
|
+
/**
|
|
22776
|
+
* Transform an array into a regexp.
|
|
22777
|
+
*/
|
|
22778
|
+
function arrayToRegexp(paths, keys, options) {
|
|
22779
|
+
var parts = paths.map(function (path) { return pathToRegexp(path, keys, options).source; });
|
|
22780
|
+
return new RegExp("(?:" + parts.join("|") + ")", flags(options));
|
|
22781
|
+
}
|
|
22782
|
+
/**
|
|
22783
|
+
* Create a path regexp from string input.
|
|
22784
|
+
*/
|
|
22785
|
+
function stringToRegexp(path, keys, options) {
|
|
22786
|
+
return tokensToRegexp(parse$2(path, options), keys, options);
|
|
22787
|
+
}
|
|
22788
|
+
/**
|
|
22789
|
+
* Expose a function for taking tokens and returning a RegExp.
|
|
22790
|
+
*/
|
|
22791
|
+
function tokensToRegexp(tokens, keys, options) {
|
|
22792
|
+
if (options === void 0) { options = {}; }
|
|
22793
|
+
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function (x) { return x; } : _d;
|
|
22794
|
+
var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
|
|
22795
|
+
var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
|
|
22796
|
+
var route = start ? "^" : "";
|
|
22797
|
+
// Iterate over the tokens and create our regexp string.
|
|
22798
|
+
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
|
22799
|
+
var token = tokens_1[_i];
|
|
22800
|
+
if (typeof token === "string") {
|
|
22801
|
+
route += escapeString(encode(token));
|
|
22802
|
+
}
|
|
22803
|
+
else {
|
|
22804
|
+
var prefix = escapeString(encode(token.prefix));
|
|
22805
|
+
var suffix = escapeString(encode(token.suffix));
|
|
22806
|
+
if (token.pattern) {
|
|
22807
|
+
if (keys)
|
|
22808
|
+
keys.push(token);
|
|
22809
|
+
if (prefix || suffix) {
|
|
22810
|
+
if (token.modifier === "+" || token.modifier === "*") {
|
|
22811
|
+
var mod = token.modifier === "*" ? "?" : "";
|
|
22812
|
+
route += "(?:" + prefix + "((?:" + token.pattern + ")(?:" + suffix + prefix + "(?:" + token.pattern + "))*)" + suffix + ")" + mod;
|
|
22813
|
+
}
|
|
22814
|
+
else {
|
|
22815
|
+
route += "(?:" + prefix + "(" + token.pattern + ")" + suffix + ")" + token.modifier;
|
|
22816
|
+
}
|
|
22817
|
+
}
|
|
22818
|
+
else {
|
|
22819
|
+
route += "(" + token.pattern + ")" + token.modifier;
|
|
22820
|
+
}
|
|
22821
|
+
}
|
|
22822
|
+
else {
|
|
22823
|
+
route += "(?:" + prefix + suffix + ")" + token.modifier;
|
|
22824
|
+
}
|
|
22825
|
+
}
|
|
22826
|
+
}
|
|
22827
|
+
if (end) {
|
|
22828
|
+
if (!strict)
|
|
22829
|
+
route += delimiter + "?";
|
|
22830
|
+
route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
|
|
22831
|
+
}
|
|
22832
|
+
else {
|
|
22833
|
+
var endToken = tokens[tokens.length - 1];
|
|
22834
|
+
var isEndDelimited = typeof endToken === "string"
|
|
22835
|
+
? delimiter.indexOf(endToken[endToken.length - 1]) > -1
|
|
22836
|
+
: // tslint:disable-next-line
|
|
22837
|
+
endToken === undefined;
|
|
22838
|
+
if (!strict) {
|
|
22839
|
+
route += "(?:" + delimiter + "(?=" + endsWith + "))?";
|
|
22840
|
+
}
|
|
22841
|
+
if (!isEndDelimited) {
|
|
22842
|
+
route += "(?=" + delimiter + "|" + endsWith + ")";
|
|
22843
|
+
}
|
|
22844
|
+
}
|
|
22845
|
+
return new RegExp(route, flags(options));
|
|
22846
|
+
}
|
|
22847
|
+
dist.tokensToRegexp = tokensToRegexp;
|
|
22848
|
+
/**
|
|
22849
|
+
* Normalize the given path string, returning a regular expression.
|
|
22850
|
+
*
|
|
22851
|
+
* An empty array can be passed in for the keys, which will hold the
|
|
22852
|
+
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
|
|
22853
|
+
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
|
|
22854
|
+
*/
|
|
22855
|
+
function pathToRegexp(path, keys, options) {
|
|
22856
|
+
if (path instanceof RegExp)
|
|
22857
|
+
return regexpToRegexp(path, keys);
|
|
22858
|
+
if (Array.isArray(path))
|
|
22859
|
+
return arrayToRegexp(path, keys, options);
|
|
22860
|
+
return stringToRegexp(path, keys, options);
|
|
22861
|
+
}
|
|
22862
|
+
dist.pathToRegexp = pathToRegexp;
|
|
22481
22863
|
|
|
22482
22864
|
var getCleanUrl$1 = {};
|
|
22483
22865
|
|
|
@@ -22512,8 +22894,8 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22512
22894
|
return path;
|
|
22513
22895
|
}
|
|
22514
22896
|
// Resolve a relative request URL against a given custom "baseUrl"
|
|
22515
|
-
// or the
|
|
22516
|
-
const origin = baseUrl || (typeof
|
|
22897
|
+
// or the document baseURI (in the case of browser/browser-like environments).
|
|
22898
|
+
const origin = baseUrl || (typeof document !== 'undefined' && document.baseURI);
|
|
22517
22899
|
return origin
|
|
22518
22900
|
? // Encode and decode the path to preserve escaped characters.
|
|
22519
22901
|
decodeURI(new URL(encodeURI(path), origin).href)
|
|
@@ -22536,12 +22918,40 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22536
22918
|
return cleanUrl(maybeAbsoluteUrl);
|
|
22537
22919
|
}
|
|
22538
22920
|
|
|
22921
|
+
/**
|
|
22922
|
+
* Coerce a path supported by MSW into a path
|
|
22923
|
+
* supported by "path-to-regexp".
|
|
22924
|
+
*/
|
|
22925
|
+
function coercePath(path) {
|
|
22926
|
+
return (path
|
|
22927
|
+
/**
|
|
22928
|
+
* Escape the protocol so that "path-to-regexp" could match
|
|
22929
|
+
* absolute URL.
|
|
22930
|
+
* @see https://github.com/pillarjs/path-to-regexp/issues/259
|
|
22931
|
+
*/
|
|
22932
|
+
.replace(/^([^\/]+)(:)(?=\/\/)/g, '$1\\$2')
|
|
22933
|
+
/**
|
|
22934
|
+
* Replace wildcards ("*") with unnamed capturing groups
|
|
22935
|
+
* because "path-to-regexp" doesn't support wildcards.
|
|
22936
|
+
* Ignore path parameter' modifiers (i.e. ":name*").
|
|
22937
|
+
*/
|
|
22938
|
+
.replace(/(?<!(^|\/|\*+):[\w]+)(\*{1,2})/g, '(.*)'));
|
|
22939
|
+
}
|
|
22539
22940
|
/**
|
|
22540
22941
|
* Returns the result of matching given request URL against a mask.
|
|
22541
22942
|
*/
|
|
22542
22943
|
function matchRequestUrl(url, path, baseUrl) {
|
|
22543
22944
|
const normalizedPath = normalizePath(path, baseUrl);
|
|
22544
|
-
|
|
22945
|
+
const cleanPath = typeof normalizedPath === 'string'
|
|
22946
|
+
? coercePath(normalizedPath)
|
|
22947
|
+
: normalizedPath;
|
|
22948
|
+
const cleanUrl = getCleanUrl_2(url);
|
|
22949
|
+
const result = match_1(cleanPath, { decode: decodeURIComponent })(cleanUrl);
|
|
22950
|
+
const params = (result && result.params) || {};
|
|
22951
|
+
return {
|
|
22952
|
+
matches: result !== false,
|
|
22953
|
+
params,
|
|
22954
|
+
};
|
|
22545
22955
|
}
|
|
22546
22956
|
|
|
22547
22957
|
/**
|
|
@@ -22590,18 +23000,21 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22590
23000
|
},
|
|
22591
23001
|
});
|
|
22592
23002
|
|
|
23003
|
+
const BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](umd|esm|iief|cjs)[\/\\]|^[^\/\\]*$/;
|
|
22593
23004
|
/**
|
|
22594
23005
|
* Return the stack trace frame of a function's invocation.
|
|
22595
23006
|
*/
|
|
22596
|
-
function getCallFrame() {
|
|
23007
|
+
function getCallFrame(error) {
|
|
22597
23008
|
// In <IE11, new Error may return an undefined stack
|
|
22598
|
-
const stack =
|
|
22599
|
-
|
|
23009
|
+
const stack = error.stack;
|
|
23010
|
+
if (!stack) {
|
|
23011
|
+
return;
|
|
23012
|
+
}
|
|
23013
|
+
const frames = stack.split('\n').slice(1);
|
|
22600
23014
|
// Get the first frame that doesn't reference the library's internal trace.
|
|
22601
23015
|
// Assume that frame is the invocation frame.
|
|
22602
|
-
const
|
|
22603
|
-
|
|
22604
|
-
return !ignoreFrameRegExp.test(frame);
|
|
23016
|
+
const declarationFrame = frames.find((frame) => {
|
|
23017
|
+
return !BUILD_FRAME.test(frame);
|
|
22605
23018
|
});
|
|
22606
23019
|
if (!declarationFrame) {
|
|
22607
23020
|
return;
|
|
@@ -22634,7 +23047,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22634
23047
|
this.shouldSkip = false;
|
|
22635
23048
|
this.ctx = options.ctx || defaultContext;
|
|
22636
23049
|
this.resolver = options.resolver;
|
|
22637
|
-
const callFrame = getCallFrame();
|
|
23050
|
+
const callFrame = getCallFrame(new Error());
|
|
22638
23051
|
this.info = Object.assign(Object.assign({}, options.info), { callFrame });
|
|
22639
23052
|
}
|
|
22640
23053
|
/**
|
|
@@ -22761,21 +23174,9 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
|
22761
23174
|
return;
|
|
22762
23175
|
}
|
|
22763
23176
|
const searchParams = getSearchParams(path);
|
|
22764
|
-
const queryParams = [];
|
|
22765
23177
|
searchParams.forEach((_, paramName) => {
|
|
22766
|
-
queryParams.push(paramName);
|
|
22767
23178
|
});
|
|
22768
|
-
devUtils.warn(
|
|
22769
|
-
Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead, and access query parameters in the response resolver function:
|
|
22770
|
-
|
|
22771
|
-
rest.${method.toLowerCase()}("${url}", (req, res, ctx) => {
|
|
22772
|
-
const query = req.url.searchParams
|
|
22773
|
-
${queryParams
|
|
22774
|
-
.map((paramName) => `\
|
|
22775
|
-
const ${paramName} = query.get("${paramName}")`)
|
|
22776
|
-
.join('\n')}
|
|
22777
|
-
})\
|
|
22778
|
-
`);
|
|
23179
|
+
devUtils.warn(`Found a redundant usage of query parameters in the request handler URL for "${method} ${path}". Please match against a path instead and access query parameters in the response resolver function using "req.url.searchParams".`);
|
|
22779
23180
|
}
|
|
22780
23181
|
parse(request, resolutionContext) {
|
|
22781
23182
|
return matchRequestUrl(request.url, this.info.path, resolutionContext === null || resolutionContext === void 0 ? void 0 : resolutionContext.baseUrl);
|
|
@@ -22784,7 +23185,11 @@ ${queryParams
|
|
|
22784
23185
|
return Object.assign(Object.assign({}, request), { params: parsedResult.params || {} });
|
|
22785
23186
|
}
|
|
22786
23187
|
predicate(request, parsedResult) {
|
|
22787
|
-
|
|
23188
|
+
const matchesMethod = this.info.method instanceof RegExp
|
|
23189
|
+
? this.info.method.test(request.method)
|
|
23190
|
+
: isStringEqual(this.info.method, request.method);
|
|
23191
|
+
// console.log({ request, matchesMethod, parsedResult })
|
|
23192
|
+
return matchesMethod && parsedResult.matches;
|
|
22788
23193
|
}
|
|
22789
23194
|
log(request, response) {
|
|
22790
23195
|
const publicUrl = getPublicUrlFromRequest(request);
|
|
@@ -22818,6 +23223,7 @@ ${queryParams
|
|
|
22818
23223
|
delay,
|
|
22819
23224
|
fetch: fetch$1,
|
|
22820
23225
|
data,
|
|
23226
|
+
extensions,
|
|
22821
23227
|
errors,
|
|
22822
23228
|
cookie,
|
|
22823
23229
|
};
|
|
@@ -22864,10 +23270,10 @@ ${queryParams
|
|
|
22864
23270
|
if (!parsedResult) {
|
|
22865
23271
|
return false;
|
|
22866
23272
|
}
|
|
22867
|
-
if (!parsedResult.operationName) {
|
|
23273
|
+
if (!parsedResult.operationName && this.info.operationType !== 'all') {
|
|
22868
23274
|
const publicUrl = getPublicUrlFromRequest(request);
|
|
22869
23275
|
devUtils.warn(`\
|
|
22870
|
-
Failed to intercept a GraphQL request at "${request.method} ${publicUrl}":
|
|
23276
|
+
Failed to intercept a GraphQL request at "${request.method} ${publicUrl}": anonymous GraphQL operations are not supported.
|
|
22871
23277
|
|
|
22872
23278
|
Consider naming this operation or using "graphql.operation" request handler to intercept GraphQL requests regardless of their operation name/type. Read more: https://mswjs.io/docs/api/graphql/operation\
|
|
22873
23279
|
`);
|
|
@@ -22877,7 +23283,7 @@ Consider naming this operation or using "graphql.operation" request handler to i
|
|
|
22877
23283
|
const hasMatchingOperationType = this.info.operationType === 'all' ||
|
|
22878
23284
|
parsedResult.operationType === this.info.operationType;
|
|
22879
23285
|
const hasMatchingOperationName = this.info.operationName instanceof RegExp
|
|
22880
|
-
? this.info.operationName.test(parsedResult.operationName)
|
|
23286
|
+
? this.info.operationName.test(parsedResult.operationName || '')
|
|
22881
23287
|
: parsedResult.operationName === this.info.operationName;
|
|
22882
23288
|
return (hasMatchingUrl.matches &&
|
|
22883
23289
|
hasMatchingOperationType &&
|
|
@@ -22887,7 +23293,10 @@ Consider naming this operation or using "graphql.operation" request handler to i
|
|
|
22887
23293
|
const loggedRequest = prepareRequest(request);
|
|
22888
23294
|
const loggedResponse = prepareResponse(response);
|
|
22889
23295
|
const statusColor = getStatusCodeColor(response.status);
|
|
22890
|
-
|
|
23296
|
+
const requestInfo = (parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName)
|
|
23297
|
+
? `${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType} ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationName}`
|
|
23298
|
+
: `anonymous ${parsedRequest === null || parsedRequest === void 0 ? void 0 : parsedRequest.operationType}`;
|
|
23299
|
+
console.groupCollapsed(devUtils.formatMessage('%s %s (%c%s%c)'), getTimestamp(), `${requestInfo}`, `color:${statusColor}`, `${response.status} ${response.statusText}`, 'color:inherit');
|
|
22891
23300
|
console.log('Request:', loggedRequest);
|
|
22892
23301
|
console.log('Handler:', this);
|
|
22893
23302
|
console.log('Response:', loggedResponse);
|
|
@@ -23047,7 +23456,12 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
|
23047
23456
|
// When the handled request returned no mocked response, warn the developer,
|
|
23048
23457
|
// as it may be an oversight on their part. Perform the request as-is.
|
|
23049
23458
|
if (!response) {
|
|
23050
|
-
devUtils.warn(
|
|
23459
|
+
devUtils.warn(`\
|
|
23460
|
+
Expected response resolver to return a mocked response Object, but got %s. The original response is going to be used instead.\
|
|
23461
|
+
\n
|
|
23462
|
+
\u2022 %s
|
|
23463
|
+
%s\
|
|
23464
|
+
`, response, handler.info.header, handler.info.callFrame);
|
|
23051
23465
|
emitter.emit('request:end', request);
|
|
23052
23466
|
(_c = handleRequestOptions === null || handleRequestOptions === void 0 ? void 0 : handleRequestOptions.onBypassResponse) === null || _c === void 0 ? void 0 : _c.call(handleRequestOptions, request);
|
|
23053
23467
|
return;
|
|
@@ -23134,8 +23548,8 @@ Read more: https://mswjs.io/docs/getting-started/mocks\
|
|
|
23134
23548
|
const { payload: actualChecksum } = yield context.events.once('INTEGRITY_CHECK_RESPONSE');
|
|
23135
23549
|
// Compare the response from the Service Worker and the
|
|
23136
23550
|
// global variable set by Rollup during the build.
|
|
23137
|
-
if (actualChecksum !== "
|
|
23138
|
-
throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"
|
|
23551
|
+
if (actualChecksum !== "02f4ad4a2797f85668baf196e553d929") {
|
|
23552
|
+
throw new Error(`Currently active Service Worker (${actualChecksum}) is behind the latest published one (${"02f4ad4a2797f85668baf196e553d929"}).`);
|
|
23139
23553
|
}
|
|
23140
23554
|
return serviceWorker;
|
|
23141
23555
|
});
|
|
@@ -24404,15 +24818,16 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
24404
24818
|
}
|
|
24405
24819
|
debug$1('no mocked response found, bypassing...');
|
|
24406
24820
|
return [2 /*return*/, pureFetch(input, init).then(function (response) { return __awaiter$1(void 0, void 0, void 0, function () {
|
|
24407
|
-
var _a, _b, _c;
|
|
24821
|
+
var cloneResponse, _a, _b, _c;
|
|
24408
24822
|
return __generator$1(this, function (_d) {
|
|
24409
24823
|
switch (_d.label) {
|
|
24410
24824
|
case 0:
|
|
24411
|
-
|
|
24825
|
+
cloneResponse = response.clone();
|
|
24826
|
+
debug$1('original fetch performed', cloneResponse);
|
|
24412
24827
|
_b = (_a = observer).emit;
|
|
24413
24828
|
_c = ['response',
|
|
24414
24829
|
isoRequest];
|
|
24415
|
-
return [4 /*yield*/, normalizeFetchResponse(
|
|
24830
|
+
return [4 /*yield*/, normalizeFetchResponse(cloneResponse)];
|
|
24416
24831
|
case 1:
|
|
24417
24832
|
_b.apply(_a, _c.concat([_d.sent()]));
|
|
24418
24833
|
return [2 /*return*/, response];
|
|
@@ -28131,6 +28546,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
28131
28546
|
};
|
|
28132
28547
|
}
|
|
28133
28548
|
const rest = {
|
|
28549
|
+
all: createRestHandler(/.+/),
|
|
28134
28550
|
head: createRestHandler(exports.RESTMethods.HEAD),
|
|
28135
28551
|
get: createRestHandler(exports.RESTMethods.GET),
|
|
28136
28552
|
post: createRestHandler(exports.RESTMethods.POST),
|
|
@@ -28191,6 +28607,7 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
28191
28607
|
exports.GraphQLHandler = GraphQLHandler;
|
|
28192
28608
|
exports.RequestHandler = RequestHandler;
|
|
28193
28609
|
exports.RestHandler = RestHandler;
|
|
28610
|
+
exports.cleanUrl = cleanUrl;
|
|
28194
28611
|
exports.compose = compose;
|
|
28195
28612
|
exports.context = index;
|
|
28196
28613
|
exports.createResponseComposition = createResponseComposition;
|
|
@@ -28206,4 +28623,4 @@ If this message still persists after updating, please report an issue: https://g
|
|
|
28206
28623
|
exports.restContext = restContext;
|
|
28207
28624
|
exports.setupWorker = setupWorker;
|
|
28208
28625
|
|
|
28209
|
-
}))
|
|
28626
|
+
}));
|