refactor(open-sse): extract safeParseJSON util, dedup tryParseJSON (B5)
Consolidate two tryParseJSON variants into helpers/jsonUtil.js with explicit fallback param. Preserve exact per-call semantics: openai-to-claude passthrough (fallback=str), geminiHelper null. geminiHelper keeps tryParseJSON re-export. No behavior change; gate: no regression. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
87fe069e9e
commit
b87cf0c96a
4 files changed
+12
-19
No files matched your search
@@ -1,5 +1,7 @@
|
||||
// Gemini helper functions for translator
|
||||
|
||||
import { safeParseJSON } from "./jsonUtil.js";
|
||||
|
||||
// Unsupported JSON Schema constraints that should be removed for Antigravity
|
||||
export const UNSUPPORTED_SCHEMA_CONSTRAINTS = [
|
||||
// Basic constraints (not supported by Gemini API)
|
||||
@@ -90,14 +92,9 @@ export function extractTextContent(content) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Try parse JSON safely
|
||||
// Try parse JSON safely (null fallback on parse error; re-export keeps legacy API)
|
||||
export function tryParseJSON(str) {
|
||||
if (typeof str !== "string") return str;
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return safeParseJSON(str, null);
|
||||
}
|
||||
|
||||
// Generate request ID
|
||||
|
||||
Reference in new issue
Block a user