UNPKG

rawsql-ts

Version:

[beta]High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.

55 lines (54 loc) 2.02 kB
import { SqlPrintToken } from "../models/SqlPrintToken"; import { IndentCharOption, NewlineOption } from "./LinePrinter"; /** * CommaBreakStyle determines how commas are placed in formatted SQL output. * - 'none': No line break for commas * - 'before': Line break before comma * - 'after': Line break after comma */ export type CommaBreakStyle = 'none' | 'before' | 'after'; /** * AndBreakStyle determines how AND operators are placed in formatted SQL output. * - 'none': No line break for AND * - 'before': Line break before AND * - 'after': Line break after AND */ export type AndBreakStyle = 'none' | 'before' | 'after'; /** * SqlPrinter formats a SqlPrintToken tree into a SQL string with flexible style options. */ export declare class SqlPrinter { /** Indent character (e.g., ' ' or '\\t') */ indentChar: IndentCharOption; /** Indent size (number of indentChar repetitions per level) */ indentSize: number; /** Newline character (e.g., '\\n' or '\\r\\n') */ newline: NewlineOption; /** Comma break style: 'none', 'before', or 'after' */ commaBreak: CommaBreakStyle; /** AND break style: 'none', 'before', or 'after' */ andBreak: AndBreakStyle; /** Keyword case style: 'none', 'upper' | 'lower' */ keywordCase: 'none' | 'upper' | 'lower'; private linePrinter; private indentIncrementContainers; /** * @param options Optional style settings for pretty printing */ constructor(options?: { indentChar?: IndentCharOption; indentSize?: number; newline?: NewlineOption; commaBreak?: CommaBreakStyle; andBreak?: AndBreakStyle; keywordCase?: 'none' | 'upper' | 'lower'; indentIncrementContainerTypes?: string[]; }); /** * Converts a SqlPrintToken tree to a formatted SQL string. * @param token The root SqlPrintToken * @param level Indentation level (default: 0) */ print(token: SqlPrintToken, level?: number): string; private appendToken; }