@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/index.mjs
CHANGED
|
@@ -238,7 +238,7 @@ import {
|
|
|
238
238
|
} from "@ai-sdk/provider-utils";
|
|
239
239
|
|
|
240
240
|
// src/version.ts
|
|
241
|
-
var VERSION = true ? "3.0.
|
|
241
|
+
var VERSION = true ? "3.0.139" : "0.0.0-test";
|
|
242
242
|
|
|
243
243
|
// src/google-generative-ai-embedding-model.ts
|
|
244
244
|
import {
|
|
@@ -694,6 +694,11 @@ function convertJSONSchemaDefinition(jsonSchema, isRoot, referenceContext) {
|
|
|
694
694
|
const nonNullTypes = type.filter((t) => t !== "null");
|
|
695
695
|
if (nonNullTypes.length === 0) {
|
|
696
696
|
result.type = "null";
|
|
697
|
+
} else if (nonNullTypes.length === 1) {
|
|
698
|
+
result.type = nonNullTypes[0];
|
|
699
|
+
if (hasNull) {
|
|
700
|
+
result.nullable = true;
|
|
701
|
+
}
|
|
697
702
|
} else {
|
|
698
703
|
result.anyOf = nonNullTypes.map((t) => ({ type: t }));
|
|
699
704
|
if (hasNull) {
|
|
@@ -1871,8 +1876,10 @@ var GoogleJSONAccumulator = class {
|
|
|
1871
1876
|
processPartialArgs(partialArgs) {
|
|
1872
1877
|
let delta = "";
|
|
1873
1878
|
for (const arg of partialArgs) {
|
|
1874
|
-
const
|
|
1875
|
-
|
|
1879
|
+
const isArrayTerminator = arg.jsonPath.endsWith("[]");
|
|
1880
|
+
const jsonPath = isArrayTerminator ? arg.jsonPath.slice(0, -2) : arg.jsonPath;
|
|
1881
|
+
const rawPath = jsonPath.replace(/^\$\./, "");
|
|
1882
|
+
if (!rawPath || rawPath === "$") continue;
|
|
1876
1883
|
const segments = parsePath(rawPath);
|
|
1877
1884
|
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
1878
1885
|
const isStringContinuation = arg.stringValue != null && existingValue !== void 0;
|
|
@@ -1887,7 +1894,16 @@ var GoogleJSONAccumulator = class {
|
|
|
1887
1894
|
continue;
|
|
1888
1895
|
}
|
|
1889
1896
|
const resolved = resolvePartialArgValue(arg);
|
|
1890
|
-
if (resolved == null)
|
|
1897
|
+
if (resolved == null) {
|
|
1898
|
+
if (existingValue !== void 0 || arg.willContinue === true) continue;
|
|
1899
|
+
setNestedValue(
|
|
1900
|
+
this.accumulatedArgs,
|
|
1901
|
+
segments,
|
|
1902
|
+
isArrayTerminator ? [] : {}
|
|
1903
|
+
);
|
|
1904
|
+
delta += this.emitContainer(segments, isArrayTerminator);
|
|
1905
|
+
continue;
|
|
1906
|
+
}
|
|
1891
1907
|
setNestedValue(this.accumulatedArgs, segments, resolved.value);
|
|
1892
1908
|
delta += this.emitNavigationTo(segments, arg, resolved.json);
|
|
1893
1909
|
}
|
|
@@ -1939,6 +1955,26 @@ var GoogleJSONAccumulator = class {
|
|
|
1939
1955
|
fragment += this.emitLeaf(leafSegment, arg, valueJson);
|
|
1940
1956
|
return fragment;
|
|
1941
1957
|
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Navigates to `targetSegments` and opens a container there. The container
|
|
1960
|
+
* stays open so later entries for its children continue inside it; it is
|
|
1961
|
+
* closed by subsequent navigation or by `finalize()`.
|
|
1962
|
+
*
|
|
1963
|
+
* Input: targetSegments=["nested","tags"], isArray=true
|
|
1964
|
+
* Output: '{"nested":{"tags":['
|
|
1965
|
+
*/
|
|
1966
|
+
emitContainer(targetSegments, isArray) {
|
|
1967
|
+
let fragment = "";
|
|
1968
|
+
if (this.stringOpen) {
|
|
1969
|
+
fragment += '"';
|
|
1970
|
+
this.stringOpen = false;
|
|
1971
|
+
}
|
|
1972
|
+
fragment += this.ensureRoot();
|
|
1973
|
+
const commonDepth = this.findCommonStackDepth(targetSegments);
|
|
1974
|
+
fragment += this.closeDownTo(commonDepth);
|
|
1975
|
+
fragment += this.openDownTo(targetSegments, isArray ? 0 : "");
|
|
1976
|
+
return fragment;
|
|
1977
|
+
}
|
|
1942
1978
|
/**
|
|
1943
1979
|
* Returns the stack depth to preserve when navigating to a new target
|
|
1944
1980
|
* container path. Always >= 1 (the root is never popped).
|