msw 1.3.2 → 2.0.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/README.md +45 -29
- package/browser/package.json +5 -0
- package/cli/init.js +3 -3
- package/config/constants.js +1 -2
- package/lib/browser/index.d.ts +104 -0
- package/lib/browser/index.js +752 -0
- package/lib/browser/index.mjs +734 -0
- package/lib/core/GraphQLHandler-b42ca96f.d.ts +74 -0
- package/lib/core/HttpResponse.d.ts +2 -0
- package/lib/core/HttpResponse.js +94 -0
- package/lib/core/HttpResponse.mjs +77 -0
- package/lib/core/RequestHandler-1a5dbdc7.d.ts +172 -0
- package/lib/core/SetupApi.d.ts +26 -0
- package/lib/core/SetupApi.js +83 -0
- package/lib/core/SetupApi.mjs +63 -0
- package/lib/core/bypass.d.ts +16 -0
- package/lib/core/bypass.js +36 -0
- package/lib/core/bypass.mjs +16 -0
- package/lib/core/delay.d.ts +18 -0
- package/lib/core/delay.js +92 -0
- package/lib/core/delay.mjs +72 -0
- package/lib/core/graphql.d.ts +109 -0
- package/lib/core/graphql.js +112 -0
- package/lib/core/graphql.mjs +96 -0
- package/lib/core/handlers/GraphQLHandler.d.ts +5 -0
- package/lib/core/handlers/GraphQLHandler.js +145 -0
- package/lib/core/handlers/GraphQLHandler.mjs +130 -0
- package/lib/core/handlers/HttpHandler.d.ts +62 -0
- package/lib/core/handlers/HttpHandler.js +149 -0
- package/lib/core/handlers/HttpHandler.mjs +133 -0
- package/lib/core/handlers/RequestHandler.d.ts +2 -0
- package/lib/core/handlers/RequestHandler.js +180 -0
- package/lib/core/handlers/RequestHandler.mjs +162 -0
- package/lib/core/http.d.ts +26 -0
- package/lib/core/http.js +39 -0
- package/lib/core/http.mjs +22 -0
- package/lib/core/http.spec.d.ts +2 -0
- package/lib/core/http.spec.js +15 -0
- package/lib/core/http.spec.mjs +14 -0
- package/lib/core/index.d.ts +18 -0
- package/lib/core/index.js +49 -0
- package/lib/core/index.mjs +28 -0
- package/lib/core/passthrough.d.ts +17 -0
- package/lib/core/passthrough.js +32 -0
- package/lib/core/passthrough.mjs +12 -0
- package/lib/core/sharedOptions.d.ts +66 -0
- package/lib/core/sharedOptions.js +16 -0
- package/lib/core/sharedOptions.mjs +0 -0
- package/lib/core/typeUtils.d.ts +7 -0
- package/lib/core/typeUtils.js +16 -0
- package/lib/core/typeUtils.mjs +0 -0
- package/lib/core/utils/HttpResponse/decorators.d.ts +12 -0
- package/lib/core/utils/HttpResponse/decorators.js +80 -0
- package/lib/core/utils/HttpResponse/decorators.mjs +52 -0
- package/lib/core/utils/getResponse.d.ts +2 -0
- package/lib/core/utils/getResponse.js +64 -0
- package/lib/core/utils/getResponse.mjs +44 -0
- package/lib/core/utils/handleRequest.d.ts +30 -0
- package/lib/core/utils/handleRequest.js +102 -0
- package/lib/core/utils/handleRequest.mjs +82 -0
- package/lib/core/utils/internal/Disposable.d.ts +7 -0
- package/lib/core/utils/internal/Disposable.js +53 -0
- package/lib/core/utils/internal/Disposable.mjs +33 -0
- package/lib/core/utils/internal/checkGlobals.d.ts +3 -0
- package/lib/core/utils/internal/checkGlobals.js +33 -0
- package/lib/core/utils/internal/checkGlobals.mjs +13 -0
- package/lib/core/utils/internal/devUtils.d.ts +19 -0
- package/lib/core/utils/internal/devUtils.js +40 -0
- package/lib/core/utils/internal/devUtils.mjs +20 -0
- package/lib/core/utils/internal/getCallFrame.d.ts +6 -0
- package/lib/core/utils/internal/getCallFrame.js +40 -0
- package/lib/core/utils/internal/getCallFrame.mjs +20 -0
- package/lib/core/utils/internal/isIterable.d.ts +6 -0
- package/lib/core/utils/internal/isIterable.js +29 -0
- package/lib/core/utils/internal/isIterable.mjs +9 -0
- package/lib/core/utils/internal/isObject.d.ts +6 -0
- package/lib/core/utils/internal/isObject.js +26 -0
- package/lib/core/utils/internal/isObject.mjs +6 -0
- package/lib/core/utils/internal/isStringEqual.d.ts +6 -0
- package/lib/core/utils/internal/isStringEqual.js +26 -0
- package/lib/core/utils/internal/isStringEqual.mjs +6 -0
- package/lib/core/utils/internal/jsonParse.d.ts +7 -0
- package/lib/core/utils/internal/jsonParse.js +30 -0
- package/lib/core/utils/internal/jsonParse.mjs +10 -0
- package/lib/core/utils/internal/mergeRight.d.ts +7 -0
- package/lib/core/utils/internal/mergeRight.js +39 -0
- package/lib/core/utils/internal/mergeRight.mjs +19 -0
- package/lib/core/utils/internal/parseGraphQLRequest.d.ts +5 -0
- package/lib/core/utils/internal/parseGraphQLRequest.js +184 -0
- package/lib/core/utils/internal/parseGraphQLRequest.mjs +165 -0
- package/lib/core/utils/internal/parseMultipartData.d.ts +10 -0
- package/lib/core/utils/internal/parseMultipartData.js +81 -0
- package/lib/core/utils/internal/parseMultipartData.mjs +61 -0
- package/lib/core/utils/internal/pipeEvents.d.ts +8 -0
- package/lib/core/utils/internal/pipeEvents.js +34 -0
- package/lib/core/utils/internal/pipeEvents.mjs +14 -0
- package/lib/core/utils/internal/requestHandlerUtils.d.ts +8 -0
- package/lib/core/utils/internal/requestHandlerUtils.js +36 -0
- package/lib/core/utils/internal/requestHandlerUtils.mjs +16 -0
- package/lib/core/utils/internal/toReadonlyArray.d.ts +6 -0
- package/lib/core/utils/internal/toReadonlyArray.js +28 -0
- package/lib/core/utils/internal/toReadonlyArray.mjs +8 -0
- package/lib/core/utils/internal/tryCatch.d.ts +3 -0
- package/lib/core/utils/internal/tryCatch.js +31 -0
- package/lib/core/utils/internal/tryCatch.mjs +11 -0
- package/lib/core/utils/internal/uuidv4.d.ts +3 -0
- package/lib/core/utils/internal/uuidv4.js +26 -0
- package/lib/core/utils/internal/uuidv4.mjs +6 -0
- package/lib/core/utils/logging/getStatusCodeColor.d.ts +11 -0
- package/lib/core/utils/logging/getStatusCodeColor.js +39 -0
- package/lib/core/utils/logging/getStatusCodeColor.mjs +19 -0
- package/lib/core/utils/logging/getTimestamp.d.ts +6 -0
- package/lib/core/utils/logging/getTimestamp.js +27 -0
- package/lib/core/utils/logging/getTimestamp.mjs +7 -0
- package/lib/core/utils/logging/serializeRequest.d.ts +12 -0
- package/lib/core/utils/logging/serializeRequest.js +55 -0
- package/lib/core/utils/logging/serializeRequest.mjs +35 -0
- package/lib/core/utils/logging/serializeResponse.d.ts +9 -0
- package/lib/core/utils/logging/serializeResponse.js +69 -0
- package/lib/core/utils/logging/serializeResponse.mjs +39 -0
- package/lib/core/utils/matching/matchRequestUrl.d.ts +19 -0
- package/lib/core/utils/matching/matchRequestUrl.js +50 -0
- package/lib/core/utils/matching/matchRequestUrl.mjs +30 -0
- package/lib/core/utils/matching/normalizePath.d.ts +12 -0
- package/lib/core/utils/matching/normalizePath.js +32 -0
- package/lib/core/utils/matching/normalizePath.mjs +12 -0
- package/lib/core/utils/request/getPublicUrlFromRequest.d.ts +7 -0
- package/lib/core/utils/request/getPublicUrlFromRequest.js +30 -0
- package/lib/core/utils/request/getPublicUrlFromRequest.mjs +10 -0
- package/lib/core/utils/request/getRequestCookies.d.ts +8 -0
- package/lib/core/utils/request/getRequestCookies.js +88 -0
- package/lib/core/utils/request/getRequestCookies.mjs +60 -0
- package/lib/core/utils/request/onUnhandledRequest.d.ts +12 -0
- package/lib/core/utils/request/onUnhandledRequest.js +193 -0
- package/lib/core/utils/request/onUnhandledRequest.mjs +165 -0
- package/lib/core/utils/request/readResponseCookies.d.ts +3 -0
- package/lib/core/utils/request/readResponseCookies.js +45 -0
- package/lib/core/utils/request/readResponseCookies.mjs +27 -0
- package/lib/core/utils/toResponseInit.d.ts +3 -0
- package/lib/core/utils/toResponseInit.js +30 -0
- package/lib/core/utils/toResponseInit.mjs +10 -0
- package/lib/core/utils/url/cleanUrl.d.ts +7 -0
- package/lib/core/utils/url/cleanUrl.js +31 -0
- package/lib/core/utils/url/cleanUrl.mjs +11 -0
- package/lib/core/utils/url/getAbsoluteUrl.d.ts +6 -0
- package/lib/core/utils/url/getAbsoluteUrl.js +37 -0
- package/lib/core/utils/url/getAbsoluteUrl.mjs +17 -0
- package/lib/core/utils/url/isAbsoluteUrl.d.ts +6 -0
- package/lib/core/utils/url/isAbsoluteUrl.js +26 -0
- package/lib/core/utils/url/isAbsoluteUrl.mjs +6 -0
- package/lib/iife/index.js +6204 -12360
- package/lib/mockServiceWorker.js +82 -93
- package/lib/native/index.d.ts +67 -7
- package/lib/native/index.js +74 -1500
- package/lib/native/index.mjs +69 -1514
- package/lib/node/index.d.ts +68 -9
- package/lib/node/index.js +77 -1508
- package/lib/node/index.mjs +71 -1521
- package/native/package.json +2 -1
- package/node/package.json +2 -1
- package/package.json +53 -23
- package/lib/SetupServerApi-1855d9c6.d.ts +0 -20
- package/lib/glossary-de6278a9.d.ts +0 -385
- package/lib/iife/index.js.map +0 -1
- package/lib/index.d.ts +0 -365
- package/lib/index.js +0 -2295
- package/lib/index.js.map +0 -1
- package/lib/node/index.js.map +0 -1
- package/lib/node/index.mjs.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var parseMultipartData_exports = {};
|
|
20
|
+
__export(parseMultipartData_exports, {
|
|
21
|
+
parseMultipartData: () => parseMultipartData
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(parseMultipartData_exports);
|
|
24
|
+
var import_headers_polyfill = require("headers-polyfill");
|
|
25
|
+
function parseContentHeaders(headersString) {
|
|
26
|
+
var _a, _b;
|
|
27
|
+
const headers = (0, import_headers_polyfill.stringToHeaders)(headersString);
|
|
28
|
+
const contentType = headers.get("content-type") || "text/plain";
|
|
29
|
+
const disposition = headers.get("content-disposition");
|
|
30
|
+
if (!disposition) {
|
|
31
|
+
throw new Error('"Content-Disposition" header is required.');
|
|
32
|
+
}
|
|
33
|
+
const directives = disposition.split(";").reduce((acc, chunk) => {
|
|
34
|
+
const [name2, ...rest] = chunk.trim().split("=");
|
|
35
|
+
acc[name2] = rest.join("=");
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
const name = (_a = directives.name) == null ? void 0 : _a.slice(1, -1);
|
|
39
|
+
const filename = (_b = directives.filename) == null ? void 0 : _b.slice(1, -1);
|
|
40
|
+
return {
|
|
41
|
+
name,
|
|
42
|
+
filename,
|
|
43
|
+
contentType
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function parseMultipartData(data, headers) {
|
|
47
|
+
const contentType = headers == null ? void 0 : headers.get("content-type");
|
|
48
|
+
if (!contentType) {
|
|
49
|
+
return void 0;
|
|
50
|
+
}
|
|
51
|
+
const [, ...directives] = contentType.split(/; */);
|
|
52
|
+
const boundary = directives.filter((d) => d.startsWith("boundary=")).map((s) => s.replace(/^boundary=/, ""))[0];
|
|
53
|
+
if (!boundary) {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
const boundaryRegExp = new RegExp(`--+${boundary}`);
|
|
57
|
+
const fields = data.split(boundaryRegExp).filter((chunk) => chunk.startsWith("\r\n") && chunk.endsWith("\r\n")).map((chunk) => chunk.trimStart().replace(/\r\n$/, ""));
|
|
58
|
+
if (!fields.length) {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
const parsedBody = {};
|
|
62
|
+
try {
|
|
63
|
+
for (const field of fields) {
|
|
64
|
+
const [contentHeaders, ...rest] = field.split("\r\n\r\n");
|
|
65
|
+
const contentBody = rest.join("\r\n\r\n");
|
|
66
|
+
const { contentType: contentType2, filename, name } = parseContentHeaders(contentHeaders);
|
|
67
|
+
const value = filename === void 0 ? contentBody : new File([contentBody], filename, { type: contentType2 });
|
|
68
|
+
const parsedValue = parsedBody[name];
|
|
69
|
+
if (parsedValue === void 0) {
|
|
70
|
+
parsedBody[name] = value;
|
|
71
|
+
} else if (Array.isArray(parsedValue)) {
|
|
72
|
+
parsedBody[name] = [...parsedValue, value];
|
|
73
|
+
} else {
|
|
74
|
+
parsedBody[name] = [parsedValue, value];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return parsedBody;
|
|
78
|
+
} catch (error) {
|
|
79
|
+
return void 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { stringToHeaders } from "headers-polyfill";
|
|
2
|
+
function parseContentHeaders(headersString) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
const headers = stringToHeaders(headersString);
|
|
5
|
+
const contentType = headers.get("content-type") || "text/plain";
|
|
6
|
+
const disposition = headers.get("content-disposition");
|
|
7
|
+
if (!disposition) {
|
|
8
|
+
throw new Error('"Content-Disposition" header is required.');
|
|
9
|
+
}
|
|
10
|
+
const directives = disposition.split(";").reduce((acc, chunk) => {
|
|
11
|
+
const [name2, ...rest] = chunk.trim().split("=");
|
|
12
|
+
acc[name2] = rest.join("=");
|
|
13
|
+
return acc;
|
|
14
|
+
}, {});
|
|
15
|
+
const name = (_a = directives.name) == null ? void 0 : _a.slice(1, -1);
|
|
16
|
+
const filename = (_b = directives.filename) == null ? void 0 : _b.slice(1, -1);
|
|
17
|
+
return {
|
|
18
|
+
name,
|
|
19
|
+
filename,
|
|
20
|
+
contentType
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function parseMultipartData(data, headers) {
|
|
24
|
+
const contentType = headers == null ? void 0 : headers.get("content-type");
|
|
25
|
+
if (!contentType) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
const [, ...directives] = contentType.split(/; */);
|
|
29
|
+
const boundary = directives.filter((d) => d.startsWith("boundary=")).map((s) => s.replace(/^boundary=/, ""))[0];
|
|
30
|
+
if (!boundary) {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
const boundaryRegExp = new RegExp(`--+${boundary}`);
|
|
34
|
+
const fields = data.split(boundaryRegExp).filter((chunk) => chunk.startsWith("\r\n") && chunk.endsWith("\r\n")).map((chunk) => chunk.trimStart().replace(/\r\n$/, ""));
|
|
35
|
+
if (!fields.length) {
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
const parsedBody = {};
|
|
39
|
+
try {
|
|
40
|
+
for (const field of fields) {
|
|
41
|
+
const [contentHeaders, ...rest] = field.split("\r\n\r\n");
|
|
42
|
+
const contentBody = rest.join("\r\n\r\n");
|
|
43
|
+
const { contentType: contentType2, filename, name } = parseContentHeaders(contentHeaders);
|
|
44
|
+
const value = filename === void 0 ? contentBody : new File([contentBody], filename, { type: contentType2 });
|
|
45
|
+
const parsedValue = parsedBody[name];
|
|
46
|
+
if (parsedValue === void 0) {
|
|
47
|
+
parsedBody[name] = value;
|
|
48
|
+
} else if (Array.isArray(parsedValue)) {
|
|
49
|
+
parsedBody[name] = [...parsedValue, value];
|
|
50
|
+
} else {
|
|
51
|
+
parsedBody[name] = [parsedValue, value];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return parsedBody;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export {
|
|
60
|
+
parseMultipartData
|
|
61
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventMap, Emitter } from 'strict-event-emitter';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pipes all emitted events from one emitter to another.
|
|
5
|
+
*/
|
|
6
|
+
declare function pipeEvents<Events extends EventMap>(source: Emitter<Events>, destination: Emitter<Events>): void;
|
|
7
|
+
|
|
8
|
+
export { pipeEvents };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pipeEvents_exports = {};
|
|
20
|
+
__export(pipeEvents_exports, {
|
|
21
|
+
pipeEvents: () => pipeEvents
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(pipeEvents_exports);
|
|
24
|
+
function pipeEvents(source, destination) {
|
|
25
|
+
const rawEmit = source.emit;
|
|
26
|
+
if (rawEmit._isPiped) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
source.emit = function(event, ...data) {
|
|
30
|
+
destination.emit(event, ...data);
|
|
31
|
+
return rawEmit.call(this, event, ...data);
|
|
32
|
+
};
|
|
33
|
+
source.emit._isPiped = true;
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function pipeEvents(source, destination) {
|
|
2
|
+
const rawEmit = source.emit;
|
|
3
|
+
if (rawEmit._isPiped) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
source.emit = function(event, ...data) {
|
|
7
|
+
destination.emit(event, ...data);
|
|
8
|
+
return rawEmit.call(this, event, ...data);
|
|
9
|
+
};
|
|
10
|
+
source.emit._isPiped = true;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
pipeEvents
|
|
14
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { R as RequestHandler, g as RequestHandlerDefaultInfo, c as RequestHandlerOptions } from '../../RequestHandler-1a5dbdc7.js';
|
|
2
|
+
import '../../typeUtils.js';
|
|
3
|
+
|
|
4
|
+
declare function use(currentHandlers: Array<RequestHandler>, ...handlers: Array<RequestHandler>): void;
|
|
5
|
+
declare function restoreHandlers(handlers: Array<RequestHandler>): void;
|
|
6
|
+
declare function resetHandlers(initialHandlers: Array<RequestHandler>, ...nextHandlers: Array<RequestHandler>): RequestHandler<RequestHandlerDefaultInfo, any, any, RequestHandlerOptions>[];
|
|
7
|
+
|
|
8
|
+
export { resetHandlers, restoreHandlers, use };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var requestHandlerUtils_exports = {};
|
|
20
|
+
__export(requestHandlerUtils_exports, {
|
|
21
|
+
resetHandlers: () => resetHandlers,
|
|
22
|
+
restoreHandlers: () => restoreHandlers,
|
|
23
|
+
use: () => use
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(requestHandlerUtils_exports);
|
|
26
|
+
function use(currentHandlers, ...handlers) {
|
|
27
|
+
currentHandlers.unshift(...handlers);
|
|
28
|
+
}
|
|
29
|
+
function restoreHandlers(handlers) {
|
|
30
|
+
handlers.forEach((handler) => {
|
|
31
|
+
handler.isUsed = false;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function resetHandlers(initialHandlers, ...nextHandlers) {
|
|
35
|
+
return nextHandlers.length > 0 ? [...nextHandlers] : [...initialHandlers];
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
function use(currentHandlers, ...handlers) {
|
|
2
|
+
currentHandlers.unshift(...handlers);
|
|
3
|
+
}
|
|
4
|
+
function restoreHandlers(handlers) {
|
|
5
|
+
handlers.forEach((handler) => {
|
|
6
|
+
handler.isUsed = false;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
function resetHandlers(initialHandlers, ...nextHandlers) {
|
|
10
|
+
return nextHandlers.length > 0 ? [...nextHandlers] : [...initialHandlers];
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
resetHandlers,
|
|
14
|
+
restoreHandlers,
|
|
15
|
+
use
|
|
16
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var toReadonlyArray_exports = {};
|
|
20
|
+
__export(toReadonlyArray_exports, {
|
|
21
|
+
toReadonlyArray: () => toReadonlyArray
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(toReadonlyArray_exports);
|
|
24
|
+
function toReadonlyArray(source) {
|
|
25
|
+
const clone = [...source];
|
|
26
|
+
Object.freeze(clone);
|
|
27
|
+
return clone;
|
|
28
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var tryCatch_exports = {};
|
|
20
|
+
__export(tryCatch_exports, {
|
|
21
|
+
tryCatch: () => tryCatch
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(tryCatch_exports);
|
|
24
|
+
function tryCatch(fn, onException) {
|
|
25
|
+
try {
|
|
26
|
+
const result = fn();
|
|
27
|
+
return result;
|
|
28
|
+
} catch (error) {
|
|
29
|
+
onException == null ? void 0 : onException(error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var uuidv4_exports = {};
|
|
20
|
+
__export(uuidv4_exports, {
|
|
21
|
+
uuidv4: () => uuidv4
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(uuidv4_exports);
|
|
24
|
+
function uuidv4() {
|
|
25
|
+
return Math.random().toString(16).slice(2);
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare enum StatusCodeColor {
|
|
2
|
+
Success = "#69AB32",
|
|
3
|
+
Warning = "#F0BB4B",
|
|
4
|
+
Danger = "#E95F5D"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Returns a HEX color for a given response status code number.
|
|
8
|
+
*/
|
|
9
|
+
declare function getStatusCodeColor(status: number): StatusCodeColor;
|
|
10
|
+
|
|
11
|
+
export { StatusCodeColor, getStatusCodeColor };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getStatusCodeColor_exports = {};
|
|
20
|
+
__export(getStatusCodeColor_exports, {
|
|
21
|
+
StatusCodeColor: () => StatusCodeColor,
|
|
22
|
+
getStatusCodeColor: () => getStatusCodeColor
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(getStatusCodeColor_exports);
|
|
25
|
+
var StatusCodeColor = /* @__PURE__ */ ((StatusCodeColor2) => {
|
|
26
|
+
StatusCodeColor2["Success"] = "#69AB32";
|
|
27
|
+
StatusCodeColor2["Warning"] = "#F0BB4B";
|
|
28
|
+
StatusCodeColor2["Danger"] = "#E95F5D";
|
|
29
|
+
return StatusCodeColor2;
|
|
30
|
+
})(StatusCodeColor || {});
|
|
31
|
+
function getStatusCodeColor(status) {
|
|
32
|
+
if (status < 300) {
|
|
33
|
+
return "#69AB32" /* Success */;
|
|
34
|
+
}
|
|
35
|
+
if (status < 400) {
|
|
36
|
+
return "#F0BB4B" /* Warning */;
|
|
37
|
+
}
|
|
38
|
+
return "#E95F5D" /* Danger */;
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var StatusCodeColor = /* @__PURE__ */ ((StatusCodeColor2) => {
|
|
2
|
+
StatusCodeColor2["Success"] = "#69AB32";
|
|
3
|
+
StatusCodeColor2["Warning"] = "#F0BB4B";
|
|
4
|
+
StatusCodeColor2["Danger"] = "#E95F5D";
|
|
5
|
+
return StatusCodeColor2;
|
|
6
|
+
})(StatusCodeColor || {});
|
|
7
|
+
function getStatusCodeColor(status) {
|
|
8
|
+
if (status < 300) {
|
|
9
|
+
return "#69AB32" /* Success */;
|
|
10
|
+
}
|
|
11
|
+
if (status < 400) {
|
|
12
|
+
return "#F0BB4B" /* Warning */;
|
|
13
|
+
}
|
|
14
|
+
return "#E95F5D" /* Danger */;
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
StatusCodeColor,
|
|
18
|
+
getStatusCodeColor
|
|
19
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var getTimestamp_exports = {};
|
|
20
|
+
__export(getTimestamp_exports, {
|
|
21
|
+
getTimestamp: () => getTimestamp
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(getTimestamp_exports);
|
|
24
|
+
function getTimestamp() {
|
|
25
|
+
const now = /* @__PURE__ */ new Date();
|
|
26
|
+
return [now.getHours(), now.getMinutes(), now.getSeconds()].map(String).map((chunk) => chunk.slice(0, 2)).map((chunk) => chunk.padStart(2, "0")).join(":");
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface LoggedRequest {
|
|
2
|
+
url: URL;
|
|
3
|
+
method: string;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
body: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Formats a mocked request for introspection in browser's console.
|
|
9
|
+
*/
|
|
10
|
+
declare function serializeRequest(request: Request): Promise<LoggedRequest>;
|
|
11
|
+
|
|
12
|
+
export { LoggedRequest, serializeRequest };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __async = (__this, __arguments, generator) => {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
var fulfilled = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
step(generator.next(value));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
reject(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var rejected = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.throw(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
var serializeRequest_exports = {};
|
|
40
|
+
__export(serializeRequest_exports, {
|
|
41
|
+
serializeRequest: () => serializeRequest
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(serializeRequest_exports);
|
|
44
|
+
function serializeRequest(request) {
|
|
45
|
+
return __async(this, null, function* () {
|
|
46
|
+
const requestClone = request.clone();
|
|
47
|
+
const requestText = yield requestClone.text();
|
|
48
|
+
return {
|
|
49
|
+
url: new URL(request.url),
|
|
50
|
+
method: request.method,
|
|
51
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
52
|
+
body: requestText
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
function serializeRequest(request) {
|
|
22
|
+
return __async(this, null, function* () {
|
|
23
|
+
const requestClone = request.clone();
|
|
24
|
+
const requestText = yield requestClone.text();
|
|
25
|
+
return {
|
|
26
|
+
url: new URL(request.url),
|
|
27
|
+
method: request.method,
|
|
28
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
29
|
+
body: requestText
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
serializeRequest
|
|
35
|
+
};
|