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.
- package/README.md +12 -6
- package/{dist/deparser → deparser}/deparser.d.ts +4 -3
- package/{dist/deparser → deparser}/deparser.js +883 -437
- package/{dist/deparser → deparser}/utils/sql-formatter.js +1 -1
- package/deparser/visitors/base.d.ts +68 -0
- package/deparser/visitors/base.js +122 -0
- package/{dist/esm → esm}/deparser/deparser.js +883 -437
- package/{dist/esm → esm}/deparser/utils/sql-formatter.js +1 -1
- package/esm/deparser/visitors/base.js +117 -0
- package/{dist/esm → esm}/v14-to-v15.js +3 -0
- package/{dist/esm → esm}/v15-to-v16.js +60 -1
- package/package.json +1 -2
- package/{dist/v14-to-v15.js → v14-to-v15.js} +3 -0
- package/{dist/v15-to-v16.d.ts → v15-to-v16.d.ts} +6 -0
- package/{dist/v15-to-v16.js → v15-to-v16.js} +60 -1
- package/dist/README.md +0 -160
- package/dist/deparser/visitors/base.d.ts +0 -21
- package/dist/deparser/visitors/base.js +0 -34
- package/dist/esm/deparser/visitors/base.js +0 -30
- package/dist/package.json +0 -42
- package/src/deparser/deparser.ts +0 -10026
- package/src/deparser/index.ts +0 -14
- package/src/deparser/utils/list-utils.ts +0 -27
- package/src/deparser/utils/quote-utils.ts +0 -86
- package/src/deparser/utils/sql-formatter.ts +0 -37
- package/src/deparser/visitors/base.ts +0 -40
- package/src/index.ts +0 -27
- package/src/v14-to-v15.ts +0 -1621
- package/src/v14-to-v17-direct.ts +0 -68
- package/src/v15-to-v16.ts +0 -3290
- package/src/v16-to-v17.ts +0 -1897
- package/tsconfig.esm.json +0 -8
- package/tsconfig.json +0 -26
- /package/{dist/LICENSE → LICENSE} +0 -0
- /package/{dist/deparser → deparser}/index.d.ts +0 -0
- /package/{dist/deparser → deparser}/index.js +0 -0
- /package/{dist/deparser → deparser}/utils/list-utils.d.ts +0 -0
- /package/{dist/deparser → deparser}/utils/list-utils.js +0 -0
- /package/{dist/deparser → deparser}/utils/quote-utils.d.ts +0 -0
- /package/{dist/deparser → deparser}/utils/quote-utils.js +0 -0
- /package/{dist/deparser → deparser}/utils/sql-formatter.d.ts +0 -0
- /package/{dist/esm → esm}/deparser/index.js +0 -0
- /package/{dist/esm → esm}/deparser/utils/list-utils.js +0 -0
- /package/{dist/esm → esm}/deparser/utils/quote-utils.js +0 -0
- /package/{dist/esm → esm}/index.js +0 -0
- /package/{dist/esm → esm}/v14-to-v17-direct.js +0 -0
- /package/{dist/esm → esm}/v16-to-v17.js +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/v14-to-v15.d.ts → v14-to-v15.d.ts} +0 -0
- /package/{dist/v14-to-v17-direct.d.ts → v14-to-v17-direct.d.ts} +0 -0
- /package/{dist/v14-to-v17-direct.js → v14-to-v17-direct.js} +0 -0
- /package/{dist/v16-to-v17.d.ts → v16-to-v17.d.ts} +0 -0
- /package/{dist/v16-to-v17.js → v16-to-v17.js} +0 -0
package/README.md
CHANGED
|
@@ -80,12 +80,17 @@ npm install pgsql-deparser
|
|
|
80
80
|
While we highly recommend using PG17, for PostgreSQL versions 13-16, use the version-specific packages:
|
|
81
81
|
|
|
82
82
|
```sh
|
|
83
|
-
npm install pgsql-deparser@
|
|
84
|
-
npm install pgsql-deparser@
|
|
85
|
-
npm install pgsql-deparser@
|
|
86
|
-
npm install pgsql-deparser@
|
|
83
|
+
npm install pgsql-deparser@pg13 # PostgreSQL 13
|
|
84
|
+
npm install pgsql-deparser@pg14 # PostgreSQL 14
|
|
85
|
+
npm install pgsql-deparser@pg15 # PostgreSQL 15
|
|
86
|
+
npm install pgsql-deparser@pg16 # PostgreSQL 16
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
**Version Status:**
|
|
90
|
+
- **PG17**: 🚀 Recommended (stable + modern AST)
|
|
91
|
+
- **PG14-16**: ⚠️ Experimental (modern AST, hardening in progress)
|
|
92
|
+
- **PG13**: Stable (legacy AST format)
|
|
93
|
+
|
|
89
94
|
## Options
|
|
90
95
|
|
|
91
96
|
The deparser accepts optional configuration for formatting and output control:
|
|
@@ -94,7 +99,7 @@ The deparser accepts optional configuration for formatting and output control:
|
|
|
94
99
|
import { deparseSync as deparse } from 'pgsql-deparser';
|
|
95
100
|
|
|
96
101
|
const options = {
|
|
97
|
-
pretty: true, // Enable pretty formatting (default:
|
|
102
|
+
pretty: true, // Enable pretty formatting (default: true)
|
|
98
103
|
newline: '\n', // Newline character (default: '\n')
|
|
99
104
|
tab: ' ', // Tab/indentation character (default: ' ')
|
|
100
105
|
semicolons: true // Add semicolons to statements (default: true)
|
|
@@ -105,7 +110,7 @@ const sql = deparse(ast, options);
|
|
|
105
110
|
|
|
106
111
|
| Option | Type | Default | Description |
|
|
107
112
|
|--------|------|---------|-------------|
|
|
108
|
-
| `pretty` | `boolean` | `
|
|
113
|
+
| `pretty` | `boolean` | `true` | Enable pretty formatting with indentation and line breaks |
|
|
109
114
|
| `newline` | `string` | `'\n'` | Character(s) used for line breaks |
|
|
110
115
|
| `tab` | `string` | `' '` | Character(s) used for indentation |
|
|
111
116
|
| `semicolons` | `boolean` | `true` | Add semicolons to SQL statements |
|
|
@@ -150,6 +155,7 @@ Built on the excellent work of several contributors:
|
|
|
150
155
|
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): Offers TypeScript type definitions for PostgreSQL AST nodes, facilitating type-safe construction, analysis, and manipulation of ASTs.
|
|
151
156
|
* [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): Provides TypeScript enum definitions for PostgreSQL constants, enabling type-safe usage of PostgreSQL enums and constants in your applications.
|
|
152
157
|
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): A comprehensive utility library for PostgreSQL, offering type-safe AST node creation and enum value conversions, simplifying the construction and manipulation of PostgreSQL ASTs.
|
|
158
|
+
* [@pgsql/traverse](https://www.npmjs.com/package/@pgsql/traverse): PostgreSQL AST traversal utilities for pgsql-parser, providing a visitor pattern for traversing PostgreSQL Abstract Syntax Tree nodes, similar to Babel's traverse functionality but specifically designed for PostgreSQL AST structures.
|
|
153
159
|
* [pg-proto-parser](https://www.npmjs.com/package/pg-proto-parser): A TypeScript tool that parses PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
|
|
154
160
|
* [libpg-query](https://github.com/launchql/libpg-query-node): The real PostgreSQL parser exposed for Node.js, used primarily in `pgsql-parser` for parsing and deparsing SQL queries.
|
|
155
161
|
|
|
@@ -36,7 +36,6 @@ export interface DeparserOptions {
|
|
|
36
36
|
* compatibility and wraps them internally for consistent processing.
|
|
37
37
|
*/
|
|
38
38
|
export declare class Deparser implements DeparserVisitor {
|
|
39
|
-
private formatter;
|
|
40
39
|
private tree;
|
|
41
40
|
private options;
|
|
42
41
|
constructor(tree: any | any[] | any, opts?: DeparserOptions);
|
|
@@ -67,10 +66,11 @@ export declare class Deparser implements DeparserVisitor {
|
|
|
67
66
|
RawStmt(node: any, context: DeparserContext): string;
|
|
68
67
|
SelectStmt(node: any, context: DeparserContext): string;
|
|
69
68
|
A_Expr(node: any, context: DeparserContext): string;
|
|
70
|
-
deparseOperatorName(name: any): string;
|
|
69
|
+
deparseOperatorName(name: any, context: DeparserContext): string;
|
|
71
70
|
private getOperatorPrecedence;
|
|
72
71
|
private needsParentheses;
|
|
73
72
|
private isComplexExpression;
|
|
73
|
+
private isComplexSelectTarget;
|
|
74
74
|
visitBetweenRange(rexpr: any, context: DeparserContext): string;
|
|
75
75
|
InsertStmt(node: any, context: DeparserContext): string;
|
|
76
76
|
UpdateStmt(node: any, context: DeparserContext): string;
|
|
@@ -90,6 +90,7 @@ export declare class Deparser implements DeparserVisitor {
|
|
|
90
90
|
formatTypeMods(typmods: any, context: DeparserContext): string | null;
|
|
91
91
|
formatSingleTypeMod(typemod: number, typeName: string): string | null;
|
|
92
92
|
getPgCatalogTypeName(typeName: string, size: string | null): string;
|
|
93
|
+
isPgCatalogType(typeName: string): boolean;
|
|
93
94
|
A_ArrayExpr(node: any, context: DeparserContext): string;
|
|
94
95
|
A_Indices(node: any, context: DeparserContext): string;
|
|
95
96
|
A_Indirection(node: any, context: DeparserContext): string;
|
|
@@ -117,7 +118,7 @@ export declare class Deparser implements DeparserVisitor {
|
|
|
117
118
|
SubLink(node: any, context: DeparserContext): string;
|
|
118
119
|
CaseWhen(node: any, context: DeparserContext): string;
|
|
119
120
|
WindowDef(node: any, context: DeparserContext): string;
|
|
120
|
-
formatWindowFrame(node: any): string | null;
|
|
121
|
+
formatWindowFrame(node: any, context: DeparserContext): string | null;
|
|
121
122
|
SortBy(node: any, context: DeparserContext): string;
|
|
122
123
|
GroupingSet(node: any, context: DeparserContext): string;
|
|
123
124
|
CommonTableExpr(node: any, context: DeparserContext): string;
|