@ai-sdk/provider-utils 2.2.0 → 2.2.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.
@@ -18569,6 +18569,10 @@ var TestServerCall = class {
18569
18569
  expect(this.request).toBeDefined();
18570
18570
  return JSON.parse(await this.request.text());
18571
18571
  }
18572
+ getRequestCredentials() {
18573
+ expect(this.request).toBeDefined();
18574
+ return this.request.credentials;
18575
+ }
18572
18576
  getRequestHeaders() {
18573
18577
  expect(this.request).toBeDefined();
18574
18578
  const requestHeaders = this.request.headers;
@@ -18768,10 +18772,11 @@ function createTestServer(routes) {
18768
18772
  const originalRoutes = structuredClone(routes);
18769
18773
  const mswServer = setupServer(
18770
18774
  ...Object.entries(routes).map(([url, handler]) => {
18771
- return http.all(url, ({ request, params }) => {
18772
- var _a4, _b2, _c2, _d, _e;
18775
+ return http.all(url, ({ request }) => {
18776
+ var _a4, _b2, _c2;
18777
+ const callNumber = calls.length;
18773
18778
  calls.push(new TestServerCall2(request));
18774
- const response = handler.response;
18779
+ const response = typeof handler.response === "function" ? handler.response({ callNumber }) : Array.isArray(handler.response) ? handler.response[callNumber] : handler.response;
18775
18780
  if (response === void 0) {
18776
18781
  return HttpResponse.json({ error: "Not Found" }, { status: 404 });
18777
18782
  }
@@ -18782,7 +18787,7 @@ function createTestServer(routes) {
18782
18787
  status: 200,
18783
18788
  headers: {
18784
18789
  "Content-Type": "application/json",
18785
- ...(_a4 = handler.response) == null ? void 0 : _a4.headers
18790
+ ...response.headers
18786
18791
  }
18787
18792
  });
18788
18793
  case "stream-chunks":
@@ -18800,9 +18805,9 @@ function createTestServer(routes) {
18800
18805
  }
18801
18806
  }
18802
18807
  );
18803
- case "readable-stream": {
18808
+ case "controlled-stream": {
18804
18809
  return new HttpResponse(
18805
- response.stream.pipeThrough(new TextEncoderStream()),
18810
+ response.controller.stream.pipeThrough(new TextEncoderStream()),
18806
18811
  {
18807
18812
  status: 200,
18808
18813
  headers: {
@@ -18817,17 +18822,17 @@ function createTestServer(routes) {
18817
18822
  case "binary": {
18818
18823
  return HttpResponse.arrayBuffer(response.body, {
18819
18824
  status: 200,
18820
- headers: (_b2 = handler.response) == null ? void 0 : _b2.headers
18825
+ headers: response.headers
18821
18826
  });
18822
18827
  }
18823
18828
  case "error":
18824
- return HttpResponse.text((_c2 = response.body) != null ? _c2 : "Error", {
18825
- status: (_d = response.status) != null ? _d : 500,
18829
+ return HttpResponse.text((_a4 = response.body) != null ? _a4 : "Error", {
18830
+ status: (_b2 = response.status) != null ? _b2 : 500,
18826
18831
  headers: response.headers
18827
18832
  });
18828
18833
  case "empty":
18829
18834
  return new HttpResponse(null, {
18830
- status: (_e = response.status) != null ? _e : 200
18835
+ status: (_c2 = response.status) != null ? _c2 : 200
18831
18836
  });
18832
18837
  default: {
18833
18838
  const _exhaustiveCheck = handlerType;
@@ -18858,9 +18863,25 @@ function createTestServer(routes) {
18858
18863
  }
18859
18864
  };
18860
18865
  }
18866
+ var TestResponseController = class {
18867
+ constructor() {
18868
+ this.transformStream = new TransformStream();
18869
+ this.writer = this.transformStream.writable.getWriter();
18870
+ }
18871
+ get stream() {
18872
+ return this.transformStream.readable;
18873
+ }
18874
+ async write(chunk) {
18875
+ await this.writer.write(chunk);
18876
+ }
18877
+ async close() {
18878
+ await this.writer.close();
18879
+ }
18880
+ };
18861
18881
  export {
18862
18882
  JsonTestServer,
18863
18883
  StreamingTestServer,
18884
+ TestResponseController,
18864
18885
  convertArrayToAsyncIterable,
18865
18886
  convertArrayToReadableStream,
18866
18887
  convertAsyncIterableToArray,