@ai-sdk/provider-utils
Advanced tools
Comparing version 0.0.16 to 1.0.0
@@ -33,2 +33,3 @@ "use strict"; | ||
__export(src_exports, { | ||
combineHeaders: () => combineHeaders, | ||
convertAsyncGeneratorToReadableStream: () => convertAsyncGeneratorToReadableStream, | ||
@@ -60,2 +61,13 @@ convertBase64ToUint8Array: () => convertBase64ToUint8Array, | ||
// src/combine-headers.ts | ||
function combineHeaders(...headers) { | ||
return headers.reduce( | ||
(combinedHeaders, currentHeaders) => ({ | ||
...combinedHeaders, | ||
...currentHeaders != null ? currentHeaders : {} | ||
}), | ||
{} | ||
); | ||
} | ||
// src/convert-async-generator-to-readable-stream.ts | ||
@@ -317,2 +329,11 @@ function convertAsyncGeneratorToReadableStream(stream) { | ||
var import_provider6 = require("@ai-sdk/provider"); | ||
// src/remove-undefined-entries.ts | ||
function removeUndefinedEntries(record) { | ||
return Object.fromEntries( | ||
Object.entries(record).filter(([_key, value]) => value != null) | ||
); | ||
} | ||
// src/post-to-api.ts | ||
var getOriginalFetch = () => fetch; | ||
@@ -330,4 +351,4 @@ var postJsonToApi = async ({ | ||
headers: { | ||
...headers, | ||
"Content-Type": "application/json" | ||
"Content-Type": "application/json", | ||
...headers | ||
}, | ||
@@ -353,8 +374,5 @@ body: { | ||
try { | ||
const definedHeaders = Object.fromEntries( | ||
Object.entries(headers).filter(([_key, value]) => value != null) | ||
); | ||
const response = await fetch2(url, { | ||
method: "POST", | ||
headers: definedHeaders, | ||
headers: removeUndefinedEntries(headers), | ||
body: body.content, | ||
@@ -581,2 +599,3 @@ signal: abortSignal | ||
0 && (module.exports = { | ||
combineHeaders, | ||
convertAsyncGeneratorToReadableStream, | ||
@@ -583,0 +602,0 @@ convertBase64ToUint8Array, |
@@ -5,2 +5,4 @@ import { JSONParseError, TypeValidationError, APICallError } from '@ai-sdk/provider'; | ||
declare function combineHeaders(...headers: Array<Record<string, string | undefined> | undefined>): Record<string, string | undefined>; | ||
/** | ||
@@ -192,2 +194,2 @@ * Converts an AsyncGenerator to a ReadableStream. | ||
export { type ParseResult, type ResponseHandler, convertAsyncGeneratorToReadableStream, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, download, extractResponseHeaders, generateId, getErrorMessage, isAbortError, isParsableJson, isParseableJson, loadApiKey, loadSetting, parseJSON, postJsonToApi, postToApi, safeParseJSON, safeValidateTypes, validateTypes, withoutTrailingSlash }; | ||
export { type ParseResult, type ResponseHandler, combineHeaders, convertAsyncGeneratorToReadableStream, convertBase64ToUint8Array, convertUint8ArrayToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createJsonStreamResponseHandler, download, extractResponseHeaders, generateId, getErrorMessage, isAbortError, isParsableJson, isParseableJson, loadApiKey, loadSetting, parseJSON, postJsonToApi, postToApi, safeParseJSON, safeValidateTypes, validateTypes, withoutTrailingSlash }; |
@@ -33,2 +33,3 @@ "use strict"; | ||
__export(src_exports, { | ||
combineHeaders: () => combineHeaders, | ||
convertAsyncGeneratorToReadableStream: () => convertAsyncGeneratorToReadableStream, | ||
@@ -60,2 +61,13 @@ convertBase64ToUint8Array: () => convertBase64ToUint8Array, | ||
// src/combine-headers.ts | ||
function combineHeaders(...headers) { | ||
return headers.reduce( | ||
(combinedHeaders, currentHeaders) => ({ | ||
...combinedHeaders, | ||
...currentHeaders != null ? currentHeaders : {} | ||
}), | ||
{} | ||
); | ||
} | ||
// src/convert-async-generator-to-readable-stream.ts | ||
@@ -317,2 +329,11 @@ function convertAsyncGeneratorToReadableStream(stream) { | ||
var import_provider6 = require("@ai-sdk/provider"); | ||
// src/remove-undefined-entries.ts | ||
function removeUndefinedEntries(record) { | ||
return Object.fromEntries( | ||
Object.entries(record).filter(([_key, value]) => value != null) | ||
); | ||
} | ||
// src/post-to-api.ts | ||
var getOriginalFetch = () => fetch; | ||
@@ -330,4 +351,4 @@ var postJsonToApi = async ({ | ||
headers: { | ||
...headers, | ||
"Content-Type": "application/json" | ||
"Content-Type": "application/json", | ||
...headers | ||
}, | ||
@@ -353,8 +374,5 @@ body: { | ||
try { | ||
const definedHeaders = Object.fromEntries( | ||
Object.entries(headers).filter(([_key, value]) => value != null) | ||
); | ||
const response = await fetch2(url, { | ||
method: "POST", | ||
headers: definedHeaders, | ||
headers: removeUndefinedEntries(headers), | ||
body: body.content, | ||
@@ -581,2 +599,3 @@ signal: abortSignal | ||
0 && (module.exports = { | ||
combineHeaders, | ||
convertAsyncGeneratorToReadableStream, | ||
@@ -583,0 +602,0 @@ convertBase64ToUint8Array, |
{ | ||
"name": "@ai-sdk/provider-utils", | ||
"version": "0.0.16", | ||
"version": "1.0.0", | ||
"license": "Apache-2.0", | ||
@@ -28,3 +28,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@ai-sdk/provider": "0.0.10", | ||
"@ai-sdk/provider": "0.0.11", | ||
"eventsource-parser": "1.1.2", | ||
@@ -31,0 +31,0 @@ "nanoid": "3.3.6", |
@@ -18,3 +18,3 @@ import { SetupServer } from 'msw/node'; | ||
getRequestBodyJson(): Promise<any>; | ||
getRequestHeaders(): Promise<Headers>; | ||
getRequestHeaders(): Promise<Record<string, string>>; | ||
setupTestEnvironment(): void; | ||
@@ -30,3 +30,3 @@ } | ||
getRequestBodyJson(): Promise<any>; | ||
getRequestHeaders(): Promise<Headers>; | ||
getRequestHeaders(): Promise<Record<string, string>>; | ||
setupTestEnvironment(): void; | ||
@@ -33,0 +33,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1679279
18468
0
+ Added@ai-sdk/provider@0.0.11(transitive)
- Removed@ai-sdk/provider@0.0.10(transitive)
Updated@ai-sdk/provider@0.0.11