(
tableId: string,
toolId: string,
originalSchema: {
type: 'object'
properties: Record<string, unknown>
required: string[]
},
originalDescription: string
)
| 31 | } |
| 32 | |
| 33 | export async function enrichTableToolSchema( |
| 34 | tableId: string, |
| 35 | toolId: string, |
| 36 | originalSchema: { |
| 37 | type: 'object' |
| 38 | properties: Record<string, unknown> |
| 39 | required: string[] |
| 40 | }, |
| 41 | originalDescription: string |
| 42 | ): Promise<{ |
| 43 | description: string |
| 44 | parameters: { |
| 45 | type: 'object' |
| 46 | properties: Record<string, unknown> |
| 47 | required: string[] |
| 48 | } |
| 49 | } | null> { |
| 50 | const tableSchema = await fetchTableSchema(tableId) |
| 51 | |
| 52 | if (!tableSchema) { |
| 53 | return null |
| 54 | } |
| 55 | |
| 56 | const enrichedDescription = enrichTableToolDescription(originalDescription, tableSchema, toolId) |
| 57 | const enrichedParams = enrichTableToolParameters( |
| 58 | { properties: originalSchema.properties, required: originalSchema.required }, |
| 59 | tableSchema, |
| 60 | toolId |
| 61 | ) |
| 62 | |
| 63 | return { |
| 64 | description: enrichedDescription, |
| 65 | parameters: { |
| 66 | type: 'object', |
| 67 | properties: enrichedParams.properties, |
| 68 | required: |
| 69 | enrichedParams.required.length > 0 ? enrichedParams.required : originalSchema.required, |
| 70 | }, |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | interface TagDefinition { |
| 75 | id: string |
no test coverage detected