@flowblade/sql-tag-format 1.1.0 → 1.1.2

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 CHANGED
@@ -1,12 +1,16 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
1
2
  let sql_formatter = require("sql-formatter");
3
+ //#region \0@oxc-project+runtime@0.122.0/helpers/typeof.js
2
4
  function _typeof(o) {
3
5
  "@babel/helpers - typeof";
4
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
5
- return typeof o$1;
6
- } : function(o$1) {
7
- return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
6
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
7
+ return typeof o;
8
+ } : function(o) {
9
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
10
  }, _typeof(o);
9
11
  }
12
+ //#endregion
13
+ //#region \0@oxc-project+runtime@0.122.0/helpers/toPrimitive.js
10
14
  function toPrimitive(t, r) {
11
15
  if ("object" != _typeof(t) || !t) return t;
12
16
  var e = t[Symbol.toPrimitive];
@@ -17,10 +21,14 @@ function toPrimitive(t, r) {
17
21
  }
18
22
  return ("string" === r ? String : Number)(t);
19
23
  }
24
+ //#endregion
25
+ //#region \0@oxc-project+runtime@0.122.0/helpers/toPropertyKey.js
20
26
  function toPropertyKey(t) {
21
27
  var i = toPrimitive(t, "string");
22
28
  return "symbol" == _typeof(i) ? i : i + "";
23
29
  }
30
+ //#endregion
31
+ //#region \0@oxc-project+runtime@0.122.0/helpers/defineProperty.js
24
32
  function _defineProperty(e, r, t) {
25
33
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
26
34
  value: t,
@@ -29,43 +37,102 @@ function _defineProperty(e, r, t) {
29
37
  writable: !0
30
38
  }) : e[r] = t, e;
31
39
  }
32
- function ownKeys(e, r) {
33
- var t = Object.keys(e);
34
- if (Object.getOwnPropertySymbols) {
35
- var o = Object.getOwnPropertySymbols(e);
36
- r && (o = o.filter(function(r$1) {
37
- return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
38
- })), t.push.apply(t, o);
39
- }
40
- return t;
41
- }
42
- function _objectSpread2(e) {
43
- for (var r = 1; r < arguments.length; r++) {
44
- var t = null != arguments[r] ? arguments[r] : {};
45
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
46
- _defineProperty(e, r$1, t[r$1]);
47
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
48
- Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
49
- });
50
- }
51
- return e;
52
- }
40
+ //#endregion
41
+ //#region src/sql-formatter.ts
53
42
  var SqlFormatter = class {
43
+ /**
44
+ * SqlFormatter constructor
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * const sqlFormatter = new SqlFormatter('postgresql');
49
+ *
50
+ * // Alternatively, you can pass in options
51
+ * // @see https://github.com/sql-formatter-org/sql-formatter/tree/master?tab=readme-ov-file#configuration-options
52
+ *
53
+ * const pgsqlFormatter = new SqlFormatter('postgresql', {
54
+ * keywordCase: 'preserve',
55
+ * identifierCase: 'preserve',
56
+ * dataTypeCase: 'preserve',
57
+ * functionCase: 'preserve',
58
+ * logicalOperatorNewline: 'before',
59
+ * expressionWidth: 50,
60
+ * linesBetweenQueries: 1,
61
+ * denseOperators: false,
62
+ * newlineBeforeSemicolon: false,
63
+ * useTabs: false,
64
+ * tabWidth: 2,
65
+ * });
66
+ *
67
+ * try {
68
+ * const formatted = pgsqlFormatter.formatOrThrow(
69
+ * 'SELECT * FROM table WHERE id = 1'
70
+ * );
71
+ * } catch (e) {
72
+ * // Might throw something similar to: Parse error: Unexpected "[col] from" at line 1 column 8
73
+ * console.log('Error:', e);
74
+ * }
75
+ * ```
76
+ */
54
77
  constructor(dialect, formatterOptions) {
55
78
  this.dialect = dialect;
56
79
  this.formatterOptions = formatterOptions;
57
- _defineProperty(this, "formatOrNull", (sql, params) => {
58
- try {
59
- return this.formatOrThrow(sql, params);
60
- } catch (_unused) {
61
- return null;
80
+ _defineProperty(
81
+ this,
82
+ /**
83
+ * Format sql to string or return null if sql cannot be parsed
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const sqlFormatter = new SqlFormatter('postgresql');
88
+ *
89
+ * const formatted = sqlFormatter.formatOrNull(
90
+ * 'SELECT * FROM table WHERE id = 1'
91
+ * );
92
+ * ```
93
+ *
94
+ * @return string if sql can be parsed, null otherwise
95
+ */
96
+ "formatOrNull",
97
+ (sql, params) => {
98
+ try {
99
+ return this.formatOrThrow(sql, params);
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+ );
105
+ _defineProperty(
106
+ this,
107
+ /**
108
+ * Format sql to string or throw an error if sql cannot be parsed
109
+ *
110
+ * @example
111
+ * ```typescript
112
+ * const sqlFormatter = new SqlFormatter('postgresql');
113
+ *
114
+ * try {
115
+ * const formatted = sqlFormatter.formatOrThrow(
116
+ * 'SELECT * FROM table WHERE id = 1'
117
+ * );
118
+ * } catch (e) {
119
+ * // Might throw something similar to: Parse error: Unexpected "[col] from" at line 1 column 8
120
+ * console.log('Error:', e);
121
+ * }
122
+ * ```
123
+ *
124
+ * @throws Error is sql cannot be parsed
125
+ */
126
+ "formatOrThrow",
127
+ (sql, params) => {
128
+ const options = params?.options ?? this.formatterOptions;
129
+ return (0, sql_formatter.format)(typeof sql === "string" ? sql : sql.sql, {
130
+ language: params?.dialect ?? this.dialect,
131
+ ...options
132
+ });
62
133
  }
63
- });
64
- _defineProperty(this, "formatOrThrow", (sql, params) => {
65
- var _params$options, _params$dialect;
66
- const options = (_params$options = params === null || params === void 0 ? void 0 : params.options) !== null && _params$options !== void 0 ? _params$options : this.formatterOptions;
67
- return (0, sql_formatter.format)(typeof sql === "string" ? sql : sql.sql, _objectSpread2({ language: (_params$dialect = params === null || params === void 0 ? void 0 : params.dialect) !== null && _params$dialect !== void 0 ? _params$dialect : this.dialect }, options));
68
- });
134
+ );
69
135
  }
70
136
  };
137
+ //#endregion
71
138
  exports.SqlFormatter = SqlFormatter;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,6 @@
1
- import { Sql } from "sql-template-tag";
1
+ import { SqlTag } from "@flowblade/sql-tag";
2
2
  import { FormatOptions, SqlLanguage } from "sql-formatter";
3
3
 
4
- //#region ../sql-tag/src/types.d.ts
5
- type SqlTag<T> = Sql & {
6
- _columns: T;
7
- };
8
- //#endregion
9
4
  //#region src/sql-formatter.d.ts
10
5
  type SqlFormatterOptions = Omit<FormatOptions, 'indentStyle'>;
11
6
  type SqlFormatterDialect = SqlLanguage;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,6 @@
1
1
  import { FormatOptions, SqlLanguage } from "sql-formatter";
2
- import { Sql } from "sql-template-tag";
2
+ import { SqlTag } from "@flowblade/sql-tag";
3
3
 
4
- //#region ../sql-tag/src/types.d.ts
5
- type SqlTag<T> = Sql & {
6
- _columns: T;
7
- };
8
- //#endregion
9
4
  //#region src/sql-formatter.d.ts
10
5
  type SqlFormatterOptions = Omit<FormatOptions, 'indentStyle'>;
11
6
  type SqlFormatterDialect = SqlLanguage;
package/dist/index.js CHANGED
@@ -1,12 +1,15 @@
1
1
  import { format } from "sql-formatter";
2
+ //#region \0@oxc-project+runtime@0.122.0/helpers/typeof.js
2
3
  function _typeof(o) {
3
4
  "@babel/helpers - typeof";
4
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
5
- return typeof o$1;
6
- } : function(o$1) {
7
- return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
5
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
6
+ return typeof o;
7
+ } : function(o) {
8
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
8
9
  }, _typeof(o);
9
10
  }
11
+ //#endregion
12
+ //#region \0@oxc-project+runtime@0.122.0/helpers/toPrimitive.js
10
13
  function toPrimitive(t, r) {
11
14
  if ("object" != _typeof(t) || !t) return t;
12
15
  var e = t[Symbol.toPrimitive];
@@ -17,10 +20,14 @@ function toPrimitive(t, r) {
17
20
  }
18
21
  return ("string" === r ? String : Number)(t);
19
22
  }
23
+ //#endregion
24
+ //#region \0@oxc-project+runtime@0.122.0/helpers/toPropertyKey.js
20
25
  function toPropertyKey(t) {
21
26
  var i = toPrimitive(t, "string");
22
27
  return "symbol" == _typeof(i) ? i : i + "";
23
28
  }
29
+ //#endregion
30
+ //#region \0@oxc-project+runtime@0.122.0/helpers/defineProperty.js
24
31
  function _defineProperty(e, r, t) {
25
32
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
26
33
  value: t,
@@ -29,43 +36,102 @@ function _defineProperty(e, r, t) {
29
36
  writable: !0
30
37
  }) : e[r] = t, e;
31
38
  }
32
- function ownKeys(e, r) {
33
- var t = Object.keys(e);
34
- if (Object.getOwnPropertySymbols) {
35
- var o = Object.getOwnPropertySymbols(e);
36
- r && (o = o.filter(function(r$1) {
37
- return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
38
- })), t.push.apply(t, o);
39
- }
40
- return t;
41
- }
42
- function _objectSpread2(e) {
43
- for (var r = 1; r < arguments.length; r++) {
44
- var t = null != arguments[r] ? arguments[r] : {};
45
- r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
46
- _defineProperty(e, r$1, t[r$1]);
47
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
48
- Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
49
- });
50
- }
51
- return e;
52
- }
39
+ //#endregion
40
+ //#region src/sql-formatter.ts
53
41
  var SqlFormatter = class {
42
+ /**
43
+ * SqlFormatter constructor
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * const sqlFormatter = new SqlFormatter('postgresql');
48
+ *
49
+ * // Alternatively, you can pass in options
50
+ * // @see https://github.com/sql-formatter-org/sql-formatter/tree/master?tab=readme-ov-file#configuration-options
51
+ *
52
+ * const pgsqlFormatter = new SqlFormatter('postgresql', {
53
+ * keywordCase: 'preserve',
54
+ * identifierCase: 'preserve',
55
+ * dataTypeCase: 'preserve',
56
+ * functionCase: 'preserve',
57
+ * logicalOperatorNewline: 'before',
58
+ * expressionWidth: 50,
59
+ * linesBetweenQueries: 1,
60
+ * denseOperators: false,
61
+ * newlineBeforeSemicolon: false,
62
+ * useTabs: false,
63
+ * tabWidth: 2,
64
+ * });
65
+ *
66
+ * try {
67
+ * const formatted = pgsqlFormatter.formatOrThrow(
68
+ * 'SELECT * FROM table WHERE id = 1'
69
+ * );
70
+ * } catch (e) {
71
+ * // Might throw something similar to: Parse error: Unexpected "[col] from" at line 1 column 8
72
+ * console.log('Error:', e);
73
+ * }
74
+ * ```
75
+ */
54
76
  constructor(dialect, formatterOptions) {
55
77
  this.dialect = dialect;
56
78
  this.formatterOptions = formatterOptions;
57
- _defineProperty(this, "formatOrNull", (sql, params) => {
58
- try {
59
- return this.formatOrThrow(sql, params);
60
- } catch (_unused) {
61
- return null;
79
+ _defineProperty(
80
+ this,
81
+ /**
82
+ * Format sql to string or return null if sql cannot be parsed
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const sqlFormatter = new SqlFormatter('postgresql');
87
+ *
88
+ * const formatted = sqlFormatter.formatOrNull(
89
+ * 'SELECT * FROM table WHERE id = 1'
90
+ * );
91
+ * ```
92
+ *
93
+ * @return string if sql can be parsed, null otherwise
94
+ */
95
+ "formatOrNull",
96
+ (sql, params) => {
97
+ try {
98
+ return this.formatOrThrow(sql, params);
99
+ } catch {
100
+ return null;
101
+ }
102
+ }
103
+ );
104
+ _defineProperty(
105
+ this,
106
+ /**
107
+ * Format sql to string or throw an error if sql cannot be parsed
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * const sqlFormatter = new SqlFormatter('postgresql');
112
+ *
113
+ * try {
114
+ * const formatted = sqlFormatter.formatOrThrow(
115
+ * 'SELECT * FROM table WHERE id = 1'
116
+ * );
117
+ * } catch (e) {
118
+ * // Might throw something similar to: Parse error: Unexpected "[col] from" at line 1 column 8
119
+ * console.log('Error:', e);
120
+ * }
121
+ * ```
122
+ *
123
+ * @throws Error is sql cannot be parsed
124
+ */
125
+ "formatOrThrow",
126
+ (sql, params) => {
127
+ const options = params?.options ?? this.formatterOptions;
128
+ return format(typeof sql === "string" ? sql : sql.sql, {
129
+ language: params?.dialect ?? this.dialect,
130
+ ...options
131
+ });
62
132
  }
63
- });
64
- _defineProperty(this, "formatOrThrow", (sql, params) => {
65
- var _params$options, _params$dialect;
66
- const options = (_params$options = params === null || params === void 0 ? void 0 : params.options) !== null && _params$options !== void 0 ? _params$options : this.formatterOptions;
67
- return format(typeof sql === "string" ? sql : sql.sql, _objectSpread2({ language: (_params$dialect = params === null || params === void 0 ? void 0 : params.dialect) !== null && _params$dialect !== void 0 ? _params$dialect : this.dialect }, options));
68
- });
133
+ );
69
134
  }
70
135
  };
136
+ //#endregion
71
137
  export { SqlFormatter };
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": "1.1.0",
4
+ "version": "1.1.2",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "Vanvelthem Sébastien",
@@ -62,42 +62,42 @@
62
62
  "test-unit-coverage": "vitest run --coverage",
63
63
  "test-unit-edge": "vitest run --environment edge-runtime",
64
64
  "test-unit-watch": "vitest --ui --api 4515",
65
- "typecheck": "tsc --project tsconfig.json --noEmit",
66
- "typecheck-build": "tsc --project tsconfig.build.json --noEmit",
65
+ "typecheck": "tsgo --project tsconfig.json --noEmit",
66
+ "typecheck-build": "tsgo --project tsconfig.build.json --noEmit",
67
67
  "ci-coverage-upload": "../../.github/scripts/download/codecov -F flowblade-sql-tag-format --dir ./coverage"
68
68
  },
69
69
  "dependencies": {
70
- "@flowblade/sql-tag": "^0.3.0",
71
- "sql-formatter": "^15.7.0"
70
+ "@flowblade/sql-tag": "^0.3.2",
71
+ "sql-formatter": "^15.7.3"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@arethetypeswrong/cli": "0.18.2",
75
- "@belgattitude/eslint-config-bases": "8.9.0",
76
- "@codspeed/vitest-plugin": "5.0.1",
75
+ "@belgattitude/eslint-config-bases": "8.10.0",
76
+ "@codspeed/vitest-plugin": "5.2.0",
77
77
  "@edge-runtime/vm": "5.0.0",
78
- "@size-limit/esbuild": "12.0.0",
79
- "@size-limit/file": "12.0.0",
80
- "@vitest/coverage-istanbul": "4.0.17",
81
- "@vitest/ui": "4.0.17",
78
+ "@size-limit/esbuild": "12.0.1",
79
+ "@size-limit/file": "12.0.1",
80
+ "@typescript/native-preview": "7.0.0-dev.20260324.1",
81
+ "@vitest/coverage-istanbul": "4.1.2",
82
+ "@vitest/ui": "4.1.2",
82
83
  "browserslist": "4.28.1",
83
84
  "browserslist-to-esbuild": "2.1.1",
84
85
  "cross-env": "10.1.0",
85
- "es-check": "9.5.4",
86
- "esbuild": "0.27.2",
86
+ "es-check": "9.6.3",
87
+ "esbuild": "0.27.4",
87
88
  "eslint": "8.57.1",
88
89
  "execa": "9.6.1",
89
90
  "npm-run-all2": "8.0.4",
90
- "prettier": "3.8.0",
91
- "publint": "0.3.16",
92
- "rimraf": "6.1.2",
93
- "size-limit": "12.0.0",
94
- "tsdown": "0.19.0",
91
+ "prettier": "3.8.1",
92
+ "publint": "0.3.18",
93
+ "rimraf": "6.1.3",
94
+ "size-limit": "12.0.1",
95
+ "tsdown": "0.21.7",
95
96
  "tsx": "4.21.0",
96
- "typedoc": "0.28.16",
97
- "typedoc-plugin-markdown": "4.9.0",
98
- "typescript": "5.9.3",
99
- "vite-tsconfig-paths": "6.0.4",
100
- "vitest": "4.0.17"
97
+ "typedoc": "0.28.18",
98
+ "typedoc-plugin-markdown": "4.11.0",
99
+ "typescript": "6.0.2",
100
+ "vitest": "4.1.2"
101
101
  },
102
102
  "engines": {
103
103
  "node": ">=20.9.0"