@ai-sdk/provider-utils 3.0.12 → 3.0.13
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 +6 -0
- package/dist/index.d.mts +10 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +33 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -172,29 +172,42 @@ function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
|
172
172
|
return "runtime/unknown";
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
// src/
|
|
176
|
-
function
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
175
|
+
// src/normalize-headers.ts
|
|
176
|
+
function normalizeHeaders(headers) {
|
|
177
|
+
if (headers == null) {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
const normalized = {};
|
|
181
|
+
if (headers instanceof Headers) {
|
|
182
|
+
headers.forEach((value, key) => {
|
|
183
|
+
normalized[key.toLowerCase()] = value;
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
if (!Array.isArray(headers)) {
|
|
187
|
+
headers = Object.entries(headers);
|
|
188
|
+
}
|
|
189
|
+
for (const [key, value] of headers) {
|
|
190
|
+
if (value != null) {
|
|
191
|
+
normalized[key.toLowerCase()] = value;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return normalized;
|
|
180
196
|
}
|
|
181
197
|
|
|
182
198
|
// src/with-user-agent-suffix.ts
|
|
183
199
|
function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
184
|
-
const
|
|
185
|
-
headers != null ? headers : {}
|
|
186
|
-
);
|
|
187
|
-
const normalizedHeaders = new Headers(cleanedHeaders);
|
|
200
|
+
const normalizedHeaders = new Headers(normalizeHeaders(headers));
|
|
188
201
|
const currentUserAgentHeader = normalizedHeaders.get("user-agent") || "";
|
|
189
202
|
normalizedHeaders.set(
|
|
190
203
|
"user-agent",
|
|
191
204
|
[currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" ")
|
|
192
205
|
);
|
|
193
|
-
return Object.fromEntries(normalizedHeaders);
|
|
206
|
+
return Object.fromEntries(normalizedHeaders.entries());
|
|
194
207
|
}
|
|
195
208
|
|
|
196
209
|
// src/version.ts
|
|
197
|
-
var VERSION = true ? "3.0.
|
|
210
|
+
var VERSION = true ? "3.0.13" : "0.0.0-test";
|
|
198
211
|
|
|
199
212
|
// src/get-from-api.ts
|
|
200
213
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -815,6 +828,13 @@ function createProviderDefinedToolFactoryWithOutputSchema({
|
|
|
815
828
|
});
|
|
816
829
|
}
|
|
817
830
|
|
|
831
|
+
// src/remove-undefined-entries.ts
|
|
832
|
+
function removeUndefinedEntries(record) {
|
|
833
|
+
return Object.fromEntries(
|
|
834
|
+
Object.entries(record).filter(([_key, value]) => value != null)
|
|
835
|
+
);
|
|
836
|
+
}
|
|
837
|
+
|
|
818
838
|
// src/resolve.ts
|
|
819
839
|
async function resolve(value) {
|
|
820
840
|
if (typeof value === "function") {
|
|
@@ -2350,6 +2370,7 @@ export {
|
|
|
2350
2370
|
loadOptionalSetting,
|
|
2351
2371
|
loadSetting,
|
|
2352
2372
|
mediaTypeToExtension,
|
|
2373
|
+
normalizeHeaders,
|
|
2353
2374
|
parseJSON,
|
|
2354
2375
|
parseJsonEventStream,
|
|
2355
2376
|
parseProviderOptions,
|