pgsql-deparser 14.0.1 → 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.
@@ -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;
@@ -2,11 +2,58 @@
2
2
  * Auto-generated file with types stripped for better tree-shaking
3
3
  * DO NOT EDIT - Generated by strip-deparser-types.ts
4
4
  */
5
- export interface DeparserContext {
5
+ import { SqlFormatter } from '../utils/sql-formatter';
6
+ export interface DeparserContextOptions {
6
7
  isStringLiteral?: boolean;
7
- parentNodeTypes: string[];
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;
8
26
  [key: string]: any;
9
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
+ }
10
57
  export interface DeparserVisitor {
11
58
  visit(node: any, context?: DeparserContext): string;
12
59
  }
@@ -4,7 +4,95 @@
4
4
  * DO NOT EDIT - Generated by strip-deparser-types.ts
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.BaseVisitor = void 0;
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;
8
96
  class BaseVisitor {
9
97
  getNodeType(node) {
10
98
  return Object.keys(node)[0];