@ai-sdk/google 4.0.103 → 4.0.105
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 +23 -0
- package/README.md +3 -15
- package/dist/index.js +30 -4
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +29 -3
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/google-json-accumulator.ts +52 -3
package/dist/internal/index.js
CHANGED
|
@@ -1048,8 +1048,9 @@ var GoogleJSONAccumulator = class {
|
|
|
1048
1048
|
processPartialArgs(partialArgs) {
|
|
1049
1049
|
let delta = "";
|
|
1050
1050
|
for (const arg of partialArgs) {
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1051
|
+
const isArrayTerminator = arg.jsonPath.endsWith("[]");
|
|
1052
|
+
const rawPath = (isArrayTerminator ? arg.jsonPath.slice(0, -2) : arg.jsonPath).replace(/^\$\./, "");
|
|
1053
|
+
if (!rawPath || rawPath === "$") continue;
|
|
1053
1054
|
const segments = parsePath(rawPath);
|
|
1054
1055
|
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
1055
1056
|
if (arg.stringValue != null && existingValue !== void 0) {
|
|
@@ -1059,7 +1060,12 @@ var GoogleJSONAccumulator = class {
|
|
|
1059
1060
|
continue;
|
|
1060
1061
|
}
|
|
1061
1062
|
const resolved = resolvePartialArgValue(arg);
|
|
1062
|
-
if (resolved == null)
|
|
1063
|
+
if (resolved == null) {
|
|
1064
|
+
if (existingValue !== void 0 || arg.willContinue === true) continue;
|
|
1065
|
+
setNestedValue(this.accumulatedArgs, segments, isArrayTerminator ? [] : {});
|
|
1066
|
+
delta += this.emitContainer(segments, isArrayTerminator);
|
|
1067
|
+
continue;
|
|
1068
|
+
}
|
|
1063
1069
|
setNestedValue(this.accumulatedArgs, segments, resolved.value);
|
|
1064
1070
|
delta += this.emitNavigationTo(segments, arg, resolved.json);
|
|
1065
1071
|
}
|
|
@@ -1118,6 +1124,26 @@ var GoogleJSONAccumulator = class {
|
|
|
1118
1124
|
return fragment;
|
|
1119
1125
|
}
|
|
1120
1126
|
/**
|
|
1127
|
+
* Navigates to `targetSegments` and opens a container there. The container
|
|
1128
|
+
* stays open so later entries for its children continue inside it; it is
|
|
1129
|
+
* closed by subsequent navigation or by `finalize()`.
|
|
1130
|
+
*
|
|
1131
|
+
* Input: targetSegments=["nested","tags"], isArray=true
|
|
1132
|
+
* Output: '{"nested":{"tags":['
|
|
1133
|
+
*/
|
|
1134
|
+
emitContainer(targetSegments, isArray) {
|
|
1135
|
+
let fragment = "";
|
|
1136
|
+
if (this.stringOpen) {
|
|
1137
|
+
fragment += "\"";
|
|
1138
|
+
this.stringOpen = false;
|
|
1139
|
+
}
|
|
1140
|
+
fragment += this.ensureRoot();
|
|
1141
|
+
const commonDepth = this.findCommonStackDepth(targetSegments);
|
|
1142
|
+
fragment += this.closeDownTo(commonDepth);
|
|
1143
|
+
fragment += this.openDownTo(targetSegments, isArray ? 0 : "");
|
|
1144
|
+
return fragment;
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1121
1147
|
* Returns the stack depth to preserve when navigating to a new target
|
|
1122
1148
|
* container path. Always >= 1 (the root is never popped).
|
|
1123
1149
|
*
|