pgsql-deparser 13.16.0 → 14.0.1
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 +88 -45
- package/deparser/deparser.d.ts +301 -0
- package/deparser/deparser.js +10005 -0
- package/deparser/index.d.ts +9 -0
- package/deparser/index.js +17 -0
- package/deparser/utils/list-utils.d.ts +8 -0
- package/deparser/utils/list-utils.js +30 -0
- package/deparser/utils/quote-utils.d.ts +24 -0
- package/deparser/utils/quote-utils.js +89 -0
- package/deparser/utils/sql-formatter.d.ts +16 -0
- package/deparser/utils/sql-formatter.js +40 -0
- package/deparser/visitors/base.d.ts +21 -0
- package/deparser/visitors/base.js +34 -0
- package/esm/deparser/deparser.js +10001 -0
- package/esm/deparser/index.js +13 -0
- package/esm/deparser/utils/list-utils.js +26 -0
- package/esm/deparser/utils/quote-utils.js +85 -0
- package/esm/deparser/utils/sql-formatter.js +36 -0
- package/esm/deparser/visitors/base.js +30 -0
- package/esm/index.js +15 -0
- package/esm/v14-to-v15.js +1220 -0
- package/esm/v14-to-v17-direct.js +67 -0
- package/esm/v15-to-v16.js +2881 -0
- package/esm/v16-to-v17.js +1488 -0
- package/index.d.ts +9 -0
- package/index.js +19 -0
- package/package.json +26 -75
- package/v14-to-v15.d.ts +616 -0
- package/v14-to-v15.js +1224 -0
- package/v14-to-v17-direct.d.ts +23 -0
- package/v14-to-v17-direct.js +71 -0
- package/v15-to-v16.d.ts +627 -0
- package/v15-to-v16.js +2885 -0
- package/v16-to-v17.d.ts +638 -0
- package/v16-to-v17.js +1492 -0
- package/main/deparser.js +0 -3495
- package/main/index.js +0 -10
- package/main/utils/index.js +0 -97
- package/module/deparser.js +0 -3492
- package/module/index.js +0 -3
- package/module/utils/index.js +0 -90
- package/src/deparser.ts +0 -4234
- package/src/index.ts +0 -3
- package/src/utils/index.ts +0 -92
- package/types/deparser.d.ts +0 -119
- package/types/index.d.ts +0 -3
- package/types/utils/index.d.ts +0 -4
|
@@ -0,0 +1,9 @@
|
|
|
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 { Deparser, DeparserOptions } from "./deparser";
|
|
6
|
+
declare const deparseMethod: typeof Deparser.deparse;
|
|
7
|
+
export declare const deparseSync: typeof Deparser.deparse;
|
|
8
|
+
export declare const deparse: (...args: Parameters<typeof deparseMethod>) => Promise<ReturnType<typeof deparseMethod>>;
|
|
9
|
+
export { Deparser, DeparserOptions };
|
|
@@ -0,0 +1,17 @@
|
|
|
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.Deparser = exports.deparse = exports.deparseSync = void 0;
|
|
8
|
+
const deparser_1 = require("./deparser");
|
|
9
|
+
Object.defineProperty(exports, "Deparser", { enumerable: true, get: function () { return deparser_1.Deparser; } });
|
|
10
|
+
const deparseMethod = deparser_1.Deparser.deparse;
|
|
11
|
+
// Export the original sync version as deparseSync
|
|
12
|
+
exports.deparseSync = deparseMethod;
|
|
13
|
+
// Create an async wrapper for deparse
|
|
14
|
+
const deparse = async (...args) => {
|
|
15
|
+
return deparseMethod(...args);
|
|
16
|
+
};
|
|
17
|
+
exports.deparse = deparse;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
+
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
+
*/
|
|
5
|
+
export declare class ListUtils {
|
|
6
|
+
static unwrapList(obj: any): any[];
|
|
7
|
+
static formatList(items: any[], separator: string, prefix: string, formatter: (item: any) => string): string;
|
|
8
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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.ListUtils = void 0;
|
|
8
|
+
class ListUtils {
|
|
9
|
+
static unwrapList(obj) {
|
|
10
|
+
if (obj === undefined || obj === null) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
if (obj.List !== undefined) {
|
|
14
|
+
return obj.List.items || [];
|
|
15
|
+
}
|
|
16
|
+
if (Array.isArray(obj)) {
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
19
|
+
return [obj];
|
|
20
|
+
}
|
|
21
|
+
static formatList(items, separator = ', ', prefix = '', formatter) {
|
|
22
|
+
if (!items || items.length === 0) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
return items
|
|
26
|
+
.map(item => `${prefix}${formatter(item)}`)
|
|
27
|
+
.join(separator);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.ListUtils = ListUtils;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
+
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
+
*/
|
|
5
|
+
export declare class QuoteUtils {
|
|
6
|
+
static needsQuotes(value: string): boolean;
|
|
7
|
+
static quote(value: any): any;
|
|
8
|
+
static escape(literal: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Escapes a string value for use in E-prefixed string literals
|
|
11
|
+
* Handles both backslashes and single quotes properly
|
|
12
|
+
*/
|
|
13
|
+
static escapeEString(value: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Formats a string as an E-prefixed string literal with proper escaping
|
|
16
|
+
* This wraps the complete E-prefix logic including detection and formatting
|
|
17
|
+
*/
|
|
18
|
+
static formatEString(value: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Determines if a string value needs E-prefix for escaped string literals
|
|
21
|
+
* Detects backslash escape sequences that require E-prefix in PostgreSQL
|
|
22
|
+
*/
|
|
23
|
+
static needsEscapePrefix(value: string): boolean;
|
|
24
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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.QuoteUtils = void 0;
|
|
8
|
+
const RESERVED_WORDS = new Set([
|
|
9
|
+
'all', 'analyse', 'analyze', 'and', 'any', 'array', 'as', 'asc', 'asymmetric',
|
|
10
|
+
'authorization', 'binary', 'both', 'case', 'cast', 'check', 'collate', 'collation',
|
|
11
|
+
'column', 'concurrently', 'constraint', 'create', 'cross', 'current_catalog',
|
|
12
|
+
'current_date', 'current_role', 'current_schema', 'current_time', 'current_timestamp',
|
|
13
|
+
'current_user', 'default', 'deferrable', 'desc', 'distinct', 'do', 'else', 'end',
|
|
14
|
+
'except', 'false', 'fetch', 'for', 'foreign', 'freeze', 'from', 'full', 'grant',
|
|
15
|
+
'group', 'having', 'ilike', 'in', 'initially', 'inner', 'intersect', 'into', 'is',
|
|
16
|
+
'isnull', 'join', 'lateral', 'leading', 'left', 'like', 'limit', 'localtime',
|
|
17
|
+
'localtimestamp', 'natural', 'not', 'notnull', 'null', 'offset', 'on', 'only',
|
|
18
|
+
'or', 'order', 'outer', 'overlaps', 'placing', 'primary', 'references', 'returning',
|
|
19
|
+
'right', 'select', 'session_user', 'similar', 'some', 'symmetric', 'table', 'tablesample',
|
|
20
|
+
'then', 'to', 'trailing', 'true', 'union', 'unique', 'user', 'using', 'variadic',
|
|
21
|
+
'verbose', 'when', 'where', 'window', 'with'
|
|
22
|
+
]);
|
|
23
|
+
class QuoteUtils {
|
|
24
|
+
static needsQuotes(value) {
|
|
25
|
+
if (!value || typeof value !== 'string') {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const lowerValue = value.toLowerCase();
|
|
29
|
+
if (RESERVED_WORDS.has(lowerValue)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (!/^[a-z_][a-z0-9_$]*$/i.test(value)) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (value !== value.toLowerCase()) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
static quote(value) {
|
|
41
|
+
if (value == null) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
return value.map(v => this.quote(v));
|
|
46
|
+
}
|
|
47
|
+
if (typeof value !== 'string') {
|
|
48
|
+
return value;
|
|
49
|
+
}
|
|
50
|
+
if (this.needsQuotes(value)) {
|
|
51
|
+
return `"${value}"`;
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
static escape(literal) {
|
|
56
|
+
return `'${literal.replace(/'/g, "''")}'`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Escapes a string value for use in E-prefixed string literals
|
|
60
|
+
* Handles both backslashes and single quotes properly
|
|
61
|
+
*/
|
|
62
|
+
static escapeEString(value) {
|
|
63
|
+
return value.replace(/\\/g, '\\\\').replace(/'/g, "''");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Formats a string as an E-prefixed string literal with proper escaping
|
|
67
|
+
* This wraps the complete E-prefix logic including detection and formatting
|
|
68
|
+
*/
|
|
69
|
+
static formatEString(value) {
|
|
70
|
+
const needsEscape = QuoteUtils.needsEscapePrefix(value);
|
|
71
|
+
if (needsEscape) {
|
|
72
|
+
const escapedValue = QuoteUtils.escapeEString(value);
|
|
73
|
+
return `E'${escapedValue}'`;
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
return QuoteUtils.escape(value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Determines if a string value needs E-prefix for escaped string literals
|
|
81
|
+
* Detects backslash escape sequences that require E-prefix in PostgreSQL
|
|
82
|
+
*/
|
|
83
|
+
static needsEscapePrefix(value) {
|
|
84
|
+
// Always use E'' if the string contains any backslashes,
|
|
85
|
+
// unless it's a raw \x... bytea-style literal.
|
|
86
|
+
return !/^\\x[0-9a-fA-F]+$/i.test(value) && value.includes('\\');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.QuoteUtils = QuoteUtils;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
+
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
+
*/
|
|
5
|
+
export declare class SqlFormatter {
|
|
6
|
+
private newlineChar;
|
|
7
|
+
private tabChar;
|
|
8
|
+
private prettyMode;
|
|
9
|
+
constructor(newlineChar?: string, tabChar?: string, prettyMode?: boolean);
|
|
10
|
+
format(parts: string[], separator?: string): string;
|
|
11
|
+
indent(text: string, count?: number): string;
|
|
12
|
+
parens(content: string): string;
|
|
13
|
+
newline(): string;
|
|
14
|
+
tab(): string;
|
|
15
|
+
isPretty(): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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.SqlFormatter = void 0;
|
|
8
|
+
class SqlFormatter {
|
|
9
|
+
newlineChar;
|
|
10
|
+
tabChar;
|
|
11
|
+
prettyMode;
|
|
12
|
+
constructor(newlineChar = '\n', tabChar = ' ', prettyMode = false) {
|
|
13
|
+
this.newlineChar = newlineChar;
|
|
14
|
+
this.tabChar = tabChar;
|
|
15
|
+
this.prettyMode = prettyMode;
|
|
16
|
+
}
|
|
17
|
+
format(parts, separator = ' ') {
|
|
18
|
+
return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
|
|
19
|
+
}
|
|
20
|
+
indent(text, count = 1) {
|
|
21
|
+
if (!this.prettyMode) {
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
const indentation = this.tabChar.repeat(count);
|
|
25
|
+
return text.split(this.newlineChar).map(line => line.trim() ? indentation + line : line).join(this.newlineChar);
|
|
26
|
+
}
|
|
27
|
+
parens(content) {
|
|
28
|
+
return `(${content})`;
|
|
29
|
+
}
|
|
30
|
+
newline() {
|
|
31
|
+
return this.newlineChar;
|
|
32
|
+
}
|
|
33
|
+
tab() {
|
|
34
|
+
return this.tabChar;
|
|
35
|
+
}
|
|
36
|
+
isPretty() {
|
|
37
|
+
return this.prettyMode;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.SqlFormatter = SqlFormatter;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated file with types stripped for better tree-shaking
|
|
3
|
+
* DO NOT EDIT - Generated by strip-deparser-types.ts
|
|
4
|
+
*/
|
|
5
|
+
export interface DeparserContext {
|
|
6
|
+
isStringLiteral?: boolean;
|
|
7
|
+
parentNodeTypes: string[];
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
}
|
|
10
|
+
export interface DeparserVisitor {
|
|
11
|
+
visit(node: any, context?: DeparserContext): string;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class BaseVisitor implements DeparserVisitor {
|
|
14
|
+
abstract visit(node: any, context?: DeparserContext): string;
|
|
15
|
+
protected getNodeType(node: any): string;
|
|
16
|
+
protected getNodeData(node: any): any;
|
|
17
|
+
protected formatList(items: any[], separator: string, prefix: string, formatter: (item: any) => string): string;
|
|
18
|
+
protected formatParts(parts: string[], separator?: string): string;
|
|
19
|
+
protected formatParens(content: string): string;
|
|
20
|
+
protected formatIndent(text: string, count?: number): string;
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 = void 0;
|
|
8
|
+
class BaseVisitor {
|
|
9
|
+
getNodeType(node) {
|
|
10
|
+
return Object.keys(node)[0];
|
|
11
|
+
}
|
|
12
|
+
getNodeData(node) {
|
|
13
|
+
const type = this.getNodeType(node);
|
|
14
|
+
return node[type];
|
|
15
|
+
}
|
|
16
|
+
formatList(items, separator = ', ', prefix = '', formatter) {
|
|
17
|
+
if (!items || items.length === 0) {
|
|
18
|
+
return '';
|
|
19
|
+
}
|
|
20
|
+
return items
|
|
21
|
+
.map(item => `${prefix}${formatter(item)}`)
|
|
22
|
+
.join(separator);
|
|
23
|
+
}
|
|
24
|
+
formatParts(parts, separator = ' ') {
|
|
25
|
+
return parts.filter(part => part !== null && part !== undefined && part !== '').join(separator);
|
|
26
|
+
}
|
|
27
|
+
formatParens(content) {
|
|
28
|
+
return `(${content})`;
|
|
29
|
+
}
|
|
30
|
+
formatIndent(text, count = 1) {
|
|
31
|
+
return text;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.BaseVisitor = BaseVisitor;
|