@ai-sdk/provider-utils 2.0.5 → 2.0.7
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/CHANGELOG.md +18 -0
- package/package.json +3 -3
- package/test/dist/index.d.mts +87 -6
- package/test/dist/index.d.ts +87 -6
- package/test/dist/index.js +342 -147
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +341 -147
- package/test/dist/index.mjs.map +1 -1
package/test/dist/index.mjs
CHANGED
@@ -146,7 +146,7 @@ invariant.as = (ErrorConstructor, predicate, message3, ...positionals) => {
|
|
146
146
|
}
|
147
147
|
};
|
148
148
|
|
149
|
-
// ../../node_modules/.pnpm/msw@2.
|
149
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/devUtils.mjs
|
150
150
|
var LIBRARY_PREFIX = "[MSW]";
|
151
151
|
function formatMessage(message3, ...positionals) {
|
152
152
|
const interpolatedMessage = format(message3, ...positionals);
|
@@ -170,7 +170,7 @@ var InternalError = class extends Error {
|
|
170
170
|
}
|
171
171
|
};
|
172
172
|
|
173
|
-
// ../../node_modules/.pnpm/msw@2.
|
173
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/checkGlobals.mjs
|
174
174
|
function checkGlobals() {
|
175
175
|
invariant(
|
176
176
|
typeof URL !== "undefined",
|
@@ -345,7 +345,7 @@ var _Emitter = class {
|
|
345
345
|
var Emitter = _Emitter;
|
346
346
|
Emitter.defaultMaxListeners = 10;
|
347
347
|
|
348
|
-
// ../../node_modules/.pnpm/msw@2.
|
348
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/pipeEvents.mjs
|
349
349
|
function pipeEvents(source, destination) {
|
350
350
|
const rawEmit = source.emit;
|
351
351
|
if (rawEmit._isPiped) {
|
@@ -359,14 +359,14 @@ function pipeEvents(source, destination) {
|
|
359
359
|
source.emit = sourceEmit;
|
360
360
|
}
|
361
361
|
|
362
|
-
// ../../node_modules/.pnpm/msw@2.
|
362
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/toReadonlyArray.mjs
|
363
363
|
function toReadonlyArray(source) {
|
364
364
|
const clone = [...source];
|
365
365
|
Object.freeze(clone);
|
366
366
|
return clone;
|
367
367
|
}
|
368
368
|
|
369
|
-
// ../../node_modules/.pnpm/msw@2.
|
369
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/Disposable.mjs
|
370
370
|
var Disposable = class {
|
371
371
|
constructor() {
|
372
372
|
__publicField(this, "subscriptions", []);
|
@@ -379,7 +379,7 @@ var Disposable = class {
|
|
379
379
|
}
|
380
380
|
};
|
381
381
|
|
382
|
-
// ../../node_modules/.pnpm/msw@2.
|
382
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/SetupApi.mjs
|
383
383
|
var InMemoryHandlersController = class {
|
384
384
|
constructor(initialHandlers) {
|
385
385
|
__publicField(this, "handlers");
|
@@ -459,7 +459,7 @@ var SetupApi = class extends Disposable {
|
|
459
459
|
}
|
460
460
|
};
|
461
461
|
|
462
|
-
// ../../node_modules/.pnpm/msw@2.
|
462
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/getCallFrame.mjs
|
463
463
|
var SOURCE_FRAME = /[\/\\]msw[\/\\]src[\/\\](.+)/;
|
464
464
|
var BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/;
|
465
465
|
function getCallFrame(error3) {
|
@@ -478,7 +478,7 @@ function getCallFrame(error3) {
|
|
478
478
|
return declarationPath;
|
479
479
|
}
|
480
480
|
|
481
|
-
// ../../node_modules/.pnpm/msw@2.
|
481
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/isIterable.mjs
|
482
482
|
function isIterable(fn) {
|
483
483
|
if (!fn) {
|
484
484
|
return false;
|
@@ -486,7 +486,7 @@ function isIterable(fn) {
|
|
486
486
|
return Reflect.has(fn, Symbol.iterator) || Reflect.has(fn, Symbol.asyncIterator);
|
487
487
|
}
|
488
488
|
|
489
|
-
// ../../node_modules/.pnpm/msw@2.
|
489
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/handlers/RequestHandler.mjs
|
490
490
|
var _RequestHandler = class _RequestHandler {
|
491
491
|
constructor(args) {
|
492
492
|
__publicField(this, "__kind");
|
@@ -638,12 +638,12 @@ var _RequestHandler = class _RequestHandler {
|
|
638
638
|
__publicField(_RequestHandler, "cache", /* @__PURE__ */ new WeakMap());
|
639
639
|
var RequestHandler = _RequestHandler;
|
640
640
|
|
641
|
-
// ../../node_modules/.pnpm/msw@2.
|
641
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/isStringEqual.mjs
|
642
642
|
function isStringEqual(actual, expected) {
|
643
643
|
return actual.toLowerCase() === expected.toLowerCase();
|
644
644
|
}
|
645
645
|
|
646
|
-
// ../../node_modules/.pnpm/msw@2.
|
646
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/logging/getStatusCodeColor.mjs
|
647
647
|
function getStatusCodeColor(status) {
|
648
648
|
if (status < 300) {
|
649
649
|
return "#69AB32";
|
@@ -654,7 +654,7 @@ function getStatusCodeColor(status) {
|
|
654
654
|
return "#E95F5D";
|
655
655
|
}
|
656
656
|
|
657
|
-
// ../../node_modules/.pnpm/msw@2.
|
657
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/logging/getTimestamp.mjs
|
658
658
|
function getTimestamp(options) {
|
659
659
|
const now = /* @__PURE__ */ new Date();
|
660
660
|
const timestamp = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
@@ -664,7 +664,7 @@ function getTimestamp(options) {
|
|
664
664
|
return timestamp;
|
665
665
|
}
|
666
666
|
|
667
|
-
// ../../node_modules/.pnpm/msw@2.
|
667
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/logging/serializeRequest.mjs
|
668
668
|
async function serializeRequest(request) {
|
669
669
|
const requestClone = request.clone();
|
670
670
|
const requestText = await requestClone.text();
|
@@ -843,7 +843,7 @@ var require_statuses = __commonJS({
|
|
843
843
|
var import_statuses = __toESM(require_statuses(), 1);
|
844
844
|
var source_default = import_statuses.default;
|
845
845
|
|
846
|
-
// ../../node_modules/.pnpm/msw@2.
|
846
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/logging/serializeResponse.mjs
|
847
847
|
var { message } = source_default;
|
848
848
|
async function serializeResponse(response) {
|
849
849
|
const responseClone = response.clone();
|
@@ -1461,7 +1461,7 @@ function serializeInput(message3) {
|
|
1461
1461
|
return message3.toString();
|
1462
1462
|
}
|
1463
1463
|
|
1464
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1464
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-I7HQIBT7.mjs
|
1465
1465
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
1466
1466
|
function getGlobalSymbol(symbol) {
|
1467
1467
|
return (
|
@@ -1616,54 +1616,77 @@ var Interceptor = class {
|
|
1616
1616
|
function createRequestId() {
|
1617
1617
|
return Math.random().toString(16).slice(2);
|
1618
1618
|
}
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
return true;
|
1623
|
-
} catch (e) {
|
1624
|
-
return false;
|
1619
|
+
var _FetchResponse = class extends Response {
|
1620
|
+
static isConfigurableStatusCode(status) {
|
1621
|
+
return status >= 200 && status <= 599;
|
1625
1622
|
}
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
headers
|
1657
|
-
|
1623
|
+
static isRedirectResponse(status) {
|
1624
|
+
return _FetchResponse.STATUS_CODES_WITH_REDIRECT.includes(status);
|
1625
|
+
}
|
1626
|
+
/**
|
1627
|
+
* Returns a boolean indicating whether the given response status
|
1628
|
+
* code represents a response that can have a body.
|
1629
|
+
*/
|
1630
|
+
static isResponseWithBody(status) {
|
1631
|
+
return !_FetchResponse.STATUS_CODES_WITHOUT_BODY.includes(status);
|
1632
|
+
}
|
1633
|
+
static setUrl(url, response) {
|
1634
|
+
if (!url) {
|
1635
|
+
return;
|
1636
|
+
}
|
1637
|
+
if (response.url != "") {
|
1638
|
+
return;
|
1639
|
+
}
|
1640
|
+
Object.defineProperty(response, "url", {
|
1641
|
+
value: url,
|
1642
|
+
enumerable: true,
|
1643
|
+
configurable: true,
|
1644
|
+
writable: false
|
1645
|
+
});
|
1646
|
+
}
|
1647
|
+
/**
|
1648
|
+
* Parses the given raw HTTP headers into a Fetch API `Headers` instance.
|
1649
|
+
*/
|
1650
|
+
static parseRawHeaders(rawHeaders) {
|
1651
|
+
const headers = new Headers();
|
1652
|
+
for (let line = 0; line < rawHeaders.length; line += 2) {
|
1653
|
+
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
1654
|
+
}
|
1655
|
+
return headers;
|
1656
|
+
}
|
1657
|
+
constructor(body, init = {}) {
|
1658
|
+
var _a4;
|
1659
|
+
const status = (_a4 = init.status) != null ? _a4 : 200;
|
1660
|
+
const safeStatus = _FetchResponse.isConfigurableStatusCode(status) ? status : 200;
|
1661
|
+
const finalBody = _FetchResponse.isResponseWithBody(status) ? body : null;
|
1662
|
+
super(finalBody, {
|
1663
|
+
...init,
|
1664
|
+
status: safeStatus
|
1665
|
+
});
|
1666
|
+
if (status !== safeStatus) {
|
1667
|
+
const stateSymbol = Object.getOwnPropertySymbols(this).find(
|
1668
|
+
(symbol) => symbol.description === "state"
|
1669
|
+
);
|
1670
|
+
if (stateSymbol) {
|
1671
|
+
const state = Reflect.get(this, stateSymbol);
|
1672
|
+
Reflect.set(state, "status", status);
|
1673
|
+
} else {
|
1674
|
+
Object.defineProperty(this, "status", {
|
1675
|
+
value: status,
|
1676
|
+
enumerable: true,
|
1677
|
+
configurable: true,
|
1678
|
+
writable: false
|
1679
|
+
});
|
1658
1680
|
}
|
1659
1681
|
}
|
1660
|
-
|
1661
|
-
}
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1682
|
+
_FetchResponse.setUrl(init.url, this);
|
1683
|
+
}
|
1684
|
+
};
|
1685
|
+
var FetchResponse = _FetchResponse;
|
1686
|
+
FetchResponse.STATUS_CODES_WITHOUT_BODY = [101, 103, 204, 205, 304];
|
1687
|
+
FetchResponse.STATUS_CODES_WITH_REDIRECT = [301, 302, 303, 307, 308];
|
1665
1688
|
|
1666
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1689
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-PJA4E426.mjs
|
1667
1690
|
var BatchInterceptor = class extends Interceptor {
|
1668
1691
|
constructor(options) {
|
1669
1692
|
BatchInterceptor.symbol = Symbol(options.name);
|
@@ -1706,7 +1729,7 @@ var BatchInterceptor = class extends Interceptor {
|
|
1706
1729
|
}
|
1707
1730
|
};
|
1708
1731
|
|
1709
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1732
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-6HYIRFX2.mjs
|
1710
1733
|
var encoder = new TextEncoder();
|
1711
1734
|
function encodeBuffer(text) {
|
1712
1735
|
return encoder.encode(text);
|
@@ -1722,15 +1745,15 @@ function toArrayBuffer(array) {
|
|
1722
1745
|
);
|
1723
1746
|
}
|
1724
1747
|
|
1725
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1748
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-6YM4PLBI.mjs
|
1726
1749
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
1727
1750
|
|
1728
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1751
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/index.mjs
|
1729
1752
|
function getCleanUrl(url, isAbsolute = true) {
|
1730
1753
|
return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
|
1731
1754
|
}
|
1732
1755
|
|
1733
|
-
// ../../node_modules/.pnpm/msw@2.
|
1756
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/url/cleanUrl.mjs
|
1734
1757
|
var REDUNDANT_CHARACTERS_EXP = /[\?|#].*$/g;
|
1735
1758
|
function getSearchParams(path) {
|
1736
1759
|
return new URL(`/${path}`, "http://localhost").searchParams;
|
@@ -1742,12 +1765,12 @@ function cleanUrl(path) {
|
|
1742
1765
|
return path.replace(REDUNDANT_CHARACTERS_EXP, "");
|
1743
1766
|
}
|
1744
1767
|
|
1745
|
-
// ../../node_modules/.pnpm/msw@2.
|
1768
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/url/isAbsoluteUrl.mjs
|
1746
1769
|
function isAbsoluteUrl(url) {
|
1747
1770
|
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
1748
1771
|
}
|
1749
1772
|
|
1750
|
-
// ../../node_modules/.pnpm/msw@2.
|
1773
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/url/getAbsoluteUrl.mjs
|
1751
1774
|
function getAbsoluteUrl(path, baseUrl) {
|
1752
1775
|
if (isAbsoluteUrl(path)) {
|
1753
1776
|
return path;
|
@@ -1762,7 +1785,7 @@ function getAbsoluteUrl(path, baseUrl) {
|
|
1762
1785
|
) : path;
|
1763
1786
|
}
|
1764
1787
|
|
1765
|
-
// ../../node_modules/.pnpm/msw@2.
|
1788
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/matching/normalizePath.mjs
|
1766
1789
|
function normalizePath(path, baseUrl) {
|
1767
1790
|
if (path instanceof RegExp) {
|
1768
1791
|
return path;
|
@@ -1771,7 +1794,7 @@ function normalizePath(path, baseUrl) {
|
|
1771
1794
|
return cleanUrl(maybeAbsoluteUrl);
|
1772
1795
|
}
|
1773
1796
|
|
1774
|
-
// ../../node_modules/.pnpm/msw@2.
|
1797
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/matching/matchRequestUrl.mjs
|
1775
1798
|
function coercePath(path) {
|
1776
1799
|
return path.replace(
|
1777
1800
|
/([:a-zA-Z_-]*)(\*{1,2})+/g,
|
@@ -1796,7 +1819,7 @@ function matchRequestUrl(url, path, baseUrl) {
|
|
1796
1819
|
};
|
1797
1820
|
}
|
1798
1821
|
|
1799
|
-
// ../../node_modules/.pnpm/msw@2.
|
1822
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/request/toPublicUrl.mjs
|
1800
1823
|
function toPublicUrl(url) {
|
1801
1824
|
if (typeof location === "undefined") {
|
1802
1825
|
return url.toString();
|
@@ -13846,7 +13869,7 @@ var require_cookie2 = __commonJS3({
|
|
13846
13869
|
var import_tough_cookie = __toESM3(require_cookie2(), 1);
|
13847
13870
|
var source_default3 = import_tough_cookie.default;
|
13848
13871
|
|
13849
|
-
// ../../node_modules/.pnpm/msw@2.
|
13872
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/cookieStore.mjs
|
13850
13873
|
var { Cookie, CookieJar, Store, MemoryCookieStore, domainMatch, pathMatch } = source_default3;
|
13851
13874
|
var WebStorageCookieStore = class extends Store {
|
13852
13875
|
constructor() {
|
@@ -13998,7 +14021,7 @@ var WebStorageCookieStore = class extends Store {
|
|
13998
14021
|
var store = isNodeProcess() ? new MemoryCookieStore() : new WebStorageCookieStore();
|
13999
14022
|
var cookieStore = new CookieJar(store);
|
14000
14023
|
|
14001
|
-
// ../../node_modules/.pnpm/msw@2.
|
14024
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/request/getRequestCookies.mjs
|
14002
14025
|
function parseCookies(input) {
|
14003
14026
|
const parsedCookies = source_default2.parse(input);
|
14004
14027
|
const cookies = {};
|
@@ -14053,7 +14076,7 @@ function getAllRequestCookies(request) {
|
|
14053
14076
|
};
|
14054
14077
|
}
|
14055
14078
|
|
14056
|
-
// ../../node_modules/.pnpm/msw@2.
|
14079
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/handlers/HttpHandler.mjs
|
14057
14080
|
var HttpMethods = /* @__PURE__ */ ((HttpMethods2) => {
|
14058
14081
|
HttpMethods2["HEAD"] = "HEAD";
|
14059
14082
|
HttpMethods2["GET"] = "GET";
|
@@ -14143,7 +14166,7 @@ var HttpHandler = class extends RequestHandler {
|
|
14143
14166
|
}
|
14144
14167
|
};
|
14145
14168
|
|
14146
|
-
// ../../node_modules/.pnpm/msw@2.
|
14169
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/http.mjs
|
14147
14170
|
function createHttpHandler(method) {
|
14148
14171
|
return (path, resolver, options = {}) => {
|
14149
14172
|
return new HttpHandler(method, path, resolver, options);
|
@@ -14574,7 +14597,7 @@ var Headers2 = class _Headers {
|
|
14574
14597
|
}
|
14575
14598
|
};
|
14576
14599
|
|
14577
|
-
// ../../node_modules/.pnpm/msw@2.
|
14600
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/handlers/WebSocketHandler.mjs
|
14578
14601
|
var kEmitter = Symbol("kEmitter");
|
14579
14602
|
var kDispatchEvent = Symbol("kDispatchEvent");
|
14580
14603
|
var kSender = Symbol("kSender");
|
@@ -14748,7 +14771,7 @@ var until = async (promise) => {
|
|
14748
14771
|
}
|
14749
14772
|
};
|
14750
14773
|
|
14751
|
-
// ../../node_modules/.pnpm/msw@2.
|
14774
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/executeHandlers.mjs
|
14752
14775
|
var executeHandlers = async ({
|
14753
14776
|
request,
|
14754
14777
|
requestId,
|
@@ -14776,7 +14799,7 @@ var executeHandlers = async ({
|
|
14776
14799
|
return null;
|
14777
14800
|
};
|
14778
14801
|
|
14779
|
-
// ../../node_modules/.pnpm/msw@2.
|
14802
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/request/onUnhandledRequest.mjs
|
14780
14803
|
async function onUnhandledRequest(request, strategy = "warn") {
|
14781
14804
|
const url = new URL(request.url);
|
14782
14805
|
const publicUrl = toPublicUrl(url) + url.search;
|
@@ -14828,7 +14851,7 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
14828
14851
|
applyStrategy(strategy);
|
14829
14852
|
}
|
14830
14853
|
|
14831
|
-
// ../../node_modules/.pnpm/msw@2.
|
14854
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
|
14832
14855
|
var { message: message2 } = source_default;
|
14833
14856
|
var kSetCookie = Symbol("kSetCookie");
|
14834
14857
|
function normalizeResponseInit(init = {}) {
|
@@ -14869,7 +14892,7 @@ function decorateResponse(response, init) {
|
|
14869
14892
|
return response;
|
14870
14893
|
}
|
14871
14894
|
|
14872
|
-
// ../../node_modules/.pnpm/msw@2.
|
14895
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/request/storeResponseCookies.mjs
|
14873
14896
|
function storeResponseCookies(request, response) {
|
14874
14897
|
const responseCookies = Reflect.get(response, kSetCookie);
|
14875
14898
|
if (responseCookies) {
|
@@ -14877,7 +14900,7 @@ function storeResponseCookies(request, response) {
|
|
14877
14900
|
}
|
14878
14901
|
}
|
14879
14902
|
|
14880
|
-
// ../../node_modules/.pnpm/msw@2.
|
14903
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/handleRequest.mjs
|
14881
14904
|
async function handleRequest(request, requestId, handlers, options, emitter, handleRequestOptions) {
|
14882
14905
|
var _a4, _b2, _c2, _d, _e, _f;
|
14883
14906
|
emitter.emit("request:start", { request, requestId });
|
@@ -14928,7 +14951,7 @@ async function handleRequest(request, requestId, handlers, options, emitter, han
|
|
14928
14951
|
return response;
|
14929
14952
|
}
|
14930
14953
|
|
14931
|
-
// ../../node_modules/.pnpm/msw@2.
|
14954
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/HttpResponse.mjs
|
14932
14955
|
var HttpResponse = class _HttpResponse extends Response {
|
14933
14956
|
constructor(body, init) {
|
14934
14957
|
const responseInit = normalizeResponseInit(init);
|
@@ -15014,6 +15037,9 @@ var HttpResponse = class _HttpResponse extends Response {
|
|
15014
15037
|
*/
|
15015
15038
|
static arrayBuffer(body, init) {
|
15016
15039
|
const responseInit = normalizeResponseInit(init);
|
15040
|
+
if (!responseInit.headers.has("Content-Type")) {
|
15041
|
+
responseInit.headers.set("Content-Type", "application/octet-stream");
|
15042
|
+
}
|
15017
15043
|
if (body && !responseInit.headers.has("Content-Length")) {
|
15018
15044
|
responseInit.headers.set("Content-Length", body.byteLength.toString());
|
15019
15045
|
}
|
@@ -15032,13 +15058,13 @@ var HttpResponse = class _HttpResponse extends Response {
|
|
15032
15058
|
}
|
15033
15059
|
};
|
15034
15060
|
|
15035
|
-
// ../../node_modules/.pnpm/msw@2.
|
15061
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/index.mjs
|
15036
15062
|
checkGlobals();
|
15037
15063
|
|
15038
|
-
// ../../node_modules/.pnpm/msw@2.
|
15064
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/node/index.mjs
|
15039
15065
|
import { AsyncLocalStorage } from "async_hooks";
|
15040
15066
|
|
15041
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
15067
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-5KMS5CTP.mjs
|
15042
15068
|
var InterceptorError = class extends Error {
|
15043
15069
|
constructor(message3) {
|
15044
15070
|
super(message3);
|
@@ -15099,6 +15125,35 @@ async function emitAsync(emitter, eventName, ...data) {
|
|
15099
15125
|
await listener.apply(emitter, data);
|
15100
15126
|
}
|
15101
15127
|
}
|
15128
|
+
function isPropertyAccessible(obj, key) {
|
15129
|
+
try {
|
15130
|
+
obj[key];
|
15131
|
+
return true;
|
15132
|
+
} catch (e) {
|
15133
|
+
return false;
|
15134
|
+
}
|
15135
|
+
}
|
15136
|
+
function createServerErrorResponse(body) {
|
15137
|
+
return new Response(
|
15138
|
+
JSON.stringify(
|
15139
|
+
body instanceof Error ? {
|
15140
|
+
name: body.name,
|
15141
|
+
message: body.message,
|
15142
|
+
stack: body.stack
|
15143
|
+
} : body
|
15144
|
+
),
|
15145
|
+
{
|
15146
|
+
status: 500,
|
15147
|
+
statusText: "Unhandled Exception",
|
15148
|
+
headers: {
|
15149
|
+
"Content-Type": "application/json"
|
15150
|
+
}
|
15151
|
+
}
|
15152
|
+
);
|
15153
|
+
}
|
15154
|
+
function isResponseError(response) {
|
15155
|
+
return isPropertyAccessible(response, "type") && response.type === "error";
|
15156
|
+
}
|
15102
15157
|
function isNodeLikeError(error3) {
|
15103
15158
|
if (error3 == null) {
|
15104
15159
|
return false;
|
@@ -15210,7 +15265,7 @@ async function handleRequest2(options) {
|
|
15210
15265
|
return false;
|
15211
15266
|
}
|
15212
15267
|
|
15213
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
15268
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-QFFDMWKW.mjs
|
15214
15269
|
import http2 from "http";
|
15215
15270
|
import https2 from "https";
|
15216
15271
|
import net2 from "net";
|
@@ -15301,13 +15356,6 @@ function baseUrlFromConnectionOptions(options) {
|
|
15301
15356
|
}
|
15302
15357
|
return url;
|
15303
15358
|
}
|
15304
|
-
function parseRawHeaders(rawHeaders) {
|
15305
|
-
const headers = new Headers();
|
15306
|
-
for (let line = 0; line < rawHeaders.length; line += 2) {
|
15307
|
-
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
15308
|
-
}
|
15309
|
-
return headers;
|
15310
|
-
}
|
15311
15359
|
var kRawHeaders = Symbol("kRawHeaders");
|
15312
15360
|
var kRestorePatches = Symbol("kRestorePatches");
|
15313
15361
|
function recordRawHeader(headers, args, behavior) {
|
@@ -15377,7 +15425,14 @@ function recordRawFetchHeaders() {
|
|
15377
15425
|
[Reflect.get(headersInit, kRawHeaders)],
|
15378
15426
|
newTarget
|
15379
15427
|
);
|
15380
|
-
ensureRawHeadersSymbol(headers2,
|
15428
|
+
ensureRawHeadersSymbol(headers2, [
|
15429
|
+
/**
|
15430
|
+
* @note Spread the retrieved headers to clone them.
|
15431
|
+
* This prevents multiple Headers instances from pointing
|
15432
|
+
* at the same internal "rawHeaders" array.
|
15433
|
+
*/
|
15434
|
+
...Reflect.get(headersInit, kRawHeaders)
|
15435
|
+
]);
|
15381
15436
|
return headers2;
|
15382
15437
|
}
|
15383
15438
|
const headers = Reflect.construct(target, args, newTarget);
|
@@ -15475,8 +15530,14 @@ var MockHttpSocket = class extends MockSocket {
|
|
15475
15530
|
constructor(options) {
|
15476
15531
|
super({
|
15477
15532
|
write: (chunk, encoding, callback) => {
|
15478
|
-
|
15533
|
+
var _a4;
|
15534
|
+
if (this.socketState !== "passthrough") {
|
15535
|
+
this.writeBuffer.push([chunk, encoding, callback]);
|
15536
|
+
}
|
15479
15537
|
if (chunk) {
|
15538
|
+
if (this.socketState === "passthrough") {
|
15539
|
+
(_a4 = this.originalSocket) == null ? void 0 : _a4.write(chunk, encoding, callback);
|
15540
|
+
}
|
15480
15541
|
this.requestParser.execute(
|
15481
15542
|
Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding)
|
15482
15543
|
);
|
@@ -15491,13 +15552,13 @@ var MockHttpSocket = class extends MockSocket {
|
|
15491
15552
|
}
|
15492
15553
|
});
|
15493
15554
|
this.writeBuffer = [];
|
15494
|
-
this.
|
15555
|
+
this.socketState = "unknown";
|
15495
15556
|
this.onRequestStart = (versionMajor, versionMinor, rawHeaders, _, path, __, ___, ____, shouldKeepAlive) => {
|
15496
15557
|
var _a4;
|
15497
15558
|
this.shouldKeepAlive = shouldKeepAlive;
|
15498
15559
|
const url = new URL(path, this.baseUrl);
|
15499
15560
|
const method = ((_a4 = this.connectionOptions.method) == null ? void 0 : _a4.toUpperCase()) || "GET";
|
15500
|
-
const headers = parseRawHeaders(rawHeaders);
|
15561
|
+
const headers = FetchResponse.parseRawHeaders(rawHeaders);
|
15501
15562
|
const canHaveBody = method !== "GET" && method !== "HEAD";
|
15502
15563
|
if (url.username || url.password) {
|
15503
15564
|
if (!headers.has("authorization")) {
|
@@ -15539,13 +15600,8 @@ var MockHttpSocket = class extends MockSocket {
|
|
15539
15600
|
});
|
15540
15601
|
};
|
15541
15602
|
this.onResponseStart = (versionMajor, versionMinor, rawHeaders, method, url, status, statusText) => {
|
15542
|
-
const headers = parseRawHeaders(rawHeaders);
|
15543
|
-
const
|
15544
|
-
if (canHaveBody) {
|
15545
|
-
this.responseStream = new Readable({ read() {
|
15546
|
-
} });
|
15547
|
-
}
|
15548
|
-
const response = new Response(
|
15603
|
+
const headers = FetchResponse.parseRawHeaders(rawHeaders);
|
15604
|
+
const response = new FetchResponse(
|
15549
15605
|
/**
|
15550
15606
|
* @note The Fetch API response instance exposed to the consumer
|
15551
15607
|
* is created over the response stream of the HTTP parser. It is NOT
|
@@ -15553,8 +15609,12 @@ var MockHttpSocket = class extends MockSocket {
|
|
15553
15609
|
* in response listener while the Socket instance delays the emission
|
15554
15610
|
* of "end" and other events until those response listeners are finished.
|
15555
15611
|
*/
|
15556
|
-
|
15612
|
+
FetchResponse.isResponseWithBody(status) ? Readable.toWeb(
|
15613
|
+
this.responseStream = new Readable({ read() {
|
15614
|
+
} })
|
15615
|
+
) : null,
|
15557
15616
|
{
|
15617
|
+
url,
|
15558
15618
|
status,
|
15559
15619
|
statusText,
|
15560
15620
|
headers
|
@@ -15569,7 +15629,7 @@ var MockHttpSocket = class extends MockSocket {
|
|
15569
15629
|
}
|
15570
15630
|
this.responseListenersPromise = this.onResponse({
|
15571
15631
|
response,
|
15572
|
-
isMockedResponse: this.
|
15632
|
+
isMockedResponse: this.socketState === "mock",
|
15573
15633
|
requestId: Reflect.get(this.request, kRequestId),
|
15574
15634
|
request: this.request,
|
15575
15635
|
socket: this
|
@@ -15619,10 +15679,12 @@ var MockHttpSocket = class extends MockSocket {
|
|
15619
15679
|
* its data/events through this Socket.
|
15620
15680
|
*/
|
15621
15681
|
passthrough() {
|
15682
|
+
this.socketState = "passthrough";
|
15622
15683
|
if (this.destroyed) {
|
15623
15684
|
return;
|
15624
15685
|
}
|
15625
15686
|
const socket = this.createConnection();
|
15687
|
+
this.originalSocket = socket;
|
15626
15688
|
this.once("error", (error3) => {
|
15627
15689
|
socket.destroy(error3);
|
15628
15690
|
});
|
@@ -15695,7 +15757,7 @@ var MockHttpSocket = class extends MockSocket {
|
|
15695
15757
|
return;
|
15696
15758
|
}
|
15697
15759
|
this.mockConnect();
|
15698
|
-
this.
|
15760
|
+
this.socketState = "mock";
|
15699
15761
|
this.flushWriteBuffer();
|
15700
15762
|
const serverResponse = new ServerResponse(new IncomingMessage(this));
|
15701
15763
|
serverResponse.assignSocket(
|
@@ -15778,8 +15840,11 @@ var MockHttpSocket = class extends MockSocket {
|
|
15778
15840
|
}
|
15779
15841
|
}
|
15780
15842
|
flushWriteBuffer() {
|
15781
|
-
for (const
|
15782
|
-
|
15843
|
+
for (const writeCall of this.writeBuffer) {
|
15844
|
+
if (typeof writeCall[2] === "function") {
|
15845
|
+
writeCall[2]();
|
15846
|
+
writeCall[2] = void 0;
|
15847
|
+
}
|
15783
15848
|
}
|
15784
15849
|
}
|
15785
15850
|
onRequestBody(chunk) {
|
@@ -16203,7 +16268,7 @@ var _ClientRequestInterceptor = class extends Interceptor {
|
|
16203
16268
|
var ClientRequestInterceptor = _ClientRequestInterceptor;
|
16204
16269
|
ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
|
16205
16270
|
|
16206
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
16271
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-TX5GBTFY.mjs
|
16207
16272
|
function hasConfigurableGlobal(propertyName) {
|
16208
16273
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
16209
16274
|
if (typeof descriptor === "undefined") {
|
@@ -16224,7 +16289,7 @@ function hasConfigurableGlobal(propertyName) {
|
|
16224
16289
|
return true;
|
16225
16290
|
}
|
16226
16291
|
|
16227
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
16292
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-OMWE7UVM.mjs
|
16228
16293
|
function concatArrayBuffer(left, right) {
|
16229
16294
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
16230
16295
|
result.set(left, 0);
|
@@ -16387,8 +16452,9 @@ function parseJson(data) {
|
|
16387
16452
|
}
|
16388
16453
|
}
|
16389
16454
|
function createResponse(request, body) {
|
16390
|
-
const responseBodyOrNull =
|
16391
|
-
return new
|
16455
|
+
const responseBodyOrNull = FetchResponse.isResponseWithBody(request.status) ? body : null;
|
16456
|
+
return new FetchResponse(responseBodyOrNull, {
|
16457
|
+
url: request.responseURL,
|
16392
16458
|
status: request.status,
|
16393
16459
|
statusText: request.statusText,
|
16394
16460
|
headers: createHeadersFromXMLHttpReqestHeaders(
|
@@ -17009,7 +17075,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
17009
17075
|
var XMLHttpRequestInterceptor = _XMLHttpRequestInterceptor;
|
17010
17076
|
XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
17011
17077
|
|
17012
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
17078
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-CTGTMEFD.mjs
|
17013
17079
|
import zlib from "zlib";
|
17014
17080
|
function canParseUrl(url) {
|
17015
17081
|
try {
|
@@ -17200,8 +17266,9 @@ var _FetchInterceptor = class extends Interceptor {
|
|
17200
17266
|
rawResponse
|
17201
17267
|
});
|
17202
17268
|
const decompressedStream = decompressResponse(rawResponse);
|
17203
|
-
const response = decompressedStream === null ? rawResponse : new
|
17204
|
-
|
17269
|
+
const response = decompressedStream === null ? rawResponse : new FetchResponse(decompressedStream, rawResponse);
|
17270
|
+
FetchResponse.setUrl(request.url, response);
|
17271
|
+
if (FetchResponse.isRedirectResponse(response.status)) {
|
17205
17272
|
if (request.redirect === "error") {
|
17206
17273
|
responsePromise.reject(createNetworkError("unexpected redirect"));
|
17207
17274
|
return;
|
@@ -17218,12 +17285,6 @@ var _FetchInterceptor = class extends Interceptor {
|
|
17218
17285
|
return;
|
17219
17286
|
}
|
17220
17287
|
}
|
17221
|
-
Object.defineProperty(response, "url", {
|
17222
|
-
writable: false,
|
17223
|
-
enumerable: true,
|
17224
|
-
configurable: false,
|
17225
|
-
value: request.url
|
17226
|
-
});
|
17227
17288
|
if (this.emitter.listenerCount("response") > 0) {
|
17228
17289
|
this.logger.info('emitting the "response" event...');
|
17229
17290
|
await emitAsync(this.emitter, "response", {
|
@@ -17289,12 +17350,12 @@ var _FetchInterceptor = class extends Interceptor {
|
|
17289
17350
|
var FetchInterceptor = _FetchInterceptor;
|
17290
17351
|
FetchInterceptor.symbol = Symbol("fetch");
|
17291
17352
|
|
17292
|
-
// ../../node_modules/.pnpm/msw@2.
|
17353
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/isObject.mjs
|
17293
17354
|
function isObject2(value) {
|
17294
17355
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
17295
17356
|
}
|
17296
17357
|
|
17297
|
-
// ../../node_modules/.pnpm/msw@2.
|
17358
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/mergeRight.mjs
|
17298
17359
|
function mergeRight(left, right) {
|
17299
17360
|
return Object.entries(right).reduce(
|
17300
17361
|
(result, [key, rightValue]) => {
|
@@ -17314,7 +17375,7 @@ function mergeRight(left, right) {
|
|
17314
17375
|
);
|
17315
17376
|
}
|
17316
17377
|
|
17317
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
17378
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/browser/chunk-TX5GBTFY.mjs
|
17318
17379
|
function hasConfigurableGlobal2(propertyName) {
|
17319
17380
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
17320
17381
|
if (typeof descriptor === "undefined") {
|
@@ -17335,7 +17396,7 @@ function hasConfigurableGlobal2(propertyName) {
|
|
17335
17396
|
return true;
|
17336
17397
|
}
|
17337
17398
|
|
17338
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
17399
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
17339
17400
|
function getGlobalSymbol2(symbol) {
|
17340
17401
|
return (
|
17341
17402
|
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
|
@@ -17482,7 +17543,7 @@ function createRequestId2() {
|
|
17482
17543
|
return Math.random().toString(16).slice(2);
|
17483
17544
|
}
|
17484
17545
|
|
17485
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
17546
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/browser/interceptors/WebSocket/index.mjs
|
17486
17547
|
function bindEvent(target, event) {
|
17487
17548
|
Object.defineProperties(event, {
|
17488
17549
|
target: {
|
@@ -18045,23 +18106,39 @@ var WebSocketClassTransport = class extends EventTarget {
|
|
18045
18106
|
}
|
18046
18107
|
send(data) {
|
18047
18108
|
queueMicrotask(() => {
|
18048
|
-
this.socket.
|
18049
|
-
|
18050
|
-
|
18051
|
-
|
18052
|
-
|
18053
|
-
|
18054
|
-
|
18055
|
-
|
18056
|
-
|
18057
|
-
|
18058
|
-
|
18059
|
-
|
18060
|
-
|
18061
|
-
|
18062
|
-
|
18063
|
-
|
18064
|
-
|
18109
|
+
if (this.socket.readyState === this.socket.CLOSING || this.socket.readyState === this.socket.CLOSED) {
|
18110
|
+
return;
|
18111
|
+
}
|
18112
|
+
const dispatchEvent = () => {
|
18113
|
+
this.socket.dispatchEvent(
|
18114
|
+
bindEvent(
|
18115
|
+
/**
|
18116
|
+
* @note Setting this event's "target" to the
|
18117
|
+
* WebSocket override instance is important.
|
18118
|
+
* This way it can tell apart original incoming events
|
18119
|
+
* (must be forwarded to the transport) from the
|
18120
|
+
* mocked message events like the one below
|
18121
|
+
* (must be dispatched on the client instance).
|
18122
|
+
*/
|
18123
|
+
this.socket,
|
18124
|
+
new MessageEvent("message", {
|
18125
|
+
data,
|
18126
|
+
origin: this.socket.url
|
18127
|
+
})
|
18128
|
+
)
|
18129
|
+
);
|
18130
|
+
};
|
18131
|
+
if (this.socket.readyState === this.socket.CONNECTING) {
|
18132
|
+
this.socket.addEventListener(
|
18133
|
+
"open",
|
18134
|
+
() => {
|
18135
|
+
dispatchEvent();
|
18136
|
+
},
|
18137
|
+
{ once: true }
|
18138
|
+
);
|
18139
|
+
} else {
|
18140
|
+
dispatchEvent();
|
18141
|
+
}
|
18065
18142
|
});
|
18066
18143
|
}
|
18067
18144
|
close(code, reason) {
|
@@ -18143,17 +18220,17 @@ var _WebSocketInterceptor = class extends Interceptor2 {
|
|
18143
18220
|
var WebSocketInterceptor = _WebSocketInterceptor;
|
18144
18221
|
WebSocketInterceptor.symbol = Symbol("websocket");
|
18145
18222
|
|
18146
|
-
// ../../node_modules/.pnpm/msw@2.
|
18223
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/ws/webSocketInterceptor.mjs
|
18147
18224
|
var webSocketInterceptor = new WebSocketInterceptor();
|
18148
18225
|
|
18149
|
-
// ../../node_modules/.pnpm/msw@2.
|
18226
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/utils/internal/isHandlerKind.mjs
|
18150
18227
|
function isHandlerKind(kind) {
|
18151
18228
|
return (input) => {
|
18152
18229
|
return input != null && typeof input === "object" && "__kind" in input && input.__kind === kind;
|
18153
18230
|
};
|
18154
18231
|
}
|
18155
18232
|
|
18156
|
-
// ../../node_modules/.pnpm/msw@2.
|
18233
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/core/ws/handleWebSocketEvent.mjs
|
18157
18234
|
function handleWebSocketEvent(options) {
|
18158
18235
|
webSocketInterceptor.on("connection", async (connection) => {
|
18159
18236
|
const handlers = options.getHandlers();
|
@@ -18201,7 +18278,7 @@ function handleWebSocketEvent(options) {
|
|
18201
18278
|
});
|
18202
18279
|
}
|
18203
18280
|
|
18204
|
-
// ../../node_modules/.pnpm/msw@2.
|
18281
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@18.18.9_typescript@5.6.3/node_modules/msw/lib/node/index.mjs
|
18205
18282
|
var DEFAULT_LISTEN_OPTIONS = {
|
18206
18283
|
onUnhandledRequest: "warn"
|
18207
18284
|
};
|
@@ -18215,7 +18292,6 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
18215
18292
|
interceptors: interceptors.map((Interceptor3) => new Interceptor3())
|
18216
18293
|
});
|
18217
18294
|
this.resolvedOptions = {};
|
18218
|
-
this.init();
|
18219
18295
|
}
|
18220
18296
|
/**
|
18221
18297
|
* Subscribe to all requests that are using the interceptor object
|
@@ -18290,6 +18366,7 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
18290
18366
|
options
|
18291
18367
|
);
|
18292
18368
|
this.interceptor.apply();
|
18369
|
+
this.init();
|
18293
18370
|
this.subscriptions.push(() => this.interceptor.dispose());
|
18294
18371
|
webSocketInterceptor.apply();
|
18295
18372
|
this.subscriptions.push(() => webSocketInterceptor.dispose());
|
@@ -18360,6 +18437,9 @@ var setupServer = (...handlers) => {
|
|
18360
18437
|
|
18361
18438
|
// src/test/json-test-server.ts
|
18362
18439
|
var JsonTestServer = class {
|
18440
|
+
/**
|
18441
|
+
* @deprecated Use createTestServer instead
|
18442
|
+
*/
|
18363
18443
|
constructor(url) {
|
18364
18444
|
this.responseHeaders = {};
|
18365
18445
|
this.responseBodyJson = {};
|
@@ -18410,6 +18490,9 @@ var JsonTestServer = class {
|
|
18410
18490
|
|
18411
18491
|
// src/test/streaming-test-server.ts
|
18412
18492
|
var StreamingTestServer = class {
|
18493
|
+
/**
|
18494
|
+
* @deprecated Use createTestServer instead
|
18495
|
+
*/
|
18413
18496
|
constructor(url) {
|
18414
18497
|
this.responseHeaders = {};
|
18415
18498
|
this.responseChunks = [];
|
@@ -18528,7 +18611,10 @@ function createServer({
|
|
18528
18611
|
var _a4, _b2;
|
18529
18612
|
pushCall(new TestServerCall(request));
|
18530
18613
|
const invocationCount = urlInvocationCounts[url]++;
|
18531
|
-
const response = responses2[
|
18614
|
+
const response = responses2[
|
18615
|
+
// TODO bug needs to be >=
|
18616
|
+
invocationCount > responses2.length ? responses2.length - 1 : invocationCount
|
18617
|
+
];
|
18532
18618
|
switch (response.type) {
|
18533
18619
|
case "json-value":
|
18534
18620
|
return HttpResponse.json(response.content, {
|
@@ -18640,6 +18726,113 @@ function describeWithTestServer(description, responses, testFunction) {
|
|
18640
18726
|
});
|
18641
18727
|
});
|
18642
18728
|
}
|
18729
|
+
|
18730
|
+
// src/test/unified-test-server.ts
|
18731
|
+
var TestServerCall2 = class {
|
18732
|
+
constructor(request) {
|
18733
|
+
this.request = request;
|
18734
|
+
}
|
18735
|
+
get requestBody() {
|
18736
|
+
return this.request.text().then(JSON.parse);
|
18737
|
+
}
|
18738
|
+
get requestHeaders() {
|
18739
|
+
const requestHeaders = this.request.headers;
|
18740
|
+
const headersObject = {};
|
18741
|
+
requestHeaders.forEach((value, key) => {
|
18742
|
+
headersObject[key] = value;
|
18743
|
+
});
|
18744
|
+
return headersObject;
|
18745
|
+
}
|
18746
|
+
get requestUrlSearchParams() {
|
18747
|
+
return new URL(this.request.url).searchParams;
|
18748
|
+
}
|
18749
|
+
get requestUrl() {
|
18750
|
+
return this.request.url;
|
18751
|
+
}
|
18752
|
+
get requestMethod() {
|
18753
|
+
return this.request.method;
|
18754
|
+
}
|
18755
|
+
};
|
18756
|
+
function createTestServer(routes) {
|
18757
|
+
const originalRoutes = structuredClone(routes);
|
18758
|
+
const mswServer = setupServer(
|
18759
|
+
...Object.entries(routes).map(([url, handler]) => {
|
18760
|
+
return http.all(url, ({ request, params }) => {
|
18761
|
+
var _a4, _b2, _c2, _d, _e;
|
18762
|
+
calls.push(new TestServerCall2(request));
|
18763
|
+
const response = handler.response;
|
18764
|
+
if (response === void 0) {
|
18765
|
+
return HttpResponse.json({ error: "Not Found" }, { status: 404 });
|
18766
|
+
}
|
18767
|
+
const handlerType = response.type;
|
18768
|
+
switch (handlerType) {
|
18769
|
+
case "json-value":
|
18770
|
+
return HttpResponse.json(response.body, {
|
18771
|
+
status: 200,
|
18772
|
+
headers: {
|
18773
|
+
"Content-Type": "application/json",
|
18774
|
+
...(_a4 = handler.response) == null ? void 0 : _a4.headers
|
18775
|
+
}
|
18776
|
+
});
|
18777
|
+
case "stream-chunks":
|
18778
|
+
return new HttpResponse(
|
18779
|
+
convertArrayToReadableStream(response.chunks).pipeThrough(
|
18780
|
+
new TextEncoderStream()
|
18781
|
+
),
|
18782
|
+
{
|
18783
|
+
status: 200,
|
18784
|
+
headers: {
|
18785
|
+
"Content-Type": "text/event-stream",
|
18786
|
+
"Cache-Control": "no-cache",
|
18787
|
+
Connection: "keep-alive",
|
18788
|
+
...response.headers
|
18789
|
+
}
|
18790
|
+
}
|
18791
|
+
);
|
18792
|
+
case "binary": {
|
18793
|
+
return HttpResponse.arrayBuffer(response.body, {
|
18794
|
+
status: 200,
|
18795
|
+
headers: (_b2 = handler.response) == null ? void 0 : _b2.headers
|
18796
|
+
});
|
18797
|
+
}
|
18798
|
+
case "error":
|
18799
|
+
return HttpResponse.text((_c2 = response.body) != null ? _c2 : "Error", {
|
18800
|
+
status: (_d = response.status) != null ? _d : 500,
|
18801
|
+
headers: response.headers
|
18802
|
+
});
|
18803
|
+
case "empty":
|
18804
|
+
return new HttpResponse(null, {
|
18805
|
+
status: (_e = response.status) != null ? _e : 200
|
18806
|
+
});
|
18807
|
+
default: {
|
18808
|
+
const _exhaustiveCheck = handlerType;
|
18809
|
+
throw new Error(`Unknown response type: ${_exhaustiveCheck}`);
|
18810
|
+
}
|
18811
|
+
}
|
18812
|
+
});
|
18813
|
+
})
|
18814
|
+
);
|
18815
|
+
let calls = [];
|
18816
|
+
beforeAll(() => {
|
18817
|
+
mswServer.listen();
|
18818
|
+
});
|
18819
|
+
beforeEach(() => {
|
18820
|
+
mswServer.resetHandlers();
|
18821
|
+
Object.entries(originalRoutes).forEach(([url, handler]) => {
|
18822
|
+
routes[url].response = handler.response;
|
18823
|
+
});
|
18824
|
+
calls = [];
|
18825
|
+
});
|
18826
|
+
afterAll(() => {
|
18827
|
+
mswServer.close();
|
18828
|
+
});
|
18829
|
+
return {
|
18830
|
+
urls: routes,
|
18831
|
+
get calls() {
|
18832
|
+
return calls;
|
18833
|
+
}
|
18834
|
+
};
|
18835
|
+
}
|
18643
18836
|
export {
|
18644
18837
|
JsonTestServer,
|
18645
18838
|
StreamingTestServer,
|
@@ -18648,6 +18841,7 @@ export {
|
|
18648
18841
|
convertAsyncIterableToArray,
|
18649
18842
|
convertReadableStreamToArray,
|
18650
18843
|
convertResponseStreamToArray,
|
18844
|
+
createTestServer,
|
18651
18845
|
describeWithTestServer,
|
18652
18846
|
withTestServer
|
18653
18847
|
};
|