prettier-plugin-sql-cst 0.18.0 → 0.19.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.
Files changed (76) hide show
  1. package/dist/CstToDocMap.d.ts +2 -2
  2. package/dist/CstToDocMap.js +1 -2
  3. package/dist/PrintFn.js +1 -2
  4. package/dist/embed.js +5 -13
  5. package/dist/embedJs.js +28 -84
  6. package/dist/embedJson.js +29 -85
  7. package/dist/embedSql.js +26 -76
  8. package/dist/index.js +28 -34
  9. package/dist/node_utils.d.ts +1 -0
  10. package/dist/node_utils.js +44 -54
  11. package/dist/options.js +1 -4
  12. package/dist/printComment.js +2 -6
  13. package/dist/printSql.js +29 -39
  14. package/dist/print_utils.js +19 -38
  15. package/dist/syntax/alias.js +2 -5
  16. package/dist/syntax/alter_action.js +115 -208
  17. package/dist/syntax/alter_table.js +18 -27
  18. package/dist/syntax/analyze.js +3 -8
  19. package/dist/syntax/base.js +6 -9
  20. package/dist/syntax/cast.js +3 -6
  21. package/dist/syntax/comment.js +53 -122
  22. package/dist/syntax/constraint.d.ts +1 -1
  23. package/dist/syntax/constraint.js +54 -90
  24. package/dist/syntax/create_table.js +49 -87
  25. package/dist/syntax/data_type.js +25 -44
  26. package/dist/syntax/dcl.js +78 -136
  27. package/dist/syntax/delete.js +4 -9
  28. package/dist/syntax/dialects/bigquery.js +70 -116
  29. package/dist/syntax/dialects/mysql.js +2 -5
  30. package/dist/syntax/dialects/postgresql.js +8 -13
  31. package/dist/syntax/dialects/sqlite.js +8 -17
  32. package/dist/syntax/do.js +3 -6
  33. package/dist/syntax/domain.js +10 -19
  34. package/dist/syntax/drop_table.js +10 -15
  35. package/dist/syntax/explain.js +6 -11
  36. package/dist/syntax/expr.js +124 -173
  37. package/dist/syntax/extension.js +12 -21
  38. package/dist/syntax/frame.js +11 -16
  39. package/dist/syntax/function.js +53 -63
  40. package/dist/syntax/index.js +54 -81
  41. package/dist/syntax/insert.js +32 -49
  42. package/dist/syntax/merge.js +25 -30
  43. package/dist/syntax/other_clauses.js +5 -14
  44. package/dist/syntax/parameter.js +13 -26
  45. package/dist/syntax/policy.js +26 -41
  46. package/dist/syntax/prepared_statements.js +23 -43
  47. package/dist/syntax/proc_clause.js +10 -15
  48. package/dist/syntax/procedural_language.js +80 -111
  49. package/dist/syntax/procedure.js +36 -40
  50. package/dist/syntax/program.js +15 -22
  51. package/dist/syntax/publication.js +26 -47
  52. package/dist/syntax/rename_table.js +7 -12
  53. package/dist/syntax/role.js +30 -55
  54. package/dist/syntax/schema.js +17 -35
  55. package/dist/syntax/select.js +157 -226
  56. package/dist/syntax/sequence.js +35 -52
  57. package/dist/syntax/subscription.js +9 -24
  58. package/dist/syntax/transaction.js +18 -33
  59. package/dist/syntax/transformMap.js +99 -63
  60. package/dist/syntax/trigger.js +48 -72
  61. package/dist/syntax/truncate.js +9 -14
  62. package/dist/syntax/type.js +11 -22
  63. package/dist/syntax/unsupported_grammar.js +3 -6
  64. package/dist/syntax/update.js +7 -14
  65. package/dist/syntax/view.js +32 -43
  66. package/dist/transform/addFinalSemicolon.js +5 -9
  67. package/dist/transform/aliasAs.js +4 -8
  68. package/dist/transform/canonicKeywords.js +16 -20
  69. package/dist/transform/canonicOperators.js +8 -12
  70. package/dist/transform/comments.js +10 -31
  71. package/dist/transform/stripTrailingCommas.js +7 -11
  72. package/dist/transform/transformCst.js +13 -17
  73. package/dist/transform/transformUtils.js +2 -6
  74. package/dist/utils.js +9 -30
  75. package/dist/visitAllNodes.js +8 -13
  76. package/package.json +9 -8
@@ -1,135 +1,104 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.proceduralLanguageMap = void 0;
13
- var print_utils_1 = require("../print_utils");
14
- exports.proceduralLanguageMap = {
1
+ import { group, hardline, indent, join, line, stripTrailingHardline, } from "../print_utils";
2
+ export const proceduralLanguageMap = {
15
3
  // BEGIN .. END
16
- block_stmt: function (print, node) {
17
- return (0, print_utils_1.group)([
18
- print.spaced(["beginKw", "atomicKw"]),
19
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
20
- node.exception ? [print_utils_1.hardline, print("exception")] : [],
21
- print_utils_1.hardline,
22
- print("endKw"),
23
- ]);
24
- },
25
- exception_clause: function (print) {
26
- return (0, print_utils_1.group)([
27
- print.spaced(["exceptionKw", "whenKw", "condition", "thenKw"]),
28
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("program"))]),
29
- ]);
30
- },
31
- error_category: function (print) { return print("errorKw"); },
4
+ block_stmt: (print, node) => group([
5
+ print.spaced(["beginKw", "atomicKw"]),
6
+ indent([hardline, stripTrailingHardline(print("program"))]),
7
+ node.exception ? [hardline, print("exception")] : [],
8
+ hardline,
9
+ print("endKw"),
10
+ ]),
11
+ exception_clause: (print) => group([
12
+ print.spaced(["exceptionKw", "whenKw", "condition", "thenKw"]),
13
+ indent([hardline, stripTrailingHardline(print("program"))]),
14
+ ]),
15
+ error_category: (print) => print("errorKw"),
32
16
  // DECLARE
33
- declare_stmt: function (print) {
34
- return (0, print_utils_1.group)((0, print_utils_1.join)(" ", __spreadArray([
35
- print("declareKw"),
36
- (0, print_utils_1.group)(print("names"))
37
- ], print.spaced(["dataType", "default"]), true)));
38
- },
39
- declare_default: function (print) { return print.spaced(["defaultKw", "expr"]); },
17
+ declare_stmt: (print) => group(join(" ", [
18
+ print("declareKw"),
19
+ group(print("names")),
20
+ ...print.spaced(["dataType", "default"]),
21
+ ])),
22
+ declare_default: (print) => print.spaced(["defaultKw", "expr"]),
40
23
  // SET
41
- set_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["setKw", "assignments"])); },
24
+ set_stmt: (print) => group(print.spaced(["setKw", "assignments"])),
42
25
  // IF
43
- if_stmt: function (print) {
44
- return (0, print_utils_1.group)((0, print_utils_1.join)(print_utils_1.hardline, __spreadArray(__spreadArray([], print("clauses"), true), [print.spaced("endIfKw")], false)));
45
- },
46
- if_clause: function (print) { return [
47
- (0, print_utils_1.group)([
26
+ if_stmt: (print) => group(join(hardline, [...print("clauses"), print.spaced("endIfKw")])),
27
+ if_clause: (print) => [
28
+ group([
48
29
  print("ifKw"),
49
- (0, print_utils_1.indent)([print_utils_1.line, print("condition")]),
50
- print_utils_1.line,
30
+ indent([line, print("condition")]),
31
+ line,
51
32
  print("thenKw"),
52
33
  ]),
53
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("consequent"))]),
54
- ]; },
55
- elseif_clause: function (print) { return [
56
- (0, print_utils_1.group)([
34
+ indent([hardline, stripTrailingHardline(print("consequent"))]),
35
+ ],
36
+ elseif_clause: (print) => [
37
+ group([
57
38
  print("elseifKw"),
58
- (0, print_utils_1.indent)([print_utils_1.line, print("condition")]),
59
- print_utils_1.line,
39
+ indent([line, print("condition")]),
40
+ line,
60
41
  print("thenKw"),
61
42
  ]),
62
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("consequent"))]),
63
- ]; },
64
- else_clause: function (print) { return [
43
+ indent([hardline, stripTrailingHardline(print("consequent"))]),
44
+ ],
45
+ else_clause: (print) => [
65
46
  print("elseKw"),
66
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("consequent"))]),
67
- ]; },
47
+ indent([hardline, stripTrailingHardline(print("consequent"))]),
48
+ ],
68
49
  // CASE
69
- case_stmt: function (print) {
70
- return (0, print_utils_1.group)([
71
- print.spaced(["caseKw", "expr"]),
72
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("clauses"))]),
73
- print_utils_1.hardline,
74
- print.spaced("endCaseKw"),
75
- ]);
76
- },
50
+ case_stmt: (print) => group([
51
+ print.spaced(["caseKw", "expr"]),
52
+ indent([hardline, join(hardline, print("clauses"))]),
53
+ hardline,
54
+ print.spaced("endCaseKw"),
55
+ ]),
77
56
  // LOOP
78
- loop_stmt: function (print) {
79
- return (0, print_utils_1.group)([
80
- print("loopKw"),
81
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
82
- print_utils_1.hardline,
83
- print.spaced("endLoopKw"),
84
- ]);
85
- },
57
+ loop_stmt: (print) => group([
58
+ print("loopKw"),
59
+ indent([hardline, stripTrailingHardline(print("body"))]),
60
+ hardline,
61
+ print.spaced("endLoopKw"),
62
+ ]),
86
63
  // REPEAT
87
- repeat_stmt: function (print) {
88
- return (0, print_utils_1.group)([
89
- print("repeatKw"),
90
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
91
- print_utils_1.hardline,
92
- print.spaced(["untilKw", "condition", "endRepeatKw"]),
93
- ]);
94
- },
64
+ repeat_stmt: (print) => group([
65
+ print("repeatKw"),
66
+ indent([hardline, stripTrailingHardline(print("body"))]),
67
+ hardline,
68
+ print.spaced(["untilKw", "condition", "endRepeatKw"]),
69
+ ]),
95
70
  // WHILE
96
- while_stmt: function (print) {
97
- return (0, print_utils_1.group)([
98
- print.spaced(["whileKw", "condition", "doKw"]),
99
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
100
- print_utils_1.hardline,
101
- print.spaced("endWhileKw"),
102
- ]);
103
- },
71
+ while_stmt: (print) => group([
72
+ print.spaced(["whileKw", "condition", "doKw"]),
73
+ indent([hardline, stripTrailingHardline(print("body"))]),
74
+ hardline,
75
+ print.spaced("endWhileKw"),
76
+ ]),
104
77
  // FOR .. IN
105
- for_stmt: function (print) {
106
- return (0, print_utils_1.group)([
107
- print.spaced(["forKw", "left", "inKw", "right", "doKw"]),
108
- (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.stripTrailingHardline)(print("body"))]),
109
- print_utils_1.hardline,
110
- print.spaced("endForKw"),
111
- ]);
112
- },
78
+ for_stmt: (print) => group([
79
+ print.spaced(["forKw", "left", "inKw", "right", "doKw"]),
80
+ indent([hardline, stripTrailingHardline(print("body"))]),
81
+ hardline,
82
+ print.spaced("endForKw"),
83
+ ]),
113
84
  // BREAK/CONTINUE
114
- break_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["breakKw", "label"])); },
115
- continue_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["continueKw", "label"])); },
116
- labeled_stmt: function (print, node) {
117
- return (0, print_utils_1.group)([
118
- print("beginLabel"),
119
- ": ",
120
- print("statement"),
121
- node.endLabel ? [" ", print(["endLabel"])] : [],
122
- ]);
123
- },
85
+ break_stmt: (print) => group(print.spaced(["breakKw", "label"])),
86
+ continue_stmt: (print) => group(print.spaced(["continueKw", "label"])),
87
+ labeled_stmt: (print, node) => group([
88
+ print("beginLabel"),
89
+ ": ",
90
+ print("statement"),
91
+ node.endLabel ? [" ", print(["endLabel"])] : [],
92
+ ]),
124
93
  // CALL
125
- call_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["callKw", "func"])); },
94
+ call_stmt: (print) => group(print.spaced(["callKw", "func"])),
126
95
  // RETURN
127
- return_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["returnKw", "expr"])); },
96
+ return_stmt: (print) => group(print.spaced(["returnKw", "expr"])),
128
97
  // RAISE
129
- raise_stmt: function (print) { return (0, print_utils_1.group)(print.spaced(["raiseKw", "message"])); },
130
- raise_message: function (print) { return [
98
+ raise_stmt: (print) => group(print.spaced(["raiseKw", "message"])),
99
+ raise_message: (print) => [
131
100
  print.spaced("usingMessageKw"),
132
101
  " = ",
133
102
  print("string"),
134
- ]; },
103
+ ],
135
104
  };
@@ -1,42 +1,38 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.procedureMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- var function_1 = require("./function");
6
- exports.procedureMap = {
7
- create_procedure_stmt: function (print, node) {
8
- return (0, print_utils_1.group)([
9
- print.spaced([
10
- "createKw",
11
- "orReplaceKw",
12
- "procedureKw",
13
- "ifNotExistsKw",
14
- "name",
15
- ]),
16
- print("params"),
17
- (0, function_1.hasOnlyAsClause)(node)
18
- ? [" ", (0, print_utils_1.group)(print("clauses"))]
19
- : [
20
- print_utils_1.hardline,
21
- (0, print_utils_1.join)(print_utils_1.hardline, print("clauses").map(function (clause) { return (0, print_utils_1.group)(clause); })),
22
- ],
23
- ]);
24
- },
25
- drop_procedure_stmt: function (print) {
26
- return (0, print_utils_1.group)([
27
- print.spaced(["dropKw", "procedureKw", "ifExistsKw", "name"]),
28
- print.spaced(["params", "behaviorKw"]),
29
- ]);
30
- },
1
+ import { group, hardline, join } from "../print_utils";
2
+ import { hasOnlyAsClause } from "./function";
3
+ export const procedureMap = {
4
+ create_procedure_stmt: (print, node) => group([
5
+ print.spaced([
6
+ "createKw",
7
+ "orReplaceKw",
8
+ "procedureKw",
9
+ "ifNotExistsKw",
10
+ "name",
11
+ ]),
12
+ print("params"),
13
+ hasOnlyAsClause(node)
14
+ ? [" ", group(print("clauses"))]
15
+ : [
16
+ hardline,
17
+ join(hardline, print("clauses").map((clause) => group(clause))),
18
+ ],
19
+ ]),
20
+ drop_procedure_stmt: (print) => group([
21
+ print.spaced([
22
+ "dropKw",
23
+ "procedureKw",
24
+ "ifExistsKw",
25
+ "signatures",
26
+ "behaviorKw",
27
+ ]),
28
+ ]),
31
29
  // almost exact copy of alter_function_stmt
32
- alter_procedure_stmt: function (print, node) {
33
- return (0, print_utils_1.group)([
34
- print.spaced(["alterKw", "procedureKw"]),
35
- " ",
36
- print(["name", "params"]),
37
- print.dynamicLine(),
38
- (0, print_utils_1.join)(print.dynamicLine(), print("actions")),
39
- node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : [],
40
- ]);
41
- },
30
+ alter_procedure_stmt: (print, node) => group([
31
+ print.spaced(["alterKw", "procedureKw"]),
32
+ " ",
33
+ print(["signature"]),
34
+ print.dynamicLine(),
35
+ join(print.dynamicLine(), print("actions")),
36
+ node.behaviorKw ? [print.dynamicLine(), print("behaviorKw")] : [],
37
+ ]),
42
38
  };
@@ -1,36 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.programMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.programMap = {
6
- program: function (print, node, path, options) {
7
- return print("statements").map(function (doc, i) {
8
- return i === node.statements.length - 1
9
- ? printFinalStatement(doc, i, node.statements, options)
10
- : printStatement(doc, i, node.statements, options);
11
- });
12
- },
1
+ import { hardline, hasEmptyLineBetweenNodes } from "../print_utils";
2
+ export const programMap = {
3
+ program: (print, node, path, options) => print("statements").map((doc, i) => i === node.statements.length - 1
4
+ ? printFinalStatement(doc, i, node.statements, options)
5
+ : printStatement(doc, i, node.statements, options)),
13
6
  };
14
- var printStatement = function (doc, i, statements, options) {
15
- var prevNode = statements[i - 1];
16
- var node = statements[i];
7
+ const printStatement = (doc, i, statements, options) => {
8
+ const prevNode = statements[i - 1];
9
+ const node = statements[i];
17
10
  if (i === 0) {
18
11
  return doc;
19
12
  }
20
13
  else if (node.type !== "empty") {
21
- if ((0, print_utils_1.hasEmptyLineBetweenNodes)(prevNode, node, options)) {
22
- return [";", print_utils_1.hardline, print_utils_1.hardline, doc];
14
+ if (hasEmptyLineBetweenNodes(prevNode, node, options)) {
15
+ return [";", hardline, hardline, doc];
23
16
  }
24
17
  else {
25
- return [";", print_utils_1.hardline, doc];
18
+ return [";", hardline, doc];
26
19
  }
27
20
  }
28
21
  else {
29
- return [";", print_utils_1.hardline, doc];
22
+ return [";", hardline, doc];
30
23
  }
31
24
  };
32
- var printFinalStatement = function (doc, i, statements, options) {
33
- var stmtDoc = printStatement(doc, i, statements, options);
25
+ const printFinalStatement = (doc, i, statements, options) => {
26
+ const stmtDoc = printStatement(doc, i, statements, options);
34
27
  if (statements[i].type === "empty") {
35
28
  // When the final statement is an empty statement,
36
29
  // this means we have inserted a semicolon and newline before it.
@@ -41,6 +34,6 @@ var printFinalStatement = function (doc, i, statements, options) {
41
34
  // If the last statement is not empty,
42
35
  // this means sqlFinalSemicolon option is false,
43
36
  // so we need to add an empty line after it.
44
- return [stmtDoc, print_utils_1.hardline];
37
+ return [stmtDoc, hardline];
45
38
  }
46
39
  };
@@ -1,48 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.publicationMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.publicationMap = {
6
- create_publication_stmt: function (print, node) {
7
- return (0, print_utils_1.group)([
8
- print.spaced(["createPublicationKw", "name"]),
9
- print("clauses").map(function (printedClause, i) {
10
- if (node.clauses[i].type === "for_publication_objects_clause") {
11
- return [" ", printedClause];
12
- }
13
- else {
14
- return [print_utils_1.line, printedClause];
15
- }
16
- }),
17
- ]);
18
- },
19
- for_publication_objects_clause: function (print) {
20
- return (0, print_utils_1.group)([print("forKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
21
- },
22
- all_publication_object: function (print) { return (0, print_utils_1.group)(print.spaced(["allKw", "typesKw"])); },
23
- publication_object_table: function (print) {
24
- return (0, print_utils_1.group)(print.spaced(["tableKw", "table", "columns", "where"]));
25
- },
26
- publication_object_tables_in_schema: function (print) {
27
- return (0, print_utils_1.group)(print.spaced(["tablesInSchemaKw", "schema"]));
28
- },
29
- alter_publication_stmt: function (print) {
30
- return (0, print_utils_1.group)([
31
- print.spaced(["alterPublicationKw", "name"]),
32
- print.dynamicLine(),
33
- print("action"),
34
- ]);
35
- },
36
- alter_action_add_publication_objects: function (print) {
37
- return (0, print_utils_1.group)([print("addKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
38
- },
39
- alter_action_set_publication_objects: function (print) {
40
- return (0, print_utils_1.group)([print("setKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
41
- },
42
- alter_action_drop_publication_objects: function (print) {
43
- return (0, print_utils_1.group)([print("dropKw"), (0, print_utils_1.indent)([print_utils_1.line, print("publicationObjects")])]);
44
- },
45
- drop_publication_stmt: function (print) {
46
- return (0, print_utils_1.group)(print.spaced(["dropPublicationKw", "ifExistsKw", "names", "behaviorKw"]));
47
- },
1
+ import { group, indent, line } from "../print_utils";
2
+ export const publicationMap = {
3
+ create_publication_stmt: (print, node) => group([
4
+ print.spaced(["createPublicationKw", "name"]),
5
+ print("clauses").map((printedClause, i) => {
6
+ if (node.clauses[i].type === "for_publication_objects_clause") {
7
+ return [" ", printedClause];
8
+ }
9
+ else {
10
+ return [line, printedClause];
11
+ }
12
+ }),
13
+ ]),
14
+ for_publication_objects_clause: (print) => group([print("forKw"), indent([line, print("publicationObjects")])]),
15
+ all_publication_object: (print) => group(print.spaced(["allKw", "typesKw"])),
16
+ publication_object_table: (print) => group(print.spaced(["tableKw", "table", "columns", "where"])),
17
+ publication_object_tables_in_schema: (print) => group(print.spaced(["tablesInSchemaKw", "schema"])),
18
+ alter_publication_stmt: (print) => group([
19
+ print.spaced(["alterPublicationKw", "name"]),
20
+ print.dynamicLine(),
21
+ print("action"),
22
+ ]),
23
+ alter_action_add_publication_objects: (print) => group([print("addKw"), indent([line, print("publicationObjects")])]),
24
+ alter_action_set_publication_objects: (print) => group([print("setKw"), indent([line, print("publicationObjects")])]),
25
+ alter_action_drop_publication_objects: (print) => group([print("dropKw"), indent([line, print("publicationObjects")])]),
26
+ drop_publication_stmt: (print) => group(print.spaced(["dropPublicationKw", "ifExistsKw", "names", "behaviorKw"])),
48
27
  };
@@ -1,13 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameTableMap = void 0;
4
- var print_utils_1 = require("../print_utils");
5
- exports.renameTableMap = {
6
- rename_table_stmt: function (print) {
7
- return (0, print_utils_1.group)([
8
- print.spaced(["renameKw", "tableKw"]),
9
- (0, print_utils_1.indent)([print_utils_1.line, print("actions")]),
10
- ]);
11
- },
12
- rename_action: function (print) { return print.spaced(["from", "toKw", "to"]); },
1
+ import { group, indent, line } from "../print_utils";
2
+ export const renameTableMap = {
3
+ rename_table_stmt: (print) => group([
4
+ print.spaced(["renameKw", "tableKw"]),
5
+ indent([line, print("actions")]),
6
+ ]),
7
+ rename_action: (print) => print.spaced(["from", "toKw", "to"]),
13
8
  };
@@ -1,56 +1,31 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.roleMap = void 0;
13
- var print_utils_1 = require("../print_utils");
14
- exports.roleMap = {
15
- create_role_stmt: function (print, node) {
16
- var _a;
17
- return (0, print_utils_1.group)(__spreadArray([
18
- print.spaced(["createRoleKw", "name", "withKw"])
19
- ], (((_a = node.options) === null || _a === void 0 ? void 0 : _a.length)
20
- ? [(0, print_utils_1.indent)([print_utils_1.line, (0, print_utils_1.join)(print.dynamicLine(), print("options"))])]
21
- : []), true));
22
- },
23
- alter_role_stmt: function (print, node) {
24
- return (0, print_utils_1.group)([
25
- (0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
26
- (0, print_utils_1.group)([print.spaced("alterRoleKw"), (0, print_utils_1.indent)([print_utils_1.line, print("name")])])
27
- ], (node.database ? print(["database"]) : []), true)),
28
- node.action.type === "alter_action_with_role_options" &&
29
- !node.action.withKw
30
- ? (0, print_utils_1.indent)([print.dynamicLine(), print("action")])
31
- : [print.dynamicLine(), print("action")],
32
- ]);
33
- },
34
- drop_role_stmt: function (print) {
35
- return (0, print_utils_1.group)(print.spaced(["dropRoleKw", "ifExistsKw", "names"]));
36
- },
37
- set_role_stmt: function (print) {
38
- return (0, print_utils_1.group)(print.spaced(["setKw", "scopeKw", "roleKw", "name"]));
39
- },
40
- reset_role_stmt: function (print) { return (0, print_utils_1.group)(print.spaced("resetRoleKw")); },
41
- role_option_keyword: function (print) { return print("kw"); },
42
- role_option_connection_limit: function (print) {
43
- return (0, print_utils_1.group)(print.spaced(["connectionLimitKw", "limit"]));
44
- },
45
- role_option_password: function (print) {
46
- return (0, print_utils_1.group)(print.spaced(["encryptedKw", "passwordKw", "password"]));
47
- },
48
- role_option_valid_until: function (print) {
49
- return (0, print_utils_1.group)(print.spaced(["validUntilKw", "timestamp"]));
50
- },
51
- role_option_in_role: function (print) { return (0, print_utils_1.group)(print.spaced(["inRoleKw", "names"])); },
52
- role_option_role: function (print) { return (0, print_utils_1.group)(print.spaced(["roleKw", "names"])); },
53
- role_option_admin: function (print) { return (0, print_utils_1.group)(print.spaced(["adminKw", "names"])); },
54
- role_option_sysid: function (print) { return (0, print_utils_1.group)(print.spaced(["sysIdKw", "sysId"])); },
55
- in_database_clause: function (print) { return (0, print_utils_1.group)(print.spaced(["inDatabaseKw", "name"])); },
1
+ import { group, indent, join, line } from "../print_utils";
2
+ export const roleMap = {
3
+ create_role_stmt: (print, node) => group([
4
+ print.spaced(["createRoleKw", "name", "withKw"]),
5
+ ...(node.options?.length
6
+ ? [indent([line, join(print.dynamicLine(), print("options"))])]
7
+ : []),
8
+ ]),
9
+ alter_role_stmt: (print, node) => group([
10
+ join(print.dynamicLine(), [
11
+ group([print.spaced("alterRoleKw"), indent([line, print("name")])]),
12
+ ...(node.database ? print(["database"]) : []),
13
+ ]),
14
+ node.action.type === "alter_action_with_role_options" &&
15
+ !node.action.withKw
16
+ ? indent([print.dynamicLine(), print("action")])
17
+ : [print.dynamicLine(), print("action")],
18
+ ]),
19
+ drop_role_stmt: (print) => group(print.spaced(["dropRoleKw", "ifExistsKw", "names"])),
20
+ set_role_stmt: (print) => group(print.spaced(["setKw", "scopeKw", "roleKw", "name"])),
21
+ reset_role_stmt: (print) => group(print.spaced("resetRoleKw")),
22
+ role_option_keyword: (print) => print("kw"),
23
+ role_option_connection_limit: (print) => group(print.spaced(["connectionLimitKw", "limit"])),
24
+ role_option_password: (print) => group(print.spaced(["encryptedKw", "passwordKw", "password"])),
25
+ role_option_valid_until: (print) => group(print.spaced(["validUntilKw", "timestamp"])),
26
+ role_option_in_role: (print) => group(print.spaced(["inRoleKw", "names"])),
27
+ role_option_role: (print) => group(print.spaced(["roleKw", "names"])),
28
+ role_option_admin: (print) => group(print.spaced(["adminKw", "names"])),
29
+ role_option_sysid: (print) => group(print.spaced(["sysIdKw", "sysId"])),
30
+ in_database_clause: (print) => group(print.spaced(["inDatabaseKw", "name"])),
56
31
  };
@@ -1,36 +1,18 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.schemaMap = void 0;
13
- var print_utils_1 = require("../print_utils");
14
- exports.schemaMap = {
15
- create_schema_stmt: function (print, node) {
16
- return (0, print_utils_1.group)([
17
- (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
18
- print.spaced(["createSchemaKw", "ifNotExistsKw", "name"])
19
- ], print("clauses"), true))),
20
- node.statements.length > 0
21
- ? (0, print_utils_1.indent)([print_utils_1.hardline, (0, print_utils_1.join)(print_utils_1.hardline, print("statements"))])
22
- : [],
23
- ]);
24
- },
25
- create_schema_authorization_clause: function (print) {
26
- return print.spaced(["authorizationKw", "role"]);
27
- },
28
- drop_schema_stmt: function (print) {
29
- return (0, print_utils_1.group)(print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"]));
30
- },
31
- alter_schema_stmt: function (print) {
32
- return (0, print_utils_1.group)((0, print_utils_1.join)(print.dynamicLine(), __spreadArray([
33
- print.spaced(["alterSchemaKw", "ifExistsKw", "name"])
34
- ], print("actions"), true)));
35
- },
1
+ import { group, hardline, indent, join } from "../print_utils";
2
+ export const schemaMap = {
3
+ create_schema_stmt: (print, node) => group([
4
+ group(join(print.dynamicLine(), [
5
+ print.spaced(["createSchemaKw", "ifNotExistsKw", "name"]),
6
+ ...print("clauses"),
7
+ ])),
8
+ node.statements.length > 0
9
+ ? indent([hardline, join(hardline, print("statements"))])
10
+ : [],
11
+ ]),
12
+ create_schema_authorization_clause: (print) => print.spaced(["authorizationKw", "role"]),
13
+ drop_schema_stmt: (print) => group(print.spaced(["dropSchemaKw", "ifExistsKw", "schemas", "behaviorKw"])),
14
+ alter_schema_stmt: (print) => group(join(print.dynamicLine(), [
15
+ print.spaced(["alterSchemaKw", "ifExistsKw", "name"]),
16
+ ...print("actions"),
17
+ ])),
36
18
  };