pgsql-parser 17.7.4 → 17.7.6

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/esm/index.js CHANGED
@@ -1 +1,2 @@
1
1
  export { parse as parse, parseSync as parseSync, loadModule as loadModule } from 'libpg-query';
2
+ export { deparse, deparseSync } from 'pgsql-deparser';
package/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { parse as parse, parseSync as parseSync, loadModule as loadModule } from 'libpg-query';
2
+ export { deparse, deparseSync } from 'pgsql-deparser';
package/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.loadModule = exports.parseSync = exports.parse = void 0;
3
+ exports.deparseSync = exports.deparse = exports.loadModule = exports.parseSync = exports.parse = void 0;
4
4
  var libpg_query_1 = require("libpg-query");
5
5
  Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return libpg_query_1.parse; } });
6
6
  Object.defineProperty(exports, "parseSync", { enumerable: true, get: function () { return libpg_query_1.parseSync; } });
7
7
  Object.defineProperty(exports, "loadModule", { enumerable: true, get: function () { return libpg_query_1.loadModule; } });
8
+ var pgsql_deparser_1 = require("pgsql-deparser");
9
+ Object.defineProperty(exports, "deparse", { enumerable: true, get: function () { return pgsql_deparser_1.deparse; } });
10
+ Object.defineProperty(exports, "deparseSync", { enumerable: true, get: function () { return pgsql_deparser_1.deparseSync; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pgsql-parser",
3
- "version": "17.7.4",
3
+ "version": "17.7.6",
4
4
  "author": "Dan Lynch <pyramation@gmail.com>",
5
5
  "description": "The real PostgreSQL query parser",
6
6
  "main": "index.js",
@@ -28,6 +28,7 @@
28
28
  "lint": "eslint . --fix",
29
29
  "test": "jest",
30
30
  "test:watch": "jest --watch",
31
+ "prepare-versions": "ts-node scripts/prepare-versions.ts",
31
32
  "test:ast": "ts-node scripts/test-ast.ts"
32
33
  },
33
34
  "keywords": [
@@ -42,7 +43,7 @@
42
43
  "dependencies": {
43
44
  "@pgsql/types": "^17.6.1",
44
45
  "libpg-query": "17.5.5",
45
- "pgsql-deparser": "^17.8.3"
46
+ "pgsql-deparser": "^17.8.4"
46
47
  },
47
- "gitHead": "de35365d6a05e91c77c04dea213d5aadfa8b19a6"
48
+ "gitHead": "db3e424332bcb223c34a1caca3f37fb6fc9a1964"
48
49
  }
@@ -1,90 +0,0 @@
1
- /* eslint-disable no-restricted-syntax */
2
- export const cleanLines = (sql) => {
3
- return sql
4
- .split('\n')
5
- .map((l) => l.trim())
6
- .filter((a) => a)
7
- .join('\n');
8
- };
9
- export const transform = (obj, props) => {
10
- let copy = null;
11
- // Handle the 3 simple types, and null or undefined
12
- if (obj == null || typeof obj !== 'object') {
13
- return obj;
14
- }
15
- // Handle Date
16
- if (obj instanceof Date) {
17
- copy = new Date();
18
- copy.setTime(obj.getTime());
19
- return copy;
20
- }
21
- // Handle Array
22
- if (obj instanceof Array) {
23
- copy = [];
24
- for (let i = 0, len = obj.length; i < len; i++) {
25
- copy[i] = transform(obj[i], props);
26
- }
27
- return copy;
28
- }
29
- // Handle Object
30
- if (obj instanceof Object || typeof obj === 'object') {
31
- copy = {};
32
- for (const attr in obj) {
33
- if (obj.hasOwnProperty(attr)) {
34
- if (props.hasOwnProperty(attr)) {
35
- if (typeof props[attr] === 'function') {
36
- copy[attr] = props[attr](obj[attr]);
37
- }
38
- else if (props[attr].hasOwnProperty(obj[attr])) {
39
- copy[attr] = props[attr][obj[attr]];
40
- }
41
- else {
42
- copy[attr] = transform(obj[attr], props);
43
- }
44
- }
45
- else {
46
- copy[attr] = transform(obj[attr], props);
47
- }
48
- }
49
- else {
50
- copy[attr] = transform(obj[attr], props);
51
- }
52
- }
53
- return copy;
54
- }
55
- throw new Error("Unable to copy obj! Its type isn't supported.");
56
- };
57
- const noop = () => undefined;
58
- export const cleanTree = (tree) => {
59
- return transform(tree, {
60
- stmt_len: noop,
61
- stmt_location: noop,
62
- location: noop,
63
- DefElem: (obj) => {
64
- if (obj.defname === 'as') {
65
- if (Array.isArray(obj.arg) && obj.arg.length) {
66
- // function
67
- obj.arg[0].String.str = obj.arg[0].String.str.trim();
68
- }
69
- else if (obj.arg.List && obj.arg.List.items) {
70
- // function
71
- obj.arg.List.items[0].String.str = obj.arg.List.items[0].String.str.trim();
72
- }
73
- else {
74
- // do stmt
75
- obj.arg.String.str = obj.arg.String.str.trim();
76
- }
77
- return cleanTree(obj);
78
- }
79
- else {
80
- return cleanTree(obj);
81
- }
82
- }
83
- });
84
- };
85
- export const cleanTreeWithStmt = (tree) => {
86
- return transform(tree, {
87
- stmt_location: noop,
88
- location: noop
89
- });
90
- };
package/utils/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export declare const cleanLines: (sql: string) => string;
2
- export declare const transform: (obj: any, props: any) => any;
3
- export declare const cleanTree: (tree: any) => any;
4
- export declare const cleanTreeWithStmt: (tree: any) => any;
package/utils/index.js DELETED
@@ -1,97 +0,0 @@
1
- "use strict";
2
- /* eslint-disable no-restricted-syntax */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.cleanTreeWithStmt = exports.cleanTree = exports.transform = exports.cleanLines = void 0;
5
- const cleanLines = (sql) => {
6
- return sql
7
- .split('\n')
8
- .map((l) => l.trim())
9
- .filter((a) => a)
10
- .join('\n');
11
- };
12
- exports.cleanLines = cleanLines;
13
- const transform = (obj, props) => {
14
- let copy = null;
15
- // Handle the 3 simple types, and null or undefined
16
- if (obj == null || typeof obj !== 'object') {
17
- return obj;
18
- }
19
- // Handle Date
20
- if (obj instanceof Date) {
21
- copy = new Date();
22
- copy.setTime(obj.getTime());
23
- return copy;
24
- }
25
- // Handle Array
26
- if (obj instanceof Array) {
27
- copy = [];
28
- for (let i = 0, len = obj.length; i < len; i++) {
29
- copy[i] = (0, exports.transform)(obj[i], props);
30
- }
31
- return copy;
32
- }
33
- // Handle Object
34
- if (obj instanceof Object || typeof obj === 'object') {
35
- copy = {};
36
- for (const attr in obj) {
37
- if (obj.hasOwnProperty(attr)) {
38
- if (props.hasOwnProperty(attr)) {
39
- if (typeof props[attr] === 'function') {
40
- copy[attr] = props[attr](obj[attr]);
41
- }
42
- else if (props[attr].hasOwnProperty(obj[attr])) {
43
- copy[attr] = props[attr][obj[attr]];
44
- }
45
- else {
46
- copy[attr] = (0, exports.transform)(obj[attr], props);
47
- }
48
- }
49
- else {
50
- copy[attr] = (0, exports.transform)(obj[attr], props);
51
- }
52
- }
53
- else {
54
- copy[attr] = (0, exports.transform)(obj[attr], props);
55
- }
56
- }
57
- return copy;
58
- }
59
- throw new Error("Unable to copy obj! Its type isn't supported.");
60
- };
61
- exports.transform = transform;
62
- const noop = () => undefined;
63
- const cleanTree = (tree) => {
64
- return (0, exports.transform)(tree, {
65
- stmt_len: noop,
66
- stmt_location: noop,
67
- location: noop,
68
- DefElem: (obj) => {
69
- if (obj.defname === 'as') {
70
- if (Array.isArray(obj.arg) && obj.arg.length) {
71
- // function
72
- obj.arg[0].String.str = obj.arg[0].String.str.trim();
73
- }
74
- else if (obj.arg.List && obj.arg.List.items) {
75
- // function
76
- obj.arg.List.items[0].String.str = obj.arg.List.items[0].String.str.trim();
77
- }
78
- else {
79
- // do stmt
80
- obj.arg.String.str = obj.arg.String.str.trim();
81
- }
82
- return (0, exports.cleanTree)(obj);
83
- }
84
- else {
85
- return (0, exports.cleanTree)(obj);
86
- }
87
- }
88
- });
89
- };
90
- exports.cleanTree = cleanTree;
91
- const cleanTreeWithStmt = (tree) => {
92
- return (0, exports.transform)(tree, {
93
- stmt_location: noop,
94
- location: noop
95
- });
96
- };
97
- exports.cleanTreeWithStmt = cleanTreeWithStmt;