@ai-sdk/google 3.0.137 → 3.0.139
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 +14 -0
- package/dist/index.js +40 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +40 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +39 -3
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +39 -3
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/convert-json-schema-to-openapi-schema.ts +11 -1
- package/src/google-json-accumulator.ts +52 -3
package/dist/internal/index.js
CHANGED
|
@@ -237,6 +237,11 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
237
237
|
const nonNullTypes = type.filter((t) => t !== "null");
|
|
238
238
|
if (nonNullTypes.length === 0) {
|
|
239
239
|
result.type = "null";
|
|
240
|
+
} else if (nonNullTypes.length === 1) {
|
|
241
|
+
result.type = nonNullTypes[0];
|
|
242
|
+
if (hasNull) {
|
|
243
|
+
result.nullable = true;
|
|
244
|
+
}
|
|
240
245
|
} else {
|
|
241
246
|
result.anyOf = nonNullTypes.map((t) => ({ type: t }));
|
|
242
247
|
if (hasNull) {
|
|
@@ -1419,8 +1424,10 @@ var GoogleJSONAccumulator = class {
|
|
|
1419
1424
|
processPartialArgs(partialArgs) {
|
|
1420
1425
|
let delta = "";
|
|
1421
1426
|
for (const arg of partialArgs) {
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1427
|
+
const isArrayTerminator = arg.jsonPath.endsWith("[]");
|
|
1428
|
+
const jsonPath = isArrayTerminator ? arg.jsonPath.slice(0, -2) : arg.jsonPath;
|
|
1429
|
+
const rawPath = jsonPath.replace(/^\$\./, "");
|
|
1430
|
+
if (!rawPath || rawPath === "$") continue;
|
|
1424
1431
|
const segments = parsePath(rawPath);
|
|
1425
1432
|
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
1426
1433
|
const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
|
|
@@ -1435,7 +1442,16 @@ var GoogleJSONAccumulator = class {
|
|
|
1435
1442
|
continue;
|
|
1436
1443
|
}
|
|
1437
1444
|
const resolved = resolvePartialArgValue(arg);
|
|
1438
|
-
if (resolved == null)
|
|
1445
|
+
if (resolved == null) {
|
|
1446
|
+
if (existingValue !== void 0 || arg.willContinue === true) continue;
|
|
1447
|
+
setNestedValue(
|
|
1448
|
+
this.accumulatedArgs,
|
|
1449
|
+
segments,
|
|
1450
|
+
isArrayTerminator ? [] : {}
|
|
1451
|
+
);
|
|
1452
|
+
delta += this.emitContainer(segments, isArrayTerminator);
|
|
1453
|
+
continue;
|
|
1454
|
+
}
|
|
1439
1455
|
setNestedValue(this.accumulatedArgs, segments, resolved.value);
|
|
1440
1456
|
delta += this.emitNavigationTo(segments, arg, resolved.json);
|
|
1441
1457
|
}
|
|
@@ -1487,6 +1503,26 @@ var GoogleJSONAccumulator = class {
|
|
|
1487
1503
|
fragment += this.emitLeaf(leafSegment, arg, valueJson);
|
|
1488
1504
|
return fragment;
|
|
1489
1505
|
}
|
|
1506
|
+
/**
|
|
1507
|
+
* Navigates to `targetSegments` and opens a container there. The container
|
|
1508
|
+
* stays open so later entries for its children continue inside it; it is
|
|
1509
|
+
* closed by subsequent navigation or by `finalize()`.
|
|
1510
|
+
*
|
|
1511
|
+
* Input: targetSegments=["nested","tags"], isArray=true
|
|
1512
|
+
* Output: '{"nested":{"tags":['
|
|
1513
|
+
*/
|
|
1514
|
+
emitContainer(targetSegments, isArray) {
|
|
1515
|
+
let fragment = "";
|
|
1516
|
+
if (this.stringOpen) {
|
|
1517
|
+
fragment += '"';
|
|
1518
|
+
this.stringOpen = false;
|
|
1519
|
+
}
|
|
1520
|
+
fragment += this.ensureRoot();
|
|
1521
|
+
const commonDepth = this.findCommonStackDepth(targetSegments);
|
|
1522
|
+
fragment += this.closeDownTo(commonDepth);
|
|
1523
|
+
fragment += this.openDownTo(targetSegments, isArray ? 0 : "");
|
|
1524
|
+
return fragment;
|
|
1525
|
+
}
|
|
1490
1526
|
/**
|
|
1491
1527
|
* Returns the stack depth to preserve when navigating to a new target
|
|
1492
1528
|
* container path. Always >= 1 (the root is never popped).
|