MCPcopy Create free account
hub / github.com/andywer/postguard / validateQuery

Function validateQuery

src/validation.ts:207–218  ·  view source on GitHub ↗
(invocation: QueryInvocation, tables: TableSchema[])

Source from the content-addressed store, hash-verified

205}
206
207export function validateQuery(invocation: QueryInvocation, tables: TableSchema[]) {
208 const tableExpressions: TableSchema[] = getAllSubqueries(invocation.query)
209 .map<TableSchema | null>(subquery =>
210 subquery.exposedAsTable
211 ? resolveSubqueryToTableSchema(subquery as Query & { exposedAsTable: string }, tables)
212 : null
213 )
214 .filter((schemaOrNull): schemaOrNull is TableSchema => schemaOrNull !== null)
215
216 validateSubquery(invocation.query, [...tables, ...tableExpressions])
217 validateQueryInvocation(invocation, [...tables, ...tableExpressions])
218}

Callers 6

subqueries.test.tsFile · 0.90
valid.test.tsFile · 0.90
runFunction · 0.90

Calls 4

getAllSubqueriesFunction · 0.90
validateSubqueryFunction · 0.85
validateQueryInvocationFunction · 0.85

Tested by

no test coverage detected