@flowblade/sql-tag-format 0.0.8 → 0.0.10
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.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +22 -19
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var sqlFormatter=require('sql-formatter');var o=class{constructor(r
|
|
1
|
+
'use strict';var sqlFormatter=require('sql-formatter');var o=class{constructor(t,r){this.dialect=t;this.formatterOptions=r;}formatOrNull=(t,r)=>{try{return this.formatOrThrow(t,r)}catch{return null}};formatOrThrow=(t,r)=>{let a=r?.options??this.formatterOptions,e=typeof t=="string"?t:t.sql;return sqlFormatter.format(e,{language:r?.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","sql","params","options","sqlFormat"],"mappings":"uDAqBO,IAAMA,CAAN,CAAA,KAAmB,CAmCxB,WAAA,CACUC,CACAC,CAAAA,CAAAA,CACR,CAFQ,IAAA,CAAA,OAAA,CAAAD,
|
|
1
|
+
{"version":3,"sources":["../src/sql-formatter.ts"],"names":["SqlFormatter","dialect","formatterOptions","sql","params","options","sqlString","sqlFormat"],"mappings":"uDAqBO,IAAMA,CAAN,CAAA,KAAmB,CAmCxB,WAAA,CACUC,CACAC,CAAAA,CAAAA,CACR,CAFQ,IAAA,CAAA,OAAA,CAAAD,EACA,IAAAC,CAAAA,gBAAAA,CAAAA,EACP,CAgBH,YAAA,CAAe,CACbC,CAAAA,CACAC,CACkB,GAAA,CAClB,GAAI,CACF,OAAO,IAAK,CAAA,aAAA,CAAcD,CAAKC,CAAAA,CAAM,CACvC,CAAA,KAAQ,CACN,OAAO,IACT,CACF,CAAA,CAqBA,aAAgB,CAAA,CACdD,CACAC,CAAAA,CAAAA,GACW,CACX,IAAMC,CAAUD,CAAAA,CAAAA,EAAQ,OAAW,EAAA,IAAA,CAAK,gBAClCE,CAAAA,CAAAA,CAAY,OAAOH,CAAQ,EAAA,QAAA,CAAWA,CAAMA,CAAAA,CAAAA,CAAI,GACtD,CAAA,OAAOI,mBAAUD,CAAAA,CAAAA,CAAW,CAC1B,QAAUF,CAAAA,CAAAA,EAAQ,OAAW,EAAA,IAAA,CAAK,OAClC,CAAA,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> | string,\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 = (\n sql: SqlTag<unknown> | string,\n params?: FormatParams\n ): string => {\n const options = params?.options ?? this.formatterOptions;\n const sqlString = typeof sql === 'string' ? sql : sql.sql;\n return sqlFormat(sqlString, {\n language: params?.dialect ?? this.dialect,\n ...options,\n });\n };\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SqlTag } from '@flowblade/sql-tag';
|
|
2
|
-
import {
|
|
2
|
+
import { SqlLanguage, FormatOptions } from 'sql-formatter';
|
|
3
3
|
|
|
4
4
|
type SqlFormatterOptions = Omit<FormatOptions, 'indentStyle'>;
|
|
5
5
|
type SqlFormatterDialect = SqlLanguage;
|
|
@@ -65,7 +65,7 @@ declare class SqlFormatter {
|
|
|
65
65
|
*
|
|
66
66
|
* @return string if sql can be parsed, null otherwise
|
|
67
67
|
*/
|
|
68
|
-
formatOrNull: (sql: SqlTag<unknown
|
|
68
|
+
formatOrNull: (sql: SqlTag<unknown> | string, params?: FormatParams) => string | null;
|
|
69
69
|
/**
|
|
70
70
|
* Format sql to string or throw an error if sql cannot be parsed
|
|
71
71
|
*
|
|
@@ -85,7 +85,7 @@ declare class SqlFormatter {
|
|
|
85
85
|
*
|
|
86
86
|
* @throws Error is sql cannot be parsed
|
|
87
87
|
*/
|
|
88
|
-
formatOrThrow: (sql: SqlTag<unknown
|
|
88
|
+
formatOrThrow: (sql: SqlTag<unknown> | string, params?: FormatParams) => string;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export { SqlFormatter, type SqlFormatterDialect, type SqlFormatterOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SqlTag } from '@flowblade/sql-tag';
|
|
2
|
-
import {
|
|
2
|
+
import { SqlLanguage, FormatOptions } from 'sql-formatter';
|
|
3
3
|
|
|
4
4
|
type SqlFormatterOptions = Omit<FormatOptions, 'indentStyle'>;
|
|
5
5
|
type SqlFormatterDialect = SqlLanguage;
|
|
@@ -65,7 +65,7 @@ declare class SqlFormatter {
|
|
|
65
65
|
*
|
|
66
66
|
* @return string if sql can be parsed, null otherwise
|
|
67
67
|
*/
|
|
68
|
-
formatOrNull: (sql: SqlTag<unknown
|
|
68
|
+
formatOrNull: (sql: SqlTag<unknown> | string, params?: FormatParams) => string | null;
|
|
69
69
|
/**
|
|
70
70
|
* Format sql to string or throw an error if sql cannot be parsed
|
|
71
71
|
*
|
|
@@ -85,7 +85,7 @@ declare class SqlFormatter {
|
|
|
85
85
|
*
|
|
86
86
|
* @throws Error is sql cannot be parsed
|
|
87
87
|
*/
|
|
88
|
-
formatOrThrow: (sql: SqlTag<unknown
|
|
88
|
+
formatOrThrow: (sql: SqlTag<unknown> | string, params?: FormatParams) => string;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
export { SqlFormatter, type SqlFormatterDialect, type SqlFormatterOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {format}from'sql-formatter';var o=class{constructor(r
|
|
1
|
+
import {format}from'sql-formatter';var o=class{constructor(t,r){this.dialect=t;this.formatterOptions=r;}formatOrNull=(t,r)=>{try{return this.formatOrThrow(t,r)}catch{return null}};formatOrThrow=(t,r)=>{let a=r?.options??this.formatterOptions,e=typeof t=="string"?t:t.sql;return format(e,{language:r?.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","sql","params","options","sqlFormat"],"mappings":"mCAqBO,IAAMA,CAAN,CAAA,KAAmB,CAmCxB,WAAA,CACUC,CACAC,CAAAA,CAAAA,CACR,CAFQ,IAAA,CAAA,OAAA,CAAAD,
|
|
1
|
+
{"version":3,"sources":["../src/sql-formatter.ts"],"names":["SqlFormatter","dialect","formatterOptions","sql","params","options","sqlString","sqlFormat"],"mappings":"mCAqBO,IAAMA,CAAN,CAAA,KAAmB,CAmCxB,WAAA,CACUC,CACAC,CAAAA,CAAAA,CACR,CAFQ,IAAA,CAAA,OAAA,CAAAD,EACA,IAAAC,CAAAA,gBAAAA,CAAAA,EACP,CAgBH,YAAA,CAAe,CACbC,CAAAA,CACAC,CACkB,GAAA,CAClB,GAAI,CACF,OAAO,IAAK,CAAA,aAAA,CAAcD,CAAKC,CAAAA,CAAM,CACvC,CAAA,KAAQ,CACN,OAAO,IACT,CACF,CAAA,CAqBA,aAAgB,CAAA,CACdD,CACAC,CAAAA,CAAAA,GACW,CACX,IAAMC,CAAUD,CAAAA,CAAAA,EAAQ,OAAW,EAAA,IAAA,CAAK,gBAClCE,CAAAA,CAAAA,CAAY,OAAOH,CAAQ,EAAA,QAAA,CAAWA,CAAMA,CAAAA,CAAAA,CAAI,GACtD,CAAA,OAAOI,MAAUD,CAAAA,CAAAA,CAAW,CAC1B,QAAUF,CAAAA,CAAAA,EAAQ,OAAW,EAAA,IAAA,CAAK,OAClC,CAAA,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> | string,\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 = (\n sql: SqlTag<unknown> | string,\n params?: FormatParams\n ): string => {\n const options = params?.options ?? this.formatterOptions;\n const sqlString = typeof sql === 'string' ? sql : sql.sql;\n return sqlFormat(sqlString, {\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.10",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Vanvelthem Sébastien",
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"main": "./dist/index.cjs",
|
|
20
20
|
"module": "./dist/index.mjs",
|
|
21
21
|
"types": "./dist/index.d.cts",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"directory": "_release/package"
|
|
24
|
+
},
|
|
22
25
|
"exports": {
|
|
23
26
|
".": {
|
|
24
27
|
"import": {
|
|
@@ -38,7 +41,7 @@
|
|
|
38
41
|
"scripts": {
|
|
39
42
|
"?build-release": "When https://github.com/atlassian/changesets/issues/432 has a solution we can remove this trick",
|
|
40
43
|
"build": "run clean && yarn run tsup",
|
|
41
|
-
"build-release": "
|
|
44
|
+
"build-release": "yarn build && rimraf ./_release && yarn pack && mkdir ./_release && tar zxvf ./package.tgz --directory ./_release && rm ./package.tgz",
|
|
42
45
|
"bench-disabled": "vitest bench --run",
|
|
43
46
|
"bench-codspeed-disabled": "cross-env CODSPEED=1 vitest bench --run",
|
|
44
47
|
"bench-watch-disabled": "vitest bench",
|
|
@@ -67,40 +70,40 @@
|
|
|
67
70
|
"sql-formatter": "^15.4.10"
|
|
68
71
|
},
|
|
69
72
|
"peerDependencies": {
|
|
70
|
-
"@flowblade/sql-tag": "
|
|
73
|
+
"@flowblade/sql-tag": "^0.1.10"
|
|
71
74
|
},
|
|
72
75
|
"devDependencies": {
|
|
73
76
|
"@arethetypeswrong/cli": "0.17.3",
|
|
74
|
-
"@belgattitude/eslint-config-bases": "6.
|
|
77
|
+
"@belgattitude/eslint-config-bases": "6.24.0",
|
|
75
78
|
"@codspeed/vitest-plugin": "4.0.0",
|
|
76
79
|
"@edge-runtime/vm": "5.0.0",
|
|
77
|
-
"@size-limit/file": "11.
|
|
78
|
-
"@size-limit/webpack": "11.
|
|
79
|
-
"@vitest/coverage-istanbul": "3.0.
|
|
80
|
-
"@vitest/ui": "3.0.
|
|
80
|
+
"@size-limit/file": "11.2.0",
|
|
81
|
+
"@size-limit/webpack": "11.2.0",
|
|
82
|
+
"@vitest/coverage-istanbul": "3.0.6",
|
|
83
|
+
"@vitest/ui": "3.0.6",
|
|
81
84
|
"browserslist": "4.24.4",
|
|
82
85
|
"browserslist-to-esbuild": "2.1.1",
|
|
83
86
|
"cross-env": "7.0.3",
|
|
84
87
|
"es-check": "8.0.1",
|
|
85
|
-
"esbuild": "0.
|
|
88
|
+
"esbuild": "0.25.0",
|
|
86
89
|
"eslint": "8.57.1",
|
|
87
90
|
"execa": "9.5.2",
|
|
88
91
|
"npm-run-all2": "7.0.2",
|
|
89
|
-
"prettier": "3.
|
|
90
|
-
"publint": "0.3.
|
|
92
|
+
"prettier": "3.5.1",
|
|
93
|
+
"publint": "0.3.5",
|
|
91
94
|
"rimraf": "6.0.1",
|
|
92
|
-
"rollup": "4.
|
|
93
|
-
"size-limit": "11.
|
|
95
|
+
"rollup": "4.34.8",
|
|
96
|
+
"size-limit": "11.2.0",
|
|
94
97
|
"tsup": "8.3.6",
|
|
95
|
-
"tsx": "4.19.
|
|
96
|
-
"typedoc": "0.27.
|
|
97
|
-
"typedoc-plugin-markdown": "4.4.
|
|
98
|
+
"tsx": "4.19.3",
|
|
99
|
+
"typedoc": "0.27.7",
|
|
100
|
+
"typedoc-plugin-markdown": "4.4.2",
|
|
98
101
|
"typescript": "5.7.3",
|
|
99
102
|
"vite-tsconfig-paths": "5.1.4",
|
|
100
|
-
"vitest": "3.0.
|
|
101
|
-
"webpack": "5.
|
|
103
|
+
"vitest": "3.0.6",
|
|
104
|
+
"webpack": "5.98.0"
|
|
102
105
|
},
|
|
103
106
|
"engines": {
|
|
104
107
|
"node": ">=18.17.0"
|
|
105
108
|
}
|
|
106
|
-
}
|
|
109
|
+
}
|