neonctl 2.28.0 → 2.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +71 -71
- package/dist/analytics.js +35 -33
- package/dist/api.js +34 -34
- package/dist/auth.js +50 -44
- package/dist/cli.js +2 -2
- package/dist/commands/auth.js +58 -52
- package/dist/commands/bootstrap.js +115 -157
- package/dist/commands/branches.js +154 -147
- package/dist/commands/bucket.js +124 -118
- package/dist/commands/checkout.js +49 -49
- package/dist/commands/config.js +212 -88
- package/dist/commands/connection_string.js +62 -62
- package/dist/commands/data_api.js +96 -96
- package/dist/commands/databases.js +23 -23
- package/dist/commands/deploy.js +12 -12
- package/dist/commands/dev.js +114 -114
- package/dist/commands/env.js +43 -43
- package/dist/commands/functions.js +97 -98
- package/dist/commands/index.js +26 -26
- package/dist/commands/init.js +23 -22
- package/dist/commands/ip_allow.js +29 -29
- package/dist/commands/link.js +223 -166
- package/dist/commands/neon_auth.js +381 -363
- package/dist/commands/operations.js +11 -11
- package/dist/commands/orgs.js +8 -8
- package/dist/commands/projects.js +101 -99
- package/dist/commands/psql.js +31 -31
- package/dist/commands/roles.js +21 -21
- package/dist/commands/schema_diff.js +23 -23
- package/dist/commands/set_context.js +17 -17
- package/dist/commands/status.js +17 -17
- package/dist/commands/user.js +5 -5
- package/dist/commands/vpc_endpoints.js +50 -50
- package/dist/config.js +7 -7
- package/dist/config_format.js +5 -5
- package/dist/context.js +23 -16
- package/dist/current_branch_fast_path.js +6 -6
- package/dist/dev/env.js +34 -34
- package/dist/dev/functions.js +4 -4
- package/dist/dev/inputs.js +6 -6
- package/dist/dev/runtime.js +25 -25
- package/dist/env.js +14 -14
- package/dist/env_file.js +13 -13
- package/dist/errors.js +19 -19
- package/dist/functions_api.js +10 -10
- package/dist/help.js +15 -15
- package/dist/index.js +94 -92
- package/dist/log.js +2 -2
- package/dist/pkg.js +5 -5
- package/dist/psql/cli.js +4 -2
- package/dist/psql/command/cmd_cond.js +61 -61
- package/dist/psql/command/cmd_connect.js +159 -154
- package/dist/psql/command/cmd_copy.js +107 -97
- package/dist/psql/command/cmd_describe.js +368 -363
- package/dist/psql/command/cmd_format.js +276 -263
- package/dist/psql/command/cmd_io.js +269 -263
- package/dist/psql/command/cmd_lo.js +74 -66
- package/dist/psql/command/cmd_meta.js +148 -148
- package/dist/psql/command/cmd_misc.js +17 -17
- package/dist/psql/command/cmd_pipeline.js +142 -135
- package/dist/psql/command/cmd_restrict.js +25 -25
- package/dist/psql/command/cmd_show.js +183 -168
- package/dist/psql/command/dispatch.js +26 -26
- package/dist/psql/command/shared.js +14 -14
- package/dist/psql/complete/filenames.js +16 -16
- package/dist/psql/complete/index.js +4 -4
- package/dist/psql/complete/matcher.js +33 -32
- package/dist/psql/complete/psqlVars.js +173 -173
- package/dist/psql/complete/queries.js +5 -3
- package/dist/psql/complete/rules.js +900 -863
- package/dist/psql/core/common.js +136 -133
- package/dist/psql/core/help.js +343 -343
- package/dist/psql/core/mainloop.js +160 -153
- package/dist/psql/core/prompt.js +126 -123
- package/dist/psql/core/settings.js +111 -111
- package/dist/psql/core/sqlHelp.js +150 -150
- package/dist/psql/core/startup.js +211 -205
- package/dist/psql/core/syncVars.js +14 -14
- package/dist/psql/core/variables.js +24 -24
- package/dist/psql/describe/formatters.js +302 -289
- package/dist/psql/describe/processNamePattern.js +28 -28
- package/dist/psql/describe/queries.js +656 -651
- package/dist/psql/index.js +436 -411
- package/dist/psql/io/history.js +36 -36
- package/dist/psql/io/input.js +15 -15
- package/dist/psql/io/lineEditor/buffer.js +27 -25
- package/dist/psql/io/lineEditor/complete.js +15 -15
- package/dist/psql/io/lineEditor/filename.js +22 -22
- package/dist/psql/io/lineEditor/index.js +65 -62
- package/dist/psql/io/lineEditor/keymap.js +325 -318
- package/dist/psql/io/lineEditor/vt100.js +60 -60
- package/dist/psql/io/pgpass.js +18 -18
- package/dist/psql/io/pgservice.js +14 -14
- package/dist/psql/io/psqlrc.js +46 -46
- package/dist/psql/print/aligned.js +175 -166
- package/dist/psql/print/asciidoc.js +51 -51
- package/dist/psql/print/crosstab.js +34 -31
- package/dist/psql/print/csv.js +25 -22
- package/dist/psql/print/html.js +54 -54
- package/dist/psql/print/json.js +12 -12
- package/dist/psql/print/latex.js +118 -118
- package/dist/psql/print/pager.js +28 -26
- package/dist/psql/print/troff.js +48 -48
- package/dist/psql/print/unaligned.js +15 -14
- package/dist/psql/print/units.js +17 -17
- package/dist/psql/scanner/slash.js +48 -46
- package/dist/psql/scanner/sql.js +88 -84
- package/dist/psql/scanner/stringutils.js +21 -17
- package/dist/psql/types/index.js +7 -7
- package/dist/psql/types/scanner.js +8 -8
- package/dist/psql/wire/connection.js +341 -327
- package/dist/psql/wire/copy.js +7 -7
- package/dist/psql/wire/pipeline.js +26 -24
- package/dist/psql/wire/protocol.js +102 -102
- package/dist/psql/wire/sasl.js +62 -62
- package/dist/psql/wire/tls.js +79 -73
- package/dist/storage_api.js +15 -15
- package/dist/test_utils/fixtures.js +34 -31
- package/dist/test_utils/oauth_server.js +5 -5
- package/dist/utils/api_enums.js +13 -13
- package/dist/utils/branch_notice.js +5 -5
- package/dist/utils/branch_picker.js +26 -26
- package/dist/utils/compute_units.js +4 -4
- package/dist/utils/enrichers.js +20 -15
- package/dist/utils/esbuild.js +28 -28
- package/dist/utils/formats.js +1 -1
- package/dist/utils/middlewares.js +3 -3
- package/dist/utils/package_manager.js +68 -0
- package/dist/utils/point_in_time.js +12 -12
- package/dist/utils/psql.js +30 -30
- package/dist/utils/string.js +2 -2
- package/dist/utils/ui.js +9 -9
- package/dist/utils/zip.js +1 -1
- package/dist/writer.js +17 -17
- package/package.json +6 -7
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
* `IGNORED`, and `IGNORED` never transitions to `TRUE`. So `isActive()`
|
|
60
60
|
* inspecting just the top frame produces the right answer.
|
|
61
61
|
*/
|
|
62
|
-
import { writeErr } from
|
|
62
|
+
import { writeErr } from "./shared.js";
|
|
63
63
|
// ---------------------------------------------------------------------------
|
|
64
64
|
// Conditional stack
|
|
65
65
|
// ---------------------------------------------------------------------------
|
|
66
|
-
const INACTIVE_STATES = [
|
|
66
|
+
const INACTIVE_STATES = ["false", "else-false", "ignored"];
|
|
67
67
|
/**
|
|
68
68
|
* Build an empty {@link CondStack}.
|
|
69
69
|
*
|
|
@@ -75,7 +75,7 @@ const INACTIVE_STATES = ['false', 'else-false', 'ignored'];
|
|
|
75
75
|
*/
|
|
76
76
|
export const createCondStack = () => {
|
|
77
77
|
const frames = [];
|
|
78
|
-
const branchTakenForInitial = (state) => state ===
|
|
78
|
+
const branchTakenForInitial = (state) => state === "true" || state === "else-true";
|
|
79
79
|
return {
|
|
80
80
|
push(state, savedQueryBufLen = 0) {
|
|
81
81
|
frames.push({
|
|
@@ -103,7 +103,7 @@ export const createCondStack = () => {
|
|
|
103
103
|
return;
|
|
104
104
|
const top = frames[frames.length - 1];
|
|
105
105
|
top.state = state;
|
|
106
|
-
if (state ===
|
|
106
|
+
if (state === "true" || state === "else-true")
|
|
107
107
|
top.branchTaken = true;
|
|
108
108
|
},
|
|
109
109
|
setSavedQueryBufLen(len) {
|
|
@@ -139,24 +139,24 @@ const isPrefixOf = (value, prefix) => value.length > 0 &&
|
|
|
139
139
|
export const parseBool = (value) => {
|
|
140
140
|
if (value.length === 0)
|
|
141
141
|
return null;
|
|
142
|
-
if (isPrefixOf(value,
|
|
142
|
+
if (isPrefixOf(value, "true"))
|
|
143
143
|
return true;
|
|
144
|
-
if (isPrefixOf(value,
|
|
144
|
+
if (isPrefixOf(value, "false"))
|
|
145
145
|
return false;
|
|
146
|
-
if (isPrefixOf(value,
|
|
146
|
+
if (isPrefixOf(value, "yes"))
|
|
147
147
|
return true;
|
|
148
|
-
if (isPrefixOf(value,
|
|
148
|
+
if (isPrefixOf(value, "no"))
|
|
149
149
|
return false;
|
|
150
150
|
if (value.length >= 2) {
|
|
151
151
|
const lower = value.toLowerCase();
|
|
152
|
-
if (
|
|
152
|
+
if ("on".startsWith(lower))
|
|
153
153
|
return true;
|
|
154
|
-
if (
|
|
154
|
+
if ("off".startsWith(lower))
|
|
155
155
|
return false;
|
|
156
156
|
}
|
|
157
|
-
if (value ===
|
|
157
|
+
if (value === "1")
|
|
158
158
|
return true;
|
|
159
|
-
if (value ===
|
|
159
|
+
if (value === "0")
|
|
160
160
|
return false;
|
|
161
161
|
return null;
|
|
162
162
|
};
|
|
@@ -183,16 +183,16 @@ export const parseBool = (value) => {
|
|
|
183
183
|
* variable-expansion needs that we don't want to disturb.
|
|
184
184
|
*/
|
|
185
185
|
const DEFINED_VAR_RE = /:\{\?([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
186
|
-
const expandDefinedVar = (text, isDefined) => text.replace(DEFINED_VAR_RE, (_match, name) => isDefined(name) ?
|
|
186
|
+
const expandDefinedVar = (text, isDefined) => text.replace(DEFINED_VAR_RE, (_match, name) => isDefined(name) ? "TRUE" : "FALSE");
|
|
187
187
|
const collectExpr = (ctx) => {
|
|
188
188
|
const parts = [];
|
|
189
189
|
for (;;) {
|
|
190
|
-
const arg = ctx.nextArg(
|
|
190
|
+
const arg = ctx.nextArg("normal");
|
|
191
191
|
if (arg === null)
|
|
192
192
|
break;
|
|
193
193
|
parts.push(arg);
|
|
194
194
|
}
|
|
195
|
-
return expandDefinedVar(parts.join(
|
|
195
|
+
return expandDefinedVar(parts.join(" "), (name) => ctx.settings.vars.has(name));
|
|
196
196
|
};
|
|
197
197
|
/**
|
|
198
198
|
* Marker call indicating "discard the expression without evaluating it".
|
|
@@ -240,7 +240,7 @@ const evalExpr = (ctx, cmdName) => {
|
|
|
240
240
|
* BackslashContext via this helper pair so command modules don't have to know
|
|
241
241
|
* about REPLContext.
|
|
242
242
|
*/
|
|
243
|
-
const COND_STACK_KEY = Symbol.for(
|
|
243
|
+
const COND_STACK_KEY = Symbol.for("neonctl.psql.condStack");
|
|
244
244
|
export const attachCondStack = (ctx, cond) => {
|
|
245
245
|
const settings = ctx.settings;
|
|
246
246
|
settings[COND_STACK_KEY] = cond;
|
|
@@ -249,7 +249,7 @@ export const getCondStack = (ctx) => {
|
|
|
249
249
|
const settings = ctx.settings;
|
|
250
250
|
const stack = settings[COND_STACK_KEY];
|
|
251
251
|
if (stack === undefined) {
|
|
252
|
-
throw new Error(
|
|
252
|
+
throw new Error("cond stack not attached; cmd_cond commands must be dispatched via runMainLoop");
|
|
253
253
|
}
|
|
254
254
|
return stack;
|
|
255
255
|
};
|
|
@@ -262,9 +262,9 @@ const errResult = (ctx, message) => {
|
|
|
262
262
|
// The `errorWritten` flag tells the mainloop not to add its own
|
|
263
263
|
// `psql: ERROR: <msg>` fallback line.
|
|
264
264
|
writeErr(`${message}\n`);
|
|
265
|
-
return { status:
|
|
265
|
+
return { status: "error", errorWritten: true };
|
|
266
266
|
};
|
|
267
|
-
const okResult = () => ({ status:
|
|
267
|
+
const okResult = () => ({ status: "ok" });
|
|
268
268
|
/**
|
|
269
269
|
* Build an `{ status: 'ok' }` result that also asks the mainloop to truncate
|
|
270
270
|
* `queryBuf` back to `len`. Mirrors upstream `discard_query_text` — called
|
|
@@ -273,7 +273,7 @@ const okResult = () => ({ status: 'ok' });
|
|
|
273
273
|
* into the surrounding statement.
|
|
274
274
|
*/
|
|
275
275
|
const truncResult = (len) => ({
|
|
276
|
-
status:
|
|
276
|
+
status: "ok",
|
|
277
277
|
truncateBufTo: len,
|
|
278
278
|
});
|
|
279
279
|
/**
|
|
@@ -282,10 +282,10 @@ const truncResult = (len) => ({
|
|
|
282
282
|
* by the elif/else/endif commands to decide whether the
|
|
283
283
|
* `discard_query_text` step should fire on transition out of the branch.
|
|
284
284
|
*/
|
|
285
|
-
const isInactiveState = (state) => state ===
|
|
285
|
+
const isInactiveState = (state) => state === "false" || state === "else-false" || state === "ignored";
|
|
286
286
|
export const cmdIf = {
|
|
287
|
-
name:
|
|
288
|
-
argMode:
|
|
287
|
+
name: "if",
|
|
288
|
+
argMode: "lex",
|
|
289
289
|
async run(ctx) {
|
|
290
290
|
const cond = getCondStack(ctx);
|
|
291
291
|
// Save the queryBuf state at the point the `\if` was encountered. The
|
|
@@ -302,23 +302,23 @@ export const cmdIf = {
|
|
|
302
302
|
// with backticks/vars disabled (psql.sql:1028 covers this with
|
|
303
303
|
// `\if false { \if \`nosuchcommand\` ... }`).
|
|
304
304
|
dropExpr();
|
|
305
|
-
cond.push(
|
|
305
|
+
cond.push("ignored", savedLen);
|
|
306
306
|
return Promise.resolve(okResult());
|
|
307
307
|
}
|
|
308
|
-
const truthy = evalExpr(ctx,
|
|
309
|
-
cond.push(truthy ?
|
|
308
|
+
const truthy = evalExpr(ctx, "if");
|
|
309
|
+
cond.push(truthy ? "true" : "false", savedLen);
|
|
310
310
|
return Promise.resolve(okResult());
|
|
311
311
|
},
|
|
312
312
|
};
|
|
313
313
|
export const cmdElif = {
|
|
314
|
-
name:
|
|
315
|
-
argMode:
|
|
314
|
+
name: "elif",
|
|
315
|
+
argMode: "lex",
|
|
316
316
|
async run(ctx) {
|
|
317
317
|
const cond = getCondStack(ctx);
|
|
318
318
|
const top = cond.top();
|
|
319
319
|
if (top === undefined) {
|
|
320
320
|
dropExpr();
|
|
321
|
-
return Promise.resolve(errResult(ctx,
|
|
321
|
+
return Promise.resolve(errResult(ctx, "\\elif: no matching \\if"));
|
|
322
322
|
}
|
|
323
323
|
// If the branch we're leaving was INACTIVE, anything its body added to
|
|
324
324
|
// `queryBuf` is scan-time accumulation we don't want — discard back to
|
|
@@ -327,23 +327,23 @@ export const cmdElif = {
|
|
|
327
327
|
const wasInactive = isInactiveState(top.state);
|
|
328
328
|
const savedLen = top.savedQueryBufLen;
|
|
329
329
|
switch (top.state) {
|
|
330
|
-
case
|
|
330
|
+
case "true": {
|
|
331
331
|
// Branch already taken — flip to IGNORED. Drop the expression
|
|
332
332
|
// without expansion (regress suite: `\if true \elif \`bad\` ...`).
|
|
333
333
|
dropExpr();
|
|
334
|
-
cond.setState(
|
|
334
|
+
cond.setState("ignored");
|
|
335
335
|
// Active branch — keep buffer text. Re-anchor savedQueryBufLen
|
|
336
336
|
// to the start of the new (ignored) branch so a later `\else`/
|
|
337
337
|
// `\endif` discards just this branch's additions.
|
|
338
338
|
cond.setSavedQueryBufLen(ctx.queryBuf.length);
|
|
339
339
|
return Promise.resolve(okResult());
|
|
340
340
|
}
|
|
341
|
-
case
|
|
341
|
+
case "false": {
|
|
342
342
|
// Have not yet found a true branch — evaluate this one.
|
|
343
343
|
// evalExpr emits its own `unrecognized value` diagnostic on failure
|
|
344
344
|
// and falls through to false, mirroring upstream.
|
|
345
|
-
const truthy = evalExpr(ctx,
|
|
346
|
-
cond.setState(truthy ?
|
|
345
|
+
const truthy = evalExpr(ctx, "elif");
|
|
346
|
+
cond.setState(truthy ? "true" : "false");
|
|
347
347
|
// Apply the discard (was INACTIVE) and re-anchor at the rolled-back
|
|
348
348
|
// length so the new branch's bookkeeping starts fresh.
|
|
349
349
|
cond.setSavedQueryBufLen(savedLen);
|
|
@@ -351,7 +351,7 @@ export const cmdElif = {
|
|
|
351
351
|
? Promise.resolve(truncResult(savedLen))
|
|
352
352
|
: Promise.resolve(okResult());
|
|
353
353
|
}
|
|
354
|
-
case
|
|
354
|
+
case "ignored": {
|
|
355
355
|
// Outer is suppressed — stay ignored, drop args without expanding.
|
|
356
356
|
// Still discard accumulated buffer text and re-anchor.
|
|
357
357
|
dropExpr();
|
|
@@ -360,63 +360,63 @@ export const cmdElif = {
|
|
|
360
360
|
? Promise.resolve(truncResult(savedLen))
|
|
361
361
|
: Promise.resolve(okResult());
|
|
362
362
|
}
|
|
363
|
-
case
|
|
364
|
-
case
|
|
363
|
+
case "else-true":
|
|
364
|
+
case "else-false":
|
|
365
365
|
dropExpr();
|
|
366
|
-
return Promise.resolve(errResult(ctx,
|
|
367
|
-
case
|
|
366
|
+
return Promise.resolve(errResult(ctx, "\\elif: cannot occur after \\else"));
|
|
367
|
+
case "none":
|
|
368
368
|
dropExpr();
|
|
369
|
-
return Promise.resolve(errResult(ctx,
|
|
369
|
+
return Promise.resolve(errResult(ctx, "\\elif: no matching \\if"));
|
|
370
370
|
}
|
|
371
371
|
},
|
|
372
372
|
};
|
|
373
373
|
export const cmdElse = {
|
|
374
|
-
name:
|
|
375
|
-
argMode:
|
|
374
|
+
name: "else",
|
|
375
|
+
argMode: "lex",
|
|
376
376
|
async run(ctx) {
|
|
377
377
|
const cond = getCondStack(ctx);
|
|
378
378
|
const top = cond.top();
|
|
379
379
|
if (top === undefined) {
|
|
380
|
-
return Promise.resolve(errResult(ctx,
|
|
380
|
+
return Promise.resolve(errResult(ctx, "\\else: no matching \\if"));
|
|
381
381
|
}
|
|
382
382
|
const wasInactive = isInactiveState(top.state);
|
|
383
383
|
const savedLen = top.savedQueryBufLen;
|
|
384
384
|
switch (top.state) {
|
|
385
|
-
case
|
|
386
|
-
cond.setState(
|
|
385
|
+
case "true":
|
|
386
|
+
cond.setState("else-false");
|
|
387
387
|
// Was ACTIVE — keep buffer text. Re-anchor at the current length so
|
|
388
388
|
// the upcoming else-false branch's additions can be discarded by
|
|
389
389
|
// the matching `\endif`.
|
|
390
390
|
cond.setSavedQueryBufLen(ctx.queryBuf.length);
|
|
391
391
|
return Promise.resolve(okResult());
|
|
392
|
-
case
|
|
393
|
-
cond.setState(
|
|
392
|
+
case "false":
|
|
393
|
+
cond.setState("else-true");
|
|
394
394
|
cond.setSavedQueryBufLen(savedLen);
|
|
395
395
|
return wasInactive
|
|
396
396
|
? Promise.resolve(truncResult(savedLen))
|
|
397
397
|
: Promise.resolve(okResult());
|
|
398
|
-
case
|
|
399
|
-
cond.setState(
|
|
398
|
+
case "ignored":
|
|
399
|
+
cond.setState("else-false");
|
|
400
400
|
cond.setSavedQueryBufLen(savedLen);
|
|
401
401
|
return wasInactive
|
|
402
402
|
? Promise.resolve(truncResult(savedLen))
|
|
403
403
|
: Promise.resolve(okResult());
|
|
404
|
-
case
|
|
405
|
-
case
|
|
406
|
-
return Promise.resolve(errResult(ctx,
|
|
407
|
-
case
|
|
408
|
-
return Promise.resolve(errResult(ctx,
|
|
404
|
+
case "else-true":
|
|
405
|
+
case "else-false":
|
|
406
|
+
return Promise.resolve(errResult(ctx, "\\else: cannot occur after \\else"));
|
|
407
|
+
case "none":
|
|
408
|
+
return Promise.resolve(errResult(ctx, "\\else: no matching \\if"));
|
|
409
409
|
}
|
|
410
410
|
},
|
|
411
411
|
};
|
|
412
412
|
export const cmdEndif = {
|
|
413
|
-
name:
|
|
414
|
-
argMode:
|
|
413
|
+
name: "endif",
|
|
414
|
+
argMode: "lex",
|
|
415
415
|
async run(ctx) {
|
|
416
416
|
const cond = getCondStack(ctx);
|
|
417
417
|
const top = cond.top();
|
|
418
418
|
if (top === undefined) {
|
|
419
|
-
return Promise.resolve(errResult(ctx,
|
|
419
|
+
return Promise.resolve(errResult(ctx, "\\endif: no matching \\if"));
|
|
420
420
|
}
|
|
421
421
|
const wasInactive = isInactiveState(top.state);
|
|
422
422
|
const savedLen = top.savedQueryBufLen;
|
|
@@ -430,8 +430,8 @@ export const cmdEndif = {
|
|
|
430
430
|
* unconditionally (i.e. ignoring `cond.isActive()`) so an `\if false` block
|
|
431
431
|
* can still be closed by `\endif`. */
|
|
432
432
|
export const COND_COMMAND_NAMES = new Set([
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
433
|
+
"if",
|
|
434
|
+
"elif",
|
|
435
|
+
"else",
|
|
436
|
+
"endif",
|
|
437
437
|
]);
|