Repository navigation
Expand file tree
/
Copy pathtypes.ts
More file actions
63 lines (59 loc) · 2.12 KB
/
Copy pathtypes.ts
File metadata and controls
63 lines (59 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { EditorState } from "@codemirror/state";
/**
* Represents a SQL parsing error with location information
*/
export interface SqlParseError {
/** Error message describing the issue */
message: string;
/** Line number where the error occurred (1-indexed) */
line: number;
/** Column number where the error occurred (1-indexed) */
column: number;
/** Severity level of the error */
severity: "error" | "warning";
}
/**
* Public parser result; custom parsers may include warnings or partial ASTs.
*/
export interface SqlParseResult {
success: boolean;
errors: SqlParseError[];
ast?: unknown;
}
/** Analysis consumers only require parsing; other capabilities are optional. */
export type SqlParserLike = Pick<SqlParser, "parse"> & Partial<Omit<SqlParser, "parse">>;
export interface SqlParser {
/**
* Identifies parser configuration for reuse across states with the same document.
* Return undefined (the default) to cache only within the exact editor state.
*/
getCacheKey?(state: EditorState): unknown;
/**
* Parse a SQL statement and return the AST
* @param sql - The SQL statement to parse
* @param opts - The state of the editor
* @returns The parsed AST
*/
parse(sql: string, opts: { state: EditorState }): Promise<SqlParseResult>;
/**
* Validate a SQL statement and return any errors
* @param sql - The SQL statement to validate
* @param opts - The state of the editor
* @returns An array of errors
*/
validateSql(sql: string, opts: { state: EditorState }): Promise<SqlParseError[]>;
/**
* Extract table references from a SQL query
* @param sql - The SQL query to analyze
* @param opts - The state of the editor
* @returns Array of table names referenced in the query
*/
extractTableReferences(sql: string, opts?: { state: EditorState }): Promise<string[]>;
/**
* Extract column references from a SQL query
* @param sql - The SQL query to analyze
* @param opts - The state of the editor
* @returns Array of column names referenced in the query
*/
extractColumnReferences(sql: string, opts?: { state: EditorState }): Promise<string[]>;
}