@ai-sdk/google 3.0.138 → 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 +8 -0
- package/dist/index.js +35 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +34 -3
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +34 -3
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/google-json-accumulator.ts +52 -3
package/dist/internal/index.js
CHANGED
|
@@ -1424,8 +1424,10 @@ var GoogleJSONAccumulator = class {
|
|
|
1424
1424
|
processPartialArgs(partialArgs) {
|
|
1425
1425
|
let delta = "";
|
|
1426
1426
|
for (const arg of partialArgs) {
|
|
1427
|
-
const
|
|
1428
|
-
|
|
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;
|
|
1429
1431
|
const segments = parsePath(rawPath);
|
|
1430
1432
|
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
1431
1433
|
const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
|
|
@@ -1440,7 +1442,16 @@ var GoogleJSONAccumulator = class {
|
|
|
1440
1442
|
continue;
|
|
1441
1443
|
}
|
|
1442
1444
|
const resolved = resolvePartialArgValue(arg);
|
|
1443
|
-
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
|
+
}
|
|
1444
1455
|
setNestedValue(this.accumulatedArgs, segments, resolved.value);
|
|
1445
1456
|
delta += this.emitNavigationTo(segments, arg, resolved.json);
|
|
1446
1457
|
}
|
|
@@ -1492,6 +1503,26 @@ var GoogleJSONAccumulator = class {
|
|
|
1492
1503
|
fragment += this.emitLeaf(leafSegment, arg, valueJson);
|
|
1493
1504
|
return fragment;
|
|
1494
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
|
+
}
|
|
1495
1526
|
/**
|
|
1496
1527
|
* Returns the stack depth to preserve when navigating to a new target
|
|
1497
1528
|
* container path. Always >= 1 (the root is never popped).
|