@ai-sdk/provider-utils 2.2.8 → 3.0.0-alpha.2
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 +178 -14
- package/dist/index.d.mts +140 -61
- package/dist/index.d.ts +140 -61
- package/dist/index.js +216 -73
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +188 -53
- package/dist/index.mjs.map +1 -1
- package/dist/test/index.d.mts +87 -0
- package/dist/test/index.d.ts +87 -0
- package/{test/dist → dist/test}/index.js +66 -358
- package/dist/test/index.js.map +1 -0
- package/{test/dist → dist/test}/index.mjs +64 -353
- package/dist/test/index.mjs.map +1 -0
- package/package.json +18 -16
- package/test.d.ts +1 -0
- package/test/dist/index.d.mts +0 -162
- package/test/dist/index.d.ts +0 -162
- package/test/dist/index.js.map +0 -1
- package/test/dist/index.mjs.map +0 -1
- /package/{test/dist → dist/test}/chunk-D6YTI3O5.mjs +0 -0
- /package/{test/dist → dist/test}/chunk-D6YTI3O5.mjs.map +0 -0
- /package/{test/dist → dist/test}/graphql-6JDEV3ML.mjs +0 -0
- /package/{test/dist → dist/test}/graphql-6JDEV3ML.mjs.map +0 -0
@@ -62,6 +62,20 @@ async function convertResponseStreamToArray(response) {
|
|
62
62
|
);
|
63
63
|
}
|
64
64
|
|
65
|
+
// src/test/is-node-version.ts
|
66
|
+
function isNodeVersion(version) {
|
67
|
+
const nodeMajorVersion = parseInt(process.version.slice(1).split(".")[0], 10);
|
68
|
+
return nodeMajorVersion === version;
|
69
|
+
}
|
70
|
+
|
71
|
+
// src/test/mock-id.ts
|
72
|
+
function mockId({
|
73
|
+
prefix = "id"
|
74
|
+
} = {}) {
|
75
|
+
let counter = 0;
|
76
|
+
return () => `${prefix}-${counter++}`;
|
77
|
+
}
|
78
|
+
|
65
79
|
// ../../node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
66
80
|
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
67
81
|
function serializePositional(positional, flag) {
|
@@ -146,7 +160,7 @@ invariant.as = (ErrorConstructor, predicate, message3, ...positionals) => {
|
|
146
160
|
}
|
147
161
|
};
|
148
162
|
|
149
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
163
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/devUtils.mjs
|
150
164
|
var LIBRARY_PREFIX = "[MSW]";
|
151
165
|
function formatMessage(message3, ...positionals) {
|
152
166
|
const interpolatedMessage = format(message3, ...positionals);
|
@@ -170,7 +184,7 @@ var InternalError = class extends Error {
|
|
170
184
|
}
|
171
185
|
};
|
172
186
|
|
173
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
187
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/checkGlobals.mjs
|
174
188
|
function checkGlobals() {
|
175
189
|
invariant(
|
176
190
|
typeof URL !== "undefined",
|
@@ -345,7 +359,7 @@ var _Emitter = class {
|
|
345
359
|
var Emitter = _Emitter;
|
346
360
|
Emitter.defaultMaxListeners = 10;
|
347
361
|
|
348
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
362
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/pipeEvents.mjs
|
349
363
|
function pipeEvents(source, destination) {
|
350
364
|
const rawEmit = source.emit;
|
351
365
|
if (rawEmit._isPiped) {
|
@@ -359,14 +373,14 @@ function pipeEvents(source, destination) {
|
|
359
373
|
source.emit = sourceEmit;
|
360
374
|
}
|
361
375
|
|
362
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
376
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/toReadonlyArray.mjs
|
363
377
|
function toReadonlyArray(source) {
|
364
378
|
const clone = [...source];
|
365
379
|
Object.freeze(clone);
|
366
380
|
return clone;
|
367
381
|
}
|
368
382
|
|
369
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
383
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/Disposable.mjs
|
370
384
|
var Disposable = class {
|
371
385
|
constructor() {
|
372
386
|
__publicField(this, "subscriptions", []);
|
@@ -379,7 +393,7 @@ var Disposable = class {
|
|
379
393
|
}
|
380
394
|
};
|
381
395
|
|
382
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
396
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/SetupApi.mjs
|
383
397
|
var InMemoryHandlersController = class {
|
384
398
|
constructor(initialHandlers) {
|
385
399
|
__publicField(this, "handlers");
|
@@ -459,7 +473,7 @@ var SetupApi = class extends Disposable {
|
|
459
473
|
}
|
460
474
|
};
|
461
475
|
|
462
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
476
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/getCallFrame.mjs
|
463
477
|
var SOURCE_FRAME = /[\/\\]msw[\/\\]src[\/\\](.+)/;
|
464
478
|
var BUILD_FRAME = /(node_modules)?[\/\\]lib[\/\\](core|browser|node|native|iife)[\/\\]|^[^\/\\]*$/;
|
465
479
|
function getCallFrame(error3) {
|
@@ -478,7 +492,7 @@ function getCallFrame(error3) {
|
|
478
492
|
return declarationPath;
|
479
493
|
}
|
480
494
|
|
481
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
495
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/isIterable.mjs
|
482
496
|
function isIterable(fn) {
|
483
497
|
if (!fn) {
|
484
498
|
return false;
|
@@ -486,7 +500,7 @@ function isIterable(fn) {
|
|
486
500
|
return Reflect.has(fn, Symbol.iterator) || Reflect.has(fn, Symbol.asyncIterator);
|
487
501
|
}
|
488
502
|
|
489
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
503
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/handlers/RequestHandler.mjs
|
490
504
|
var _RequestHandler = class _RequestHandler {
|
491
505
|
constructor(args) {
|
492
506
|
__publicField(this, "__kind");
|
@@ -638,12 +652,12 @@ var _RequestHandler = class _RequestHandler {
|
|
638
652
|
__publicField(_RequestHandler, "cache", /* @__PURE__ */ new WeakMap());
|
639
653
|
var RequestHandler = _RequestHandler;
|
640
654
|
|
641
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
655
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/isStringEqual.mjs
|
642
656
|
function isStringEqual(actual, expected) {
|
643
657
|
return actual.toLowerCase() === expected.toLowerCase();
|
644
658
|
}
|
645
659
|
|
646
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
660
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/logging/getStatusCodeColor.mjs
|
647
661
|
function getStatusCodeColor(status) {
|
648
662
|
if (status < 300) {
|
649
663
|
return "#69AB32";
|
@@ -654,7 +668,7 @@ function getStatusCodeColor(status) {
|
|
654
668
|
return "#E95F5D";
|
655
669
|
}
|
656
670
|
|
657
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
671
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/logging/getTimestamp.mjs
|
658
672
|
function getTimestamp(options) {
|
659
673
|
const now = /* @__PURE__ */ new Date();
|
660
674
|
const timestamp = `${now.getHours().toString().padStart(2, "0")}:${now.getMinutes().toString().padStart(2, "0")}:${now.getSeconds().toString().padStart(2, "0")}`;
|
@@ -664,7 +678,7 @@ function getTimestamp(options) {
|
|
664
678
|
return timestamp;
|
665
679
|
}
|
666
680
|
|
667
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
681
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/logging/serializeRequest.mjs
|
668
682
|
async function serializeRequest(request) {
|
669
683
|
const requestClone = request.clone();
|
670
684
|
const requestText = await requestClone.text();
|
@@ -843,7 +857,7 @@ var require_statuses = __commonJS({
|
|
843
857
|
var import_statuses = __toESM(require_statuses(), 1);
|
844
858
|
var source_default = import_statuses.default;
|
845
859
|
|
846
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
860
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/logging/serializeResponse.mjs
|
847
861
|
var { message } = source_default;
|
848
862
|
async function serializeResponse(response) {
|
849
863
|
const responseClone = response.clone();
|
@@ -1753,7 +1767,7 @@ function getCleanUrl(url, isAbsolute = true) {
|
|
1753
1767
|
return [isAbsolute && url.origin, url.pathname].filter(Boolean).join("");
|
1754
1768
|
}
|
1755
1769
|
|
1756
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
1770
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/url/cleanUrl.mjs
|
1757
1771
|
var REDUNDANT_CHARACTERS_EXP = /[\?|#].*$/g;
|
1758
1772
|
function getSearchParams(path) {
|
1759
1773
|
return new URL(`/${path}`, "http://localhost").searchParams;
|
@@ -1765,12 +1779,12 @@ function cleanUrl(path) {
|
|
1765
1779
|
return path.replace(REDUNDANT_CHARACTERS_EXP, "");
|
1766
1780
|
}
|
1767
1781
|
|
1768
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
1782
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/url/isAbsoluteUrl.mjs
|
1769
1783
|
function isAbsoluteUrl(url) {
|
1770
1784
|
return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
|
1771
1785
|
}
|
1772
1786
|
|
1773
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
1787
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/url/getAbsoluteUrl.mjs
|
1774
1788
|
function getAbsoluteUrl(path, baseUrl) {
|
1775
1789
|
if (isAbsoluteUrl(path)) {
|
1776
1790
|
return path;
|
@@ -1785,7 +1799,7 @@ function getAbsoluteUrl(path, baseUrl) {
|
|
1785
1799
|
) : path;
|
1786
1800
|
}
|
1787
1801
|
|
1788
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
1802
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/matching/normalizePath.mjs
|
1789
1803
|
function normalizePath(path, baseUrl) {
|
1790
1804
|
if (path instanceof RegExp) {
|
1791
1805
|
return path;
|
@@ -1794,7 +1808,7 @@ function normalizePath(path, baseUrl) {
|
|
1794
1808
|
return cleanUrl(maybeAbsoluteUrl);
|
1795
1809
|
}
|
1796
1810
|
|
1797
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
1811
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/matching/matchRequestUrl.mjs
|
1798
1812
|
function coercePath(path) {
|
1799
1813
|
return path.replace(
|
1800
1814
|
/([:a-zA-Z_-]*)(\*{1,2})+/g,
|
@@ -1819,7 +1833,7 @@ function matchRequestUrl(url, path, baseUrl) {
|
|
1819
1833
|
};
|
1820
1834
|
}
|
1821
1835
|
|
1822
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
1836
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/request/toPublicUrl.mjs
|
1823
1837
|
function toPublicUrl(url) {
|
1824
1838
|
if (typeof location === "undefined") {
|
1825
1839
|
return url.toString();
|
@@ -13869,7 +13883,7 @@ var require_cookie2 = __commonJS3({
|
|
13869
13883
|
var import_tough_cookie = __toESM3(require_cookie2(), 1);
|
13870
13884
|
var source_default3 = import_tough_cookie.default;
|
13871
13885
|
|
13872
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
13886
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/cookieStore.mjs
|
13873
13887
|
var { Cookie, CookieJar, Store, MemoryCookieStore, domainMatch, pathMatch } = source_default3;
|
13874
13888
|
var WebStorageCookieStore = class extends Store {
|
13875
13889
|
constructor() {
|
@@ -14021,7 +14035,7 @@ var WebStorageCookieStore = class extends Store {
|
|
14021
14035
|
var store = isNodeProcess() ? new MemoryCookieStore() : new WebStorageCookieStore();
|
14022
14036
|
var cookieStore = new CookieJar(store);
|
14023
14037
|
|
14024
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14038
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/request/getRequestCookies.mjs
|
14025
14039
|
function parseCookies(input) {
|
14026
14040
|
const parsedCookies = source_default2.parse(input);
|
14027
14041
|
const cookies = {};
|
@@ -14076,7 +14090,7 @@ function getAllRequestCookies(request) {
|
|
14076
14090
|
};
|
14077
14091
|
}
|
14078
14092
|
|
14079
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14093
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/handlers/HttpHandler.mjs
|
14080
14094
|
var HttpMethods = /* @__PURE__ */ ((HttpMethods2) => {
|
14081
14095
|
HttpMethods2["HEAD"] = "HEAD";
|
14082
14096
|
HttpMethods2["GET"] = "GET";
|
@@ -14166,7 +14180,7 @@ var HttpHandler = class extends RequestHandler {
|
|
14166
14180
|
}
|
14167
14181
|
};
|
14168
14182
|
|
14169
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14183
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/http.mjs
|
14170
14184
|
function createHttpHandler(method) {
|
14171
14185
|
return (path, resolver, options = {}) => {
|
14172
14186
|
return new HttpHandler(method, path, resolver, options);
|
@@ -14597,7 +14611,7 @@ var Headers2 = class _Headers {
|
|
14597
14611
|
}
|
14598
14612
|
};
|
14599
14613
|
|
14600
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14614
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/handlers/WebSocketHandler.mjs
|
14601
14615
|
var kEmitter = Symbol("kEmitter");
|
14602
14616
|
var kDispatchEvent = Symbol("kDispatchEvent");
|
14603
14617
|
var kSender = Symbol("kSender");
|
@@ -14771,7 +14785,7 @@ var until = async (promise) => {
|
|
14771
14785
|
}
|
14772
14786
|
};
|
14773
14787
|
|
14774
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14788
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/executeHandlers.mjs
|
14775
14789
|
var executeHandlers = async ({
|
14776
14790
|
request,
|
14777
14791
|
requestId,
|
@@ -14799,7 +14813,7 @@ var executeHandlers = async ({
|
|
14799
14813
|
return null;
|
14800
14814
|
};
|
14801
14815
|
|
14802
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14816
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/request/onUnhandledRequest.mjs
|
14803
14817
|
async function onUnhandledRequest(request, strategy = "warn") {
|
14804
14818
|
const url = new URL(request.url);
|
14805
14819
|
const publicUrl = toPublicUrl(url) + url.search;
|
@@ -14851,7 +14865,7 @@ Read more: https://mswjs.io/docs/getting-started/mocks`;
|
|
14851
14865
|
applyStrategy(strategy);
|
14852
14866
|
}
|
14853
14867
|
|
14854
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14868
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/HttpResponse/decorators.mjs
|
14855
14869
|
var { message: message2 } = source_default;
|
14856
14870
|
var kSetCookie = Symbol("kSetCookie");
|
14857
14871
|
function normalizeResponseInit(init = {}) {
|
@@ -14892,7 +14906,7 @@ function decorateResponse(response, init) {
|
|
14892
14906
|
return response;
|
14893
14907
|
}
|
14894
14908
|
|
14895
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14909
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/request/storeResponseCookies.mjs
|
14896
14910
|
function storeResponseCookies(request, response) {
|
14897
14911
|
const responseCookies = Reflect.get(response, kSetCookie);
|
14898
14912
|
if (responseCookies) {
|
@@ -14900,7 +14914,7 @@ function storeResponseCookies(request, response) {
|
|
14900
14914
|
}
|
14901
14915
|
}
|
14902
14916
|
|
14903
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14917
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/handleRequest.mjs
|
14904
14918
|
async function handleRequest(request, requestId, handlers, options, emitter, handleRequestOptions) {
|
14905
14919
|
var _a4, _b2, _c2, _d, _e, _f;
|
14906
14920
|
emitter.emit("request:start", { request, requestId });
|
@@ -14951,7 +14965,7 @@ async function handleRequest(request, requestId, handlers, options, emitter, han
|
|
14951
14965
|
return response;
|
14952
14966
|
}
|
14953
14967
|
|
14954
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
14968
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/HttpResponse.mjs
|
14955
14969
|
var HttpResponse = class _HttpResponse extends Response {
|
14956
14970
|
constructor(body, init) {
|
14957
14971
|
const responseInit = normalizeResponseInit(init);
|
@@ -15058,10 +15072,10 @@ var HttpResponse = class _HttpResponse extends Response {
|
|
15058
15072
|
}
|
15059
15073
|
};
|
15060
15074
|
|
15061
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
15075
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/index.mjs
|
15062
15076
|
checkGlobals();
|
15063
15077
|
|
15064
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
15078
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/node/index.mjs
|
15065
15079
|
import { AsyncLocalStorage } from "async_hooks";
|
15066
15080
|
|
15067
15081
|
// ../../node_modules/.pnpm/@mswjs+interceptors@0.37.5/node_modules/@mswjs/interceptors/lib/node/chunk-5KMS5CTP.mjs
|
@@ -17350,12 +17364,12 @@ var _FetchInterceptor = class extends Interceptor {
|
|
17350
17364
|
var FetchInterceptor = _FetchInterceptor;
|
17351
17365
|
FetchInterceptor.symbol = Symbol("fetch");
|
17352
17366
|
|
17353
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
17367
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/isObject.mjs
|
17354
17368
|
function isObject2(value) {
|
17355
17369
|
return value != null && typeof value === "object" && !Array.isArray(value);
|
17356
17370
|
}
|
17357
17371
|
|
17358
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
17372
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/mergeRight.mjs
|
17359
17373
|
function mergeRight(left, right) {
|
17360
17374
|
return Object.entries(right).reduce(
|
17361
17375
|
(result, [key, rightValue]) => {
|
@@ -18220,17 +18234,17 @@ var _WebSocketInterceptor = class extends Interceptor2 {
|
|
18220
18234
|
var WebSocketInterceptor = _WebSocketInterceptor;
|
18221
18235
|
WebSocketInterceptor.symbol = Symbol("websocket");
|
18222
18236
|
|
18223
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
18237
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/ws/webSocketInterceptor.mjs
|
18224
18238
|
var webSocketInterceptor = new WebSocketInterceptor();
|
18225
18239
|
|
18226
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
18240
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/utils/internal/isHandlerKind.mjs
|
18227
18241
|
function isHandlerKind(kind) {
|
18228
18242
|
return (input) => {
|
18229
18243
|
return input != null && typeof input === "object" && "__kind" in input && input.__kind === kind;
|
18230
18244
|
};
|
18231
18245
|
}
|
18232
18246
|
|
18233
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
18247
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/core/ws/handleWebSocketEvent.mjs
|
18234
18248
|
function handleWebSocketEvent(options) {
|
18235
18249
|
webSocketInterceptor.on("connection", async (connection) => {
|
18236
18250
|
const handlers = options.getHandlers();
|
@@ -18278,7 +18292,7 @@ function handleWebSocketEvent(options) {
|
|
18278
18292
|
});
|
18279
18293
|
}
|
18280
18294
|
|
18281
|
-
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.
|
18295
|
+
// ../../node_modules/.pnpm/msw@2.7.0_@types+node@20.17.24_typescript@5.8.3/node_modules/msw/lib/node/index.mjs
|
18282
18296
|
var DEFAULT_LISTEN_OPTIONS = {
|
18283
18297
|
onUnhandledRequest: "warn"
|
18284
18298
|
};
|
@@ -18435,319 +18449,12 @@ var setupServer = (...handlers) => {
|
|
18435
18449
|
return new SetupServerApi(handlers);
|
18436
18450
|
};
|
18437
18451
|
|
18438
|
-
// src/test/json-test-server.ts
|
18439
|
-
var JsonTestServer = class {
|
18440
|
-
/**
|
18441
|
-
* @deprecated Use createTestServer instead
|
18442
|
-
*/
|
18443
|
-
constructor(url) {
|
18444
|
-
this.responseHeaders = {};
|
18445
|
-
this.responseBodyJson = {};
|
18446
|
-
const responseBodyJson = () => this.responseBodyJson;
|
18447
|
-
this.server = setupServer(
|
18448
|
-
http.post(url, ({ request }) => {
|
18449
|
-
this.request = request;
|
18450
|
-
return HttpResponse.json(responseBodyJson(), {
|
18451
|
-
headers: {
|
18452
|
-
"Content-Type": "application/json",
|
18453
|
-
...this.responseHeaders
|
18454
|
-
}
|
18455
|
-
});
|
18456
|
-
})
|
18457
|
-
);
|
18458
|
-
}
|
18459
|
-
async getRequestBodyJson() {
|
18460
|
-
expect(this.request).toBeDefined();
|
18461
|
-
return JSON.parse(await this.request.text());
|
18462
|
-
}
|
18463
|
-
async getRequestHeaders() {
|
18464
|
-
expect(this.request).toBeDefined();
|
18465
|
-
const requestHeaders = this.request.headers;
|
18466
|
-
const headersObject = {};
|
18467
|
-
requestHeaders.forEach((value, key) => {
|
18468
|
-
headersObject[key] = value;
|
18469
|
-
});
|
18470
|
-
return headersObject;
|
18471
|
-
}
|
18472
|
-
async getRequestUrlSearchParams() {
|
18473
|
-
expect(this.request).toBeDefined();
|
18474
|
-
return new URL(this.request.url).searchParams;
|
18475
|
-
}
|
18476
|
-
async getRequestUrl() {
|
18477
|
-
expect(this.request).toBeDefined();
|
18478
|
-
return new URL(this.request.url).toString();
|
18479
|
-
}
|
18480
|
-
setupTestEnvironment() {
|
18481
|
-
beforeAll(() => this.server.listen());
|
18482
|
-
beforeEach(() => {
|
18483
|
-
this.responseBodyJson = {};
|
18484
|
-
this.request = void 0;
|
18485
|
-
});
|
18486
|
-
afterEach(() => this.server.resetHandlers());
|
18487
|
-
afterAll(() => this.server.close());
|
18488
|
-
}
|
18489
|
-
};
|
18490
|
-
|
18491
|
-
// src/test/mock-id.ts
|
18492
|
-
function mockId({
|
18493
|
-
prefix = "id"
|
18494
|
-
} = {}) {
|
18495
|
-
let counter = 0;
|
18496
|
-
return () => `${prefix}-${counter++}`;
|
18497
|
-
}
|
18498
|
-
|
18499
|
-
// src/test/streaming-test-server.ts
|
18500
|
-
var StreamingTestServer = class {
|
18501
|
-
/**
|
18502
|
-
* @deprecated Use createTestServer instead
|
18503
|
-
*/
|
18504
|
-
constructor(url) {
|
18505
|
-
this.responseHeaders = {};
|
18506
|
-
this.responseChunks = [];
|
18507
|
-
const responseChunks = () => this.responseChunks;
|
18508
|
-
this.server = setupServer(
|
18509
|
-
http.post(url, ({ request }) => {
|
18510
|
-
this.request = request;
|
18511
|
-
const encoder2 = new TextEncoder();
|
18512
|
-
const stream = new ReadableStream({
|
18513
|
-
async start(controller) {
|
18514
|
-
try {
|
18515
|
-
for (const chunk of responseChunks()) {
|
18516
|
-
controller.enqueue(encoder2.encode(chunk));
|
18517
|
-
}
|
18518
|
-
} finally {
|
18519
|
-
controller.close();
|
18520
|
-
}
|
18521
|
-
}
|
18522
|
-
});
|
18523
|
-
return new HttpResponse(stream, {
|
18524
|
-
status: 200,
|
18525
|
-
headers: {
|
18526
|
-
"Content-Type": "text/event-stream",
|
18527
|
-
"Cache-Control": "no-cache",
|
18528
|
-
Connection: "keep-alive",
|
18529
|
-
...this.responseHeaders
|
18530
|
-
}
|
18531
|
-
});
|
18532
|
-
})
|
18533
|
-
);
|
18534
|
-
}
|
18535
|
-
async getRequestBodyJson() {
|
18536
|
-
expect(this.request).toBeDefined();
|
18537
|
-
return JSON.parse(await this.request.text());
|
18538
|
-
}
|
18539
|
-
async getRequestHeaders() {
|
18540
|
-
expect(this.request).toBeDefined();
|
18541
|
-
const requestHeaders = this.request.headers;
|
18542
|
-
const headersObject = {};
|
18543
|
-
requestHeaders.forEach((value, key) => {
|
18544
|
-
headersObject[key] = value;
|
18545
|
-
});
|
18546
|
-
return headersObject;
|
18547
|
-
}
|
18548
|
-
async getRequestUrlSearchParams() {
|
18549
|
-
expect(this.request).toBeDefined();
|
18550
|
-
return new URL(this.request.url).searchParams;
|
18551
|
-
}
|
18552
|
-
setupTestEnvironment() {
|
18553
|
-
beforeAll(() => this.server.listen());
|
18554
|
-
beforeEach(() => {
|
18555
|
-
this.responseChunks = [];
|
18556
|
-
this.request = void 0;
|
18557
|
-
});
|
18558
|
-
afterEach(() => this.server.resetHandlers());
|
18559
|
-
afterAll(() => this.server.close());
|
18560
|
-
}
|
18561
|
-
};
|
18562
|
-
|
18563
18452
|
// src/test/test-server.ts
|
18564
18453
|
var TestServerCall = class {
|
18565
18454
|
constructor(request) {
|
18566
18455
|
this.request = request;
|
18567
18456
|
}
|
18568
|
-
|
18569
|
-
expect(this.request).toBeDefined();
|
18570
|
-
return JSON.parse(await this.request.text());
|
18571
|
-
}
|
18572
|
-
getRequestCredentials() {
|
18573
|
-
expect(this.request).toBeDefined();
|
18574
|
-
return this.request.credentials;
|
18575
|
-
}
|
18576
|
-
getRequestHeaders() {
|
18577
|
-
expect(this.request).toBeDefined();
|
18578
|
-
const requestHeaders = this.request.headers;
|
18579
|
-
const headersObject = {};
|
18580
|
-
requestHeaders.forEach((value, key) => {
|
18581
|
-
headersObject[key] = value;
|
18582
|
-
});
|
18583
|
-
return headersObject;
|
18584
|
-
}
|
18585
|
-
getRequestUrlSearchParams() {
|
18586
|
-
expect(this.request).toBeDefined();
|
18587
|
-
return new URL(this.request.url).searchParams;
|
18588
|
-
}
|
18589
|
-
};
|
18590
|
-
function createServer({
|
18591
|
-
responses,
|
18592
|
-
pushCall,
|
18593
|
-
pushController
|
18594
|
-
}) {
|
18595
|
-
const responsesArray = Array.isArray(responses) ? responses : [responses];
|
18596
|
-
const responsesByUrl = responsesArray.reduce(
|
18597
|
-
(responsesByUrl2, response) => {
|
18598
|
-
if (!responsesByUrl2[response.url]) {
|
18599
|
-
responsesByUrl2[response.url] = [];
|
18600
|
-
}
|
18601
|
-
responsesByUrl2[response.url].push(response);
|
18602
|
-
return responsesByUrl2;
|
18603
|
-
},
|
18604
|
-
{}
|
18605
|
-
);
|
18606
|
-
const streams = {};
|
18607
|
-
responsesArray.filter(
|
18608
|
-
(response) => response.type === "controlled-stream"
|
18609
|
-
).forEach((response) => {
|
18610
|
-
var _a4, _b2;
|
18611
|
-
let streamController;
|
18612
|
-
const stream = new ReadableStream({
|
18613
|
-
start(controller) {
|
18614
|
-
streamController = controller;
|
18615
|
-
}
|
18616
|
-
});
|
18617
|
-
pushController((_a4 = response.id) != null ? _a4 : "", () => streamController);
|
18618
|
-
streams[(_b2 = response.id) != null ? _b2 : ""] = stream;
|
18619
|
-
});
|
18620
|
-
const urlInvocationCounts = Object.fromEntries(
|
18621
|
-
Object.entries(responsesByUrl).map(([url]) => [url, 0])
|
18622
|
-
);
|
18623
|
-
return setupServer(
|
18624
|
-
...Object.entries(responsesByUrl).map(([url, responses2]) => {
|
18625
|
-
return http.post(url, ({ request }) => {
|
18626
|
-
var _a4, _b2;
|
18627
|
-
pushCall(new TestServerCall(request));
|
18628
|
-
const invocationCount = urlInvocationCounts[url]++;
|
18629
|
-
const response = responses2[
|
18630
|
-
// TODO bug needs to be >=
|
18631
|
-
invocationCount > responses2.length ? responses2.length - 1 : invocationCount
|
18632
|
-
];
|
18633
|
-
switch (response.type) {
|
18634
|
-
case "json-value":
|
18635
|
-
return HttpResponse.json(response.content, {
|
18636
|
-
status: 200,
|
18637
|
-
headers: {
|
18638
|
-
"Content-Type": "application/json",
|
18639
|
-
...response.headers
|
18640
|
-
}
|
18641
|
-
});
|
18642
|
-
case "stream-values":
|
18643
|
-
return new HttpResponse(
|
18644
|
-
convertArrayToReadableStream(response.content).pipeThrough(
|
18645
|
-
new TextEncoderStream()
|
18646
|
-
),
|
18647
|
-
{
|
18648
|
-
status: 200,
|
18649
|
-
headers: {
|
18650
|
-
"Content-Type": "text/event-stream",
|
18651
|
-
"Cache-Control": "no-cache",
|
18652
|
-
Connection: "keep-alive",
|
18653
|
-
...response.headers
|
18654
|
-
}
|
18655
|
-
}
|
18656
|
-
);
|
18657
|
-
case "controlled-stream": {
|
18658
|
-
return new HttpResponse(
|
18659
|
-
streams[(_a4 = response.id) != null ? _a4 : ""].pipeThrough(new TextEncoderStream()),
|
18660
|
-
{
|
18661
|
-
status: 200,
|
18662
|
-
headers: {
|
18663
|
-
"Content-Type": "text/event-stream",
|
18664
|
-
"Cache-Control": "no-cache",
|
18665
|
-
Connection: "keep-alive",
|
18666
|
-
...response.headers
|
18667
|
-
}
|
18668
|
-
}
|
18669
|
-
);
|
18670
|
-
}
|
18671
|
-
case "error":
|
18672
|
-
return HttpResponse.text((_b2 = response.content) != null ? _b2 : "Error", {
|
18673
|
-
status: response.status,
|
18674
|
-
headers: {
|
18675
|
-
...response.headers
|
18676
|
-
}
|
18677
|
-
});
|
18678
|
-
}
|
18679
|
-
});
|
18680
|
-
})
|
18681
|
-
);
|
18682
|
-
}
|
18683
|
-
function withTestServer(responses, testFunction) {
|
18684
|
-
return async () => {
|
18685
|
-
const calls = [];
|
18686
|
-
const controllers = {};
|
18687
|
-
const server = createServer({
|
18688
|
-
responses,
|
18689
|
-
pushCall: (call) => calls.push(call),
|
18690
|
-
pushController: (id, controller) => {
|
18691
|
-
controllers[id] = controller;
|
18692
|
-
}
|
18693
|
-
});
|
18694
|
-
try {
|
18695
|
-
server.listen();
|
18696
|
-
await testFunction({
|
18697
|
-
calls: () => calls,
|
18698
|
-
call: (index) => calls[index],
|
18699
|
-
getStreamController: (id) => {
|
18700
|
-
return controllers[id]();
|
18701
|
-
},
|
18702
|
-
get streamController() {
|
18703
|
-
return controllers[""]();
|
18704
|
-
}
|
18705
|
-
});
|
18706
|
-
} finally {
|
18707
|
-
server.close();
|
18708
|
-
}
|
18709
|
-
};
|
18710
|
-
}
|
18711
|
-
function describeWithTestServer(description, responses, testFunction) {
|
18712
|
-
describe(description, () => {
|
18713
|
-
let calls;
|
18714
|
-
let controllers;
|
18715
|
-
let server;
|
18716
|
-
beforeAll(() => {
|
18717
|
-
server = createServer({
|
18718
|
-
responses,
|
18719
|
-
pushCall: (call) => calls.push(call),
|
18720
|
-
pushController: (id, controller) => {
|
18721
|
-
controllers[id] = controller;
|
18722
|
-
}
|
18723
|
-
});
|
18724
|
-
server.listen();
|
18725
|
-
});
|
18726
|
-
beforeEach(() => {
|
18727
|
-
calls = [];
|
18728
|
-
controllers = {};
|
18729
|
-
server.resetHandlers();
|
18730
|
-
});
|
18731
|
-
afterAll(() => {
|
18732
|
-
server.close();
|
18733
|
-
});
|
18734
|
-
testFunction({
|
18735
|
-
calls: () => calls,
|
18736
|
-
call: (index) => calls[index],
|
18737
|
-
getStreamController: (id) => controllers[id](),
|
18738
|
-
get streamController() {
|
18739
|
-
return controllers[""]();
|
18740
|
-
}
|
18741
|
-
});
|
18742
|
-
});
|
18743
|
-
}
|
18744
|
-
|
18745
|
-
// src/test/unified-test-server.ts
|
18746
|
-
var TestServerCall2 = class {
|
18747
|
-
constructor(request) {
|
18748
|
-
this.request = request;
|
18749
|
-
}
|
18750
|
-
get requestBody() {
|
18457
|
+
get requestBodyJson() {
|
18751
18458
|
return this.request.text().then(JSON.parse);
|
18752
18459
|
}
|
18753
18460
|
get requestBodyMultipart() {
|
@@ -18793,7 +18500,7 @@ function createTestServer(routes) {
|
|
18793
18500
|
return http.all(url, ({ request }) => {
|
18794
18501
|
var _a4, _b2, _c2;
|
18795
18502
|
const callNumber = calls.length;
|
18796
|
-
calls.push(new
|
18503
|
+
calls.push(new TestServerCall(request));
|
18797
18504
|
const response = typeof handler.response === "function" ? handler.response({ callNumber }) : Array.isArray(handler.response) ? handler.response[callNumber] : handler.response;
|
18798
18505
|
if (response === void 0) {
|
18799
18506
|
return HttpResponse.json({ error: "Not Found" }, { status: 404 });
|
@@ -18824,6 +18531,13 @@ function createTestServer(routes) {
|
|
18824
18531
|
}
|
18825
18532
|
);
|
18826
18533
|
case "controlled-stream": {
|
18534
|
+
if (request.signal) {
|
18535
|
+
request.signal.addEventListener("abort", () => {
|
18536
|
+
response.controller.error(
|
18537
|
+
new DOMException("Aborted", "AbortError")
|
18538
|
+
);
|
18539
|
+
});
|
18540
|
+
}
|
18827
18541
|
return new HttpResponse(
|
18828
18542
|
response.controller.stream.pipeThrough(new TextEncoderStream()),
|
18829
18543
|
{
|
@@ -18900,8 +18614,6 @@ var TestResponseController = class {
|
|
18900
18614
|
}
|
18901
18615
|
};
|
18902
18616
|
export {
|
18903
|
-
JsonTestServer,
|
18904
|
-
StreamingTestServer,
|
18905
18617
|
TestResponseController,
|
18906
18618
|
convertArrayToAsyncIterable,
|
18907
18619
|
convertArrayToReadableStream,
|
@@ -18909,9 +18621,8 @@ export {
|
|
18909
18621
|
convertReadableStreamToArray,
|
18910
18622
|
convertResponseStreamToArray,
|
18911
18623
|
createTestServer,
|
18912
|
-
|
18913
|
-
mockId
|
18914
|
-
withTestServer
|
18624
|
+
isNodeVersion,
|
18625
|
+
mockId
|
18915
18626
|
};
|
18916
18627
|
/*! Bundled license information:
|
18917
18628
|
|