pgsql-deparser 13.16.0 → 13.18.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.
@@ -1,92 +0,0 @@
1
- /* eslint-disable no-restricted-syntax */
2
-
3
- export const cleanLines = (sql) => {
4
- return sql
5
- .split('\n')
6
- .map((l) => l.trim())
7
- .filter((a) => a)
8
- .join('\n');
9
- };
10
-
11
- export const transform = (obj, props) => {
12
- let copy = null;
13
- // Handle the 3 simple types, and null or undefined
14
- if (obj == null || typeof obj !== 'object') {
15
- return obj;
16
- }
17
-
18
- // Handle Date
19
- if (obj instanceof Date) {
20
- copy = new Date();
21
- copy.setTime(obj.getTime());
22
- return copy;
23
- }
24
-
25
- // Handle Array
26
- if (obj instanceof Array) {
27
- copy = [];
28
- for (let i = 0, len = obj.length; i < len; i++) {
29
- copy[i] = transform(obj[i], props);
30
- }
31
- return copy;
32
- }
33
-
34
- // Handle Object
35
- if (obj instanceof Object || typeof obj === 'object') {
36
- copy = {};
37
- for (const attr in obj) {
38
- if (obj.hasOwnProperty(attr)) {
39
- if (props.hasOwnProperty(attr)) {
40
- if (typeof props[attr] === 'function') {
41
- copy[attr] = props[attr](obj[attr]);
42
- } else if (props[attr].hasOwnProperty(obj[attr])) {
43
- copy[attr] = props[attr][obj[attr]];
44
- } else {
45
- copy[attr] = transform(obj[attr], props);
46
- }
47
- } else {
48
- copy[attr] = transform(obj[attr], props);
49
- }
50
- } else {
51
- copy[attr] = transform(obj[attr], props);
52
- }
53
- }
54
- return copy;
55
- }
56
-
57
- throw new Error("Unable to copy obj! Its type isn't supported.");
58
- };
59
-
60
- const noop = () => undefined;
61
-
62
- export const cleanTree = (tree) => {
63
- return transform(tree, {
64
- stmt_len: noop,
65
- stmt_location: noop,
66
- location: noop,
67
- DefElem: (obj) => {
68
- if (obj.defname === 'as') {
69
- if (Array.isArray(obj.arg) && obj.arg.length) {
70
- // function
71
- obj.arg[0].String.str = obj.arg[0].String.str.trim();
72
- } else if (obj.arg.List && obj.arg.List.items) {
73
- // function
74
- obj.arg.List.items[0].String.str = obj.arg.List.items[0].String.str.trim();
75
- } else {
76
- // do stmt
77
- obj.arg.String.str = obj.arg.String.str.trim();
78
- }
79
- return cleanTree(obj);
80
- } else {
81
- return cleanTree(obj);
82
- }
83
- }
84
- });
85
- };
86
-
87
- export const cleanTreeWithStmt = (tree) => {
88
- return transform(tree, {
89
- stmt_location: noop,
90
- location: noop
91
- });
92
- };
@@ -1,119 +0,0 @@
1
- import { A_ArrayExpr, A_Const, A_Expr, A_Indices, A_Indirection, A_Star, AccessPriv, Alias, AlterDefaultPrivilegesStmt, AlterDomainStmt, AlterEnumStmt, AlterObjectSchemaStmt, AlterOwnerStmt, AlterSeqStmt, AlterTableCmd, AlterTableStmt, BitString, BooleanTest, BoolExpr, CallStmt, CaseExpr, CaseWhen, CoalesceExpr, CollateClause, ColumnDef, ColumnRef, CommentStmt, CommonTableExpr, CompositeTypeStmt, Constraint, CopyStmt, CreateDomainStmt, CreateEnumStmt, CreateExtensionStmt, CreateFunctionStmt, CreatePolicyStmt, CreateRoleStmt, CreateSchemaStmt, CreateSeqStmt, CreateStmt, CreateTableAsStmt, CreateTrigStmt, DefElem, DefineStmt, DeleteStmt, DoStmt, DropStmt, ExplainStmt, Float, FuncCall, FunctionParameter, GrantRoleStmt, GrantStmt, GroupingFunc, GroupingSet, IndexElem, IndexStmt, InsertStmt, Integer, IntoClause, JoinExpr, LockingClause, LockStmt, MinMaxExpr, MultiAssignRef, NamedArgExpr, NullTest, ObjectWithArgs, ParamRef, RangeFunction, RangeSubselect, RangeTableSample, RangeVar, RawStmt, RenameStmt, ResTarget, RoleSpec, RowExpr, RuleStmt, SelectStmt, SetToDefault, SortBy, SQLValueFunction, String as TString, SubLink, TransactionStmt, TruncateStmt, TypeCast, TypeName, UpdateStmt, VariableSetStmt, VariableShowStmt, ViewStmt, WindowDef, WithClause } from '@pgsql/types';
2
- export default class Deparser {
3
- static deparse(query: any, opts: any): any;
4
- constructor(tree: any, opts?: {});
5
- deparseQuery(): any;
6
- deparseNodes(nodes: any, context: any): any;
7
- deparseReturningList(list: any, context: any): any;
8
- list(nodes: any, separator: string, prefix: string, context: any): any;
9
- listQuotes(nodes: any, separator?: string): any;
10
- quote(value: any): any;
11
- escape(literal: any): string;
12
- getPgCatalogTypeName(typeName: any, size: any): string;
13
- type(names: any, args: any): any;
14
- deparse(item: any, context: any): any;
15
- RawStmt(node: RawStmt, context?: {}): any;
16
- RuleStmt(node: RuleStmt, context?: {}): string;
17
- A_Expr(node: A_Expr, context?: {}): string;
18
- Alias(node: Alias, context?: {}): string;
19
- A_ArrayExpr(node: A_ArrayExpr): string;
20
- A_Const(node: A_Const, context?: {}): any;
21
- A_Indices(node: A_Indices, context?: {}): string;
22
- A_Indirection(node: A_Indirection, context?: {}): string;
23
- A_Star(node: A_Star): string;
24
- BitString(node: BitString): string;
25
- BoolExpr(node: BoolExpr, context?: {}): string;
26
- BooleanTest(node: BooleanTest, context?: {}): string;
27
- CaseExpr(node: CaseExpr, context?: {}): string;
28
- CoalesceExpr(node: CoalesceExpr, context?: {}): string;
29
- CollateClause(node: CollateClause, context?: {}): string;
30
- CompositeTypeStmt(node: CompositeTypeStmt, context?: {}): string;
31
- RenameStmt(node: RenameStmt, context?: {}): string;
32
- AlterOwnerStmt(node: AlterOwnerStmt, context?: {}): string;
33
- AlterObjectSchemaStmt(node: AlterObjectSchemaStmt, context?: {}): string;
34
- ColumnDef(node: ColumnDef, context?: {}): any;
35
- SQLValueFunction(node: SQLValueFunction): "CURRENT_USER" | "SESSION_USER" | "CURRENT_DATE" | "CURRENT_TIMESTAMP";
36
- ColumnRef(node: ColumnRef, context?: {}): any;
37
- CommentStmt(node: CommentStmt, context?: {}): string;
38
- CommonTableExpr(node: CommonTableExpr, context?: {}): string;
39
- DefineStmt(node: DefineStmt, context?: {}): string;
40
- DefElem(node: DefElem, context?: {}): any;
41
- DoStmt(node: DoStmt): string;
42
- Float(node: Float): string;
43
- FuncCall(node: FuncCall, context?: {}): string;
44
- GroupingFunc(node: GroupingFunc, context?: {}): string;
45
- GroupingSet(node: GroupingSet, context?: {}): string;
46
- IndexStmt(node: IndexStmt, context?: {}): string;
47
- IndexElem(node: IndexElem, context?: {}): any;
48
- InsertStmt(node: InsertStmt, context?: {}): string;
49
- SetToDefault(node: SetToDefault): string;
50
- MultiAssignRef(node: MultiAssignRef, context?: {}): string;
51
- DeleteStmt(node: DeleteStmt, context?: {}): string;
52
- UpdateStmt(node: UpdateStmt, context?: {}): string;
53
- Integer(node: Integer, context?: {}): string;
54
- IntoClause(node: IntoClause, context?: {}): string;
55
- JoinExpr(node: JoinExpr, context?: {}): string;
56
- LockingClause(node: LockingClause, context?: {}): string;
57
- LockStmt(node: LockStmt, context?: {}): string;
58
- MinMaxExpr(node: MinMaxExpr, context?: {}): string;
59
- NamedArgExpr(node: NamedArgExpr, context?: {}): string;
60
- Null(node: any): string;
61
- NullTest(node: NullTest, context?: {}): string;
62
- ParamRef(node: ParamRef): string;
63
- RangeFunction(node: RangeFunction, context?: {}): string;
64
- RangeSubselect(node: RangeSubselect, context?: {}): string;
65
- RangeTableSample(node: RangeTableSample, context?: {}): string;
66
- RangeVar(node: RangeVar, context?: {}): string;
67
- ResTarget(node: ResTarget, context?: {}): any;
68
- RowExpr(node: RowExpr, context?: {}): string;
69
- ExplainStmt(node: ExplainStmt, context?: {}): string;
70
- SelectStmt(node: SelectStmt, context?: {}): string;
71
- TruncateStmt(node: TruncateStmt, context?: {}): string;
72
- AlterDefaultPrivilegesStmt(node: AlterDefaultPrivilegesStmt, context?: {}): string;
73
- AlterTableStmt(node: AlterTableStmt, context?: {}): string;
74
- AlterTableCmd(node: AlterTableCmd, context?: {}): string;
75
- CreateEnumStmt(node: CreateEnumStmt, context?: {}): string;
76
- AlterEnumStmt(node: AlterEnumStmt, context?: {}): string;
77
- AlterDomainStmt(node: AlterDomainStmt, context?: {}): string;
78
- CreateExtensionStmt(node: CreateExtensionStmt): string;
79
- DropStmt(node: DropStmt, context?: {}): string;
80
- CreatePolicyStmt(node: CreatePolicyStmt, context?: {}): string;
81
- AlterPolicyStmt(node: any, context?: {}): string;
82
- ViewStmt(node: ViewStmt, context?: {}): string;
83
- CreateSeqStmt(node: CreateSeqStmt, context?: {}): string;
84
- AlterSeqStmt(node: AlterSeqStmt, context?: {}): string;
85
- CreateTableAsStmt(node: CreateTableAsStmt, context?: {}): string;
86
- CreateTrigStmt(node: CreateTrigStmt, context?: {}): string;
87
- CreateDomainStmt(node: CreateDomainStmt, context?: {}): string;
88
- CreateStmt(node: CreateStmt, context?: {}): string;
89
- ConstraintStmt(node: any): string;
90
- ReferenceConstraint(node: any, context?: {}): string;
91
- ExclusionConstraint(node: any, context?: {}): string;
92
- Constraint(node: Constraint, context?: {}): string;
93
- AccessPriv(node: AccessPriv): string;
94
- VariableSetStmt(node: VariableSetStmt): string;
95
- VariableShowStmt(node: VariableShowStmt): string;
96
- FuncWithArgs(node: any, context?: {}): string;
97
- FunctionParameter(node: FunctionParameter, context?: {}): string;
98
- CreateFunctionStmt(node: CreateFunctionStmt, context?: {}): string;
99
- CreateSchemaStmt(node: CreateSchemaStmt): string;
100
- RoleSpec(node: RoleSpec): any;
101
- GrantStmt(node: GrantStmt): string;
102
- GrantRoleStmt(node: GrantRoleStmt, context?: {}): string;
103
- CreateRoleStmt(node: CreateRoleStmt, context?: {}): string;
104
- TransactionStmt(node: TransactionStmt, context?: {}): string;
105
- SortBy(node: SortBy, context?: {}): string;
106
- ObjectWithArgs(node: ObjectWithArgs, context?: {}): string;
107
- String(node: TString): string;
108
- SubLink(node: SubLink, context?: {}): string;
109
- TypeCast(node: TypeCast, context?: {}): string;
110
- TypeName(node: TypeName, context?: {}): string;
111
- CaseWhen(node: CaseWhen, context?: {}): string;
112
- WindowDef(node: WindowDef, context?: {}): string;
113
- WithClause(node: WithClause, context?: {}): string;
114
- CopyStmt(node: CopyStmt, context?: {}): string;
115
- CallStmt(node: CallStmt, context?: {}): string;
116
- deparseFrameOptions(options: any, refName: any, startOffset: any, endOffset: any): string;
117
- deparseInterval(node: TypeName): string;
118
- interval(mask: any): any;
119
- }
package/types/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import Deparser from './deparser';
2
- declare const deparse: typeof Deparser.deparse;
3
- export { deparse, Deparser };
@@ -1,4 +0,0 @@
1
- export declare const cleanLines: (sql: any) => any;
2
- export declare const transform: (obj: any, props: any) => any;
3
- export declare const cleanTree: (tree: any) => any;
4
- export declare const cleanTreeWithStmt: (tree: any) => any;