@adonis-agora/agent
Version:
Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.
37 lines • 1.55 kB
TypeScript
import type { SqlParserLike } from './parser.js';
/**
* Thrown when a statement is not a single, read-only SELECT — i.e. it is an
* INSERT/UPDATE/DELETE, DDL, a CALL, a multi-statement string, or it fails to
* parse. The handler surfaces `.message` to the model so it can re-plan.
*/
export declare class SqlValidationError extends Error {
constructor(message: string);
}
export interface SqlValidationResult {
/** Every base table the statement references (CTEs, joins, subqueries walked). */
tables: string[];
}
/**
* Parses SQL (MySQL dialect) and asserts it is a single SELECT, returning the
* set of tables it touches. Domain-agnostic: it knows nothing about which
* tables a caller may read — that is the `TableAccessPolicy`'s job.
*
* The `node-sql-parser` `Parser` is injected (see {@link loadSqlParser}) so this file never imports the
* optional peer at module load.
*/
export declare class SqlValidator {
private readonly parser;
constructor(parser: SqlParserLike);
/**
* Throws `SqlValidationError` unless `sql` is exactly one SELECT statement.
* On success returns the distinct base table names referenced.
*/
validate(sql: string): SqlValidationResult;
/**
* Distinct base table names a statement touches — walking CTEs, subqueries,
* and joins. Backed by `node-sql-parser`'s `tableList`, which emits
* `mode::db::table` strings; the table name is the last segment.
*/
private extractReferencedTables;
}
//# sourceMappingURL=sql-validator.d.ts.map