(serialized: typeof SerializedCatalog.Type)
| 43 | } |
| 44 | |
| 45 | export function deserializeToJsonSchema(serialized: typeof SerializedCatalog.Type): { |
| 46 | tools: ReadonlyArray<{ |
| 47 | path: string; |
| 48 | description?: string; |
| 49 | tags?: ReadonlyArray<string>; |
| 50 | namespace?: string; |
| 51 | input?: JsonSchema; |
| 52 | output?: JsonSchema; |
| 53 | error?: JsonSchema; |
| 54 | }>; |
| 55 | types: Record<string, unknown>; |
| 56 | } { |
| 57 | const types = serialized.types; |
| 58 | |
| 59 | function resolveRef(ref: string | undefined): JsonSchema | undefined { |
| 60 | if (!ref) return undefined; |
| 61 | const schema = types[ref]; |
| 62 | if (!schema) return undefined; |
| 63 | return { |
| 64 | ...(schema as JsonSchema), |
| 65 | $defs: types as Record<string, JsonSchema>, |
| 66 | }; |
| 67 | } |
| 68 | |
| 69 | return { |
| 70 | tools: serialized.tools.map((tool) => ({ |
| 71 | path: tool.path, |
| 72 | description: tool.description, |
| 73 | integrationId: tool.integrationId, |
| 74 | input: resolveRef(tool.input), |
| 75 | output: resolveRef(tool.output), |
| 76 | error: resolveRef(tool.error), |
| 77 | })), |
| 78 | types, |
| 79 | }; |
| 80 | } |
nothing calls this directly
no test coverage detected