pgsql-deparser 13.16.0 → 13.19.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.
Files changed (50) hide show
  1. package/README.md +94 -45
  2. package/deparser/deparser.d.ts +302 -0
  3. package/deparser/deparser.js +10451 -0
  4. package/deparser/index.d.ts +9 -0
  5. package/deparser/index.js +17 -0
  6. package/deparser/utils/list-utils.d.ts +8 -0
  7. package/deparser/utils/list-utils.js +30 -0
  8. package/deparser/utils/quote-utils.d.ts +24 -0
  9. package/deparser/utils/quote-utils.js +89 -0
  10. package/deparser/utils/sql-formatter.d.ts +16 -0
  11. package/deparser/utils/sql-formatter.js +40 -0
  12. package/deparser/visitors/base.d.ts +68 -0
  13. package/deparser/visitors/base.js +122 -0
  14. package/esm/deparser/deparser.js +10447 -0
  15. package/esm/deparser/index.js +13 -0
  16. package/esm/deparser/utils/list-utils.js +26 -0
  17. package/esm/deparser/utils/quote-utils.js +85 -0
  18. package/esm/deparser/utils/sql-formatter.js +36 -0
  19. package/esm/deparser/visitors/base.js +117 -0
  20. package/esm/index.js +15 -0
  21. package/esm/v13-to-v14.js +2750 -0
  22. package/esm/v13-to-v17-direct.js +78 -0
  23. package/esm/v14-to-v15.js +1223 -0
  24. package/esm/v15-to-v16.js +2940 -0
  25. package/esm/v16-to-v17.js +1488 -0
  26. package/index.d.ts +9 -0
  27. package/index.js +19 -0
  28. package/package.json +26 -75
  29. package/v13-to-v14.d.ts +253 -0
  30. package/v13-to-v14.js +2754 -0
  31. package/v13-to-v17-direct.d.ts +24 -0
  32. package/v13-to-v17-direct.js +82 -0
  33. package/v14-to-v15.d.ts +616 -0
  34. package/v14-to-v15.js +1227 -0
  35. package/v15-to-v16.d.ts +633 -0
  36. package/v15-to-v16.js +2944 -0
  37. package/v16-to-v17.d.ts +638 -0
  38. package/v16-to-v17.js +1492 -0
  39. package/main/deparser.js +0 -3495
  40. package/main/index.js +0 -10
  41. package/main/utils/index.js +0 -97
  42. package/module/deparser.js +0 -3492
  43. package/module/index.js +0 -3
  44. package/module/utils/index.js +0 -90
  45. package/src/deparser.ts +0 -4234
  46. package/src/index.ts +0 -3
  47. package/src/utils/index.ts +0 -92
  48. package/types/deparser.d.ts +0 -119
  49. package/types/index.d.ts +0 -3
  50. package/types/utils/index.d.ts +0 -4
package/main/index.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Deparser = exports.deparse = void 0;
7
- const deparser_1 = __importDefault(require("./deparser"));
8
- exports.Deparser = deparser_1.default;
9
- const deparse = deparser_1.default.deparse;
10
- exports.deparse = deparse;
@@ -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;