@ai-sdk/amazon-bedrock 3.1.0-beta.7 → 3.1.0-beta.9

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ai-sdk/amazon-bedrock
2
2
 
3
+ ## 3.1.0-beta.9
4
+
5
+ ### Patch Changes
6
+
7
+ - d4b2964: fix(provider/amazon-bedrock): normalise headers and body if input is of instance Request
8
+
9
+ ## 3.1.0-beta.8
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [a5a8db4]
14
+ - @ai-sdk/anthropic@2.1.0-beta.8
15
+
3
16
  ## 3.1.0-beta.7
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "3.1.0-beta.7" : "0.0.0-test";
33
+ var VERSION = true ? "3.1.0-beta.9" : "0.0.0-test";
34
34
 
35
35
  // src/bedrock-provider.ts
36
36
  var import_internal2 = require("@ai-sdk/anthropic/internal");
@@ -1495,21 +1495,33 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1495
1495
  var import_aws4fetch = require("aws4fetch");
1496
1496
  function createSigV4FetchFunction(getCredentials, fetch = globalThis.fetch) {
1497
1497
  return async (input, init) => {
1498
- var _a;
1499
- const originalHeaders = extractHeaders(init == null ? void 0 : init.headers);
1498
+ var _a, _b;
1499
+ const request = input instanceof Request ? input : void 0;
1500
+ const originalHeaders = (0, import_provider_utils7.combineHeaders)(
1501
+ extractHeaders(request == null ? void 0 : request.headers),
1502
+ extractHeaders(init == null ? void 0 : init.headers)
1503
+ );
1500
1504
  const headersWithUserAgent = (0, import_provider_utils7.withUserAgentSuffix)(
1501
1505
  originalHeaders,
1502
1506
  `ai-sdk/amazon-bedrock/${VERSION}`,
1503
1507
  (0, import_provider_utils7.getRuntimeEnvironmentUserAgent)()
1504
1508
  );
1505
- if (((_a = init == null ? void 0 : init.method) == null ? void 0 : _a.toUpperCase()) !== "POST" || !(init == null ? void 0 : init.body)) {
1509
+ let effectiveBody = (_a = init == null ? void 0 : init.body) != null ? _a : void 0;
1510
+ if (effectiveBody === void 0 && request && request.body !== null) {
1511
+ try {
1512
+ effectiveBody = await request.clone().text();
1513
+ } catch (e) {
1514
+ }
1515
+ }
1516
+ const effectiveMethod = (_b = init == null ? void 0 : init.method) != null ? _b : request == null ? void 0 : request.method;
1517
+ if ((effectiveMethod == null ? void 0 : effectiveMethod.toUpperCase()) !== "POST" || !effectiveBody) {
1506
1518
  return fetch(input, {
1507
1519
  ...init,
1508
1520
  headers: headersWithUserAgent
1509
1521
  });
1510
1522
  }
1511
1523
  const url = typeof input === "string" ? input : input instanceof URL ? input.href : input.url;
1512
- const body = prepareBodyString(init.body);
1524
+ const body = prepareBodyString(effectiveBody);
1513
1525
  const credentials = await getCredentials();
1514
1526
  const signer = new import_aws4fetch.AwsV4Signer({
1515
1527
  url,