Commit 15393c9
committed
feat(react-sdk): return discriminated union from safeSchemaToJsonSchema
Change `safeSchemaToJsonSchema` to return a discriminated union result object instead of `JSONSchema7 | undefined`. This makes error handling explicit and allows callers to decide how strictly to handle failures.
- Introduce `SafeSchemaToJsonSchemaResult` type with `success` discriminator
- Return a structured error when no schema is provided
- Preserve console error logging while surfacing the error message
- Keep `schemaToJsonSchema` behavior unchanged, still delegating to `toJsonSchema.sync` for standard schemas1 parent 8bdf46f commit 15393c9
1 file changed
+32
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
180 | 184 | | |
181 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
182 | 189 | | |
183 | | - | |
| 190 | + | |
| 191 | + | |
184 | 192 | | |
185 | 193 | | |
186 | 194 | | |
187 | | - | |
| 195 | + | |
188 | 196 | | |
189 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
190 | 202 | | |
191 | 203 | | |
192 | 204 | | |
193 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
194 | 210 | | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
195 | 216 | | |
196 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
197 | 223 | | |
198 | 224 | | |
0 commit comments