pgsql-deparser 14.0.0 → 14.1.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 (54) hide show
  1. package/README.md +12 -6
  2. package/{dist/deparser → deparser}/deparser.d.ts +4 -3
  3. package/{dist/deparser → deparser}/deparser.js +883 -437
  4. package/{dist/deparser → deparser}/utils/sql-formatter.js +1 -1
  5. package/deparser/visitors/base.d.ts +68 -0
  6. package/deparser/visitors/base.js +122 -0
  7. package/{dist/esm → esm}/deparser/deparser.js +883 -437
  8. package/{dist/esm → esm}/deparser/utils/sql-formatter.js +1 -1
  9. package/esm/deparser/visitors/base.js +117 -0
  10. package/{dist/esm → esm}/v14-to-v15.js +3 -0
  11. package/{dist/esm → esm}/v15-to-v16.js +60 -1
  12. package/package.json +1 -2
  13. package/{dist/v14-to-v15.js → v14-to-v15.js} +3 -0
  14. package/{dist/v15-to-v16.d.ts → v15-to-v16.d.ts} +6 -0
  15. package/{dist/v15-to-v16.js → v15-to-v16.js} +60 -1
  16. package/dist/README.md +0 -160
  17. package/dist/deparser/visitors/base.d.ts +0 -21
  18. package/dist/deparser/visitors/base.js +0 -34
  19. package/dist/esm/deparser/visitors/base.js +0 -30
  20. package/dist/package.json +0 -42
  21. package/src/deparser/deparser.ts +0 -10026
  22. package/src/deparser/index.ts +0 -14
  23. package/src/deparser/utils/list-utils.ts +0 -27
  24. package/src/deparser/utils/quote-utils.ts +0 -86
  25. package/src/deparser/utils/sql-formatter.ts +0 -37
  26. package/src/deparser/visitors/base.ts +0 -40
  27. package/src/index.ts +0 -27
  28. package/src/v14-to-v15.ts +0 -1621
  29. package/src/v14-to-v17-direct.ts +0 -68
  30. package/src/v15-to-v16.ts +0 -3290
  31. package/src/v16-to-v17.ts +0 -1897
  32. package/tsconfig.esm.json +0 -8
  33. package/tsconfig.json +0 -26
  34. /package/{dist/LICENSE → LICENSE} +0 -0
  35. /package/{dist/deparser → deparser}/index.d.ts +0 -0
  36. /package/{dist/deparser → deparser}/index.js +0 -0
  37. /package/{dist/deparser → deparser}/utils/list-utils.d.ts +0 -0
  38. /package/{dist/deparser → deparser}/utils/list-utils.js +0 -0
  39. /package/{dist/deparser → deparser}/utils/quote-utils.d.ts +0 -0
  40. /package/{dist/deparser → deparser}/utils/quote-utils.js +0 -0
  41. /package/{dist/deparser → deparser}/utils/sql-formatter.d.ts +0 -0
  42. /package/{dist/esm → esm}/deparser/index.js +0 -0
  43. /package/{dist/esm → esm}/deparser/utils/list-utils.js +0 -0
  44. /package/{dist/esm → esm}/deparser/utils/quote-utils.js +0 -0
  45. /package/{dist/esm → esm}/index.js +0 -0
  46. /package/{dist/esm → esm}/v14-to-v17-direct.js +0 -0
  47. /package/{dist/esm → esm}/v16-to-v17.js +0 -0
  48. /package/{dist/index.d.ts → index.d.ts} +0 -0
  49. /package/{dist/index.js → index.js} +0 -0
  50. /package/{dist/v14-to-v15.d.ts → v14-to-v15.d.ts} +0 -0
  51. /package/{dist/v14-to-v17-direct.d.ts → v14-to-v17-direct.d.ts} +0 -0
  52. /package/{dist/v14-to-v17-direct.js → v14-to-v17-direct.js} +0 -0
  53. /package/{dist/v16-to-v17.d.ts → v16-to-v17.d.ts} +0 -0
  54. /package/{dist/v16-to-v17.js → v16-to-v17.js} +0 -0
@@ -9,7 +9,7 @@ class SqlFormatter {
9
9
  newlineChar;
10
10
  tabChar;
11
11
  prettyMode;
12
- constructor(newlineChar = '\n', tabChar = ' ', prettyMode = false) {
12
+ constructor(newlineChar = '\n', tabChar = ' ', prettyMode = true) {
13
13
  this.newlineChar = newlineChar;
14
14
  this.tabChar = tabChar;
15
15
  this.prettyMode = prettyMode;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Auto-generated file with types stripped for better tree-shaking
3
+ * DO NOT EDIT - Generated by strip-deparser-types.ts
4
+ */
5
+ import { SqlFormatter } from '../utils/sql-formatter';
6
+ export interface DeparserContextOptions {
7
+ isStringLiteral?: boolean;
8
+ parentNodeTypes?: string[];
9
+ indentLevel?: number;
10
+ prettyMode?: boolean;
11
+ formatter?: SqlFormatter;
12
+ select?: boolean;
13
+ from?: boolean;
14
+ group?: boolean;
15
+ sort?: boolean;
16
+ insertColumns?: boolean;
17
+ update?: boolean;
18
+ bool?: boolean;
19
+ isColumnConstraint?: boolean;
20
+ isDomainConstraint?: boolean;
21
+ alterColumnOptions?: boolean;
22
+ alterTableOptions?: boolean;
23
+ isEnumValue?: boolean;
24
+ objtype?: string;
25
+ subtype?: string;
26
+ [key: string]: any;
27
+ }
28
+ export declare class DeparserContext {
29
+ readonly indentLevel: number;
30
+ readonly prettyMode: boolean;
31
+ readonly isStringLiteral?: boolean;
32
+ readonly parentNodeTypes: string[];
33
+ private readonly formatter;
34
+ readonly select?: boolean;
35
+ readonly from?: boolean;
36
+ readonly group?: boolean;
37
+ readonly sort?: boolean;
38
+ readonly insertColumns?: boolean;
39
+ readonly update?: boolean;
40
+ readonly bool?: boolean;
41
+ readonly isColumnConstraint?: boolean;
42
+ readonly isDomainConstraint?: boolean;
43
+ readonly alterColumnOptions?: boolean;
44
+ readonly alterTableOptions?: boolean;
45
+ readonly isEnumValue?: boolean;
46
+ readonly objtype?: string;
47
+ readonly subtype?: string;
48
+ readonly [key: string]: any;
49
+ constructor({ indentLevel, prettyMode, isStringLiteral, parentNodeTypes, formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest }?: DeparserContextOptions);
50
+ spawn(nodeType: string, overrides?: Partial<DeparserContextOptions>): DeparserContext;
51
+ indent(text: string, count?: number): string;
52
+ newline(): string;
53
+ parens(content: string): string;
54
+ format(parts: string[], separator?: string): string;
55
+ isPretty(): boolean;
56
+ }
57
+ export interface DeparserVisitor {
58
+ visit(node: any, context?: DeparserContext): string;
59
+ }
60
+ export declare abstract class BaseVisitor implements DeparserVisitor {
61
+ abstract visit(node: any, context?: DeparserContext): string;
62
+ protected getNodeType(node: any): string;
63
+ protected getNodeData(node: any): any;
64
+ protected formatList(items: any[], separator: string, prefix: string, formatter: (item: any) => string): string;
65
+ protected formatParts(parts: string[], separator?: string): string;
66
+ protected formatParens(content: string): string;
67
+ protected formatIndent(text: string, count?: number): string;
68
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ /**
3
+ * Auto-generated file with types stripped for better tree-shaking
4
+ * DO NOT EDIT - Generated by strip-deparser-types.ts
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.BaseVisitor = exports.DeparserContext = void 0;
8
+ const sql_formatter_1 = require("../utils/sql-formatter");
9
+ class DeparserContext {
10
+ indentLevel;
11
+ prettyMode;
12
+ isStringLiteral;
13
+ parentNodeTypes;
14
+ formatter;
15
+ select;
16
+ from;
17
+ group;
18
+ sort;
19
+ insertColumns;
20
+ update;
21
+ bool;
22
+ isColumnConstraint;
23
+ isDomainConstraint;
24
+ alterColumnOptions;
25
+ alterTableOptions;
26
+ isEnumValue;
27
+ objtype;
28
+ subtype;
29
+ constructor({ indentLevel = 0, prettyMode = true, isStringLiteral, parentNodeTypes = [], formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest } = {}) {
30
+ this.indentLevel = indentLevel;
31
+ this.prettyMode = prettyMode;
32
+ this.isStringLiteral = isStringLiteral;
33
+ this.parentNodeTypes = parentNodeTypes;
34
+ this.formatter = formatter || new sql_formatter_1.SqlFormatter('\n', ' ', prettyMode);
35
+ this.select = select;
36
+ this.from = from;
37
+ this.group = group;
38
+ this.sort = sort;
39
+ this.insertColumns = insertColumns;
40
+ this.update = update;
41
+ this.bool = bool;
42
+ this.isColumnConstraint = isColumnConstraint;
43
+ this.isDomainConstraint = isDomainConstraint;
44
+ this.alterColumnOptions = alterColumnOptions;
45
+ this.alterTableOptions = alterTableOptions;
46
+ this.isEnumValue = isEnumValue;
47
+ this.objtype = objtype;
48
+ this.subtype = subtype;
49
+ Object.assign(this, rest);
50
+ }
51
+ spawn(nodeType, overrides = {}) {
52
+ return new DeparserContext({
53
+ indentLevel: this.indentLevel,
54
+ prettyMode: this.prettyMode,
55
+ isStringLiteral: this.isStringLiteral,
56
+ parentNodeTypes: [...this.parentNodeTypes, nodeType],
57
+ formatter: this.formatter,
58
+ select: this.select,
59
+ from: this.from,
60
+ group: this.group,
61
+ sort: this.sort,
62
+ insertColumns: this.insertColumns,
63
+ update: this.update,
64
+ bool: this.bool,
65
+ isColumnConstraint: this.isColumnConstraint,
66
+ isDomainConstraint: this.isDomainConstraint,
67
+ alterColumnOptions: this.alterColumnOptions,
68
+ alterTableOptions: this.alterTableOptions,
69
+ isEnumValue: this.isEnumValue,
70
+ objtype: this.objtype,
71
+ subtype: this.subtype,
72
+ ...overrides,
73
+ });
74
+ }
75
+ indent(text, count) {
76
+ if (!this.prettyMode) {
77
+ return text;
78
+ }
79
+ const indentCount = count !== undefined ? count : this.indentLevel + 1;
80
+ return this.formatter.indent(text, indentCount);
81
+ }
82
+ newline() {
83
+ return this.formatter.newline();
84
+ }
85
+ parens(content) {
86
+ return this.formatter.parens(content);
87
+ }
88
+ format(parts, separator) {
89
+ return this.formatter.format(parts, separator);
90
+ }
91
+ isPretty() {
92
+ return this.formatter.isPretty();
93
+ }
94
+ }
95
+ exports.DeparserContext = DeparserContext;
96
+ class BaseVisitor {
97
+ getNodeType(node) {
98
+ return Object.keys(node)[0];
99
+ }
100
+ getNodeData(node) {
101
+ const type = this.getNodeType(node);
102
+ return node[type];
103
+ }
104
+ formatList(items, separator = ', ', prefix = '', formatter) {
105
+ if (!items || items.length === 0) {
106
+ return '';
107
+ }
108
+ return items
109
+ .map(item => `${prefix}${formatter(item)}`)
110
+ .join(separator);
111
+ }
112
+ formatParts(parts, separator = ' ') {
113
+ return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
114
+ }
115
+ formatParens(content) {
116
+ return `(${content})`;
117
+ }
118
+ formatIndent(text, count = 1) {
119
+ return text;
120
+ }
121
+ }
122
+ exports.BaseVisitor = BaseVisitor;