@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/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  } from "@ai-sdk/provider-utils";
8
8
 
9
9
  // src/version.ts
10
- var VERSION = true ? "3.0.0-beta.82" : "0.0.0-test";
10
+ var VERSION = true ? "3.0.0-beta.84" : "0.0.0-test";
11
11
 
12
12
  // src/google-generative-ai-embedding-model.ts
13
13
  import {
@@ -251,10 +251,19 @@ function convertGoogleGenerativeAIUsage(usage) {
251
251
  }
252
252
 
253
253
  // src/convert-json-schema-to-openapi-schema.ts
254
- function convertJSONSchemaToOpenAPISchema(jsonSchema) {
255
- if (jsonSchema == null || isEmptyObjectSchema(jsonSchema)) {
254
+ function convertJSONSchemaToOpenAPISchema(jsonSchema, isRoot = true) {
255
+ if (jsonSchema == null) {
256
256
  return void 0;
257
257
  }
258
+ if (isEmptyObjectSchema(jsonSchema)) {
259
+ if (isRoot) {
260
+ return void 0;
261
+ }
262
+ if (typeof jsonSchema === "object" && jsonSchema.description) {
263
+ return { type: "object", description: jsonSchema.description };
264
+ }
265
+ return { type: "object" };
266
+ }
258
267
  if (typeof jsonSchema === "boolean") {
259
268
  return { type: "boolean", properties: {} };
260
269
  }
@@ -301,17 +310,19 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
301
310
  if (properties != null) {
302
311
  result.properties = Object.entries(properties).reduce(
303
312
  (acc, [key, value]) => {
304
- acc[key] = convertJSONSchemaToOpenAPISchema(value);
313
+ acc[key] = convertJSONSchemaToOpenAPISchema(value, false);
305
314
  return acc;
306
315
  },
307
316
  {}
308
317
  );
309
318
  }
310
319
  if (items) {
311
- result.items = Array.isArray(items) ? items.map(convertJSONSchemaToOpenAPISchema) : convertJSONSchemaToOpenAPISchema(items);
320
+ result.items = Array.isArray(items) ? items.map((item) => convertJSONSchemaToOpenAPISchema(item, false)) : convertJSONSchemaToOpenAPISchema(items, false);
312
321
  }
313
322
  if (allOf) {
314
- result.allOf = allOf.map(convertJSONSchemaToOpenAPISchema);
323
+ result.allOf = allOf.map(
324
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
325
+ );
315
326
  }
316
327
  if (anyOf) {
317
328
  if (anyOf.some(
@@ -321,21 +332,30 @@ function convertJSONSchemaToOpenAPISchema(jsonSchema) {
321
332
  (schema) => !(typeof schema === "object" && (schema == null ? void 0 : schema.type) === "null")
322
333
  );
323
334
  if (nonNullSchemas.length === 1) {
324
- const converted = convertJSONSchemaToOpenAPISchema(nonNullSchemas[0]);
335
+ const converted = convertJSONSchemaToOpenAPISchema(
336
+ nonNullSchemas[0],
337
+ false
338
+ );
325
339
  if (typeof converted === "object") {
326
340
  result.nullable = true;
327
341
  Object.assign(result, converted);
328
342
  }
329
343
  } else {
330
- result.anyOf = nonNullSchemas.map(convertJSONSchemaToOpenAPISchema);
344
+ result.anyOf = nonNullSchemas.map(
345
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
346
+ );
331
347
  result.nullable = true;
332
348
  }
333
349
  } else {
334
- result.anyOf = anyOf.map(convertJSONSchemaToOpenAPISchema);
350
+ result.anyOf = anyOf.map(
351
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
352
+ );
335
353
  }
336
354
  }
337
355
  if (oneOf) {
338
- result.oneOf = oneOf.map(convertJSONSchemaToOpenAPISchema);
356
+ result.oneOf = oneOf.map(
357
+ (item) => convertJSONSchemaToOpenAPISchema(item, false)
358
+ );
339
359
  }
340
360
  if (minLength !== void 0) {
341
361
  result.minLength = minLength;