@ai-sdk/provider-utils 4.0.46 → 4.0.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/provider-utils",
3
- "version": "4.0.46",
3
+ "version": "4.0.48",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -1,7 +1,9 @@
1
1
  import type { JSONSchema7, JSONSchema7Definition } from '@ai-sdk/provider';
2
2
 
3
3
  /**
4
- * Recursively adds additionalProperties: false to the JSON schema. This is necessary because some providers (e.g. OpenAI) do not support additionalProperties: true.
4
+ * Recursively adds additionalProperties: false to object schemas that do not
5
+ * define a schema for their additional properties. This is necessary because
6
+ * some providers (e.g. OpenAI) do not support additionalProperties: true.
5
7
  */
6
8
  export function addAdditionalPropertiesToJsonSchema(
7
9
  jsonSchema: JSONSchema7,
@@ -10,7 +12,12 @@ export function addAdditionalPropertiesToJsonSchema(
10
12
  jsonSchema.type === 'object' ||
11
13
  (Array.isArray(jsonSchema.type) && jsonSchema.type.includes('object'))
12
14
  ) {
13
- jsonSchema.additionalProperties = false;
15
+ const { additionalProperties } = jsonSchema;
16
+ jsonSchema.additionalProperties =
17
+ additionalProperties != null && typeof additionalProperties !== 'boolean'
18
+ ? visit(additionalProperties)
19
+ : false;
20
+
14
21
  const { properties } = jsonSchema;
15
22
  if (properties != null) {
16
23
  for (const key of Object.keys(properties)) {
@@ -131,7 +131,11 @@ export async function getDefaultDownloadFetch(): Promise<FetchFunction> {
131
131
  return (safeNodeFetchPromise ??= createSafeNodeFetch());
132
132
  }
133
133
 
134
- function isNodeDefaultFetch(fetch: FetchFunction): boolean {
134
+ function isNodeDefaultFetch(fetch: unknown): boolean {
135
+ if (typeof fetch !== 'function') {
136
+ return false;
137
+ }
138
+
135
139
  const source = Function.prototype.toString.call(fetch);
136
140
  return (
137
141
  source.includes('internal/deps/undici') ||