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,394 +0,0 @@
1
- /**
2
- * psql string utilities.
3
- *
4
- * TypeScript port of PostgreSQL's `src/bin/psql/stringutils.c`. Three pure
5
- * helpers used by the slash-command scanner and by code that constructs
6
- * round-trippable argument strings (notably tab-completion output).
7
- *
8
- * - {@link strtokx} — upstream `strtokx()`, a tokenizer with
9
- * configurable whitespace, delimiter, quote and
10
- * escape sets. Implemented as a pure function that
11
- * returns `{ token, rest }` rather than the upstream
12
- * re-entrant-via-static-variables style.
13
- * - {@link quoteIfNeeded} — upstream `quote_if_needed()`. Returns the value
14
- * unchanged when it contains no characters that
15
- * require quoting; otherwise wraps in `quote`,
16
- * doubling any embedded `quote` characters.
17
- * - {@link dequote} — small companion to `quote_if_needed()`. Strips a
18
- * single surrounding `quote` and undoubles any
19
- * embedded occurrences (the inverse of the wrap
20
- * done by `quoteIfNeeded`).
21
- * - {@link tryConsumeVarSubstitution} — `:NAME`/`:'NAME'`/`:"NAME"`
22
- * substitution helper used by the SQL scanner.
23
- * (The slash-arg scanner has its own local copy of
24
- * the same logic; future work can collapse them.)
25
- *
26
- * Deviations from upstream that are intentional:
27
- *
28
- * - All inputs are JS strings, processed as UTF-16 code units. Upstream uses
29
- * `PQmblenBounded()` to advance one multibyte character at a time; for the
30
- * purposes of `strtokx`/`quote_if_needed`/`strip_quotes` the only thing
31
- * that matters is matching ASCII delimiter / quote / escape bytes, which
32
- * are guaranteed not to be the middle byte of a multibyte sequence in any
33
- * PostgreSQL-supported encoding. We therefore safely walk the string one
34
- * code unit at a time.
35
- * - The `encoding` argument is accepted for API parity but is currently
36
- * unused. The slash scanner passes it through; documenting it lets us add
37
- * encoding-aware handling later without a signature break.
38
- * - `strtokx` returns `{ token, rest }`. The caller iterates by passing
39
- * `rest` back in; this is friendlier to TS than threading a hidden static.
40
- */
41
- /**
42
- * Tokenizer used by the psql slash-command scanner.
43
- *
44
- * Behaviour, matching upstream `strtokx()`:
45
- * 1. Skip any characters in `whitespace`.
46
- * 2. If the cursor sits on a character in `delim`, return that single
47
- * character as the token (the delimiter itself is a token).
48
- * 3. If the cursor sits on a quote character, scan until the matching quote.
49
- * Doubled quotes are kept verbatim in the returned token (the caller can
50
- * post-process by passing the result through {@link dequote}). The
51
- * `escape` character, when set, lets the next character be taken
52
- * literally — including a quote that would otherwise close the token.
53
- * 4. Otherwise scan until the next whitespace, delim, or quote character and
54
- * return everything consumed.
55
- *
56
- * @param input remaining input string
57
- * @param whitespace characters treated as whitespace (any sequence is
58
- * a single separator and is consumed without
59
- * emitting a token)
60
- * @param delim characters returned as standalone single-char
61
- * tokens (use `""` to disable)
62
- * @param quote characters that open a quoted token (use `""` to
63
- * disable)
64
- * @param escape character that lets the next char be taken
65
- * literally inside a quoted token (use `""` to
66
- * disable)
67
- * @param eAcceptInUnquoted optional set of "E-string" prefixes — letters that
68
- * when followed by a single quote start a quoted
69
- * token with backslash escaping enabled. Pass `"Ee"`
70
- * to mirror upstream's `e_strings = true`. `null`
71
- * disables the behaviour.
72
- * @param atEol when `true`, a trailing delim character is left in
73
- * the remainder for the next call. When `false`,
74
- * trailing whitespace and any single trailing delim
75
- * are consumed before returning.
76
- * @param encoding accepted for API parity; unused.
77
- *
78
- * @returns `{ token, rest }` where `token` is `null` at end of input.
79
- */
80
- export const strtokx = (input, whitespace, delim, quote, escape, eAcceptInUnquoted, atEol, encoding) => {
81
- void encoding; // documented as unused
82
- let i = 0;
83
- const n = input.length;
84
- // 1. Skip leading whitespace.
85
- while (i < n && whitespace.includes(input[i]))
86
- i++;
87
- if (i >= n) {
88
- return { token: null, rest: "" };
89
- }
90
- // 2. Single-character delim token.
91
- if (delim.length > 0 && delim.includes(input[i])) {
92
- const token = input[i];
93
- i++;
94
- if (!atEol) {
95
- // Consume one immediately-following separator (whitespace) so the next
96
- // call lands cleanly on the next real token. Upstream achieves the
97
- // same effect by inserting a null after the delim and advancing
98
- // `string` past it.
99
- while (i < n && whitespace.includes(input[i]))
100
- i++;
101
- }
102
- return { token, rest: input.slice(i) };
103
- }
104
- // 3. Quoted token.
105
- let p = i;
106
- let effectiveQuote = quote;
107
- let effectiveEscape = escape;
108
- // E-string prefix handling — upstream's `if (e_strings && (*p == 'E' ||
109
- // *p == 'e') && p[1] == '\'') { quote = "'"; escape = '\\'; p++; }`.
110
- if (eAcceptInUnquoted &&
111
- p + 1 < n &&
112
- eAcceptInUnquoted.includes(input[p]) &&
113
- input[p + 1] === "'") {
114
- effectiveQuote = "'";
115
- effectiveEscape = "\\";
116
- p++;
117
- }
118
- if (effectiveQuote.length > 0 && effectiveQuote.includes(input[p])) {
119
- const thisQuote = input[p];
120
- const start = p;
121
- p++; // step over opening quote
122
- while (p < n) {
123
- const c = input[p];
124
- if (effectiveEscape.length > 0 &&
125
- c === effectiveEscape &&
126
- p + 1 < n) {
127
- // escape + anything (except end-of-input) is a literal data char
128
- p += 2;
129
- continue;
130
- }
131
- if (c === thisQuote && input[p + 1] === thisQuote) {
132
- // doubled quote — keep both in the returned token; the caller can
133
- // dequote() if they want a clean value.
134
- p += 2;
135
- continue;
136
- }
137
- if (c === thisQuote) {
138
- p++; // step over closing quote
139
- break;
140
- }
141
- p++;
142
- }
143
- const token = input.slice(start, p);
144
- if (!atEol) {
145
- while (p < n && whitespace.includes(input[p]))
146
- p++;
147
- }
148
- return { token, rest: input.slice(p) };
149
- }
150
- // 4. Bareword: scan to next whitespace, delim, or quote.
151
- const start = p;
152
- while (p < n) {
153
- const c = input[p];
154
- if (whitespace.includes(c))
155
- break;
156
- if (delim.length > 0 && delim.includes(c))
157
- break;
158
- if (quote.length > 0 && quote.includes(c))
159
- break;
160
- p++;
161
- }
162
- const token = input.slice(start, p);
163
- // Always skip trailing whitespace so the next call lands on the next
164
- // non-blank character. When `atEol` is `false` we additionally consume a
165
- // single trailing delim — the caller has told us delims are line-internal
166
- // separators rather than significant tokens.
167
- while (p < n && whitespace.includes(input[p]))
168
- p++;
169
- if (!atEol && p < n && delim.length > 0 && delim.includes(input[p])) {
170
- p++;
171
- while (p < n && whitespace.includes(input[p]))
172
- p++;
173
- }
174
- return { token, rest: input.slice(p) };
175
- };
176
- /**
177
- * Wrap `value` in `quote` if it contains any character in `escapeChars`,
178
- * `quote` itself, or is otherwise ambiguous; embedded occurrences of `quote`
179
- * are doubled to escape them. If no quoting is needed the original `value` is
180
- * returned verbatim (so this is a no-op for already-clean tokens).
181
- *
182
- * @param value string to (possibly) quote
183
- * @param escapeChars characters whose presence in `value` triggers quoting
184
- * (typically the same character set passed as `whitespace`
185
- * / `delim` to {@link strtokx})
186
- * @param quote quote character to wrap with (e.g. `'` or `"`)
187
- */
188
- export const quoteIfNeeded = (value, escapeChars, quote) => {
189
- if (quote.length !== 1) {
190
- throw new Error("quoteIfNeeded: quote must be exactly one character");
191
- }
192
- let needsQuotes = false;
193
- let escaped = "";
194
- for (const c of value) {
195
- if (c === quote) {
196
- needsQuotes = true;
197
- escaped += quote + quote;
198
- }
199
- else {
200
- if (escapeChars.includes(c))
201
- needsQuotes = true;
202
- escaped += c;
203
- }
204
- }
205
- if (!needsQuotes)
206
- return value;
207
- return quote + escaped + quote;
208
- };
209
- /**
210
- * Inverse of {@link quoteIfNeeded}. If `value` is wrapped in `quote`, strip
211
- * the outer quotes and undouble any embedded `quote` occurrences. If `value`
212
- * is not wrapped in `quote`, it is returned unchanged.
213
- *
214
- * @param value any string (quoted or bare)
215
- * @param quote quote character used to wrap (e.g. `'` or `"`)
216
- */
217
- export const dequote = (value, quote) => {
218
- if (quote.length !== 1) {
219
- throw new Error("dequote: quote must be exactly one character");
220
- }
221
- if (value.length < 2 ||
222
- !value.startsWith(quote) ||
223
- !value.endsWith(quote)) {
224
- return value;
225
- }
226
- const inner = value.slice(1, -1);
227
- // Undouble embedded quote chars.
228
- let out = "";
229
- let i = 0;
230
- while (i < inner.length) {
231
- if (inner[i] === quote && inner[i + 1] === quote) {
232
- out += quote;
233
- i += 2;
234
- }
235
- else {
236
- out += inner[i];
237
- i++;
238
- }
239
- }
240
- return out;
241
- };
242
- /**
243
- * SQL-literal-quote a value for the `:'varname'` substitution form.
244
- *
245
- * Mirrors libpq's `PQescapeLiteral` for the common case: wrap in `'…'`,
246
- * double any embedded `'`, and backslash-escape any embedded `\`. Upstream
247
- * additionally emits an `E` prefix when the value contains backslashes; we
248
- * preserve that behaviour for compatibility with code that round-trips
249
- * through the SQL parser.
250
- */
251
- export const quoteSqlLiteral = (value) => {
252
- let needsEscape = false;
253
- let inner = "";
254
- for (const c of value) {
255
- if (c === "'")
256
- inner += "''";
257
- else if (c === "\\") {
258
- inner += "\\\\";
259
- needsEscape = true;
260
- }
261
- else {
262
- inner += c;
263
- }
264
- }
265
- return needsEscape ? `E'${inner}'` : `'${inner}'`;
266
- };
267
- /**
268
- * SQL-identifier-quote a value for the `:"varname"` substitution form.
269
- * Wraps the value in `"…"` and doubles any embedded `"`.
270
- */
271
- export const quoteSqlIdent = (value) => {
272
- let inner = "";
273
- for (const c of value) {
274
- inner += c === '"' ? '""' : c;
275
- }
276
- return `"${inner}"`;
277
- };
278
- // Variable-name character class. Upstream's `variable_char` flex rule matches
279
- // `[A-Za-z0-9_\x80-\xff]+`. We do not allow a leading digit (matches
280
- // `VarStore`'s `[A-Za-z_][A-Za-z0-9_]*` validation rule) — a token like `:1`
281
- // is not a substitution. The high-byte range `\x80-\xff` is spelled with
282
- // explicit `\x..` escapes so the `_` and the range stay separated; an earlier
283
- // `[A-Za-z0-9_-ÿ]` form silently included `{`, `|`, `}`, `~` via the
284
- // dash-range bridge between `_` (0x5F) and `ÿ` (0xFF), which broke the
285
- // `:{?NAME}` brace-form lookup whose closing `}` would be eaten as part of
286
- // the name.
287
- const VAR_NAME_CONT_RE = /[A-Za-z0-9_\x80-\xff]/;
288
- const VAR_NAME_START_RE = /[A-Za-z_\x80-\xff]/;
289
- const isVarNameStart = (c) => c !== undefined && VAR_NAME_START_RE.test(c);
290
- const isVarNameCont = (c) => c !== undefined && VAR_NAME_CONT_RE.test(c);
291
- /**
292
- * Attempt to consume one of the `:NAME`, `:'NAME'`, `:"NAME"` variable
293
- * substitution forms at position `i` in `s`. Returns the new index plus the
294
- * substituted text, or `null` if no recognised form is present (i.e. the
295
- * caller should emit `s[i]` verbatim and advance one char).
296
- *
297
- * When `varLookup` is `undefined`, substitution is disabled outright (the
298
- * function returns `null` for every call).
299
- *
300
- * Unknown variables: upstream still ECHOes the raw `:NAME` token rather than
301
- * substituting an empty string, so a misspelled reference stays visible to
302
- * the user. We mirror that for all three forms.
303
- *
304
- * Edge cases handled here so callers don't repeat them:
305
- *
306
- * - `::` (PostgreSQL cast operator): when `s[i+1] === ':'`, we treat the
307
- * sequence as not-a-substitution and return `null`. The caller is then
308
- * responsible for advancing past both colons (the SQL scanner does that
309
- * in a dedicated branch before calling us).
310
- * - `:` followed by a non-identifier char: returns `null`. The caller emits
311
- * the literal `:` and continues.
312
- * - `:'` or `:"` with no matching closing quote or empty name: returns
313
- * `null`. We require at least one identifier character and a properly
314
- * closed quote, matching upstream's flex rules.
315
- */
316
- export const tryConsumeVarSubstitution = (s, i, varLookup) => {
317
- if (varLookup === undefined)
318
- return null;
319
- if (s[i] !== ":")
320
- return null;
321
- const next = s[i + 1];
322
- if (next === undefined)
323
- return null;
324
- // `::` cast operator — never a substitution.
325
- if (next === ":")
326
- return null;
327
- // :{?NAME} — defined-variable test. Emits literal `TRUE` if the named
328
- // variable is set, `FALSE` otherwise. Mirrors upstream's
329
- // `psqlscan_test_variable` (flex rule `:\{\?{variable_char}+\}` in
330
- // `psqlscan.l`). Unlike the other forms we recognise here, an unset variable
331
- // is NOT echoed back as a literal — the whole point of `:{?NAME}` is to
332
- // produce a boolean regardless of definedness. A malformed brace expression
333
- // (missing closing `}`, empty NAME, or non-variable_char content) returns
334
- // `null` so the caller emits the literal `:` and continues, matching the
335
- // upstream flex fallback rule `:\{\?{variable_char}*`.
336
- if (next === "{" && s[i + 2] === "?") {
337
- let j = i + 3;
338
- while (j < s.length && isVarNameCont(s[j]))
339
- j++;
340
- if (j > i + 3 && s[j] === "}") {
341
- const name = s.slice(i + 3, j);
342
- const value = varLookup(name);
343
- return { end: j + 1, text: value !== undefined ? "TRUE" : "FALSE" };
344
- }
345
- return null;
346
- }
347
- // :"NAME" — SQL identifier quote
348
- if (next === '"') {
349
- let j = i + 2;
350
- while (j < s.length && isVarNameCont(s[j]))
351
- j++;
352
- if (j > i + 2 && s[j] === '"') {
353
- const name = s.slice(i + 2, j);
354
- const value = varLookup(name);
355
- if (value === undefined) {
356
- // Echo the literal `:"NAME"` for visibility.
357
- return { end: j + 1, text: s.slice(i, j + 1) };
358
- }
359
- return { end: j + 1, text: quoteSqlIdent(value) };
360
- }
361
- return null;
362
- }
363
- // :'NAME' — SQL literal quote
364
- if (next === "'") {
365
- let j = i + 2;
366
- while (j < s.length && isVarNameCont(s[j]))
367
- j++;
368
- if (j > i + 2 && s[j] === "'") {
369
- const name = s.slice(i + 2, j);
370
- const value = varLookup(name);
371
- if (value === undefined) {
372
- return { end: j + 1, text: s.slice(i, j + 1) };
373
- }
374
- return { end: j + 1, text: quoteSqlLiteral(value) };
375
- }
376
- return null;
377
- }
378
- // :NAME — plain substitution. We require the first char to be an
379
- // identifier-start char (no leading digit) to avoid eating `:1` etc.
380
- if (isVarNameStart(next)) {
381
- let j = i + 1;
382
- while (j < s.length && isVarNameCont(s[j]))
383
- j++;
384
- const name = s.slice(i + 1, j);
385
- const value = varLookup(name);
386
- if (value === undefined) {
387
- // Unset → emit literally so it stays visible. Upstream ECHOes the
388
- // entire `:name` text in this case.
389
- return { end: j, text: s.slice(i, j) };
390
- }
391
- return { end: j, text: value };
392
- }
393
- return null;
394
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- export * from "./backslash.js";
2
- export * from "./connection.js";
3
- export * from "./printer.js";
4
- export * from "./repl.js";
5
- export * from "./scanner.js";
6
- export * from "./settings.js";
7
- export * from "./variables.js";
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,24 +0,0 @@
1
- /**
2
- * Returns true if the scanner status represents an unterminated statement
3
- * waiting for more input. Useful for callers that only care whether to draw
4
- * PROMPT2 vs PROMPT1 and don't care about the specific reason.
5
- */
6
- export const isContinueStatus = (s) => s === "continue" ||
7
- s === "continue-quote" ||
8
- s === "continue-dquote" ||
9
- s === "continue-dollar" ||
10
- s === "paren" ||
11
- s === "comment";
12
- export const initialScanState = () => ({
13
- promptStatus: "ready",
14
- parenDepth: 0,
15
- dollarTag: null,
16
- inLineComment: false,
17
- inBlockComment: 0,
18
- inSingleQuote: false,
19
- inDoubleQuote: false,
20
- inEscapeString: false,
21
- beginDepth: 0,
22
- identifierLetters: ["", "", "", ""],
23
- identifierCount: 0,
24
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};