neonctl 2.27.1 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -3
- package/dist/analytics.js +52 -34
- package/dist/api.js +643 -13
- package/dist/auth.js +50 -44
- package/dist/cli.js +8 -1
- package/dist/commands/auth.js +64 -51
- package/dist/commands/bootstrap.js +115 -157
- package/dist/commands/branches.js +160 -150
- package/dist/commands/bucket.js +183 -146
- package/dist/commands/checkout.js +51 -51
- package/dist/commands/config.js +228 -82
- package/dist/commands/connection_string.js +62 -62
- package/dist/commands/data_api.js +100 -101
- package/dist/commands/databases.js +29 -26
- 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 +101 -104
- package/dist/commands/index.js +27 -25
- package/dist/commands/init.js +23 -22
- package/dist/commands/ip_allow.js +29 -29
- package/dist/commands/link.js +232 -182
- package/dist/commands/neon_auth.js +385 -370
- package/dist/commands/operations.js +11 -11
- package/dist/commands/orgs.js +8 -8
- package/dist/commands/projects.js +103 -101
- package/dist/commands/psql.js +31 -31
- package/dist/commands/roles.js +27 -24
- package/dist/commands/schema_diff.js +25 -26
- package/dist/commands/set_context.js +17 -17
- package/dist/commands/status.js +40 -0
- 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 +37 -14
- package/dist/current_branch_fast_path.js +55 -0
- package/dist/dev/env.js +33 -33
- 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 +68 -5
- package/dist/functions_api.js +10 -10
- package/dist/help.js +15 -15
- package/dist/index.js +110 -107
- package/dist/log.js +2 -2
- package/dist/parameters.gen.js +14 -14
- 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 +22 -23
- package/dist/test_utils/fixtures.js +74 -41
- package/dist/test_utils/oauth_server.js +5 -5
- package/dist/utils/api_enums.js +33 -0
- 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 +28 -16
- 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 +10 -12
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
* are constant for the life of the process and set once at startup — see
|
|
28
28
|
* {@link setStartupVars}.
|
|
29
29
|
*/
|
|
30
|
-
const asString = (value) => typeof value ===
|
|
31
|
-
const asPort = (value) => typeof value ===
|
|
30
|
+
const asString = (value) => typeof value === "string" ? value : undefined;
|
|
31
|
+
const asPort = (value) => typeof value === "number" && Number.isFinite(value)
|
|
32
32
|
? String(value)
|
|
33
33
|
: undefined;
|
|
34
34
|
/**
|
|
@@ -44,30 +44,30 @@ export const syncConnectionVars = (vars, conn) => {
|
|
|
44
44
|
const target = conn;
|
|
45
45
|
const database = asString(target.database);
|
|
46
46
|
if (database !== undefined)
|
|
47
|
-
vars.set(
|
|
47
|
+
vars.set("DBNAME", database);
|
|
48
48
|
const user = asString(target.user);
|
|
49
49
|
if (user !== undefined)
|
|
50
|
-
vars.set(
|
|
50
|
+
vars.set("USER", user);
|
|
51
51
|
const host = asString(target.host);
|
|
52
52
|
if (host !== undefined)
|
|
53
|
-
vars.set(
|
|
53
|
+
vars.set("HOST", host);
|
|
54
54
|
const port = asPort(target.port);
|
|
55
55
|
if (port !== undefined)
|
|
56
|
-
vars.set(
|
|
56
|
+
vars.set("PORT", port);
|
|
57
57
|
// ENCODING tracks the server's `client_encoding` ParameterStatus. The
|
|
58
58
|
// mainloop refreshes it after each `SET client_encoding`; seed it here so
|
|
59
59
|
// it is populated from the very first prompt (and re-seeded after `\c`).
|
|
60
|
-
const encoding = conn.parameterStatus(
|
|
60
|
+
const encoding = conn.parameterStatus("client_encoding");
|
|
61
61
|
if (encoding !== undefined)
|
|
62
|
-
vars.set(
|
|
63
|
-
const serverVersionName = conn.parameterStatus(
|
|
62
|
+
vars.set("ENCODING", encoding);
|
|
63
|
+
const serverVersionName = conn.parameterStatus("server_version");
|
|
64
64
|
if (serverVersionName !== undefined) {
|
|
65
|
-
vars.set(
|
|
65
|
+
vars.set("SERVER_VERSION_NAME", serverVersionName);
|
|
66
66
|
}
|
|
67
67
|
// `Connection.serverVersion` is the libpq-style integer (e.g. 180004 for
|
|
68
68
|
// 18.4); 0 means "not yet reported" — skip it so we don't write a bogus 0.
|
|
69
69
|
if (conn.serverVersion > 0) {
|
|
70
|
-
vars.set(
|
|
70
|
+
vars.set("SERVER_VERSION_NUM", String(conn.serverVersion));
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
/**
|
|
@@ -94,9 +94,9 @@ export const syncConnectionVars = (vars, conn) => {
|
|
|
94
94
|
* numeric `:VERSION_NUM` comparison gets a monotonic integer.
|
|
95
95
|
*/
|
|
96
96
|
export const setStartupVars = (vars, clientVersion) => {
|
|
97
|
-
vars.set(
|
|
98
|
-
vars.set(
|
|
99
|
-
vars.set(
|
|
97
|
+
vars.set("VERSION", `psql-ts (neonctl) ${clientVersion}`);
|
|
98
|
+
vars.set("VERSION_NAME", clientVersion);
|
|
99
|
+
vars.set("VERSION_NUM", String(clientVersionNum(clientVersion)));
|
|
100
100
|
};
|
|
101
101
|
/**
|
|
102
102
|
* Map a `MAJOR.MINOR.PATCH` semver-style version string into PG's
|
|
@@ -44,25 +44,25 @@ const isPrefixOf = (value, prefix) => value.length > 0 &&
|
|
|
44
44
|
const parseBool = (value) => {
|
|
45
45
|
if (value.length === 0)
|
|
46
46
|
return null;
|
|
47
|
-
if (isPrefixOf(value,
|
|
47
|
+
if (isPrefixOf(value, "true"))
|
|
48
48
|
return true;
|
|
49
|
-
if (isPrefixOf(value,
|
|
49
|
+
if (isPrefixOf(value, "false"))
|
|
50
50
|
return false;
|
|
51
|
-
if (isPrefixOf(value,
|
|
51
|
+
if (isPrefixOf(value, "yes"))
|
|
52
52
|
return true;
|
|
53
|
-
if (isPrefixOf(value,
|
|
53
|
+
if (isPrefixOf(value, "no"))
|
|
54
54
|
return false;
|
|
55
55
|
// 'on'/'off' need at least 2 chars; 'o' alone is ambiguous.
|
|
56
56
|
if (value.length >= 2) {
|
|
57
57
|
const lower = value.toLowerCase();
|
|
58
|
-
if (
|
|
58
|
+
if ("on".startsWith(lower))
|
|
59
59
|
return true;
|
|
60
|
-
if (
|
|
60
|
+
if ("off".startsWith(lower))
|
|
61
61
|
return false;
|
|
62
62
|
}
|
|
63
|
-
if (value ===
|
|
63
|
+
if (value === "1")
|
|
64
64
|
return true;
|
|
65
|
-
if (value ===
|
|
65
|
+
if (value === "0")
|
|
66
66
|
return false;
|
|
67
67
|
// WP-06 extension: any other strtol-parsable integer is truthy if non-zero,
|
|
68
68
|
// falsy if zero. Upstream `ParseVariableBool` rejects "42" outright; we
|
|
@@ -91,25 +91,25 @@ const parseInt32 = (value) => {
|
|
|
91
91
|
// base 0 are not portable enough for this).
|
|
92
92
|
let body = trimmed;
|
|
93
93
|
let sign = 1;
|
|
94
|
-
if (body.startsWith(
|
|
94
|
+
if (body.startsWith("+")) {
|
|
95
95
|
body = body.slice(1);
|
|
96
96
|
}
|
|
97
|
-
else if (body.startsWith(
|
|
97
|
+
else if (body.startsWith("-")) {
|
|
98
98
|
sign = -1;
|
|
99
99
|
body = body.slice(1);
|
|
100
100
|
}
|
|
101
101
|
if (body.length === 0)
|
|
102
102
|
return null;
|
|
103
103
|
let radix = 10;
|
|
104
|
-
if (body.startsWith(
|
|
104
|
+
if (body.startsWith("0x") || body.startsWith("0X")) {
|
|
105
105
|
radix = 16;
|
|
106
106
|
body = body.slice(2);
|
|
107
107
|
}
|
|
108
|
-
else if (body.startsWith(
|
|
108
|
+
else if (body.startsWith("0o") || body.startsWith("0O")) {
|
|
109
109
|
radix = 8;
|
|
110
110
|
body = body.slice(2);
|
|
111
111
|
}
|
|
112
|
-
else if (body.length > 1 && body.startsWith(
|
|
112
|
+
else if (body.length > 1 && body.startsWith("0")) {
|
|
113
113
|
// C strtol with base 0 treats a leading 0 as octal. JS users typically
|
|
114
114
|
// expect decimal; we follow upstream for behavioural fidelity.
|
|
115
115
|
radix = 8;
|
|
@@ -138,7 +138,7 @@ export class VarStore {
|
|
|
138
138
|
}
|
|
139
139
|
trySet(name, value) {
|
|
140
140
|
if (!VALID_NAME_RE.test(name)) {
|
|
141
|
-
return { ok: false, reason:
|
|
141
|
+
return { ok: false, reason: "invalid-name" };
|
|
142
142
|
}
|
|
143
143
|
const hooks = this.hooks.get(name);
|
|
144
144
|
let toStore = value;
|
|
@@ -160,12 +160,12 @@ export class VarStore {
|
|
|
160
160
|
for (const hook of hooks) {
|
|
161
161
|
const result = hook(toStore);
|
|
162
162
|
if (result === false) {
|
|
163
|
-
return { ok: false, reason:
|
|
163
|
+
return { ok: false, reason: "hook-veto" };
|
|
164
164
|
}
|
|
165
|
-
if (typeof result ===
|
|
166
|
-
return { ok: false, reason:
|
|
165
|
+
if (typeof result === "string") {
|
|
166
|
+
return { ok: false, reason: "hook-veto", error: result };
|
|
167
167
|
}
|
|
168
|
-
if (typeof result ===
|
|
168
|
+
if (typeof result === "object" && result !== null) {
|
|
169
169
|
toStore = result.substitute;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -190,7 +190,7 @@ export class VarStore {
|
|
|
190
190
|
let substituted = null;
|
|
191
191
|
for (const hook of hooks) {
|
|
192
192
|
const r = hook(null);
|
|
193
|
-
if (typeof r ===
|
|
193
|
+
if (typeof r === "object" && r !== null && "substitute" in r) {
|
|
194
194
|
substituted = r.substitute;
|
|
195
195
|
}
|
|
196
196
|
}
|
|
@@ -235,9 +235,9 @@ export class VarStore {
|
|
|
235
235
|
// is needed for variables whose default matches the unset substitute.
|
|
236
236
|
const current = this.values.get(name);
|
|
237
237
|
const result = hook(current ?? null);
|
|
238
|
-
if (typeof result ===
|
|
238
|
+
if (typeof result === "object" &&
|
|
239
239
|
result !== null &&
|
|
240
|
-
|
|
240
|
+
"substitute" in result) {
|
|
241
241
|
this.values.set(name, result.substitute);
|
|
242
242
|
hook(result.substitute);
|
|
243
243
|
}
|
|
@@ -260,15 +260,15 @@ export class VarStore {
|
|
|
260
260
|
// "auto" all map to 'auto'. psql's actual call site does an
|
|
261
261
|
// `pg_strncasecmp(value, "auto", len)` before falling through to
|
|
262
262
|
// ParseVariableBool — we do the same.
|
|
263
|
-
if (isPrefixOf(value,
|
|
264
|
-
return
|
|
263
|
+
if (isPrefixOf(value, "auto"))
|
|
264
|
+
return "auto";
|
|
265
265
|
const parsed = parseBool(value);
|
|
266
266
|
if (parsed === null) {
|
|
267
267
|
return {
|
|
268
268
|
error: `unrecognized value "${value}" for "${name}": Boolean expected`,
|
|
269
269
|
};
|
|
270
270
|
}
|
|
271
|
-
return parsed ?
|
|
271
|
+
return parsed ? "on" : "off";
|
|
272
272
|
}
|
|
273
273
|
asInt(name, defaultValue = 0) {
|
|
274
274
|
const value = this.values.get(name);
|