@ai-sdk/google 2.0.49 → 2.0.50

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,11 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 2.0.50
4
+
5
+ ### Patch Changes
6
+
7
+ - 7c30c1d: fix(provider/google): preserve nested empty object schemas in tool parameters to fix "property is not defined" validation errors when using required properties with empty object types
8
+
3
9
  ## 2.0.49
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@ module.exports = __toCommonJS(src_exports);
30
30
  var import_provider_utils15 = require("@ai-sdk/provider-utils");
31
31
 
32
32
  // src/version.ts
33
- var VERSION = true ? "2.0.49" : "0.0.0-test";
33
+ var VERSION = true ? "2.0.50" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -206,10 +206,16 @@ var import_provider_utils6 = require("@ai-sdk/provider-utils");
206
206
  var import_v45 = require("zod/v4");
207
207
 
208
208
  // src/convert-json-schema-to-openapi-schema.ts
209
- function convertJSONSchemaToOpenAPISchema(jsonSchema) {
210
- if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
209
+ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
210
+ if (jsonSchema == null) {
211
211
  return void 0;
212
212
  }
213
+ if (isEmptyObjectSchema(jsonSchema)) {
214
+ if (isRoot) {
215
+ return void 0;
216
+ }
217
+ return { type: "object" };
218
+ }
213
219
  if (typeof jsonSchema === "boolean") {
214
220
  return { type: "boolean", properties: {} };
215
221
  }
@@ -256,17 +262,19 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
256
262
  if (properties != null) {
257
263
  result.properties = Object.entries(properties).reduce(
258
264
  (acc, [key, value]) => {
259
- acc[key] = convertJSONSchemaToOpenAPISchema(value);
265
+ acc[key] = convertJSONSchemaToOpenAPISchema(value, false);
260
266
  return acc;
261
267
  },
262
268
  {}
263
269
  );
264
270
  }
265
271
  if (items) {
266
- result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
272
+ result.items = Array.isArray(items) ? items.map((item) => convertJSONSchemaToOpenAPISchema(item, false)) : convertJSONSchemaToOpenAPISchema(items, false);
267
273
  }
268
274
  if (allOf) {
269
- result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
275
+ result.allOf = allOf.map(
276
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
277
+ );
270
278
  }
271
279
  if (anyOf) {
272
280
  if (anyOf.some(
@@ -276,21 +284,30 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
276
284
  (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
277
285
  );
278
286
  if (nonNullSchemas.length === 1) {
279
- const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
287
+ const converted = convertJSONSchemaToOpenAPISchema(
288
+ nonNullSchemas[0],
289
+ false
290
+ );
280
291
  if (typeof converted === "object") {
281
292
  result.nullable = true;
282
293
  Object.assign(result, converted);
283
294
  }
284
295
  } else {
285
- result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
296
+ result.anyOf = nonNullSchemas.map(
297
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
298
+ );
286
299
  result.nullable = true;
287
300
  }
288
301
  } else {
289
- result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
302
+ result.anyOf = anyOf.map(
303
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
304
+ );
290
305
  }
291
306
  }
292
307
  if (oneOf) {
293
- result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
308
+ result.oneOf = oneOf.map(
309
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
310
+ );
294
311
  }
295
312
  if (minLength !== void 0) {
296
313
  result.minLength = minLength;