libpg-query
Version:
The real PostgreSQL query parser
52 lines (51 loc) • 1.83 kB
TypeScript
/**
* DO NOT MODIFY MANUALLY — this is generated from the templates dir
*
* To make changes, edit the files in the templates/ directory and run:
* npm run copy:templates
*/
import { ParseResult } from "@pgsql/types";
export * from "@pgsql/types";
export interface ScanToken {
start: number;
end: number;
text: string;
tokenType: number;
tokenName: string;
keywordKind: number;
keywordName: string;
}
export interface ScanResult {
version: number;
tokens: ScanToken[];
}
export interface SqlErrorDetails {
message: string;
cursorPosition: number;
fileName?: string;
functionName?: string;
lineNumber?: number;
context?: string;
}
export declare class SqlError extends Error {
sqlDetails?: SqlErrorDetails;
constructor(message: string, details?: SqlErrorDetails);
}
export declare function hasSqlDetails(error: unknown): error is SqlError;
export declare function formatSqlError(error: SqlError, query: string, options?: {
showPosition?: boolean;
showQuery?: boolean;
color?: boolean;
maxQueryLength?: number;
}): string;
export declare function loadModule(): Promise<void>;
export declare const parse: (query: string) => Promise<ParseResult>;
export declare const parsePlPgSQL: (query: string) => Promise<ParseResult>;
export declare const fingerprint: (query: string) => Promise<string>;
export declare const normalize: (query: string) => Promise<string>;
export declare function parseSync(query: string): ParseResult;
export declare function parsePlPgSQLSync(query: string): ParseResult;
export declare function fingerprintSync(query: string): string;
export declare function normalizeSync(query: string): string;
export declare const scan: (query: string) => Promise<ScanResult>;
export declare function scanSync(query: string): ScanResult;