rawsql-ts
Version:
High-performance SQL parser and AST analyzer written in TypeScript. Provides fast parsing and advanced transformation capabilities.
30 lines (29 loc) • 1.63 kB
TypeScript
import { SqlPrintToken, SqlPrintTokenContainerType } from "../models/SqlPrintToken";
import type { WithClauseStyle } from "./SqlFormatter";
export type CommaBreakStyle = 'none' | 'before' | 'after';
export interface OnelineFormattingOptions {
parenthesesOneLine: boolean;
betweenOneLine: boolean;
valuesOneLine: boolean;
joinOneLine: boolean;
caseOneLine: boolean;
subqueryOneLine: boolean;
insertColumnsOneLine: boolean;
withClauseStyle: WithClauseStyle;
}
interface FormatInsertClauseResult {
handled: boolean;
text?: string;
}
export declare class OnelineFormattingHelper {
private readonly options;
constructor(options: OnelineFormattingOptions);
shouldFormatContainer(token: SqlPrintToken, shouldIndentNested: boolean): boolean;
isInsertClauseOneline(parentContainerType?: SqlPrintTokenContainerType): boolean;
shouldInsertJoinNewline(insideWithClause: boolean): boolean;
resolveCommaBreak(parentContainerType: SqlPrintTokenContainerType | undefined, commaBreak: CommaBreakStyle, cteCommaBreak: CommaBreakStyle, valuesCommaBreak: CommaBreakStyle): CommaBreakStyle;
shouldSkipInsertClauseSpace(parentContainerType: SqlPrintTokenContainerType | undefined, nextToken: SqlPrintToken | undefined, currentLineText: string): boolean;
shouldSkipCommentBlockSpace(parentContainerType: SqlPrintTokenContainerType | undefined, insideWithClause: boolean): boolean;
formatInsertClauseToken(text: string, parentContainerType: SqlPrintTokenContainerType | undefined, currentLineText: string, ensureTrailingSpace: () => void): FormatInsertClauseResult;
}
export {};