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.
Files changed (169) hide show
  1. package/README.md +45 -29
  2. package/browser/package.json +5 -0
  3. package/cli/init.js +3 -3
  4. package/config/constants.js +1 -2
  5. package/lib/browser/index.d.ts +104 -0
  6. package/lib/browser/index.js +752 -0
  7. package/lib/browser/index.mjs +734 -0
  8. package/lib/core/GraphQLHandler-b42ca96f.d.ts +74 -0
  9. package/lib/core/HttpResponse.d.ts +2 -0
  10. package/lib/core/HttpResponse.js +94 -0
  11. package/lib/core/HttpResponse.mjs +77 -0
  12. package/lib/core/RequestHandler-1a5dbdc7.d.ts +172 -0
  13. package/lib/core/SetupApi.d.ts +26 -0
  14. package/lib/core/SetupApi.js +83 -0
  15. package/lib/core/SetupApi.mjs +63 -0
  16. package/lib/core/bypass.d.ts +16 -0
  17. package/lib/core/bypass.js +36 -0
  18. package/lib/core/bypass.mjs +16 -0
  19. package/lib/core/delay.d.ts +18 -0
  20. package/lib/core/delay.js +92 -0
  21. package/lib/core/delay.mjs +72 -0
  22. package/lib/core/graphql.d.ts +109 -0
  23. package/lib/core/graphql.js +112 -0
  24. package/lib/core/graphql.mjs +96 -0
  25. package/lib/core/handlers/GraphQLHandler.d.ts +5 -0
  26. package/lib/core/handlers/GraphQLHandler.js +145 -0
  27. package/lib/core/handlers/GraphQLHandler.mjs +130 -0
  28. package/lib/core/handlers/HttpHandler.d.ts +62 -0
  29. package/lib/core/handlers/HttpHandler.js +149 -0
  30. package/lib/core/handlers/HttpHandler.mjs +133 -0
  31. package/lib/core/handlers/RequestHandler.d.ts +2 -0
  32. package/lib/core/handlers/RequestHandler.js +180 -0
  33. package/lib/core/handlers/RequestHandler.mjs +162 -0
  34. package/lib/core/http.d.ts +26 -0
  35. package/lib/core/http.js +39 -0
  36. package/lib/core/http.mjs +22 -0
  37. package/lib/core/http.spec.d.ts +2 -0
  38. package/lib/core/http.spec.js +15 -0
  39. package/lib/core/http.spec.mjs +14 -0
  40. package/lib/core/index.d.ts +18 -0
  41. package/lib/core/index.js +49 -0
  42. package/lib/core/index.mjs +28 -0
  43. package/lib/core/passthrough.d.ts +17 -0
  44. package/lib/core/passthrough.js +32 -0
  45. package/lib/core/passthrough.mjs +12 -0
  46. package/lib/core/sharedOptions.d.ts +66 -0
  47. package/lib/core/sharedOptions.js +16 -0
  48. package/lib/core/sharedOptions.mjs +0 -0
  49. package/lib/core/typeUtils.d.ts +7 -0
  50. package/lib/core/typeUtils.js +16 -0
  51. package/lib/core/typeUtils.mjs +0 -0
  52. package/lib/core/utils/HttpResponse/decorators.d.ts +12 -0
  53. package/lib/core/utils/HttpResponse/decorators.js +80 -0
  54. package/lib/core/utils/HttpResponse/decorators.mjs +52 -0
  55. package/lib/core/utils/getResponse.d.ts +2 -0
  56. package/lib/core/utils/getResponse.js +64 -0
  57. package/lib/core/utils/getResponse.mjs +44 -0
  58. package/lib/core/utils/handleRequest.d.ts +30 -0
  59. package/lib/core/utils/handleRequest.js +102 -0
  60. package/lib/core/utils/handleRequest.mjs +82 -0
  61. package/lib/core/utils/internal/Disposable.d.ts +7 -0
  62. package/lib/core/utils/internal/Disposable.js +53 -0
  63. package/lib/core/utils/internal/Disposable.mjs +33 -0
  64. package/lib/core/utils/internal/checkGlobals.d.ts +3 -0
  65. package/lib/core/utils/internal/checkGlobals.js +33 -0
  66. package/lib/core/utils/internal/checkGlobals.mjs +13 -0
  67. package/lib/core/utils/internal/devUtils.d.ts +19 -0
  68. package/lib/core/utils/internal/devUtils.js +40 -0
  69. package/lib/core/utils/internal/devUtils.mjs +20 -0
  70. package/lib/core/utils/internal/getCallFrame.d.ts +6 -0
  71. package/lib/core/utils/internal/getCallFrame.js +40 -0
  72. package/lib/core/utils/internal/getCallFrame.mjs +20 -0
  73. package/lib/core/utils/internal/isIterable.d.ts +6 -0
  74. package/lib/core/utils/internal/isIterable.js +29 -0
  75. package/lib/core/utils/internal/isIterable.mjs +9 -0
  76. package/lib/core/utils/internal/isObject.d.ts +6 -0
  77. package/lib/core/utils/internal/isObject.js +26 -0
  78. package/lib/core/utils/internal/isObject.mjs +6 -0
  79. package/lib/core/utils/internal/isStringEqual.d.ts +6 -0
  80. package/lib/core/utils/internal/isStringEqual.js +26 -0
  81. package/lib/core/utils/internal/isStringEqual.mjs +6 -0
  82. package/lib/core/utils/internal/jsonParse.d.ts +7 -0
  83. package/lib/core/utils/internal/jsonParse.js +30 -0
  84. package/lib/core/utils/internal/jsonParse.mjs +10 -0
  85. package/lib/core/utils/internal/mergeRight.d.ts +7 -0
  86. package/lib/core/utils/internal/mergeRight.js +39 -0
  87. package/lib/core/utils/internal/mergeRight.mjs +19 -0
  88. package/lib/core/utils/internal/parseGraphQLRequest.d.ts +5 -0
  89. package/lib/core/utils/internal/parseGraphQLRequest.js +184 -0
  90. package/lib/core/utils/internal/parseGraphQLRequest.mjs +165 -0
  91. package/lib/core/utils/internal/parseMultipartData.d.ts +10 -0
  92. package/lib/core/utils/internal/parseMultipartData.js +81 -0
  93. package/lib/core/utils/internal/parseMultipartData.mjs +61 -0
  94. package/lib/core/utils/internal/pipeEvents.d.ts +8 -0
  95. package/lib/core/utils/internal/pipeEvents.js +34 -0
  96. package/lib/core/utils/internal/pipeEvents.mjs +14 -0
  97. package/lib/core/utils/internal/requestHandlerUtils.d.ts +8 -0
  98. package/lib/core/utils/internal/requestHandlerUtils.js +36 -0
  99. package/lib/core/utils/internal/requestHandlerUtils.mjs +16 -0
  100. package/lib/core/utils/internal/toReadonlyArray.d.ts +6 -0
  101. package/lib/core/utils/internal/toReadonlyArray.js +28 -0
  102. package/lib/core/utils/internal/toReadonlyArray.mjs +8 -0
  103. package/lib/core/utils/internal/tryCatch.d.ts +3 -0
  104. package/lib/core/utils/internal/tryCatch.js +31 -0
  105. package/lib/core/utils/internal/tryCatch.mjs +11 -0
  106. package/lib/core/utils/internal/uuidv4.d.ts +3 -0
  107. package/lib/core/utils/internal/uuidv4.js +26 -0
  108. package/lib/core/utils/internal/uuidv4.mjs +6 -0
  109. package/lib/core/utils/logging/getStatusCodeColor.d.ts +11 -0
  110. package/lib/core/utils/logging/getStatusCodeColor.js +39 -0
  111. package/lib/core/utils/logging/getStatusCodeColor.mjs +19 -0
  112. package/lib/core/utils/logging/getTimestamp.d.ts +6 -0
  113. package/lib/core/utils/logging/getTimestamp.js +27 -0
  114. package/lib/core/utils/logging/getTimestamp.mjs +7 -0
  115. package/lib/core/utils/logging/serializeRequest.d.ts +12 -0
  116. package/lib/core/utils/logging/serializeRequest.js +55 -0
  117. package/lib/core/utils/logging/serializeRequest.mjs +35 -0
  118. package/lib/core/utils/logging/serializeResponse.d.ts +9 -0
  119. package/lib/core/utils/logging/serializeResponse.js +69 -0
  120. package/lib/core/utils/logging/serializeResponse.mjs +39 -0
  121. package/lib/core/utils/matching/matchRequestUrl.d.ts +19 -0
  122. package/lib/core/utils/matching/matchRequestUrl.js +50 -0
  123. package/lib/core/utils/matching/matchRequestUrl.mjs +30 -0
  124. package/lib/core/utils/matching/normalizePath.d.ts +12 -0
  125. package/lib/core/utils/matching/normalizePath.js +32 -0
  126. package/lib/core/utils/matching/normalizePath.mjs +12 -0
  127. package/lib/core/utils/request/getPublicUrlFromRequest.d.ts +7 -0
  128. package/lib/core/utils/request/getPublicUrlFromRequest.js +30 -0
  129. package/lib/core/utils/request/getPublicUrlFromRequest.mjs +10 -0
  130. package/lib/core/utils/request/getRequestCookies.d.ts +8 -0
  131. package/lib/core/utils/request/getRequestCookies.js +88 -0
  132. package/lib/core/utils/request/getRequestCookies.mjs +60 -0
  133. package/lib/core/utils/request/onUnhandledRequest.d.ts +12 -0
  134. package/lib/core/utils/request/onUnhandledRequest.js +193 -0
  135. package/lib/core/utils/request/onUnhandledRequest.mjs +165 -0
  136. package/lib/core/utils/request/readResponseCookies.d.ts +3 -0
  137. package/lib/core/utils/request/readResponseCookies.js +45 -0
  138. package/lib/core/utils/request/readResponseCookies.mjs +27 -0
  139. package/lib/core/utils/toResponseInit.d.ts +3 -0
  140. package/lib/core/utils/toResponseInit.js +30 -0
  141. package/lib/core/utils/toResponseInit.mjs +10 -0
  142. package/lib/core/utils/url/cleanUrl.d.ts +7 -0
  143. package/lib/core/utils/url/cleanUrl.js +31 -0
  144. package/lib/core/utils/url/cleanUrl.mjs +11 -0
  145. package/lib/core/utils/url/getAbsoluteUrl.d.ts +6 -0
  146. package/lib/core/utils/url/getAbsoluteUrl.js +37 -0
  147. package/lib/core/utils/url/getAbsoluteUrl.mjs +17 -0
  148. package/lib/core/utils/url/isAbsoluteUrl.d.ts +6 -0
  149. package/lib/core/utils/url/isAbsoluteUrl.js +26 -0
  150. package/lib/core/utils/url/isAbsoluteUrl.mjs +6 -0
  151. package/lib/iife/index.js +6204 -12360
  152. package/lib/mockServiceWorker.js +82 -93
  153. package/lib/native/index.d.ts +67 -7
  154. package/lib/native/index.js +74 -1500
  155. package/lib/native/index.mjs +69 -1514
  156. package/lib/node/index.d.ts +68 -9
  157. package/lib/node/index.js +77 -1508
  158. package/lib/node/index.mjs +71 -1521
  159. package/native/package.json +2 -1
  160. package/node/package.json +2 -1
  161. package/package.json +53 -23
  162. package/lib/SetupServerApi-1855d9c6.d.ts +0 -20
  163. package/lib/glossary-de6278a9.d.ts +0 -385
  164. package/lib/iife/index.js.map +0 -1
  165. package/lib/index.d.ts +0 -365
  166. package/lib/index.js +0 -2295
  167. package/lib/index.js.map +0 -1
  168. package/lib/node/index.js.map +0 -1
  169. 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,6 @@
1
+ /**
2
+ * Creates an immutable copy of the given array.
3
+ */
4
+ declare function toReadonlyArray<T>(source: Array<T>): ReadonlyArray<T>;
5
+
6
+ export { toReadonlyArray };
@@ -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,8 @@
1
+ function toReadonlyArray(source) {
2
+ const clone = [...source];
3
+ Object.freeze(clone);
4
+ return clone;
5
+ }
6
+ export {
7
+ toReadonlyArray
8
+ };
@@ -0,0 +1,3 @@
1
+ declare function tryCatch<Fn extends (...args: any[]) => any>(fn: Fn, onException?: (error: Error) => void): ReturnType<Fn> | undefined;
2
+
3
+ export { tryCatch };
@@ -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,11 @@
1
+ function tryCatch(fn, onException) {
2
+ try {
3
+ const result = fn();
4
+ return result;
5
+ } catch (error) {
6
+ onException == null ? void 0 : onException(error);
7
+ }
8
+ }
9
+ export {
10
+ tryCatch
11
+ };
@@ -0,0 +1,3 @@
1
+ declare function uuidv4(): string;
2
+
3
+ export { uuidv4 };
@@ -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,6 @@
1
+ function uuidv4() {
2
+ return Math.random().toString(16).slice(2);
3
+ }
4
+ export {
5
+ uuidv4
6
+ };
@@ -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,6 @@
1
+ /**
2
+ * Returns a timestamp string in a "HH:MM:SS" format.
3
+ */
4
+ declare function getTimestamp(): string;
5
+
6
+ export { getTimestamp };
@@ -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,7 @@
1
+ function getTimestamp() {
2
+ const now = /* @__PURE__ */ new Date();
3
+ return [now.getHours(), now.getMinutes(), now.getSeconds()].map(String).map((chunk) => chunk.slice(0, 2)).map((chunk) => chunk.padStart(2, "0")).join(":");
4
+ }
5
+ export {
6
+ getTimestamp
7
+ };
@@ -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
+ };
@@ -0,0 +1,9 @@
1
+ interface SerializedResponse {
2
+ status: number;
3
+ statusText: string;
4
+ headers: Record<string, any>;
5
+ body: string;
6
+ }
7
+ declare function serializeResponse(response: Response): Promise<SerializedResponse>;
8
+
9
+ export { SerializedResponse, serializeResponse };