prettier-plugin-sql-cst 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/CstToDocMap.d.ts +11 -0
- package/dist/PrintFn.d.ts +14 -0
- package/dist/embed.d.ts +3 -0
- package/dist/embedJs.d.ts +3 -0
- package/dist/embedJson.d.ts +3 -0
- package/dist/index.d.ts +6 -0
- package/dist/node_utils.d.ts +16 -0
- package/dist/options.d.ts +8 -0
- package/dist/printComment.d.ts +3 -0
- package/dist/printSql.d.ts +5 -0
- package/dist/print_utils.d.ts +13 -0
- package/dist/syntax/alias.d.ts +3 -0
- package/dist/syntax/alter_table.d.ts +3 -0
- package/dist/syntax/analyze.d.ts +3 -0
- package/dist/syntax/base.d.ts +3 -0
- package/dist/syntax/bigquery.d.ts +3 -0
- package/dist/syntax/constraint.d.ts +3 -0
- package/dist/syntax/create_table.d.ts +3 -0
- package/dist/syntax/data_type.d.ts +3 -0
- package/dist/syntax/dcl.d.ts +3 -0
- package/dist/syntax/delete.d.ts +3 -0
- package/dist/syntax/drop_table.d.ts +3 -0
- package/dist/syntax/explain.d.ts +3 -0
- package/dist/syntax/expr.d.ts +3 -0
- package/dist/syntax/frame.d.ts +3 -0
- package/dist/syntax/function.d.ts +3 -0
- package/dist/syntax/index.d.ts +3 -0
- package/dist/syntax/insert.d.ts +3 -0
- package/dist/syntax/merge.d.ts +3 -0
- package/dist/syntax/prepared_statements.d.ts +3 -0
- package/dist/syntax/proc_clause.d.ts +3 -0
- package/dist/syntax/procedural_language.d.ts +3 -0
- package/dist/syntax/procedure.d.ts +3 -0
- package/dist/syntax/program.d.ts +3 -0
- package/dist/syntax/schema.d.ts +3 -0
- package/dist/syntax/select.d.ts +3 -0
- package/dist/syntax/sqlite.d.ts +3 -0
- package/dist/syntax/transaction.d.ts +3 -0
- package/dist/syntax/transformMap.d.ts +3 -0
- package/dist/syntax/trigger.d.ts +3 -0
- package/dist/syntax/truncate.d.ts +3 -0
- package/dist/syntax/update.d.ts +3 -0
- package/dist/syntax/view.d.ts +3 -0
- package/dist/transform/addFinalSemicolon.d.ts +2 -0
- package/dist/transform/aliasAs.d.ts +2 -0
- package/dist/transform/comments.d.ts +10 -0
- package/dist/transform/stripTrailingCommas.d.ts +2 -0
- package/dist/transform/transformCst.d.ts +2 -0
- package/dist/utils.d.ts +9 -0
- package/dist/visitAllNodes.d.ts +2 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -115,4 +115,3 @@ Though the general principles should be mostly in place by now.
|
|
|
115
115
|
[sql-parser-cst]: https://github.com/nene/sql-parser-cst
|
|
116
116
|
[wadler-prettier]: http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf
|
|
117
117
|
[STYLE_GUIDE]: ./STYLE_GUIDE.md
|
|
118
|
-
[#2]: https://github.com/nene/prettier-plugin-sql-cst/issues/2
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Node } from "sql-parser-cst";
|
|
2
|
+
import { AstPath, Doc } from "prettier";
|
|
3
|
+
import { PrintFn } from "./PrintFn";
|
|
4
|
+
import { AllPrettierOptions } from "./options";
|
|
5
|
+
export type NodeByType<TType, TNode> = Extract<TNode, {
|
|
6
|
+
type: TType;
|
|
7
|
+
}>;
|
|
8
|
+
export type ToDocFn<TNode> = (print: PrintFn<TNode>, node: TNode, path: AstPath<TNode>, options: AllPrettierOptions<TNode>) => Doc;
|
|
9
|
+
export type CstToDocMap<TNode extends Node> = {
|
|
10
|
+
[TType in TNode["type"]]: ToDocFn<NodeByType<TType, TNode>>;
|
|
11
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AstPath, Doc } from "prettier";
|
|
2
|
+
import { Node } from "sql-parser-cst";
|
|
3
|
+
export type OldPrintFn = (path: AstPath<Node> | string) => Doc;
|
|
4
|
+
export type PrintFn<T, K = PrintableKey<T>> = {
|
|
5
|
+
(path: AstPath<Node>): Doc;
|
|
6
|
+
(path: K extends keyof T ? (T[K] extends any[] ? K : never) : never): Doc[];
|
|
7
|
+
(path: K): Doc;
|
|
8
|
+
(path: K[]): Doc[];
|
|
9
|
+
spaced(path: K): Doc[];
|
|
10
|
+
spaced(path: K[]): Doc[];
|
|
11
|
+
};
|
|
12
|
+
export type PrintableKey<T> = Exclude<keyof T, ReservedKey>;
|
|
13
|
+
type ReservedKey = "type" | "range" | "leading" | "trailing";
|
|
14
|
+
export {};
|
package/dist/embed.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Node } from "sql-parser-cst";
|
|
2
|
+
import { Parser, Printer, SupportLanguage } from "prettier";
|
|
3
|
+
export { options } from "./options";
|
|
4
|
+
export declare const languages: SupportLanguage[];
|
|
5
|
+
export declare const parsers: Record<string, Parser<Node>>;
|
|
6
|
+
export declare const printers: Record<string, Printer>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Node } from "sql-parser-cst";
|
|
2
|
+
export declare const isProgram: (node: any) => node is import("sql-parser-cst").Program;
|
|
3
|
+
export declare const isValuesClause: (node: any) => node is import("sql-parser-cst").ValuesClause;
|
|
4
|
+
export declare const isFuncCall: (node: any) => node is import("sql-parser-cst").FuncCall;
|
|
5
|
+
export declare const isFuncArgs: (node: any) => node is import("sql-parser-cst").FuncArgs;
|
|
6
|
+
export declare const isCreateTableStmt: (node: any) => node is import("sql-parser-cst").CreateTableStmt;
|
|
7
|
+
export declare const isKeyword: (node: any) => node is import("sql-parser-cst").Keyword<string>;
|
|
8
|
+
export declare const isEmpty: (node: any) => node is import("sql-parser-cst").Empty;
|
|
9
|
+
export declare const isJsonLiteral: (node: any) => node is import("sql-parser-cst").JsonLiteral;
|
|
10
|
+
export declare const isStringLiteral: (node: any) => node is import("sql-parser-cst").StringLiteral;
|
|
11
|
+
export declare const isArraySubscript: (node: any) => node is import("sql-parser-cst").ArraySubscript;
|
|
12
|
+
export declare const isAsClause: (node: any) => node is import("sql-parser-cst").AsClause<Node>;
|
|
13
|
+
export declare const isParenExpr: (node: any) => node is import("sql-parser-cst").ParenExpr<Node>;
|
|
14
|
+
export declare const isListExpr: (node: any) => node is import("sql-parser-cst").ListExpr<Node>;
|
|
15
|
+
export declare const isCreateFunctionStmt: (node: any) => node is import("sql-parser-cst").CreateFunctionStmt;
|
|
16
|
+
export declare const isLanguageClause: (node: any) => node is import("sql-parser-cst").LanguageClause;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ParserOptions, SupportOptions } from "prettier";
|
|
2
|
+
import { Node, ParserOptions as CstParserOptions } from "sql-parser-cst";
|
|
3
|
+
export interface SqlPluginOptions {
|
|
4
|
+
sqlKeywordCase: "preserve" | "upper" | "lower";
|
|
5
|
+
sqlParamTypes: NonNullable<CstParserOptions["paramTypes"]>;
|
|
6
|
+
}
|
|
7
|
+
export type AllPrettierOptions<T = Node> = ParserOptions<T> & SqlPluginOptions;
|
|
8
|
+
export declare const options: SupportOptions;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Node } from "sql-parser-cst";
|
|
2
|
+
import { AstPath, Doc } from "prettier";
|
|
3
|
+
import { OldPrintFn } from "./PrintFn";
|
|
4
|
+
import { AllPrettierOptions } from "./options";
|
|
5
|
+
export declare function printSql(path: AstPath<Node>, options: AllPrettierOptions, oldPrint: OldPrintFn): Doc;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Doc, doc } from "prettier";
|
|
2
|
+
import { Node } from "sql-parser-cst";
|
|
3
|
+
export declare const line: doc.builders.Line, hardline: doc.builders.Concat, softline: doc.builders.Softline, indent: typeof doc.builders.indent, group: typeof doc.builders.group, lineSuffix: typeof doc.builders.lineSuffix, ifBreak: typeof doc.builders.ifBreak, breakParent: doc.builders.BreakParent;
|
|
4
|
+
export declare const stripTrailingHardline: typeof doc.utils.stripTrailingHardline;
|
|
5
|
+
/** Improved join() that also accepts a non-array docs parameter */
|
|
6
|
+
export declare const join: (sep: Doc, docs: Doc) => Doc;
|
|
7
|
+
/** True when the Node contains a newline in original source code */
|
|
8
|
+
export declare const containsNewline: (node: Node, opts: {
|
|
9
|
+
originalText: string;
|
|
10
|
+
}) => boolean;
|
|
11
|
+
export declare const hasEmptyLineBetweenNodes: (node1: Node, node2: Node, opts: {
|
|
12
|
+
originalText: string;
|
|
13
|
+
}) => boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Program, Whitespace } from "sql-parser-cst";
|
|
2
|
+
/**
|
|
3
|
+
* Gathers comments from .leading and .trailing fields of all nodes
|
|
4
|
+
* into a single .comments field in root Program node.
|
|
5
|
+
*
|
|
6
|
+
* Deletes the .leading and .trailing fields of all nodes.
|
|
7
|
+
*/
|
|
8
|
+
export declare const moveCommentsToRoot: (cst: Program) => Program & {
|
|
9
|
+
comments: Whitespace[];
|
|
10
|
+
};
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Node } from "sql-parser-cst";
|
|
2
|
+
export declare const isDefined: <T>(value: T | undefined) => value is T;
|
|
3
|
+
export declare const isString: (value: any) => value is string;
|
|
4
|
+
export declare const isObject: (x: any) => x is Record<string, any>;
|
|
5
|
+
export declare const isArray: (x: any) => x is any[];
|
|
6
|
+
export declare const isEmptyArray: (x: any) => x is [];
|
|
7
|
+
export declare const isNode: (value: any) => value is Node;
|
|
8
|
+
export declare const arrayWrap: <T>(x: T | T[]) => T[];
|
|
9
|
+
export declare const last: <T>(arr: T[]) => T;
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prettier-plugin-sql-cst",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Prettier plugin for SQL",
|
|
5
5
|
"author": "Rene Saarsoo <nene@triin.net>",
|
|
6
6
|
"license": "GPL-3.0-or-later",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "https://github.com/nene/prettier-plugin-sql-cst"
|