pgsql-deparser 13.18.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 (42) hide show
  1. package/LICENSE +21 -0
  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/{src/deparser/deparser.ts → esm/deparser/deparser.js} +589 -616
  15. package/{src/deparser/index.ts → esm/deparser/index.js} +3 -4
  16. package/{src/deparser/utils/list-utils.ts → esm/deparser/utils/list-utils.js} +2 -3
  17. package/{src/deparser/utils/quote-utils.ts → esm/deparser/utils/quote-utils.js} +6 -7
  18. package/{src/deparser/utils/sql-formatter.ts → esm/deparser/utils/sql-formatter.js} +10 -11
  19. package/{src/deparser/visitors/base.ts → esm/deparser/visitors/base.js} +34 -62
  20. package/esm/index.js +15 -0
  21. package/{src/v13-to-v14.ts → esm/v13-to-v14.js} +472 -609
  22. package/{src/v13-to-v17-direct.ts → esm/v13-to-v17-direct.js} +11 -12
  23. package/{src/v14-to-v15.ts → esm/v14-to-v15.js} +261 -662
  24. package/{src/v15-to-v16.ts → esm/v15-to-v16.js} +814 -1229
  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 +1 -1
  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/src/index.ts +0 -27
  40. package/src/v16-to-v17.ts +0 -1897
  41. package/tsconfig.esm.json +0 -8
  42. package/tsconfig.json +0 -26
@@ -2,13 +2,12 @@
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
-
6
- import { Deparser, DeparserOptions } from "./deparser";
5
+ import { Deparser } from "./deparser";
7
6
  const deparseMethod = Deparser.deparse;
8
7
  // Export the original sync version as deparseSync
9
8
  export const deparseSync = deparseMethod;
10
9
  // Create an async wrapper for deparse
11
- export const deparse = async (...args: Parameters<typeof deparseMethod>): Promise<ReturnType<typeof deparseMethod>> => {
10
+ export const deparse = async (...args) => {
12
11
  return deparseMethod(...args);
13
12
  };
14
- export { Deparser, DeparserOptions };
13
+ export { Deparser };
@@ -2,9 +2,8 @@
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
-
6
5
  export class ListUtils {
7
- static unwrapList(obj: any): any[] {
6
+ static unwrapList(obj) {
8
7
  if (obj === undefined || obj === null) {
9
8
  return [];
10
9
  }
@@ -16,7 +15,7 @@ export class ListUtils {
16
15
  }
17
16
  return [obj];
18
17
  }
19
- static formatList(items: any[], separator: string = ', ', prefix: string = '', formatter: (item: any) => string): string {
18
+ static formatList(items, separator = ', ', prefix = '', formatter) {
20
19
  if (!items || items.length === 0) {
21
20
  return '';
22
21
  }
@@ -2,7 +2,6 @@
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
-
6
5
  const RESERVED_WORDS = new Set([
7
6
  'all', 'analyse', 'analyze', 'and', 'any', 'array', 'as', 'asc', 'asymmetric',
8
7
  'authorization', 'binary', 'both', 'case', 'cast', 'check', 'collate', 'collation',
@@ -19,7 +18,7 @@ const RESERVED_WORDS = new Set([
19
18
  'verbose', 'when', 'where', 'window', 'with'
20
19
  ]);
21
20
  export class QuoteUtils {
22
- static needsQuotes(value: string): boolean {
21
+ static needsQuotes(value) {
23
22
  if (!value || typeof value !== 'string') {
24
23
  return false;
25
24
  }
@@ -35,7 +34,7 @@ export class QuoteUtils {
35
34
  }
36
35
  return false;
37
36
  }
38
- static quote(value: any): any {
37
+ static quote(value) {
39
38
  if (value == null) {
40
39
  return null;
41
40
  }
@@ -50,21 +49,21 @@ export class QuoteUtils {
50
49
  }
51
50
  return value;
52
51
  }
53
- static escape(literal: string): string {
52
+ static escape(literal) {
54
53
  return `'${literal.replace(/'/g, "''")}'`;
55
54
  }
56
55
  /**
57
56
  * Escapes a string value for use in E-prefixed string literals
58
57
  * Handles both backslashes and single quotes properly
59
58
  */
60
- static escapeEString(value: string): string {
59
+ static escapeEString(value) {
61
60
  return value.replace(/\\/g, '\\\\').replace(/'/g, "''");
62
61
  }
63
62
  /**
64
63
  * Formats a string as an E-prefixed string literal with proper escaping
65
64
  * This wraps the complete E-prefix logic including detection and formatting
66
65
  */
67
- static formatEString(value: string): string {
66
+ static formatEString(value) {
68
67
  const needsEscape = QuoteUtils.needsEscapePrefix(value);
69
68
  if (needsEscape) {
70
69
  const escapedValue = QuoteUtils.escapeEString(value);
@@ -78,7 +77,7 @@ export class QuoteUtils {
78
77
  * Determines if a string value needs E-prefix for escaped string literals
79
78
  * Detects backslash escape sequences that require E-prefix in PostgreSQL
80
79
  */
81
- static needsEscapePrefix(value: string): boolean {
80
+ static needsEscapePrefix(value) {
82
81
  // Always use E'' if the string contains any backslashes,
83
82
  // unless it's a raw \x... bytea-style literal.
84
83
  return !/^\\x[0-9a-fA-F]+$/i.test(value) && value.includes('\\');
@@ -2,36 +2,35 @@
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
-
6
5
  export class SqlFormatter {
7
- private newlineChar: string;
8
- private tabChar: string;
9
- private prettyMode: boolean;
10
- constructor(newlineChar: string = '\n', tabChar: string = ' ', prettyMode: boolean = true) {
6
+ newlineChar;
7
+ tabChar;
8
+ prettyMode;
9
+ constructor(newlineChar = '\n', tabChar = ' ', prettyMode = true) {
11
10
  this.newlineChar = newlineChar;
12
11
  this.tabChar = tabChar;
13
12
  this.prettyMode = prettyMode;
14
13
  }
15
- format(parts: string[], separator: string = ' '): string {
14
+ format(parts, separator = ' ') {
16
15
  return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
17
16
  }
18
- indent(text: string, count: number = 1): string {
17
+ indent(text, count = 1) {
19
18
  if (!this.prettyMode) {
20
19
  return text;
21
20
  }
22
21
  const indentation = this.tabChar.repeat(count);
23
22
  return text.split(this.newlineChar).map(line => line.trim() ? indentation + line : line).join(this.newlineChar);
24
23
  }
25
- parens(content: string): string {
24
+ parens(content) {
26
25
  return `(${content})`;
27
26
  }
28
- newline(): string {
27
+ newline() {
29
28
  return this.newlineChar;
30
29
  }
31
- tab(): string {
30
+ tab() {
32
31
  return this.tabChar;
33
32
  }
34
- isPretty(): boolean {
33
+ isPretty() {
35
34
  return this.prettyMode;
36
35
  }
37
36
  }
@@ -2,52 +2,28 @@
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
-
6
5
  import { SqlFormatter } from '../utils/sql-formatter';
7
- export interface DeparserContextOptions {
8
- isStringLiteral?: boolean;
9
- parentNodeTypes?: string[];
10
- indentLevel?: number;
11
- prettyMode?: boolean;
12
- formatter?: SqlFormatter;
13
- select?: boolean;
14
- from?: boolean;
15
- group?: boolean;
16
- sort?: boolean;
17
- insertColumns?: boolean;
18
- update?: boolean;
19
- bool?: boolean;
20
- isColumnConstraint?: boolean;
21
- isDomainConstraint?: boolean;
22
- alterColumnOptions?: boolean;
23
- alterTableOptions?: boolean;
24
- isEnumValue?: boolean;
25
- objtype?: string;
26
- subtype?: string;
27
- [key: string]: any;
28
- }
29
6
  export class DeparserContext {
30
- readonly indentLevel: number;
31
- readonly prettyMode: boolean;
32
- readonly isStringLiteral?: boolean;
33
- readonly parentNodeTypes: string[];
34
- private readonly formatter: SqlFormatter;
35
- readonly select?: boolean;
36
- readonly from?: boolean;
37
- readonly group?: boolean;
38
- readonly sort?: boolean;
39
- readonly insertColumns?: boolean;
40
- readonly update?: boolean;
41
- readonly bool?: boolean;
42
- readonly isColumnConstraint?: boolean;
43
- readonly isDomainConstraint?: boolean;
44
- readonly alterColumnOptions?: boolean;
45
- readonly alterTableOptions?: boolean;
46
- readonly isEnumValue?: boolean;
47
- readonly objtype?: string;
48
- readonly subtype?: string;
49
- readonly [key: string]: any;
50
- constructor({ indentLevel = 0, prettyMode = true, isStringLiteral, parentNodeTypes = [], formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest }: DeparserContextOptions = {}) {
7
+ indentLevel;
8
+ prettyMode;
9
+ isStringLiteral;
10
+ parentNodeTypes;
11
+ formatter;
12
+ select;
13
+ from;
14
+ group;
15
+ sort;
16
+ insertColumns;
17
+ update;
18
+ bool;
19
+ isColumnConstraint;
20
+ isDomainConstraint;
21
+ alterColumnOptions;
22
+ alterTableOptions;
23
+ isEnumValue;
24
+ objtype;
25
+ subtype;
26
+ constructor({ indentLevel = 0, prettyMode = true, isStringLiteral, parentNodeTypes = [], formatter, select, from, group, sort, insertColumns, update, bool, isColumnConstraint, isDomainConstraint, alterColumnOptions, alterTableOptions, isEnumValue, objtype, subtype, ...rest } = {}) {
51
27
  this.indentLevel = indentLevel;
52
28
  this.prettyMode = prettyMode;
53
29
  this.isStringLiteral = isStringLiteral;
@@ -69,7 +45,7 @@ export class DeparserContext {
69
45
  this.subtype = subtype;
70
46
  Object.assign(this, rest);
71
47
  }
72
- spawn(nodeType: string, overrides: Partial<DeparserContextOptions> = {}): DeparserContext {
48
+ spawn(nodeType, overrides = {}) {
73
49
  return new DeparserContext({
74
50
  indentLevel: this.indentLevel,
75
51
  prettyMode: this.prettyMode,
@@ -93,39 +69,35 @@ export class DeparserContext {
93
69
  ...overrides,
94
70
  });
95
71
  }
96
- indent(text: string, count?: number): string {
72
+ indent(text, count) {
97
73
  if (!this.prettyMode) {
98
74
  return text;
99
75
  }
100
76
  const indentCount = count !== undefined ? count : this.indentLevel + 1;
101
77
  return this.formatter.indent(text, indentCount);
102
78
  }
103
- newline(): string {
79
+ newline() {
104
80
  return this.formatter.newline();
105
81
  }
106
- parens(content: string): string {
82
+ parens(content) {
107
83
  return this.formatter.parens(content);
108
84
  }
109
- format(parts: string[], separator?: string): string {
85
+ format(parts, separator) {
110
86
  return this.formatter.format(parts, separator);
111
87
  }
112
- isPretty(): boolean {
88
+ isPretty() {
113
89
  return this.formatter.isPretty();
114
90
  }
115
91
  }
116
- export interface DeparserVisitor {
117
- visit(node: any, context?: DeparserContext): string;
118
- }
119
- export abstract class BaseVisitor implements DeparserVisitor {
120
- abstract visit(node: any, context?: DeparserContext): string;
121
- protected getNodeType(node: any): string {
92
+ export class BaseVisitor {
93
+ getNodeType(node) {
122
94
  return Object.keys(node)[0];
123
95
  }
124
- protected getNodeData(node: any): any {
96
+ getNodeData(node) {
125
97
  const type = this.getNodeType(node);
126
- return (node as any)[type];
98
+ return node[type];
127
99
  }
128
- protected formatList(items: any[], separator: string = ', ', prefix: string = '', formatter: (item: any) => string): string {
100
+ formatList(items, separator = ', ', prefix = '', formatter) {
129
101
  if (!items || items.length === 0) {
130
102
  return '';
131
103
  }
@@ -133,13 +105,13 @@ export abstract class BaseVisitor implements DeparserVisitor {
133
105
  .map(item => `${prefix}${formatter(item)}`)
134
106
  .join(separator);
135
107
  }
136
- protected formatParts(parts: string[], separator: string = ' '): string {
108
+ formatParts(parts, separator = ' ') {
137
109
  return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
138
110
  }
139
- protected formatParens(content: string): string {
111
+ formatParens(content) {
140
112
  return `(${content})`;
141
113
  }
142
- protected formatIndent(text: string, count: number = 1): string {
114
+ formatIndent(text, count = 1) {
143
115
  return text;
144
116
  }
145
117
  }
package/esm/index.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Deparser for PostgreSQL version 13
3
+ * Auto-generated by generate-version-deparsers.ts
4
+ */
5
+ import { deparse as deparse17, deparseSync as deparseSync17 } from './deparser';
6
+ import { PG13ToPG17Transformer } from './v13-to-v17-direct';
7
+ const tx = new PG13ToPG17Transformer();
8
+ export async function deparse(query, opts) {
9
+ const ast17 = tx.transform(query);
10
+ return await deparse17(ast17, opts);
11
+ }
12
+ export function deparseSync(query, opts) {
13
+ const ast17 = tx.transform(query);
14
+ return deparseSync17(ast17, opts);
15
+ }