neonctl 2.37.1 → 2.38.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 (159) hide show
  1. package/README.md +15 -700
  2. package/bin/cli.js +3 -0
  3. package/package.json +8 -75
  4. package/dist/analytics.js +0 -168
  5. package/dist/api.js +0 -720
  6. package/dist/auth.js +0 -125
  7. package/dist/callback.html +0 -60
  8. package/dist/cli.js +0 -9
  9. package/dist/commands/api.js +0 -278
  10. package/dist/commands/auth.js +0 -214
  11. package/dist/commands/bootstrap.js +0 -481
  12. package/dist/commands/branches.js +0 -488
  13. package/dist/commands/bucket.js +0 -549
  14. package/dist/commands/checkout.js +0 -321
  15. package/dist/commands/config.js +0 -626
  16. package/dist/commands/connection_string.js +0 -172
  17. package/dist/commands/data_api.js +0 -284
  18. package/dist/commands/databases.js +0 -82
  19. package/dist/commands/deploy.js +0 -26
  20. package/dist/commands/dev.js +0 -698
  21. package/dist/commands/diff.js +0 -222
  22. package/dist/commands/env.js +0 -189
  23. package/dist/commands/functions.js +0 -373
  24. package/dist/commands/index.js +0 -62
  25. package/dist/commands/init.js +0 -73
  26. package/dist/commands/inspect.js +0 -65
  27. package/dist/commands/ip_allow.js +0 -137
  28. package/dist/commands/link.js +0 -1121
  29. package/dist/commands/neon_auth.js +0 -1028
  30. package/dist/commands/operations.js +0 -28
  31. package/dist/commands/orgs.js +0 -24
  32. package/dist/commands/projects.js +0 -413
  33. package/dist/commands/psql.js +0 -62
  34. package/dist/commands/roles.js +0 -65
  35. package/dist/commands/schema_diff.js +0 -151
  36. package/dist/commands/set_context.js +0 -29
  37. package/dist/commands/snapshots.js +0 -455
  38. package/dist/commands/status.js +0 -40
  39. package/dist/commands/user.js +0 -15
  40. package/dist/commands/vpc_endpoints.js +0 -134
  41. package/dist/config.js +0 -11
  42. package/dist/config_format.js +0 -72
  43. package/dist/context.js +0 -231
  44. package/dist/current_branch_fast_path.js +0 -55
  45. package/dist/dev/env.js +0 -244
  46. package/dist/dev/functions.js +0 -70
  47. package/dist/dev/inputs.js +0 -63
  48. package/dist/dev/runtime.js +0 -146
  49. package/dist/env.js +0 -36
  50. package/dist/env_file.js +0 -159
  51. package/dist/errors.js +0 -80
  52. package/dist/functions_api.js +0 -48
  53. package/dist/help.js +0 -146
  54. package/dist/index.js +0 -240
  55. package/dist/log.js +0 -18
  56. package/dist/parameters.gen.js +0 -480
  57. package/dist/pkg.js +0 -25
  58. package/dist/psql/cli.js +0 -53
  59. package/dist/psql/command/cmd_cond.js +0 -437
  60. package/dist/psql/command/cmd_connect.js +0 -820
  61. package/dist/psql/command/cmd_copy.js +0 -1035
  62. package/dist/psql/command/cmd_describe.js +0 -1815
  63. package/dist/psql/command/cmd_format.js +0 -948
  64. package/dist/psql/command/cmd_io.js +0 -2193
  65. package/dist/psql/command/cmd_lo.js +0 -393
  66. package/dist/psql/command/cmd_meta.js +0 -969
  67. package/dist/psql/command/cmd_misc.js +0 -187
  68. package/dist/psql/command/cmd_pipeline.js +0 -1148
  69. package/dist/psql/command/cmd_restrict.js +0 -171
  70. package/dist/psql/command/cmd_show.js +0 -766
  71. package/dist/psql/command/dispatch.js +0 -343
  72. package/dist/psql/command/inputQueue.js +0 -42
  73. package/dist/psql/command/shared.js +0 -71
  74. package/dist/psql/complete/filenames.js +0 -139
  75. package/dist/psql/complete/index.js +0 -104
  76. package/dist/psql/complete/matcher.js +0 -315
  77. package/dist/psql/complete/psqlVars.js +0 -249
  78. package/dist/psql/complete/queries.js +0 -493
  79. package/dist/psql/complete/rules.js +0 -2424
  80. package/dist/psql/core/common.js +0 -1253
  81. package/dist/psql/core/help.js +0 -576
  82. package/dist/psql/core/mainloop.js +0 -1360
  83. package/dist/psql/core/prompt.js +0 -439
  84. package/dist/psql/core/settings.js +0 -686
  85. package/dist/psql/core/sqlHelp.js +0 -1066
  86. package/dist/psql/core/startup.js +0 -846
  87. package/dist/psql/core/syncVars.js +0 -116
  88. package/dist/psql/core/variables.js +0 -287
  89. package/dist/psql/describe/formatters.js +0 -1330
  90. package/dist/psql/describe/processNamePattern.js +0 -270
  91. package/dist/psql/describe/queries.js +0 -2452
  92. package/dist/psql/describe/versionGate.js +0 -44
  93. package/dist/psql/index.js +0 -2030
  94. package/dist/psql/io/history.js +0 -299
  95. package/dist/psql/io/input.js +0 -120
  96. package/dist/psql/io/lineEditor/buffer.js +0 -325
  97. package/dist/psql/io/lineEditor/complete.js +0 -227
  98. package/dist/psql/io/lineEditor/filename.js +0 -159
  99. package/dist/psql/io/lineEditor/index.js +0 -893
  100. package/dist/psql/io/lineEditor/keymap.js +0 -745
  101. package/dist/psql/io/lineEditor/vt100.js +0 -363
  102. package/dist/psql/io/pgpass.js +0 -202
  103. package/dist/psql/io/pgservice.js +0 -194
  104. package/dist/psql/io/psqlrc.js +0 -422
  105. package/dist/psql/print/aligned.js +0 -1748
  106. package/dist/psql/print/asciidoc.js +0 -230
  107. package/dist/psql/print/crosstab.js +0 -463
  108. package/dist/psql/print/csv.js +0 -76
  109. package/dist/psql/print/html.js +0 -240
  110. package/dist/psql/print/json.js +0 -96
  111. package/dist/psql/print/latex.js +0 -379
  112. package/dist/psql/print/pager.js +0 -267
  113. package/dist/psql/print/troff.js +0 -240
  114. package/dist/psql/print/unaligned.js +0 -99
  115. package/dist/psql/print/units.js +0 -188
  116. package/dist/psql/scanner/slash.js +0 -515
  117. package/dist/psql/scanner/sql.js +0 -914
  118. package/dist/psql/scanner/stringutils.js +0 -394
  119. package/dist/psql/types/backslash.js +0 -1
  120. package/dist/psql/types/connection.js +0 -1
  121. package/dist/psql/types/index.js +0 -7
  122. package/dist/psql/types/printer.js +0 -1
  123. package/dist/psql/types/repl.js +0 -1
  124. package/dist/psql/types/scanner.js +0 -24
  125. package/dist/psql/types/settings.js +0 -1
  126. package/dist/psql/types/variables.js +0 -1
  127. package/dist/psql/wire/connection.js +0 -2857
  128. package/dist/psql/wire/copy.js +0 -108
  129. package/dist/psql/wire/notify.js +0 -59
  130. package/dist/psql/wire/pipeline.js +0 -521
  131. package/dist/psql/wire/protocol.js +0 -466
  132. package/dist/psql/wire/sasl.js +0 -294
  133. package/dist/psql/wire/tls.js +0 -602
  134. package/dist/storage_api.js +0 -147
  135. package/dist/test_utils/fixtures.js +0 -121
  136. package/dist/test_utils/oauth_server.js +0 -9
  137. package/dist/types.js +0 -1
  138. package/dist/utils/ai_gateway_notice.js +0 -180
  139. package/dist/utils/api_enums.js +0 -33
  140. package/dist/utils/auth.js +0 -5
  141. package/dist/utils/branch_notice.js +0 -22
  142. package/dist/utils/branch_picker.js +0 -103
  143. package/dist/utils/compute_units.js +0 -28
  144. package/dist/utils/config_diff.js +0 -185
  145. package/dist/utils/enrichers.js +0 -161
  146. package/dist/utils/esbuild.js +0 -158
  147. package/dist/utils/formats.js +0 -18
  148. package/dist/utils/git_diff.js +0 -90
  149. package/dist/utils/inspect_db.js +0 -153
  150. package/dist/utils/inspect_queries.js +0 -372
  151. package/dist/utils/middlewares.js +0 -20
  152. package/dist/utils/openapi.js +0 -114
  153. package/dist/utils/package_manager.js +0 -68
  154. package/dist/utils/point_in_time.js +0 -56
  155. package/dist/utils/psql.js +0 -120
  156. package/dist/utils/string.js +0 -5
  157. package/dist/utils/ui.js +0 -59
  158. package/dist/utils/zip.js +0 -4
  159. package/dist/writer.js +0 -97
@@ -1,104 +0,0 @@
1
- /**
2
- * Public entrypoint for psql tab completion.
3
- *
4
- * The `LineEditor` (WP-24) accepts a `Completer` of shape
5
- * `(input, cursor) => Promise<CompletionResult>`. We return a CURRIED
6
- * factory `psqlCompleter(ctx)` that captures the settings reference so the
7
- * completer can read `ctx.settings.db` lazily on every call — important
8
- * because `\c` swaps out the live connection.
9
- *
10
- * `CompletionResult` (defined in lineEditor/complete.ts):
11
- *
12
- * - candidates: string[] the list shown / inserted
13
- * - commonPrefix: string longest prefix the editor can insert without
14
- * making a choice (`apply` walks this)
15
- * - replaceLength: number code-points to chop off the buffer before
16
- * inserting `candidates[i]` / commonPrefix
17
- *
18
- * Our `findCompletions` returns raw candidate strings; we compute the common
19
- * prefix here. `replaceLength` is the code-point length of the partial word
20
- * the cursor was sitting on (`currentWord`), which we already compute in
21
- * `splitForCompletion` during tokenization.
22
- */
23
- import { splitForCompletion } from "./matcher.js";
24
- import { findCompletions } from "./rules.js";
25
- /**
26
- * Build a completer bound to the given settings. The settings reference is
27
- * captured by closure; we never snapshot, so changes to `settings.db` (via
28
- * `\c`) take effect immediately.
29
- */
30
- export const psqlCompleter = (ctx) => {
31
- const completer = async (input, cursor) => {
32
- const { prevWords, currentWord, replaceLength } = splitForCompletion(input, cursor);
33
- const ruleCtx = {
34
- settings: ctx.settings,
35
- queryBuf: ctx.getQueryBuf?.() ?? "",
36
- };
37
- const { candidates } = await findCompletions(prevWords, currentWord, ruleCtx);
38
- // De-duplicate while preserving order.
39
- const seen = new Set();
40
- const deduped = [];
41
- for (const c of candidates) {
42
- if (!seen.has(c)) {
43
- seen.add(c);
44
- deduped.push(c);
45
- }
46
- }
47
- // Stable sort so the listing is predictable. The first-character sort
48
- // key uses lowercase so case-mixed candidate lists don't look chaotic.
49
- deduped.sort((a, b) => {
50
- const la = a.toLowerCase();
51
- const lb = b.toLowerCase();
52
- if (la < lb)
53
- return -1;
54
- if (la > lb)
55
- return 1;
56
- return 0;
57
- });
58
- const commonPrefix = longestCommonPrefix(deduped, currentWord);
59
- return {
60
- candidates: deduped,
61
- commonPrefix,
62
- replaceLength,
63
- };
64
- };
65
- return completer;
66
- };
67
- // ---------------------------------------------------------------------------
68
- // Helpers.
69
- // ---------------------------------------------------------------------------
70
- /**
71
- * Return the longest common prefix of all candidates, but never shorter
72
- * than the user's partial input (so we don't backtrack the buffer when the
73
- * completion is a no-op).
74
- *
75
- * If there's a single candidate, returns it whole.
76
- */
77
- const longestCommonPrefix = (candidates, fallback) => {
78
- if (candidates.length === 0)
79
- return fallback;
80
- if (candidates.length === 1)
81
- return candidates[0];
82
- // Use code-point iteration so multi-byte characters don't get cut.
83
- const arrs = candidates.map((c) => Array.from(c));
84
- const minLen = arrs.reduce((m, a) => Math.min(m, a.length), Infinity);
85
- const out = [];
86
- for (let i = 0; i < minLen; i++) {
87
- const first = arrs[0][i];
88
- let ok = true;
89
- for (let j = 1; j < arrs.length; j++) {
90
- if (arrs[j][i] !== first) {
91
- ok = false;
92
- break;
93
- }
94
- }
95
- if (!ok)
96
- break;
97
- out.push(first);
98
- }
99
- // Common prefix should not be shorter than what's already typed.
100
- const candidatePrefix = out.join("");
101
- if (candidatePrefix.length >= fallback.length)
102
- return candidatePrefix;
103
- return fallback;
104
- };
@@ -1,315 +0,0 @@
1
- /**
2
- * Matches / TailMatches / HeadMatches DSL.
3
- *
4
- * TypeScript port of the pattern-matching helpers in psql's tab-complete.in.c.
5
- * The C source uses a varargs macro layered on top of `word_matches()` to
6
- * decide whether a sequence of "previous words" matches a pattern. We
7
- * reproduce the same shape with plain functions because (a) JS has no
8
- * preprocessor macros and (b) array spread is the natural varargs analogue.
9
- *
10
- * Matches('SELECT', MatchAny, 'FROM') — exact word-count match.
11
- * TailMatches('SELECT', MatchAny, 'FROM') — match the last N words.
12
- * HeadMatches('ALTER', 'TABLE') — match the first N words.
13
- *
14
- * Wildcards and special tokens (mirroring the upstream constants):
15
- *
16
- * MatchAny — any single word (`NULL` upstream).
17
- * MatchAnyExcept(x) — any word that doesn't match `x` (upstream `"!x"`).
18
- * '*' inside a pattern — wildcard within a single word (e.g. `'pg_*'`).
19
- * '|' inside a pattern — alternation (e.g. `'TABLE|VIEW'`).
20
- *
21
- * Comparisons are case-insensitive by default (SQL keywords); pass
22
- * `caseSensitive: true` to the DSL helpers when matching strictly.
23
- *
24
- * The tokenizer is exported separately because the `index.ts` entry point
25
- * needs to do the same word-split-then-match dance.
26
- */
27
- export const MatchAny = null;
28
- export const MatchAnyExcept = (pattern) => "!" + pattern;
29
- const cimatch = (s1, s2, n, caseSensitive) => {
30
- if (s1.length < n || s2.length < n)
31
- return false;
32
- const a = s1.slice(0, n);
33
- const b = s2.slice(0, n);
34
- if (caseSensitive)
35
- return a === b;
36
- return a.toLowerCase() === b.toLowerCase();
37
- };
38
- /**
39
- * Return true iff `word` matches `pattern`. `null`/`MatchAny` matches
40
- * everything. A leading `!` inverts the match. `|` separates alternatives.
41
- * `*` is a single-word wildcard.
42
- */
43
- export const wordMatches = (pattern, word, caseSensitive = false) => {
44
- if (pattern === null)
45
- return true;
46
- if (pattern.startsWith("!")) {
47
- return !wordMatches(pattern.slice(1), word, caseSensitive);
48
- }
49
- const wordlen = word.length;
50
- let cursor = pattern;
51
- for (;;) {
52
- let starIdx = -1;
53
- let i = 0;
54
- while (i < cursor.length && cursor[i] !== "|") {
55
- if (cursor[i] === "*")
56
- starIdx = i;
57
- i++;
58
- }
59
- if (starIdx >= 0) {
60
- const beforeLen = starIdx;
61
- const afterLen = i - starIdx - 1;
62
- if (wordlen >= beforeLen + afterLen &&
63
- cimatch(word, cursor, beforeLen, caseSensitive) &&
64
- cimatch(word.slice(wordlen - afterLen), cursor.slice(starIdx + 1), afterLen, caseSensitive)) {
65
- return true;
66
- }
67
- }
68
- else {
69
- if (wordlen === i &&
70
- cimatch(word, cursor, wordlen, caseSensitive)) {
71
- return true;
72
- }
73
- }
74
- if (i >= cursor.length)
75
- break;
76
- cursor = cursor.slice(i + 1);
77
- }
78
- return false;
79
- };
80
- /**
81
- * Exact-length match: every word in `words` must match the corresponding
82
- * pattern. `words` here is "previous words" — i.e. the words BEFORE the
83
- * current (in-progress) word.
84
- *
85
- * The upstream uses `previous_words_count + 1 == narg` because the C array
86
- * includes both prev words AND the current. Our representation only stores
87
- * prev words; the caller passes the in-progress word separately.
88
- *
89
- * prev = ['SELECT'], pattern = ['SELECT'] → true (1 == 1)
90
- * prev = ['SELECT', 'a'], pattern = ['SELECT'] → false (2 != 1)
91
- */
92
- export const Matches = (prev, patterns, caseSensitive = false) => {
93
- if (prev.length !== patterns.length)
94
- return false;
95
- for (let k = 0; k < patterns.length; k++) {
96
- if (!wordMatches(patterns[k], prev[k], caseSensitive))
97
- return false;
98
- }
99
- return true;
100
- };
101
- /**
102
- * Tail match: the LAST N words of `prev` must match the patterns.
103
- *
104
- * prev = ['SELECT', 'a', 'FROM'], patterns = ['FROM'] → true
105
- * prev = ['SELECT'], patterns = ['SELECT', 'FROM'] → false (too few)
106
- */
107
- export const TailMatches = (prev, patterns, caseSensitive = false) => {
108
- if (prev.length < patterns.length)
109
- return false;
110
- const offset = prev.length - patterns.length;
111
- for (let k = 0; k < patterns.length; k++) {
112
- if (!wordMatches(patterns[k], prev[offset + k], caseSensitive))
113
- return false;
114
- }
115
- return true;
116
- };
117
- /**
118
- * Head match: the FIRST N words of `prev` must match.
119
- *
120
- * prev = ['ALTER', 'TABLE', 'foo'], patterns = ['ALTER', 'TABLE'] → true
121
- */
122
- export const HeadMatches = (prev, patterns, caseSensitive = false) => {
123
- if (prev.length < patterns.length)
124
- return false;
125
- for (let k = 0; k < patterns.length; k++) {
126
- if (!wordMatches(patterns[k], prev[k], caseSensitive))
127
- return false;
128
- }
129
- return true;
130
- };
131
- /**
132
- * Split `input` into psql-style words for completion purposes.
133
- *
134
- * - Whitespace is the basic separator.
135
- * - "..." treated as ONE word (quoted identifier).
136
- * - '...' treated as ONE word (string literal).
137
- * - \backslash... treated as ONE word (the backslash command).
138
- * - Punctuation (commas, parens, semicolons) is broken into its own word.
139
- * - Embedded `.` (schema-qualifier) keeps the dotted name as a single word
140
- * so completion sees `pg_catalog.pg_class` whole.
141
- *
142
- * The tokenizer is intentionally pragmatic — it doesn't validate SQL, it
143
- * just slices well enough for the rule body to inspect previous words.
144
- */
145
- export const tokenize = (input) => {
146
- const out = [];
147
- let i = 0;
148
- while (i < input.length) {
149
- const ch = input[i];
150
- // Whitespace.
151
- if (ch === " " || ch === "\t" || ch === "\n" || ch === "\r") {
152
- i++;
153
- continue;
154
- }
155
- // Backslash command. Capture the entire backslash word as one token.
156
- if (ch === "\\") {
157
- const start = i;
158
- i++;
159
- // Single-char commands like `\!` and `\?` are valid; otherwise read
160
- // letters until we hit whitespace or punctuation.
161
- if (i < input.length && /[!?]/.test(input[i])) {
162
- i++;
163
- }
164
- else {
165
- while (i < input.length && /[A-Za-z_]/.test(input[i]))
166
- i++;
167
- // Fold a trailing `+` run (the verbose suffix) into the command word
168
- // so `\dt+ <TAB>` tokenizes as a single word and the describe rules
169
- // that key on `prevWords.length === 1` still fire. The
170
- // `S` (system-objects) suffix is already a letter, so it's consumed
171
- // above; only `+` needs explicit handling here.
172
- while (i < input.length && input[i] === "+")
173
- i++;
174
- }
175
- out.push({
176
- text: input.slice(start, i),
177
- raw: input.slice(start, i),
178
- start,
179
- end: i,
180
- });
181
- continue;
182
- }
183
- // Double-quoted identifier.
184
- if (ch === '"') {
185
- const start = i;
186
- i++;
187
- while (i < input.length) {
188
- if (input[i] === '"') {
189
- // "" inside quotes is an escaped quote.
190
- if (input[i + 1] === '"') {
191
- i += 2;
192
- continue;
193
- }
194
- i++;
195
- break;
196
- }
197
- i++;
198
- }
199
- out.push({
200
- text: input.slice(start, i),
201
- raw: input.slice(start, i),
202
- start,
203
- end: i,
204
- });
205
- continue;
206
- }
207
- // Single-quoted string literal.
208
- if (ch === "'") {
209
- const start = i;
210
- i++;
211
- while (i < input.length) {
212
- if (input[i] === "\\" && i + 1 < input.length) {
213
- i += 2;
214
- continue;
215
- }
216
- if (input[i] === "'") {
217
- if (input[i + 1] === "'") {
218
- i += 2;
219
- continue;
220
- }
221
- i++;
222
- break;
223
- }
224
- i++;
225
- }
226
- out.push({
227
- text: input.slice(start, i),
228
- raw: input.slice(start, i),
229
- start,
230
- end: i,
231
- });
232
- continue;
233
- }
234
- // Punctuation that splits words.
235
- if (ch === "," ||
236
- ch === ";" ||
237
- ch === "(" ||
238
- ch === ")" ||
239
- ch === "[" ||
240
- ch === "]") {
241
- out.push({ text: ch, raw: ch, start: i, end: i + 1 });
242
- i++;
243
- continue;
244
- }
245
- // Bareword: letters, digits, underscore, `.` (schema qualifier), `:` (var
246
- // expansion marker is kept inside the word), `$` (positional param).
247
- const start = i;
248
- while (i < input.length) {
249
- const c = input[i];
250
- if (c === " " ||
251
- c === "\t" ||
252
- c === "\n" ||
253
- c === "\r" ||
254
- c === "," ||
255
- c === ";" ||
256
- c === "(" ||
257
- c === ")" ||
258
- c === "[" ||
259
- c === "]" ||
260
- c === '"' ||
261
- c === "'" ||
262
- c === "\\") {
263
- break;
264
- }
265
- i++;
266
- }
267
- out.push({
268
- text: input.slice(start, i),
269
- raw: input.slice(start, i),
270
- start,
271
- end: i,
272
- });
273
- }
274
- return out;
275
- };
276
- /**
277
- * Slice `input` at `cursor`, then determine what's being completed:
278
- *
279
- * - `prevWords`: the completed words ENTIRELY before the cursor.
280
- * - `currentWord`: the partial word the cursor is sitting in (may be '').
281
- * - `replaceLength`: number of code points to chop off the input before
282
- * inserting the completion (= length of currentWord in code points).
283
- *
284
- * The tokenizer is run on `input.slice(0, cursor)` and the LAST token, if
285
- * it ends exactly at cursor and didn't start with whitespace/punctuation,
286
- * becomes the current word. Otherwise the current word is empty (the user
287
- * just typed a space and is starting a new word).
288
- */
289
- export const splitForCompletion = (input, cursor) => {
290
- const head = input.slice(0, cursor);
291
- const tokens = tokenize(head);
292
- if (tokens.length === 0) {
293
- return { prevWords: [], currentWord: "", replaceLength: 0 };
294
- }
295
- const last = tokens[tokens.length - 1];
296
- // The cursor is sitting inside the last token if (a) it ends exactly at
297
- // cursor AND (b) the last char before cursor isn't whitespace.
298
- const charBefore = head[head.length - 1];
299
- const inWhitespace = charBefore === " " ||
300
- charBefore === "\t" ||
301
- charBefore === "\n" ||
302
- charBefore === "\r";
303
- if (last.end === head.length && !inWhitespace) {
304
- return {
305
- prevWords: tokens.slice(0, -1).map((t) => t.text),
306
- currentWord: last.text,
307
- replaceLength: Array.from(last.text).length,
308
- };
309
- }
310
- return {
311
- prevWords: tokens.map((t) => t.text),
312
- currentWord: "",
313
- replaceLength: 0,
314
- };
315
- };
@@ -1,249 +0,0 @@
1
- /**
2
- * Static-list completion candidates for psql special variables, settings,
3
- * and the small enums their values take.
4
- *
5
- * The values come from `pset_lookup_option` and the var-hook table in psql
6
- * (`src/bin/psql/variables.c` + `command.c`). We keep this module pure data
7
- * so it's trivial to extend as new variables are added in later WPs.
8
- */
9
- /** All psql special variables (anything that has a hook in variables.c). */
10
- export const SPECIAL_VARIABLES = [
11
- "AUTOCOMMIT",
12
- "COMP_KEYWORD_CASE",
13
- "DBNAME",
14
- "ECHO",
15
- "ECHO_HIDDEN",
16
- "ENCODING",
17
- "ERROR",
18
- "FETCH_COUNT",
19
- "HIDE_TABLEAM",
20
- "HIDE_TOAST_COMPRESSION",
21
- "HISTCONTROL",
22
- "HISTFILE",
23
- "HISTSIZE",
24
- "HOST",
25
- "IGNOREEOF",
26
- "LASTOID",
27
- "LAST_ERROR_MESSAGE",
28
- "LAST_ERROR_SQLSTATE",
29
- "ON_ERROR_ROLLBACK",
30
- "ON_ERROR_STOP",
31
- "PORT",
32
- "PROMPT1",
33
- "PROMPT2",
34
- "PROMPT3",
35
- "QUIET",
36
- "ROW_COUNT",
37
- "SERVER_VERSION_NAME",
38
- "SERVER_VERSION_NUM",
39
- "SHELL_ERROR",
40
- "SHELL_EXIT_CODE",
41
- "SHOW_ALL_RESULTS",
42
- "SHOW_CONTEXT",
43
- "SINGLELINE",
44
- "SINGLESTEP",
45
- "SQLSTATE",
46
- "USER",
47
- "VERBOSITY",
48
- "VERSION",
49
- "VERSION_NAME",
50
- "VERSION_NUM",
51
- ];
52
- /** `\pset` option names. */
53
- export const PSET_OPTIONS = [
54
- "border",
55
- "columns",
56
- "csv_fieldsep",
57
- "display_false",
58
- "display_true",
59
- "expanded",
60
- "fieldsep",
61
- "fieldsep_zero",
62
- "footer",
63
- "format",
64
- "linestyle",
65
- "null",
66
- "numericlocale",
67
- "pager",
68
- "pager_min_lines",
69
- "recordsep",
70
- "recordsep_zero",
71
- "tableattr",
72
- "title",
73
- "tuples_only",
74
- "unicode_border_linestyle",
75
- "unicode_column_linestyle",
76
- "unicode_header_linestyle",
77
- "xheader_width",
78
- ];
79
- /** Output formats accepted by `\pset format`. */
80
- export const PSET_FORMATS = [
81
- "aligned",
82
- "asciidoc",
83
- "csv",
84
- "html",
85
- "latex",
86
- "latex-longtable",
87
- "troff-ms",
88
- "unaligned",
89
- "wrapped",
90
- ];
91
- /** Line styles accepted by `\pset linestyle`. */
92
- export const PSET_LINESTYLES = [
93
- "ascii",
94
- "old-ascii",
95
- "unicode",
96
- ];
97
- /** Unicode border/column/header line styles. */
98
- export const PSET_UNICODE_STYLES = ["single", "double"];
99
- /** `xheader_width` argument forms. */
100
- export const PSET_XHEADER_WIDTHS = [
101
- "column",
102
- "full",
103
- "page",
104
- ];
105
- /** On/off/auto enum, used by many variables. */
106
- export const ON_OFF = ["on", "off"];
107
- export const ON_OFF_AUTO = ["on", "off", "auto"];
108
- /** Echo modes. */
109
- export const ECHO_MODES = [
110
- "none",
111
- "errors",
112
- "queries",
113
- "all",
114
- ];
115
- export const ECHO_HIDDEN_MODES = ["off", "on", "noexec"];
116
- export const ON_ERROR_ROLLBACK_MODES = [
117
- "off",
118
- "on",
119
- "interactive",
120
- ];
121
- export const VERBOSITY_MODES = [
122
- "default",
123
- "verbose",
124
- "terse",
125
- "sqlstate",
126
- ];
127
- export const SHOW_CONTEXT_MODES = [
128
- "never",
129
- "errors",
130
- "always",
131
- ];
132
- export const COMP_KEYWORD_CASE_MODES = [
133
- "lower",
134
- "upper",
135
- "preserve-lower",
136
- "preserve-upper",
137
- ];
138
- export const HIST_CONTROL_MODES = [
139
- "none",
140
- "ignorespace",
141
- "ignoredups",
142
- "ignoreboth",
143
- ];
144
- /** A handful of common client encodings — enough to be useful at `\encoding`. */
145
- export const ENCODINGS = [
146
- "BIG5",
147
- "EUC_CN",
148
- "EUC_JIS_2004",
149
- "EUC_JP",
150
- "EUC_KR",
151
- "EUC_TW",
152
- "GB18030",
153
- "GBK",
154
- "ISO_8859_5",
155
- "ISO_8859_6",
156
- "ISO_8859_7",
157
- "ISO_8859_8",
158
- "JOHAB",
159
- "KOI8R",
160
- "KOI8U",
161
- "LATIN1",
162
- "LATIN2",
163
- "LATIN3",
164
- "LATIN4",
165
- "LATIN5",
166
- "LATIN6",
167
- "LATIN7",
168
- "LATIN8",
169
- "LATIN9",
170
- "LATIN10",
171
- "MULE_INTERNAL",
172
- "SJIS",
173
- "SHIFT_JIS_2004",
174
- "SQL_ASCII",
175
- "UHC",
176
- "UTF8",
177
- "WIN866",
178
- "WIN874",
179
- "WIN1250",
180
- "WIN1251",
181
- "WIN1252",
182
- "WIN1253",
183
- "WIN1254",
184
- "WIN1255",
185
- "WIN1256",
186
- "WIN1257",
187
- "WIN1258",
188
- ];
189
- /**
190
- * For a given `\pset` option, return the list of values it accepts. Returns
191
- * `null` for free-form options (title, fieldsep, etc.).
192
- */
193
- export const psetValuesFor = (option) => {
194
- switch (option) {
195
- case "format":
196
- return PSET_FORMATS;
197
- case "linestyle":
198
- return PSET_LINESTYLES;
199
- case "unicode_border_linestyle":
200
- case "unicode_column_linestyle":
201
- case "unicode_header_linestyle":
202
- return PSET_UNICODE_STYLES;
203
- case "xheader_width":
204
- return PSET_XHEADER_WIDTHS;
205
- case "expanded":
206
- case "pager":
207
- return ON_OFF_AUTO;
208
- case "footer":
209
- case "tuples_only":
210
- case "numericlocale":
211
- case "fieldsep_zero":
212
- case "recordsep_zero":
213
- return ON_OFF;
214
- default:
215
- return null;
216
- }
217
- };
218
- /**
219
- * For a given special variable, return acceptable values, or `null` if free-form.
220
- */
221
- export const variableValuesFor = (name) => {
222
- switch (name) {
223
- case "AUTOCOMMIT":
224
- case "ON_ERROR_STOP":
225
- case "QUIET":
226
- case "SINGLELINE":
227
- case "SINGLESTEP":
228
- case "SHOW_ALL_RESULTS":
229
- case "HIDE_TOAST_COMPRESSION":
230
- case "HIDE_TABLEAM":
231
- return ON_OFF;
232
- case "ECHO":
233
- return ECHO_MODES;
234
- case "ECHO_HIDDEN":
235
- return ECHO_HIDDEN_MODES;
236
- case "ON_ERROR_ROLLBACK":
237
- return ON_ERROR_ROLLBACK_MODES;
238
- case "VERBOSITY":
239
- return VERBOSITY_MODES;
240
- case "SHOW_CONTEXT":
241
- return SHOW_CONTEXT_MODES;
242
- case "COMP_KEYWORD_CASE":
243
- return COMP_KEYWORD_CASE_MODES;
244
- case "HISTCONTROL":
245
- return HIST_CONTROL_MODES;
246
- default:
247
- return null;
248
- }
249
- };