pgsql-deparser 13.6.2 → 13.7.0

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/module/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import Deparser from './deparser';
2
2
  const deparse = Deparser.deparse;
3
- export { deparse, Deparser };
3
+ export { deparse, Deparser };
@@ -1,90 +1,90 @@
1
1
  /* eslint-disable no-restricted-syntax */
2
- export const cleanLines = sql => {
3
- return sql.split('\n').map(l => l.trim()).filter(a => a).join('\n');
2
+ export const cleanLines = (sql) => {
3
+ return sql
4
+ .split('\n')
5
+ .map((l) => l.trim())
6
+ .filter((a) => a)
7
+ .join('\n');
4
8
  };
5
9
  export const transform = (obj, props) => {
6
- let copy = null; // Handle the 3 simple types, and null or undefined
7
-
8
- if (obj == null || typeof obj !== 'object') {
9
- return obj;
10
- } // Handle Date
11
-
12
-
13
- if (obj instanceof Date) {
14
- copy = new Date();
15
- copy.setTime(obj.getTime());
16
- return copy;
17
- } // Handle Array
18
-
19
-
20
- if (obj instanceof Array) {
21
- copy = [];
22
-
23
- for (let i = 0, len = obj.length; i < len; i++) {
24
- copy[i] = transform(obj[i], 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;
25
14
  }
26
-
27
- return copy;
28
- } // Handle Object
29
-
30
-
31
- if (obj instanceof Object || typeof obj === 'object') {
32
- copy = {};
33
-
34
- for (const attr in obj) {
35
- if (obj.hasOwnProperty(attr)) {
36
- if (props.hasOwnProperty(attr)) {
37
- if (typeof props[attr] === 'function') {
38
- copy[attr] = props[attr](obj[attr]);
39
- } else if (props[attr].hasOwnProperty(obj[attr])) {
40
- copy[attr] = props[attr][obj[attr]];
41
- } else {
42
- copy[attr] = transform(obj[attr], props);
43
- }
44
- } else {
45
- copy[attr] = transform(obj[attr], props);
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
+ }
46
52
  }
47
- } else {
48
- copy[attr] = transform(obj[attr], props);
49
- }
53
+ return copy;
50
54
  }
51
-
52
- return copy;
53
- }
54
-
55
- throw new Error("Unable to copy obj! Its type isn't supported.");
55
+ throw new Error("Unable to copy obj! Its type isn't supported.");
56
56
  };
57
-
58
57
  const noop = () => undefined;
59
-
60
- export const cleanTree = tree => {
61
- return transform(tree, {
62
- stmt_len: noop,
63
- stmt_location: noop,
64
- location: noop,
65
- DefElem: obj => {
66
- if (obj.defname === 'as') {
67
- if (Array.isArray(obj.arg) && obj.arg.length) {
68
- // function
69
- obj.arg[0].String.str = obj.arg[0].String.str.trim();
70
- } else if (obj.arg.List && obj.arg.List.items) {
71
- // function
72
- obj.arg.List.items[0].String.str = obj.arg.List.items[0].String.str.trim();
73
- } else {
74
- // do stmt
75
- obj.arg.String.str = obj.arg.String.str.trim();
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
+ }
76
82
  }
77
-
78
- return cleanTree(obj);
79
- } else {
80
- return cleanTree(obj);
81
- }
82
- }
83
- });
83
+ });
84
+ };
85
+ export const cleanTreeWithStmt = (tree) => {
86
+ return transform(tree, {
87
+ stmt_location: noop,
88
+ location: noop
89
+ });
84
90
  };
85
- export const cleanTreeWithStmt = tree => {
86
- return transform(tree, {
87
- stmt_location: noop,
88
- location: noop
89
- });
90
- };
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "pgsql-deparser",
3
- "version": "13.6.2",
3
+ "version": "13.7.0",
4
4
  "description": "PostgreSQL AST Deparser",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/launchql/pgsql-parser",
7
7
  "license": "SEE LICENSE IN LICENSE",
8
8
  "main": "main/index.js",
9
9
  "module": "module/index.js",
10
+ "typings": "types/index.d.ts",
10
11
  "directories": {
11
12
  "lib": "src",
12
13
  "test": "__tests__"
13
14
  },
14
15
  "files": [
15
- "main",
16
- "module"
16
+ "types",
17
+ "module",
18
+ "src",
19
+ "main"
17
20
  ],
18
21
  "keywords": [
19
22
  "sql",
@@ -33,13 +36,14 @@
33
36
  "url": "https://github.com/launchql/pgsql-parser"
34
37
  },
35
38
  "scripts": {
36
- "build:main": "cross-env BABEL_ENV=production babel src --out-dir main --delete-dir-on-start",
37
- "build:module": "cross-env MODULE=true babel src --out-dir module --delete-dir-on-start",
39
+ "build:main": "yarn tsc -p tsconfig.json --outDir main --module commonjs",
40
+ "build:module": "yarn tsc -p tsconfig.json --outDir module --module es2022",
38
41
  "build": "npm run build:module && npm run build:main",
42
+ "buidl": "npm run build",
43
+ "buidl:clean": "npm run clean && npm run buidl",
39
44
  "prepare": "npm run build",
40
- "lint": "eslint src --fix",
41
- "dev": "cross-env NODE_ENV=development babel-node src/index",
42
- "watch": "cross-env NODE_ENV=development babel-watch src/index",
45
+ "lint": "eslint .",
46
+ "format": "eslint . --fix",
43
47
  "test": "jest",
44
48
  "test:watch": "jest --watch",
45
49
  "test:debug": "node --inspect node_modules/.bin/jest --runInBand"
@@ -47,32 +51,39 @@
47
51
  "bugs": {
48
52
  "url": "https://github.com/launchql/pgsql-parser/issues"
49
53
  },
54
+ "jest": {
55
+ "preset": "ts-jest",
56
+ "testEnvironment": "node",
57
+ "transform": {
58
+ "^.+\\.ts?$": "ts-jest"
59
+ },
60
+ "transformIgnorePatterns": [
61
+ "<rootDir>/node_modules/"
62
+ ],
63
+ "testPathIgnorePatterns": [
64
+ "main/",
65
+ "module/",
66
+ "types/"
67
+ ]
68
+ },
50
69
  "devDependencies": {
51
- "@babel/cli": "7.11.6",
52
- "@babel/core": "7.11.6",
53
- "@babel/node": "^7.12.1",
54
- "@babel/plugin-proposal-class-properties": "7.10.4",
55
- "@babel/plugin-proposal-export-default-from": "7.10.4",
56
- "@babel/plugin-proposal-object-rest-spread": "7.11.0",
57
- "@babel/plugin-transform-runtime": "7.11.5",
58
- "@babel/preset-env": "7.11.5",
59
- "babel-core": "7.0.0-bridge.0",
60
- "babel-eslint": "10.1.0",
61
- "babel-watch": "^7.0.0",
62
- "cross-env": "^7.0.2",
63
- "eslint": "^6.8.0",
64
- "eslint-config-prettier": "^6.10.0",
65
- "eslint-plugin-prettier": "^3.1.2",
66
- "glob": "7.1.6",
67
- "jest": "^25.1.0",
68
- "pgsql-parser": "^13.7.2",
69
- "prettier": "^2.1.2",
70
- "regenerator-runtime": "^0.13.2"
70
+ "@types/jest": "^29.5.0",
71
+ "eslint": "8.38.0",
72
+ "eslint-config-prettier": "^8.8.0",
73
+ "eslint-plugin-prettier": "^4.0.0",
74
+ "esprima": "4.0.1",
75
+ "glob": "8.0.3",
76
+ "jest": "^29.7.0",
77
+ "pgsql-parser": "^13.8.0",
78
+ "prettier": "^2.8.7",
79
+ "rimraf": "5.0.5",
80
+ "ts-jest": "^29.1.0",
81
+ "ts-node": "10.9.2",
82
+ "typescript": "^5.0.4"
71
83
  },
72
84
  "dependencies": {
73
- "@babel/runtime": "^7.11.2",
74
85
  "dotty": "^0.1.0",
75
- "pgsql-enums": "^13.2.1"
86
+ "pgsql-enums": "^13.3.0"
76
87
  },
77
- "gitHead": "83258cc27286b55be6fa3834cbbe16414181bdbf"
88
+ "gitHead": "7d1df1770583c50d0fa68dd0cf90beedc9d46e40"
78
89
  }