(customTool: CustomToolRow)
| 29 | type CustomToolRow = NonNullable<Awaited<ReturnType<typeof getCustomToolByIdOrTitle>>> |
| 30 | |
| 31 | function toCustomToolDefinition(customTool: CustomToolRow): CustomToolDefinition | null { |
| 32 | const parsedSchema = customToolSchemaSchema.safeParse(customTool.schema) |
| 33 | if (!parsedSchema.success) { |
| 34 | logger.error(`Invalid custom tool schema: ${customTool.id}`, { |
| 35 | issues: parsedSchema.error.issues, |
| 36 | }) |
| 37 | return null |
| 38 | } |
| 39 | |
| 40 | return { |
| 41 | id: customTool.id, |
| 42 | workspaceId: customTool.workspaceId, |
| 43 | userId: customTool.userId, |
| 44 | title: customTool.title, |
| 45 | schema: parsedSchema.data, |
| 46 | code: customTool.code, |
| 47 | createdAt: customTool.createdAt.toISOString(), |
| 48 | updatedAt: customTool.updatedAt?.toISOString(), |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Execute the actual request and transform the response. |
no test coverage detected