@ai-sdk/provider-utils 2.0.6 → 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 +8 -0
- package/package.json +2 -2
- package/test/dist/index.d.mts +87 -20
- package/test/dist/index.d.ts +87 -20
- package/test/dist/index.js +397 -257
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +396 -256
- package/test/dist/index.mjs.map +1 -1
package/test/dist/index.mjs
CHANGED
@@ -7,6 +7,61 @@ import {
|
|
7
7
|
__require
|
8
8
|
} from "./chunk-D6YTI3O5.mjs";
|
9
9
|
|
10
|
+
// src/test/convert-array-to-async-iterable.ts
|
11
|
+
function convertArrayToAsyncIterable(values) {
|
12
|
+
return {
|
13
|
+
async *[Symbol.asyncIterator]() {
|
14
|
+
for (const value of values) {
|
15
|
+
yield value;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
};
|
19
|
+
}
|
20
|
+
|
21
|
+
// src/test/convert-array-to-readable-stream.ts
|
22
|
+
function convertArrayToReadableStream(values) {
|
23
|
+
return new ReadableStream({
|
24
|
+
start(controller) {
|
25
|
+
try {
|
26
|
+
for (const value of values) {
|
27
|
+
controller.enqueue(value);
|
28
|
+
}
|
29
|
+
} finally {
|
30
|
+
controller.close();
|
31
|
+
}
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
// src/test/convert-async-iterable-to-array.ts
|
37
|
+
async function convertAsyncIterableToArray(iterable) {
|
38
|
+
const result = [];
|
39
|
+
for await (const item of iterable) {
|
40
|
+
result.push(item);
|
41
|
+
}
|
42
|
+
return result;
|
43
|
+
}
|
44
|
+
|
45
|
+
// src/test/convert-readable-stream-to-array.ts
|
46
|
+
async function convertReadableStreamToArray(stream) {
|
47
|
+
const reader = stream.getReader();
|
48
|
+
const result = [];
|
49
|
+
while (true) {
|
50
|
+
const { done, value } = await reader.read();
|
51
|
+
if (done)
|
52
|
+
break;
|
53
|
+
result.push(value);
|
54
|
+
}
|
55
|
+
return result;
|
56
|
+
}
|
57
|
+
|
58
|
+
// src/test/convert-response-stream-to-array.ts
|
59
|
+
async function convertResponseStreamToArray(response) {
|
60
|
+
return convertReadableStreamToArray(
|
61
|
+
response.body.pipeThrough(new TextDecoderStream())
|
62
|
+
);
|
63
|
+
}
|
64
|
+
|
10
65
|
// ../../node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
11
66
|
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
12
67
|
function serializePositional(positional, flag) {
|
@@ -91,7 +146,7 @@ invariant.as = (ErrorConstructor, predicate, message3, ...positionals) => {
|
|
91
146
|
}
|
92
147
|
};
|
93
148
|
|
94
|
-
// ../../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
|
95
150
|
var LIBRARY_PREFIX = "[MSW]";
|
96
151
|
function formatMessage(message3, ...positionals) {
|
97
152
|
const interpolatedMessage = format(message3, ...positionals);
|
@@ -115,7 +170,7 @@ var InternalError = class extends Error {
|
|
115
170
|
}
|
116
171
|
};
|
117
172
|
|
118
|
-
// ../../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
|
119
174
|
function checkGlobals() {
|
120
175
|
invariant(
|
121
176
|
typeof URL !== "undefined",
|
@@ -290,7 +345,7 @@ var _Emitter = class {
|
|
290
345
|
var Emitter = _Emitter;
|
291
346
|
Emitter.defaultMaxListeners = 10;
|
292
347
|
|
293
|
-
// ../../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
|
294
349
|
function pipeEvents(source, destination) {
|
295
350
|
const rawEmit = source.emit;
|
296
351
|
if (rawEmit._isPiped) {
|
@@ -304,14 +359,14 @@ function pipeEvents(source, destination) {
|
|
304
359
|
source.emit = sourceEmit;
|
305
360
|
}
|
306
361
|
|
307
|
-
// ../../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
|
308
363
|
function toReadonlyArray(source) {
|
309
364
|
const clone = [...source];
|
310
365
|
Object.freeze(clone);
|
311
366
|
return clone;
|
312
367
|
}
|
313
368
|
|
314
|
-
// ../../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
|
315
370
|
var Disposable = class {
|
316
371
|
constructor() {
|
317
372
|
__publicField(this, "subscriptions", []);
|
@@ -324,7 +379,7 @@ var Disposable = class {
|
|
324
379
|
}
|
325
380
|
};
|
326
381
|
|
327
|
-
// ../../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
|
328
383
|
var InMemoryHandlersController = class {
|
329
384
|
constructor(initialHandlers) {
|
330
385
|
__publicField(this, "handlers");
|
@@ -404,7 +459,7 @@ var SetupApi = class extends Disposable {
|
|
404
459
|
}
|
405
460
|
};
|
406
461
|
|
407
|
-
// ../../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
|
408
463
|
var SOURCE_FRAME = /[\/\\]msw[\/\\]src[\/\\](.+)/;
|
409
464
|
var BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/;
|
410
465
|
function getCallFrame(error3) {
|
@@ -423,7 +478,7 @@ function getCallFrame(error3) {
|
|
423
478
|
return declarationPath;
|
424
479
|
}
|
425
480
|
|
426
|
-
// ../../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
|
427
482
|
function isIterable(fn) {
|
428
483
|
if (!fn) {
|
429
484
|
return false;
|
@@ -431,7 +486,7 @@ function isIterable(fn) {
|
|
431
486
|
return Reflect.has(fn, Symbol.iterator) || Reflect.has(fn, Symbol.asyncIterator);
|
432
487
|
}
|
433
488
|
|
434
|
-
// ../../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
|
435
490
|
var _RequestHandler = class _RequestHandler {
|
436
491
|
constructor(args) {
|
437
492
|
__publicField(this, "__kind");
|
@@ -583,12 +638,12 @@ var _RequestHandler = class _RequestHandler {
|
|
583
638
|
__publicField(_RequestHandler, "cache", /* @__PURE__ */ new WeakMap());
|
584
639
|
var RequestHandler = _RequestHandler;
|
585
640
|
|
586
|
-
// ../../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
|
587
642
|
function isStringEqual(actual, expected) {
|
588
643
|
return actual.toLowerCase() === expected.toLowerCase();
|
589
644
|
}
|
590
645
|
|
591
|
-
// ../../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
|
592
647
|
function getStatusCodeColor(status) {
|
593
648
|
if (status < 300) {
|
594
649
|
return "#69AB32";
|
@@ -599,7 +654,7 @@ function getStatusCodeColor(status) {
|
|
599
654
|
return "#E95F5D";
|
600
655
|
}
|
601
656
|
|
602
|
-
// ../../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
|
603
658
|
function getTimestamp(options) {
|
604
659
|
const now = /* @__PURE__ */ new Date();
|
605
660
|
const timestamp = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
@@ -609,7 +664,7 @@ function getTimestamp(options) {
|
|
609
664
|
return timestamp;
|
610
665
|
}
|
611
666
|
|
612
|
-
// ../../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
|
613
668
|
async function serializeRequest(request) {
|
614
669
|
const requestClone = request.clone();
|
615
670
|
const requestText = await requestClone.text();
|
@@ -788,7 +843,7 @@ var require_statuses = __commonJS({
|
|
788
843
|
var import_statuses = __toESM(require_statuses(), 1);
|
789
844
|
var source_default = import_statuses.default;
|
790
845
|
|
791
|
-
// ../../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
|
792
847
|
var { message } = source_default;
|
793
848
|
async function serializeResponse(response) {
|
794
849
|
const responseClone = response.clone();
|
@@ -1406,7 +1461,7 @@ function serializeInput(message3) {
|
|
1406
1461
|
return message3.toString();
|
1407
1462
|
}
|
1408
1463
|
|
1409
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1464
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-I7HQIBT7.mjs
|
1410
1465
|
var INTERNAL_REQUEST_ID_HEADER_NAME = "x-interceptors-internal-request-id";
|
1411
1466
|
function getGlobalSymbol(symbol) {
|
1412
1467
|
return (
|
@@ -1561,54 +1616,77 @@ var Interceptor = class {
|
|
1561
1616
|
function createRequestId() {
|
1562
1617
|
return Math.random().toString(16).slice(2);
|
1563
1618
|
}
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
return true;
|
1568
|
-
} catch (e) {
|
1569
|
-
return false;
|
1619
|
+
var _FetchResponse = class extends Response {
|
1620
|
+
static isConfigurableStatusCode(status) {
|
1621
|
+
return status >= 200 && status <= 599;
|
1570
1622
|
}
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
headers
|
1602
|
-
|
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
|
+
});
|
1603
1680
|
}
|
1604
1681
|
}
|
1605
|
-
|
1606
|
-
}
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
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];
|
1610
1688
|
|
1611
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1689
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-PJA4E426.mjs
|
1612
1690
|
var BatchInterceptor = class extends Interceptor {
|
1613
1691
|
constructor(options) {
|
1614
1692
|
BatchInterceptor.symbol = Symbol(options.name);
|
@@ -1651,7 +1729,7 @@ var BatchInterceptor = class extends Interceptor {
|
|
1651
1729
|
}
|
1652
1730
|
};
|
1653
1731
|
|
1654
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1732
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-6HYIRFX2.mjs
|
1655
1733
|
var encoder = new TextEncoder();
|
1656
1734
|
function encodeBuffer(text) {
|
1657
1735
|
return encoder.encode(text);
|
@@ -1667,15 +1745,15 @@ function toArrayBuffer(array) {
|
|
1667
1745
|
);
|
1668
1746
|
}
|
1669
1747
|
|
1670
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1748
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-6YM4PLBI.mjs
|
1671
1749
|
var IS_PATCHED_MODULE = Symbol("isPatchedModule");
|
1672
1750
|
|
1673
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
1751
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/index.mjs
|
1674
1752
|
function getCleanUrl(url, isAbsolute = true) {
|
1675
1753
|
return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
|
1676
1754
|
}
|
1677
1755
|
|
1678
|
-
// ../../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
|
1679
1757
|
var REDUNDANT_CHARACTERS_EXP = /[\?|#].*$/g;
|
1680
1758
|
function getSearchParams(path) {
|
1681
1759
|
return new URL(`/${path}`, "http://localhost").searchParams;
|
@@ -1687,12 +1765,12 @@ function cleanUrl(path) {
|
|
1687
1765
|
return path.replace(REDUNDANT_CHARACTERS_EXP, "");
|
1688
1766
|
}
|
1689
1767
|
|
1690
|
-
// ../../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
|
1691
1769
|
function isAbsoluteUrl(url) {
|
1692
1770
|
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
1693
1771
|
}
|
1694
1772
|
|
1695
|
-
// ../../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
|
1696
1774
|
function getAbsoluteUrl(path, baseUrl) {
|
1697
1775
|
if (isAbsoluteUrl(path)) {
|
1698
1776
|
return path;
|
@@ -1707,7 +1785,7 @@ function getAbsoluteUrl(path, baseUrl) {
|
|
1707
1785
|
) : path;
|
1708
1786
|
}
|
1709
1787
|
|
1710
|
-
// ../../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
|
1711
1789
|
function normalizePath(path, baseUrl) {
|
1712
1790
|
if (path instanceof RegExp) {
|
1713
1791
|
return path;
|
@@ -1716,7 +1794,7 @@ function normalizePath(path, baseUrl) {
|
|
1716
1794
|
return cleanUrl(maybeAbsoluteUrl);
|
1717
1795
|
}
|
1718
1796
|
|
1719
|
-
// ../../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
|
1720
1798
|
function coercePath(path) {
|
1721
1799
|
return path.replace(
|
1722
1800
|
/([:a-zA-Z_-]*)(\*{1,2})+/g,
|
@@ -1741,7 +1819,7 @@ function matchRequestUrl(url, path, baseUrl) {
|
|
1741
1819
|
};
|
1742
1820
|
}
|
1743
1821
|
|
1744
|
-
// ../../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
|
1745
1823
|
function toPublicUrl(url) {
|
1746
1824
|
if (typeof location === "undefined") {
|
1747
1825
|
return url.toString();
|
@@ -13791,7 +13869,7 @@ var require_cookie2 = __commonJS3({
|
|
13791
13869
|
var import_tough_cookie = __toESM3(require_cookie2(), 1);
|
13792
13870
|
var source_default3 = import_tough_cookie.default;
|
13793
13871
|
|
13794
|
-
// ../../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
|
13795
13873
|
var { Cookie, CookieJar, Store, MemoryCookieStore, domainMatch, pathMatch } = source_default3;
|
13796
13874
|
var WebStorageCookieStore = class extends Store {
|
13797
13875
|
constructor() {
|
@@ -13943,7 +14021,7 @@ var WebStorageCookieStore = class extends Store {
|
|
13943
14021
|
var store = isNodeProcess() ? new MemoryCookieStore() : new WebStorageCookieStore();
|
13944
14022
|
var cookieStore = new CookieJar(store);
|
13945
14023
|
|
13946
|
-
// ../../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
|
13947
14025
|
function parseCookies(input) {
|
13948
14026
|
const parsedCookies = source_default2.parse(input);
|
13949
14027
|
const cookies = {};
|
@@ -13998,7 +14076,7 @@ function getAllRequestCookies(request) {
|
|
13998
14076
|
};
|
13999
14077
|
}
|
14000
14078
|
|
14001
|
-
// ../../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
|
14002
14080
|
var HttpMethods = /* @__PURE__ */ ((HttpMethods2) => {
|
14003
14081
|
HttpMethods2["HEAD"] = "HEAD";
|
14004
14082
|
HttpMethods2["GET"] = "GET";
|
@@ -14088,7 +14166,7 @@ var HttpHandler = class extends RequestHandler {
|
|
14088
14166
|
}
|
14089
14167
|
};
|
14090
14168
|
|
14091
|
-
// ../../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
|
14092
14170
|
function createHttpHandler(method) {
|
14093
14171
|
return (path, resolver, options = {}) => {
|
14094
14172
|
return new HttpHandler(method, path, resolver, options);
|
@@ -14519,7 +14597,7 @@ var Headers2 = class _Headers {
|
|
14519
14597
|
}
|
14520
14598
|
};
|
14521
14599
|
|
14522
|
-
// ../../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
|
14523
14601
|
var kEmitter = Symbol("kEmitter");
|
14524
14602
|
var kDispatchEvent = Symbol("kDispatchEvent");
|
14525
14603
|
var kSender = Symbol("kSender");
|
@@ -14693,7 +14771,7 @@ var until = async (promise) => {
|
|
14693
14771
|
}
|
14694
14772
|
};
|
14695
14773
|
|
14696
|
-
// ../../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
|
14697
14775
|
var executeHandlers = async ({
|
14698
14776
|
request,
|
14699
14777
|
requestId,
|
@@ -14721,7 +14799,7 @@ var executeHandlers = async ({
|
|
14721
14799
|
return null;
|
14722
14800
|
};
|
14723
14801
|
|
14724
|
-
// ../../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
|
14725
14803
|
async function onUnhandledRequest(request, strategy = "warn") {
|
14726
14804
|
const url = new URL(request.url);
|
14727
14805
|
const publicUrl = toPublicUrl(url) + url.search;
|
@@ -14773,7 +14851,7 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
14773
14851
|
applyStrategy(strategy);
|
14774
14852
|
}
|
14775
14853
|
|
14776
|
-
// ../../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
|
14777
14855
|
var { message: message2 } = source_default;
|
14778
14856
|
var kSetCookie = Symbol("kSetCookie");
|
14779
14857
|
function normalizeResponseInit(init = {}) {
|
@@ -14814,7 +14892,7 @@ function decorateResponse(response, init) {
|
|
14814
14892
|
return response;
|
14815
14893
|
}
|
14816
14894
|
|
14817
|
-
// ../../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
|
14818
14896
|
function storeResponseCookies(request, response) {
|
14819
14897
|
const responseCookies = Reflect.get(response, kSetCookie);
|
14820
14898
|
if (responseCookies) {
|
@@ -14822,7 +14900,7 @@ function storeResponseCookies(request, response) {
|
|
14822
14900
|
}
|
14823
14901
|
}
|
14824
14902
|
|
14825
|
-
// ../../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
|
14826
14904
|
async function handleRequest(request, requestId, handlers, options, emitter, handleRequestOptions) {
|
14827
14905
|
var _a4, _b2, _c2, _d, _e, _f;
|
14828
14906
|
emitter.emit("request:start", { request, requestId });
|
@@ -14873,7 +14951,7 @@ async function handleRequest(request, requestId, handlers, options, emitter, han
|
|
14873
14951
|
return response;
|
14874
14952
|
}
|
14875
14953
|
|
14876
|
-
// ../../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
|
14877
14955
|
var HttpResponse = class _HttpResponse extends Response {
|
14878
14956
|
constructor(body, init) {
|
14879
14957
|
const responseInit = normalizeResponseInit(init);
|
@@ -14959,6 +15037,9 @@ var HttpResponse = class _HttpResponse extends Response {
|
|
14959
15037
|
*/
|
14960
15038
|
static arrayBuffer(body, init) {
|
14961
15039
|
const responseInit = normalizeResponseInit(init);
|
15040
|
+
if (!responseInit.headers.has("Content-Type")) {
|
15041
|
+
responseInit.headers.set("Content-Type", "application/octet-stream");
|
15042
|
+
}
|
14962
15043
|
if (body && !responseInit.headers.has("Content-Length")) {
|
14963
15044
|
responseInit.headers.set("Content-Length", body.byteLength.toString());
|
14964
15045
|
}
|
@@ -14977,13 +15058,13 @@ var HttpResponse = class _HttpResponse extends Response {
|
|
14977
15058
|
}
|
14978
15059
|
};
|
14979
15060
|
|
14980
|
-
// ../../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
|
14981
15062
|
checkGlobals();
|
14982
15063
|
|
14983
|
-
// ../../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
|
14984
15065
|
import { AsyncLocalStorage } from "async_hooks";
|
14985
15066
|
|
14986
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
15067
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-5KMS5CTP.mjs
|
14987
15068
|
var InterceptorError = class extends Error {
|
14988
15069
|
constructor(message3) {
|
14989
15070
|
super(message3);
|
@@ -15044,6 +15125,35 @@ async function emitAsync(emitter, eventName, ...data) {
|
|
15044
15125
|
await listener.apply(emitter, data);
|
15045
15126
|
}
|
15046
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
|
+
}
|
15047
15157
|
function isNodeLikeError(error3) {
|
15048
15158
|
if (error3 == null) {
|
15049
15159
|
return false;
|
@@ -15155,7 +15265,7 @@ async function handleRequest2(options) {
|
|
15155
15265
|
return false;
|
15156
15266
|
}
|
15157
15267
|
|
15158
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
15268
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-QFFDMWKW.mjs
|
15159
15269
|
import http2 from "http";
|
15160
15270
|
import https2 from "https";
|
15161
15271
|
import net2 from "net";
|
@@ -15246,13 +15356,6 @@ function baseUrlFromConnectionOptions(options) {
|
|
15246
15356
|
}
|
15247
15357
|
return url;
|
15248
15358
|
}
|
15249
|
-
function parseRawHeaders(rawHeaders) {
|
15250
|
-
const headers = new Headers();
|
15251
|
-
for (let line = 0; line < rawHeaders.length; line += 2) {
|
15252
|
-
headers.append(rawHeaders[line], rawHeaders[line + 1]);
|
15253
|
-
}
|
15254
|
-
return headers;
|
15255
|
-
}
|
15256
15359
|
var kRawHeaders = Symbol("kRawHeaders");
|
15257
15360
|
var kRestorePatches = Symbol("kRestorePatches");
|
15258
15361
|
function recordRawHeader(headers, args, behavior) {
|
@@ -15322,7 +15425,14 @@ function recordRawFetchHeaders() {
|
|
15322
15425
|
[Reflect.get(headersInit, kRawHeaders)],
|
15323
15426
|
newTarget
|
15324
15427
|
);
|
15325
|
-
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
|
+
]);
|
15326
15436
|
return headers2;
|
15327
15437
|
}
|
15328
15438
|
const headers = Reflect.construct(target, args, newTarget);
|
@@ -15420,8 +15530,14 @@ var MockHttpSocket = class extends MockSocket {
|
|
15420
15530
|
constructor(options) {
|
15421
15531
|
super({
|
15422
15532
|
write: (chunk, encoding, callback) => {
|
15423
|
-
|
15533
|
+
var _a4;
|
15534
|
+
if (this.socketState !== "passthrough") {
|
15535
|
+
this.writeBuffer.push([chunk, encoding, callback]);
|
15536
|
+
}
|
15424
15537
|
if (chunk) {
|
15538
|
+
if (this.socketState === "passthrough") {
|
15539
|
+
(_a4 = this.originalSocket) == null ? void 0 : _a4.write(chunk, encoding, callback);
|
15540
|
+
}
|
15425
15541
|
this.requestParser.execute(
|
15426
15542
|
Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk, encoding)
|
15427
15543
|
);
|
@@ -15436,13 +15552,13 @@ var MockHttpSocket = class extends MockSocket {
|
|
15436
15552
|
}
|
15437
15553
|
});
|
15438
15554
|
this.writeBuffer = [];
|
15439
|
-
this.
|
15555
|
+
this.socketState = "unknown";
|
15440
15556
|
this.onRequestStart = (versionMajor, versionMinor, rawHeaders, _, path, __, ___, ____, shouldKeepAlive) => {
|
15441
15557
|
var _a4;
|
15442
15558
|
this.shouldKeepAlive = shouldKeepAlive;
|
15443
15559
|
const url = new URL(path, this.baseUrl);
|
15444
15560
|
const method = ((_a4 = this.connectionOptions.method) == null ? void 0 : _a4.toUpperCase()) || "GET";
|
15445
|
-
const headers = parseRawHeaders(rawHeaders);
|
15561
|
+
const headers = FetchResponse.parseRawHeaders(rawHeaders);
|
15446
15562
|
const canHaveBody = method !== "GET" && method !== "HEAD";
|
15447
15563
|
if (url.username || url.password) {
|
15448
15564
|
if (!headers.has("authorization")) {
|
@@ -15484,13 +15600,8 @@ var MockHttpSocket = class extends MockSocket {
|
|
15484
15600
|
});
|
15485
15601
|
};
|
15486
15602
|
this.onResponseStart = (versionMajor, versionMinor, rawHeaders, method, url, status, statusText) => {
|
15487
|
-
const headers = parseRawHeaders(rawHeaders);
|
15488
|
-
const
|
15489
|
-
if (canHaveBody) {
|
15490
|
-
this.responseStream = new Readable({ read() {
|
15491
|
-
} });
|
15492
|
-
}
|
15493
|
-
const response = new Response(
|
15603
|
+
const headers = FetchResponse.parseRawHeaders(rawHeaders);
|
15604
|
+
const response = new FetchResponse(
|
15494
15605
|
/**
|
15495
15606
|
* @note The Fetch API response instance exposed to the consumer
|
15496
15607
|
* is created over the response stream of the HTTP parser. It is NOT
|
@@ -15498,8 +15609,12 @@ var MockHttpSocket = class extends MockSocket {
|
|
15498
15609
|
* in response listener while the Socket instance delays the emission
|
15499
15610
|
* of "end" and other events until those response listeners are finished.
|
15500
15611
|
*/
|
15501
|
-
|
15612
|
+
FetchResponse.isResponseWithBody(status) ? Readable.toWeb(
|
15613
|
+
this.responseStream = new Readable({ read() {
|
15614
|
+
} })
|
15615
|
+
) : null,
|
15502
15616
|
{
|
15617
|
+
url,
|
15503
15618
|
status,
|
15504
15619
|
statusText,
|
15505
15620
|
headers
|
@@ -15514,7 +15629,7 @@ var MockHttpSocket = class extends MockSocket {
|
|
15514
15629
|
}
|
15515
15630
|
this.responseListenersPromise = this.onResponse({
|
15516
15631
|
response,
|
15517
|
-
isMockedResponse: this.
|
15632
|
+
isMockedResponse: this.socketState === "mock",
|
15518
15633
|
requestId: Reflect.get(this.request, kRequestId),
|
15519
15634
|
request: this.request,
|
15520
15635
|
socket: this
|
@@ -15564,10 +15679,12 @@ var MockHttpSocket = class extends MockSocket {
|
|
15564
15679
|
* its data/events through this Socket.
|
15565
15680
|
*/
|
15566
15681
|
passthrough() {
|
15682
|
+
this.socketState = "passthrough";
|
15567
15683
|
if (this.destroyed) {
|
15568
15684
|
return;
|
15569
15685
|
}
|
15570
15686
|
const socket = this.createConnection();
|
15687
|
+
this.originalSocket = socket;
|
15571
15688
|
this.once("error", (error3) => {
|
15572
15689
|
socket.destroy(error3);
|
15573
15690
|
});
|
@@ -15640,7 +15757,7 @@ var MockHttpSocket = class extends MockSocket {
|
|
15640
15757
|
return;
|
15641
15758
|
}
|
15642
15759
|
this.mockConnect();
|
15643
|
-
this.
|
15760
|
+
this.socketState = "mock";
|
15644
15761
|
this.flushWriteBuffer();
|
15645
15762
|
const serverResponse = new ServerResponse(new IncomingMessage(this));
|
15646
15763
|
serverResponse.assignSocket(
|
@@ -15723,8 +15840,11 @@ var MockHttpSocket = class extends MockSocket {
|
|
15723
15840
|
}
|
15724
15841
|
}
|
15725
15842
|
flushWriteBuffer() {
|
15726
|
-
for (const
|
15727
|
-
|
15843
|
+
for (const writeCall of this.writeBuffer) {
|
15844
|
+
if (typeof writeCall[2] === "function") {
|
15845
|
+
writeCall[2]();
|
15846
|
+
writeCall[2] = void 0;
|
15847
|
+
}
|
15728
15848
|
}
|
15729
15849
|
}
|
15730
15850
|
onRequestBody(chunk) {
|
@@ -16148,7 +16268,7 @@ var _ClientRequestInterceptor = class extends Interceptor {
|
|
16148
16268
|
var ClientRequestInterceptor = _ClientRequestInterceptor;
|
16149
16269
|
ClientRequestInterceptor.symbol = Symbol("client-request-interceptor");
|
16150
16270
|
|
16151
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
16271
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-TX5GBTFY.mjs
|
16152
16272
|
function hasConfigurableGlobal(propertyName) {
|
16153
16273
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
16154
16274
|
if (typeof descriptor === "undefined") {
|
@@ -16169,7 +16289,7 @@ function hasConfigurableGlobal(propertyName) {
|
|
16169
16289
|
return true;
|
16170
16290
|
}
|
16171
16291
|
|
16172
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
16292
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-OMWE7UVM.mjs
|
16173
16293
|
function concatArrayBuffer(left, right) {
|
16174
16294
|
const result = new Uint8Array(left.byteLength + right.byteLength);
|
16175
16295
|
result.set(left, 0);
|
@@ -16332,8 +16452,9 @@ function parseJson(data) {
|
|
16332
16452
|
}
|
16333
16453
|
}
|
16334
16454
|
function createResponse(request, body) {
|
16335
|
-
const responseBodyOrNull =
|
16336
|
-
return new
|
16455
|
+
const responseBodyOrNull = FetchResponse.isResponseWithBody(request.status) ? body : null;
|
16456
|
+
return new FetchResponse(responseBodyOrNull, {
|
16457
|
+
url: request.responseURL,
|
16337
16458
|
status: request.status,
|
16338
16459
|
statusText: request.statusText,
|
16339
16460
|
headers: createHeadersFromXMLHttpReqestHeaders(
|
@@ -16954,7 +17075,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
16954
17075
|
var XMLHttpRequestInterceptor = _XMLHttpRequestInterceptor;
|
16955
17076
|
XMLHttpRequestInterceptor.interceptorSymbol = Symbol("xhr");
|
16956
17077
|
|
16957
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
17078
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-CTGTMEFD.mjs
|
16958
17079
|
import zlib from "zlib";
|
16959
17080
|
function canParseUrl(url) {
|
16960
17081
|
try {
|
@@ -17145,8 +17266,9 @@ var _FetchInterceptor = class extends Interceptor {
|
|
17145
17266
|
rawResponse
|
17146
17267
|
});
|
17147
17268
|
const decompressedStream = decompressResponse(rawResponse);
|
17148
|
-
const response = decompressedStream === null ? rawResponse : new
|
17149
|
-
|
17269
|
+
const response = decompressedStream === null ? rawResponse : new FetchResponse(decompressedStream, rawResponse);
|
17270
|
+
FetchResponse.setUrl(request.url, response);
|
17271
|
+
if (FetchResponse.isRedirectResponse(response.status)) {
|
17150
17272
|
if (request.redirect === "error") {
|
17151
17273
|
responsePromise.reject(createNetworkError("unexpected redirect"));
|
17152
17274
|
return;
|
@@ -17163,12 +17285,6 @@ var _FetchInterceptor = class extends Interceptor {
|
|
17163
17285
|
return;
|
17164
17286
|
}
|
17165
17287
|
}
|
17166
|
-
Object.defineProperty(response, "url", {
|
17167
|
-
writable: false,
|
17168
|
-
enumerable: true,
|
17169
|
-
configurable: false,
|
17170
|
-
value: request.url
|
17171
|
-
});
|
17172
17288
|
if (this.emitter.listenerCount("response") > 0) {
|
17173
17289
|
this.logger.info('emitting the "response" event...');
|
17174
17290
|
await emitAsync(this.emitter, "response", {
|
@@ -17234,12 +17350,12 @@ var _FetchInterceptor = class extends Interceptor {
|
|
17234
17350
|
var FetchInterceptor = _FetchInterceptor;
|
17235
17351
|
FetchInterceptor.symbol = Symbol("fetch");
|
17236
17352
|
|
17237
|
-
// ../../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
|
17238
17354
|
function isObject2(value) {
|
17239
17355
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
17240
17356
|
}
|
17241
17357
|
|
17242
|
-
// ../../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
|
17243
17359
|
function mergeRight(left, right) {
|
17244
17360
|
return Object.entries(right).reduce(
|
17245
17361
|
(result, [key, rightValue]) => {
|
@@ -17259,7 +17375,7 @@ function mergeRight(left, right) {
|
|
17259
17375
|
);
|
17260
17376
|
}
|
17261
17377
|
|
17262
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
17378
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/browser/chunk-TX5GBTFY.mjs
|
17263
17379
|
function hasConfigurableGlobal2(propertyName) {
|
17264
17380
|
const descriptor = Object.getOwnPropertyDescriptor(globalThis, propertyName);
|
17265
17381
|
if (typeof descriptor === "undefined") {
|
@@ -17280,7 +17396,7 @@ function hasConfigurableGlobal2(propertyName) {
|
|
17280
17396
|
return true;
|
17281
17397
|
}
|
17282
17398
|
|
17283
|
-
// ../../node_modules/.pnpm/@mswjs+interceptors@0.
|
17399
|
+
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/browser/chunk-QED3Q6Z2.mjs
|
17284
17400
|
function getGlobalSymbol2(symbol) {
|
17285
17401
|
return (
|
17286
17402
|
// @ts-ignore https://github.com/Microsoft/TypeScript/issues/24587
|
@@ -17427,7 +17543,7 @@ function createRequestId2() {
|
|
17427
17543
|
return Math.random().toString(16).slice(2);
|
17428
17544
|
}
|
17429
17545
|
|
17430
|
-
// ../../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
|
17431
17547
|
function bindEvent(target, event) {
|
17432
17548
|
Object.defineProperties(event, {
|
17433
17549
|
target: {
|
@@ -17990,23 +18106,39 @@ var WebSocketClassTransport = class extends EventTarget {
|
|
17990
18106
|
}
|
17991
18107
|
send(data) {
|
17992
18108
|
queueMicrotask(() => {
|
17993
|
-
this.socket.
|
17994
|
-
|
17995
|
-
|
17996
|
-
|
17997
|
-
|
17998
|
-
|
17999
|
-
|
18000
|
-
|
18001
|
-
|
18002
|
-
|
18003
|
-
|
18004
|
-
|
18005
|
-
|
18006
|
-
|
18007
|
-
|
18008
|
-
|
18009
|
-
|
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
|
+
}
|
18010
18142
|
});
|
18011
18143
|
}
|
18012
18144
|
close(code, reason) {
|
@@ -18088,17 +18220,17 @@ var _WebSocketInterceptor = class extends Interceptor2 {
|
|
18088
18220
|
var WebSocketInterceptor = _WebSocketInterceptor;
|
18089
18221
|
WebSocketInterceptor.symbol = Symbol("websocket");
|
18090
18222
|
|
18091
|
-
// ../../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
|
18092
18224
|
var webSocketInterceptor = new WebSocketInterceptor();
|
18093
18225
|
|
18094
|
-
// ../../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
|
18095
18227
|
function isHandlerKind(kind) {
|
18096
18228
|
return (input) => {
|
18097
18229
|
return input != null && typeof input === "object" && "__kind" in input && input.__kind === kind;
|
18098
18230
|
};
|
18099
18231
|
}
|
18100
18232
|
|
18101
|
-
// ../../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
|
18102
18234
|
function handleWebSocketEvent(options) {
|
18103
18235
|
webSocketInterceptor.on("connection", async (connection) => {
|
18104
18236
|
const handlers = options.getHandlers();
|
@@ -18146,7 +18278,7 @@ function handleWebSocketEvent(options) {
|
|
18146
18278
|
});
|
18147
18279
|
}
|
18148
18280
|
|
18149
|
-
// ../../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
|
18150
18282
|
var DEFAULT_LISTEN_OPTIONS = {
|
18151
18283
|
onUnhandledRequest: "warn"
|
18152
18284
|
};
|
@@ -18160,7 +18292,6 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
18160
18292
|
interceptors: interceptors.map((Interceptor3) => new Interceptor3())
|
18161
18293
|
});
|
18162
18294
|
this.resolvedOptions = {};
|
18163
|
-
this.init();
|
18164
18295
|
}
|
18165
18296
|
/**
|
18166
18297
|
* Subscribe to all requests that are using the interceptor object
|
@@ -18235,6 +18366,7 @@ var SetupServerCommonApi = class extends SetupApi {
|
|
18235
18366
|
options
|
18236
18367
|
);
|
18237
18368
|
this.interceptor.apply();
|
18369
|
+
this.init();
|
18238
18370
|
this.subscriptions.push(() => this.interceptor.dispose());
|
18239
18371
|
webSocketInterceptor.apply();
|
18240
18372
|
this.subscriptions.push(() => webSocketInterceptor.dispose());
|
@@ -18303,116 +18435,11 @@ var setupServer = (...handlers) => {
|
|
18303
18435
|
return new SetupServerApi(handlers);
|
18304
18436
|
};
|
18305
18437
|
|
18306
|
-
// src/test/binary-test-server.ts
|
18307
|
-
var BinaryTestServer = class {
|
18308
|
-
constructor(url) {
|
18309
|
-
this.responseBody = null;
|
18310
|
-
this.responseHeaders = {};
|
18311
|
-
this.responseStatus = 200;
|
18312
|
-
this.server = setupServer(
|
18313
|
-
http.post(url, ({ request }) => {
|
18314
|
-
this.request = request;
|
18315
|
-
if (this.responseBody === null) {
|
18316
|
-
return new HttpResponse(null, { status: this.responseStatus });
|
18317
|
-
}
|
18318
|
-
return new HttpResponse(this.responseBody, {
|
18319
|
-
status: this.responseStatus,
|
18320
|
-
headers: this.responseHeaders
|
18321
|
-
});
|
18322
|
-
})
|
18323
|
-
);
|
18324
|
-
}
|
18325
|
-
async getRequestBodyJson() {
|
18326
|
-
expect(this.request).toBeDefined();
|
18327
|
-
return JSON.parse(await this.request.text());
|
18328
|
-
}
|
18329
|
-
async getRequestHeaders() {
|
18330
|
-
expect(this.request).toBeDefined();
|
18331
|
-
const requestHeaders = this.request.headers;
|
18332
|
-
const headersObject = {};
|
18333
|
-
requestHeaders.forEach((value, key) => {
|
18334
|
-
headersObject[key] = value;
|
18335
|
-
});
|
18336
|
-
return headersObject;
|
18337
|
-
}
|
18338
|
-
async getRequestUrlSearchParams() {
|
18339
|
-
expect(this.request).toBeDefined();
|
18340
|
-
return new URL(this.request.url).searchParams;
|
18341
|
-
}
|
18342
|
-
async getRequestUrl() {
|
18343
|
-
expect(this.request).toBeDefined();
|
18344
|
-
return new URL(this.request.url).toString();
|
18345
|
-
}
|
18346
|
-
setupTestEnvironment() {
|
18347
|
-
beforeAll(() => this.server.listen());
|
18348
|
-
beforeEach(() => {
|
18349
|
-
this.responseBody = null;
|
18350
|
-
this.request = void 0;
|
18351
|
-
this.responseHeaders = {};
|
18352
|
-
this.responseStatus = 200;
|
18353
|
-
});
|
18354
|
-
afterEach(() => this.server.resetHandlers());
|
18355
|
-
afterAll(() => this.server.close());
|
18356
|
-
}
|
18357
|
-
};
|
18358
|
-
|
18359
|
-
// src/test/convert-array-to-async-iterable.ts
|
18360
|
-
function convertArrayToAsyncIterable(values) {
|
18361
|
-
return {
|
18362
|
-
async *[Symbol.asyncIterator]() {
|
18363
|
-
for (const value of values) {
|
18364
|
-
yield value;
|
18365
|
-
}
|
18366
|
-
}
|
18367
|
-
};
|
18368
|
-
}
|
18369
|
-
|
18370
|
-
// src/test/convert-array-to-readable-stream.ts
|
18371
|
-
function convertArrayToReadableStream(values) {
|
18372
|
-
return new ReadableStream({
|
18373
|
-
start(controller) {
|
18374
|
-
try {
|
18375
|
-
for (const value of values) {
|
18376
|
-
controller.enqueue(value);
|
18377
|
-
}
|
18378
|
-
} finally {
|
18379
|
-
controller.close();
|
18380
|
-
}
|
18381
|
-
}
|
18382
|
-
});
|
18383
|
-
}
|
18384
|
-
|
18385
|
-
// src/test/convert-async-iterable-to-array.ts
|
18386
|
-
async function convertAsyncIterableToArray(iterable) {
|
18387
|
-
const result = [];
|
18388
|
-
for await (const item of iterable) {
|
18389
|
-
result.push(item);
|
18390
|
-
}
|
18391
|
-
return result;
|
18392
|
-
}
|
18393
|
-
|
18394
|
-
// src/test/convert-readable-stream-to-array.ts
|
18395
|
-
async function convertReadableStreamToArray(stream) {
|
18396
|
-
const reader = stream.getReader();
|
18397
|
-
const result = [];
|
18398
|
-
while (true) {
|
18399
|
-
const { done, value } = await reader.read();
|
18400
|
-
if (done)
|
18401
|
-
break;
|
18402
|
-
result.push(value);
|
18403
|
-
}
|
18404
|
-
return result;
|
18405
|
-
}
|
18406
|
-
|
18407
|
-
// src/test/convert-response-stream-to-array.ts
|
18408
|
-
async function convertResponseStreamToArray(response) {
|
18409
|
-
return convertReadableStreamToArray(
|
18410
|
-
response.body.pipeThrough(new TextDecoderStream())
|
18411
|
-
);
|
18412
|
-
}
|
18413
|
-
|
18414
18438
|
// src/test/json-test-server.ts
|
18415
18439
|
var JsonTestServer = class {
|
18440
|
+
/**
|
18441
|
+
* @deprecated Use createTestServer instead
|
18442
|
+
*/
|
18416
18443
|
constructor(url) {
|
18417
18444
|
this.responseHeaders = {};
|
18418
18445
|
this.responseBodyJson = {};
|
@@ -18463,6 +18490,9 @@ var JsonTestServer = class {
|
|
18463
18490
|
|
18464
18491
|
// src/test/streaming-test-server.ts
|
18465
18492
|
var StreamingTestServer = class {
|
18493
|
+
/**
|
18494
|
+
* @deprecated Use createTestServer instead
|
18495
|
+
*/
|
18466
18496
|
constructor(url) {
|
18467
18497
|
this.responseHeaders = {};
|
18468
18498
|
this.responseChunks = [];
|
@@ -18581,7 +18611,10 @@ function createServer({
|
|
18581
18611
|
var _a4, _b2;
|
18582
18612
|
pushCall(new TestServerCall(request));
|
18583
18613
|
const invocationCount = urlInvocationCounts[url]++;
|
18584
|
-
const response = responses2[
|
18614
|
+
const response = responses2[
|
18615
|
+
// TODO bug needs to be >=
|
18616
|
+
invocationCount > responses2.length ? responses2.length - 1 : invocationCount
|
18617
|
+
];
|
18585
18618
|
switch (response.type) {
|
18586
18619
|
case "json-value":
|
18587
18620
|
return HttpResponse.json(response.content, {
|
@@ -18693,8 +18726,114 @@ function describeWithTestServer(description, responses, testFunction) {
|
|
18693
18726
|
});
|
18694
18727
|
});
|
18695
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
|
+
}
|
18696
18836
|
export {
|
18697
|
-
BinaryTestServer,
|
18698
18837
|
JsonTestServer,
|
18699
18838
|
StreamingTestServer,
|
18700
18839
|
convertArrayToAsyncIterable,
|
@@ -18702,6 +18841,7 @@ export {
|
|
18702
18841
|
convertAsyncIterableToArray,
|
18703
18842
|
convertReadableStreamToArray,
|
18704
18843
|
convertResponseStreamToArray,
|
18844
|
+
createTestServer,
|
18705
18845
|
describeWithTestServer,
|
18706
18846
|
withTestServer
|
18707
18847
|
};
|