@ai-sdk/google 3.0.0-beta.82 → 3.0.0-beta.84

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,17 @@
1
1
  # @ai-sdk/google
2
2
 
3
+ ## 3.0.0-beta.84
4
+
5
+ ### Patch Changes
6
+
7
+ - fd788ce: fix(provider/google): preserve nested empty object schemas and descriptions in tool parameters
8
+
9
+ ## 3.0.0-beta.83
10
+
11
+ ### Patch Changes
12
+
13
+ - 166b6d7: 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
14
+
3
15
  ## 3.0.0-beta.82
4
16
 
5
17
  ### 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 ? "3.0.0-beta.82" : "0.0.0-test";
33
+ var VERSION = true ? "3.0.0-beta.84" : "0.0.0-test";
34
34
 
35
35
  // src/google-generative-ai-embedding-model.ts
36
36
  var import_provider = require("@ai-sdk/provider");
@@ -247,10 +247,19 @@ function convertGoogleGenerativeAIUsage(usage) {
247
247
  }
248
248
 
249
249
  // src/convert-json-schema-to-openapi-schema.ts
250
- function convertJSONSchemaToOpenAPISchema(jsonSchema) {
251
- if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
250
+ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
251
+ if (jsonSchema == null) {
252
252
  return void 0;
253
253
  }
254
+ if (isEmptyObjectSchema(jsonSchema)) {
255
+ if (isRoot) {
256
+ return void 0;
257
+ }
258
+ if (typeof jsonSchema === "object" && jsonSchema.description) {
259
+ return { type: "object", description: jsonSchema.description };
260
+ }
261
+ return { type: "object" };
262
+ }
254
263
  if (typeof jsonSchema === "boolean") {
255
264
  return { type: "boolean", properties: {} };
256
265
  }
@@ -297,17 +306,19 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
297
306
  if (properties != null) {
298
307
  result.properties = Object.entries(properties).reduce(
299
308
  (acc, [key, value]) => {
300
- acc[key] = convertJSONSchemaToOpenAPISchema(value);
309
+ acc[key] = convertJSONSchemaToOpenAPISchema(value, false);
301
310
  return acc;
302
311
  },
303
312
  {}
304
313
  );
305
314
  }
306
315
  if (items) {
307
- result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
316
+ result.items = Array.isArray(items) ? items.map((item) => convertJSONSchemaToOpenAPISchema(item, false)) : convertJSONSchemaToOpenAPISchema(items, false);
308
317
  }
309
318
  if (allOf) {
310
- result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
319
+ result.allOf = allOf.map(
320
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
321
+ );
311
322
  }
312
323
  if (anyOf) {
313
324
  if (anyOf.some(
@@ -317,21 +328,30 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
317
328
  (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
318
329
  );
319
330
  if (nonNullSchemas.length === 1) {
320
- const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
331
+ const converted = convertJSONSchemaToOpenAPISchema(
332
+ nonNullSchemas[0],
333
+ false
334
+ );
321
335
  if (typeof converted === "object") {
322
336
  result.nullable = true;
323
337
  Object.assign(result, converted);
324
338
  }
325
339
  } else {
326
- result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
340
+ result.anyOf = nonNullSchemas.map(
341
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
342
+ );
327
343
  result.nullable = true;
328
344
  }
329
345
  } else {
330
- result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
346
+ result.anyOf = anyOf.map(
347
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
348
+ );
331
349
  }
332
350
  }
333
351
  if (oneOf) {
334
- result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
352
+ result.oneOf = oneOf.map(
353
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
354
+ );
335
355
  }
336
356
  if (minLength !== void 0) {
337
357
  result.minLength = minLength;