@flowblade/sql-tag-format 0.0.6 → 0.0.7
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var sqlFormatter=require('sql-formatter');var
|
|
1
|
+
'use strict';var sqlFormatter=require('sql-formatter');var o=class{constructor(r,t){this.dialect=r;this.formatterOptions=t;}formatOrNull=(r,t)=>{try{return this.formatOrThrow(r,t)}catch{return null}};formatOrThrow=(r,t)=>{let a=t?.options??this.formatterOptions;return sqlFormatter.format(r.sql,{language:t?.dialect??this.dialect,...a})}};exports.SqlFormatter=o;//# sourceMappingURL=index.cjs.map
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sql-formatter.ts"],"names":["SqlFormatter","dialect","formatterOptions","
|
|
1
|
+
{"version":3,"sources":["../src/sql-formatter.ts"],"names":["SqlFormatter","dialect","formatterOptions","sql","params","options","sqlFormat"],"mappings":"uDAqBO,IAAMA,CAAN,CAAA,KAAmB,CAmCxB,WAAA,CACUC,CACAC,CAAAA,CAAAA,CACR,CAFQ,IAAA,CAAA,OAAA,CAAAD,CACA,CAAA,IAAA,CAAA,gBAAA,CAAAC,EACP,CAgBH,YAAe,CAAA,CACbC,CACAC,CAAAA,CAAAA,GACkB,CAClB,GAAI,CACF,OAAO,IAAK,CAAA,aAAA,CAAcD,CAAKC,CAAAA,CAAM,CACvC,CAAA,KAAQ,CACN,OAAO,IACT,CACF,CAqBA,CAAA,aAAA,CAAgB,CAACD,CAAAA,CAAsBC,CAAkC,GAAA,CACvE,IAAMC,CAAAA,CAAUD,CAAQ,EAAA,OAAA,EAAW,IAAK,CAAA,gBAAA,CACxC,OAAOE,mBAAAA,CAAUH,CAAI,CAAA,GAAA,CAAK,CACxB,QAAA,CAAUC,CAAQ,EAAA,OAAA,EAAW,IAAK,CAAA,OAAA,CAClC,GAAGC,CACL,CAAC,CACH,CACF","file":"index.cjs","sourcesContent":["import type { SqlTag } from '@flowblade/sql-tag';\nimport {\n format as sqlFormat,\n type FormatOptions,\n type SqlLanguage,\n} from 'sql-formatter';\n\nexport type SqlFormatterOptions = Omit<FormatOptions, 'indentStyle'>;\nexport type SqlFormatterDialect = SqlLanguage;\n\ntype FormatParams = {\n /**\n * If not provided will default to the dialect provided in the constructor\n */\n dialect?: SqlFormatterDialect;\n /**\n * If not provided will default to the formatter options provided in the constructor\n */\n options?: Partial<SqlFormatterOptions>;\n};\n\nexport class SqlFormatter {\n /**\n * SqlFormatter constructor\n *\n * @example\n * ```typescript\n * const sqlFormatter = new SqlFormatter('postgresql');\n *\n * // Alternatively, you can pass in options\n * // @see https://github.com/sql-formatter-org/sql-formatter/tree/master?tab=readme-ov-file#configuration-options\n *\n * const pgsqlFormatter = new SqlFormatter('postgresql', {\n * keywordCase: 'preserve',\n * identifierCase: 'preserve',\n * dataTypeCase: 'preserve',\n * functionCase: 'preserve',\n * logicalOperatorNewline: 'before',\n * expressionWidth: 50,\n * linesBetweenQueries: 1,\n * denseOperators: false,\n * newlineBeforeSemicolon: false,\n * useTabs: false,\n * tabWidth: 2,\n * });\n *\n * try {\n * const formatted = pgsqlFormatter.formatOrThrow(\n * 'SELECT * FROM table WHERE id = 1'\n * );\n * } catch (e) {\n * // Might throw something similar to: Parse error: Unexpected \"[col] from\" at line 1 column 8\n * console.log('Error:', e);\n * }\n * ```\n */\n constructor(\n private dialect: SqlFormatterDialect,\n private formatterOptions?: SqlFormatterOptions\n ) {}\n\n /**\n * Format sql to string or return null if sql cannot be parsed\n *\n * @example\n * ```typescript\n * const sqlFormatter = new SqlFormatter('postgresql');\n *\n * const formatted = sqlFormatter.formatOrNull(\n * 'SELECT * FROM table WHERE id = 1'\n * );\n * ```\n *\n * @return string if sql can be parsed, null otherwise\n */\n formatOrNull = (\n sql: SqlTag<unknown>,\n params?: FormatParams\n ): string | null => {\n try {\n return this.formatOrThrow(sql, params);\n } catch {\n return null;\n }\n };\n\n /**\n * Format sql to string or throw an error if sql cannot be parsed\n *\n * @example\n * ```typescript\n * const sqlFormatter = new SqlFormatter('postgresql');\n *\n * try {\n * const formatted = sqlFormatter.formatOrThrow(\n * 'SELECT * FROM table WHERE id = 1'\n * );\n * } catch (e) {\n * // Might throw something similat to: Parse error: Unexpected \"[col] from\" at line 1 column 8\n * console.log('Error:', e);\n * }\n * ```\n *\n * @throws Error is sql cannot be parsed\n */\n formatOrThrow = (sql: SqlTag<unknown>, params?: FormatParams): string => {\n const options = params?.options ?? this.formatterOptions;\n return sqlFormat(sql.sql, {\n language: params?.dialect ?? this.dialect,\n ...options,\n });\n };\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {format}from'sql-formatter';var
|
|
1
|
+
import {format}from'sql-formatter';var o=class{constructor(r,t){this.dialect=r;this.formatterOptions=t;}formatOrNull=(r,t)=>{try{return this.formatOrThrow(r,t)}catch{return null}};formatOrThrow=(r,t)=>{let a=t?.options??this.formatterOptions;return format(r.sql,{language:t?.dialect??this.dialect,...a})}};export{o as SqlFormatter};//# sourceMappingURL=index.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sql-formatter.ts"],"names":["SqlFormatter","dialect","formatterOptions","
|
|
1
|
+
{"version":3,"sources":["../src/sql-formatter.ts"],"names":["SqlFormatter","dialect","formatterOptions","sql","params","options","sqlFormat"],"mappings":"mCAqBO,IAAMA,CAAN,CAAA,KAAmB,CAmCxB,WAAA,CACUC,CACAC,CAAAA,CAAAA,CACR,CAFQ,IAAA,CAAA,OAAA,CAAAD,CACA,CAAA,IAAA,CAAA,gBAAA,CAAAC,EACP,CAgBH,YAAe,CAAA,CACbC,CACAC,CAAAA,CAAAA,GACkB,CAClB,GAAI,CACF,OAAO,IAAK,CAAA,aAAA,CAAcD,CAAKC,CAAAA,CAAM,CACvC,CAAA,KAAQ,CACN,OAAO,IACT,CACF,CAqBA,CAAA,aAAA,CAAgB,CAACD,CAAAA,CAAsBC,CAAkC,GAAA,CACvE,IAAMC,CAAAA,CAAUD,CAAQ,EAAA,OAAA,EAAW,IAAK,CAAA,gBAAA,CACxC,OAAOE,MAAAA,CAAUH,CAAI,CAAA,GAAA,CAAK,CACxB,QAAA,CAAUC,CAAQ,EAAA,OAAA,EAAW,IAAK,CAAA,OAAA,CAClC,GAAGC,CACL,CAAC,CACH,CACF","file":"index.mjs","sourcesContent":["import type { SqlTag } from '@flowblade/sql-tag';\nimport {\n format as sqlFormat,\n type FormatOptions,\n type SqlLanguage,\n} from 'sql-formatter';\n\nexport type SqlFormatterOptions = Omit<FormatOptions, 'indentStyle'>;\nexport type SqlFormatterDialect = SqlLanguage;\n\ntype FormatParams = {\n /**\n * If not provided will default to the dialect provided in the constructor\n */\n dialect?: SqlFormatterDialect;\n /**\n * If not provided will default to the formatter options provided in the constructor\n */\n options?: Partial<SqlFormatterOptions>;\n};\n\nexport class SqlFormatter {\n /**\n * SqlFormatter constructor\n *\n * @example\n * ```typescript\n * const sqlFormatter = new SqlFormatter('postgresql');\n *\n * // Alternatively, you can pass in options\n * // @see https://github.com/sql-formatter-org/sql-formatter/tree/master?tab=readme-ov-file#configuration-options\n *\n * const pgsqlFormatter = new SqlFormatter('postgresql', {\n * keywordCase: 'preserve',\n * identifierCase: 'preserve',\n * dataTypeCase: 'preserve',\n * functionCase: 'preserve',\n * logicalOperatorNewline: 'before',\n * expressionWidth: 50,\n * linesBetweenQueries: 1,\n * denseOperators: false,\n * newlineBeforeSemicolon: false,\n * useTabs: false,\n * tabWidth: 2,\n * });\n *\n * try {\n * const formatted = pgsqlFormatter.formatOrThrow(\n * 'SELECT * FROM table WHERE id = 1'\n * );\n * } catch (e) {\n * // Might throw something similar to: Parse error: Unexpected \"[col] from\" at line 1 column 8\n * console.log('Error:', e);\n * }\n * ```\n */\n constructor(\n private dialect: SqlFormatterDialect,\n private formatterOptions?: SqlFormatterOptions\n ) {}\n\n /**\n * Format sql to string or return null if sql cannot be parsed\n *\n * @example\n * ```typescript\n * const sqlFormatter = new SqlFormatter('postgresql');\n *\n * const formatted = sqlFormatter.formatOrNull(\n * 'SELECT * FROM table WHERE id = 1'\n * );\n * ```\n *\n * @return string if sql can be parsed, null otherwise\n */\n formatOrNull = (\n sql: SqlTag<unknown>,\n params?: FormatParams\n ): string | null => {\n try {\n return this.formatOrThrow(sql, params);\n } catch {\n return null;\n }\n };\n\n /**\n * Format sql to string or throw an error if sql cannot be parsed\n *\n * @example\n * ```typescript\n * const sqlFormatter = new SqlFormatter('postgresql');\n *\n * try {\n * const formatted = sqlFormatter.formatOrThrow(\n * 'SELECT * FROM table WHERE id = 1'\n * );\n * } catch (e) {\n * // Might throw something similat to: Parse error: Unexpected \"[col] from\" at line 1 column 8\n * console.log('Error:', e);\n * }\n * ```\n *\n * @throws Error is sql cannot be parsed\n */\n formatOrThrow = (sql: SqlTag<unknown>, params?: FormatParams): string => {\n const options = params?.options ?? this.formatterOptions;\n return sqlFormat(sql.sql, {\n language: params?.dialect ?? this.dialect,\n ...options,\n });\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowblade/sql-tag-format",
|
|
3
3
|
"description": "Formatter utilities for @flowblade/sql-tag",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.7",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Vanvelthem Sébastien",
|
|
@@ -64,20 +64,20 @@
|
|
|
64
64
|
"ci-coverage-upload": "../../.github/scripts/download/codecov -F flowblade-sql-tag-format --dir ./coverage"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"sql-formatter": "^15.4.
|
|
67
|
+
"sql-formatter": "^15.4.10"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@flowblade/sql-tag": "workspace:^"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@arethetypeswrong/cli": "0.17.3",
|
|
74
|
-
"@belgattitude/eslint-config-bases": "6.
|
|
74
|
+
"@belgattitude/eslint-config-bases": "6.20.0",
|
|
75
75
|
"@codspeed/vitest-plugin": "4.0.0",
|
|
76
76
|
"@edge-runtime/vm": "5.0.0",
|
|
77
77
|
"@size-limit/file": "11.1.6",
|
|
78
78
|
"@size-limit/webpack": "11.1.6",
|
|
79
|
-
"@vitest/coverage-istanbul": "
|
|
80
|
-
"@vitest/ui": "
|
|
79
|
+
"@vitest/coverage-istanbul": "3.0.4",
|
|
80
|
+
"@vitest/ui": "3.0.4",
|
|
81
81
|
"browserslist": "4.24.4",
|
|
82
82
|
"browserslist-to-esbuild": "2.1.1",
|
|
83
83
|
"cross-env": "7.0.3",
|
|
@@ -89,15 +89,15 @@
|
|
|
89
89
|
"prettier": "3.4.2",
|
|
90
90
|
"publint": "0.3.2",
|
|
91
91
|
"rimraf": "6.0.1",
|
|
92
|
-
"rollup": "4.
|
|
92
|
+
"rollup": "4.32.1",
|
|
93
93
|
"size-limit": "11.1.6",
|
|
94
|
-
"tsup": "8.3.
|
|
94
|
+
"tsup": "8.3.6",
|
|
95
95
|
"tsx": "4.19.2",
|
|
96
96
|
"typedoc": "0.27.6",
|
|
97
97
|
"typedoc-plugin-markdown": "4.4.1",
|
|
98
98
|
"typescript": "5.7.3",
|
|
99
99
|
"vite-tsconfig-paths": "5.1.4",
|
|
100
|
-
"vitest": "
|
|
100
|
+
"vitest": "3.0.4",
|
|
101
101
|
"webpack": "5.97.1"
|
|
102
102
|
},
|
|
103
103
|
"engines": {
|