prettier-sql
Version:
Format whitespace in a SQL query to make it more readable
65 lines (64 loc) • 3 kB
TypeScript
/**
* Builds a RegExp containing all operators for a SQL dialect
* @param {string} monadOperators - concatenated string of all 1-length operators
* @param {string[]} polyadOperators - list of strings of all >1-length operators
*/
export declare const createOperatorRegex: (monadOperators: string, polyadOperators: string[]) => RegExp;
/**
* Builds a RegExp for valid line comments in a SQL dialect
* @param {string[]} lineCommentTypes - list of character strings that denote line comments
*/
export declare const createLineCommentRegex: (lineCommentTypes: string[]) => RegExp;
/**
* Builds a RegExp for all Reserved Keywords in a SQL dialect
* @param {string[]} reservedKeywords - list of strings of all Reserved Keywords
* @param {string} specialWordChars - concatenated string of all special chars that can appear in valid identifiers (and not in Reserved Keywords)
*/
export declare const createReservedWordRegex: (reservedKeywords: string[], specialWordChars?: string) => RegExp;
/**
* Builds a RegExp for valid identifiers in a SQL dialect
* @param {Object} specialChars
* @param {string} specialChars.any - concatenated string of chars that can appear anywhere in a valid identifier
* @param {string} specialChars.prefix - concatenated string of chars that only appear at the beginning of a valid identifier
* @param {string} specialChars.suffix - concatenated string of chars that only appear at the end of a valid identifier
*/
export declare const createWordRegex: (specialChars?: {
any?: string;
prefix?: string;
suffix?: string;
}) => RegExp;
declare const patterns: {
'``': string;
'{}': string;
'[]': string;
'""': string;
"''": string;
"N''": string;
"x''": string;
"U&''": string;
'U&""': string;
$$: string;
};
export declare type StringPatternType = keyof typeof patterns;
/**
* Builds a string pattern for matching string patterns for all given string types
* @param {StringPatternType[]} stringTypes - list of strings that denote string patterns
*/
export declare const createStringPattern: (stringTypes: StringPatternType[]) => string;
/**
* Builds a RegExp for matching string patterns using `createStringPattern`
* @param {StringPatternType[]} stringTypes - list of strings that denote string patterns
*/
export declare const createStringRegex: (stringTypes: StringPatternType[]) => RegExp;
/**
* Builds a RegExp for matching parenthesis patterns, escaping them with `escapeParen`
* @param {string[]} parens - list of strings that denote parenthesis patterns
*/
export declare const createParenRegex: (parens: string[]) => RegExp;
/**
* Builds a RegExp for placeholder patterns
* @param {string[]} types - list of strings that denote placeholder types
* @param {string} pattern - string that denotes placeholder pattern
*/
export declare const createPlaceholderRegex: (types: string[], pattern: string) => RegExp | undefined;
export {};