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
package/dist/psql/print/html.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatNumericLocale } from
|
|
1
|
+
import { formatNumericLocale } from "./units.js";
|
|
2
2
|
/**
|
|
3
3
|
* HTML printer.
|
|
4
4
|
*
|
|
@@ -52,10 +52,10 @@ import { formatNumericLocale } from './units.js';
|
|
|
52
52
|
// INT2, INT4, INT8, FLOAT4, FLOAT8, NUMERIC, INTERVAL.
|
|
53
53
|
const NUMERIC_OIDS = new Set([21, 23, 20, 700, 701, 1700, 1186]);
|
|
54
54
|
export const htmlPrinter = {
|
|
55
|
-
format:
|
|
55
|
+
format: "html",
|
|
56
56
|
printQuery(rs, opts, out) {
|
|
57
57
|
const topt = opts.topt;
|
|
58
|
-
if (topt.expanded ===
|
|
58
|
+
if (topt.expanded === "on") {
|
|
59
59
|
return printExpanded(rs, opts, out);
|
|
60
60
|
}
|
|
61
61
|
return printFlat(rs, opts, out);
|
|
@@ -66,27 +66,27 @@ const printFlat = (rs, opts, out) => {
|
|
|
66
66
|
const tuplesOnly = topt.tuplesOnly;
|
|
67
67
|
const startTable = topt.startTable;
|
|
68
68
|
const stopTable = topt.stopTable;
|
|
69
|
-
const nullPrint = opts.nullPrint !==
|
|
69
|
+
const nullPrint = opts.nullPrint !== "" ? opts.nullPrint : topt.nullPrint;
|
|
70
70
|
const title = opts.title ?? topt.title;
|
|
71
71
|
const footers = opts.footers ?? topt.footers;
|
|
72
72
|
const headers = rs.fields.map((f) => f.name);
|
|
73
|
-
const aligns = rs.fields.map((f) => NUMERIC_OIDS.has(f.dataTypeID) ?
|
|
73
|
+
const aligns = rs.fields.map((f) => NUMERIC_OIDS.has(f.dataTypeID) ? "right" : "left");
|
|
74
74
|
const cells = rs.rows.map((row) => row.map((cell) => renderCell(cell, nullPrint, topt.numericLocale)));
|
|
75
|
-
let buf =
|
|
75
|
+
let buf = "";
|
|
76
76
|
if (startTable) {
|
|
77
77
|
buf += `<table border="${String(topt.border)}"`;
|
|
78
78
|
if (topt.tableAttr)
|
|
79
79
|
buf += ` ${topt.tableAttr}`;
|
|
80
|
-
buf +=
|
|
80
|
+
buf += ">\n";
|
|
81
81
|
if (!tuplesOnly && title) {
|
|
82
|
-
buf +=
|
|
82
|
+
buf += " <caption>" + escapeHtml(title) + "</caption>\n";
|
|
83
83
|
}
|
|
84
84
|
if (!tuplesOnly) {
|
|
85
|
-
buf +=
|
|
85
|
+
buf += " <tr>\n";
|
|
86
86
|
for (const h of headers) {
|
|
87
|
-
buf += ' <th align="center">' + escapeHtml(h) +
|
|
87
|
+
buf += ' <th align="center">' + escapeHtml(h) + "</th>\n";
|
|
88
88
|
}
|
|
89
|
-
buf +=
|
|
89
|
+
buf += " </tr>\n";
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
for (const row of cells) {
|
|
@@ -94,31 +94,31 @@ const printFlat = (rs, opts, out) => {
|
|
|
94
94
|
row.forEach((value, idx) => {
|
|
95
95
|
buf += ` <td align="${aligns[idx]}">`;
|
|
96
96
|
if (isWhitespaceOnly(value)) {
|
|
97
|
-
buf +=
|
|
97
|
+
buf += " ";
|
|
98
98
|
}
|
|
99
99
|
else {
|
|
100
100
|
buf += escapeHtml(value);
|
|
101
101
|
}
|
|
102
|
-
buf +=
|
|
102
|
+
buf += "</td>\n";
|
|
103
103
|
});
|
|
104
|
-
buf +=
|
|
104
|
+
buf += " </tr>\n";
|
|
105
105
|
}
|
|
106
106
|
if (stopTable) {
|
|
107
|
-
buf +=
|
|
107
|
+
buf += "</table>\n";
|
|
108
108
|
if (!tuplesOnly) {
|
|
109
109
|
const effective = effectiveFooters(rs, topt, footers);
|
|
110
110
|
if (effective.length > 0) {
|
|
111
|
-
buf +=
|
|
111
|
+
buf += "<p>";
|
|
112
112
|
for (const f of effective) {
|
|
113
|
-
buf += escapeHtml(f) +
|
|
113
|
+
buf += escapeHtml(f) + "<br />\n";
|
|
114
114
|
}
|
|
115
|
-
buf +=
|
|
115
|
+
buf += "</p>";
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
// Upstream `print_html_text` finishes with an unconditional
|
|
119
119
|
// `fputc('\n', fout)` AFTER the (optional) `<p>...</p>` block. The
|
|
120
120
|
// trailing newline appears regardless of footers / tuplesOnly.
|
|
121
|
-
buf +=
|
|
121
|
+
buf += "\n";
|
|
122
122
|
}
|
|
123
123
|
out.write(buf);
|
|
124
124
|
return Promise.resolve();
|
|
@@ -128,20 +128,20 @@ const printExpanded = (rs, opts, out) => {
|
|
|
128
128
|
const tuplesOnly = topt.tuplesOnly;
|
|
129
129
|
const startTable = topt.startTable;
|
|
130
130
|
const stopTable = topt.stopTable;
|
|
131
|
-
const nullPrint = opts.nullPrint !==
|
|
131
|
+
const nullPrint = opts.nullPrint !== "" ? opts.nullPrint : topt.nullPrint;
|
|
132
132
|
const title = opts.title ?? topt.title;
|
|
133
133
|
const footers = opts.footers ?? topt.footers;
|
|
134
134
|
const headers = rs.fields.map((f) => f.name);
|
|
135
|
-
const aligns = rs.fields.map((f) => NUMERIC_OIDS.has(f.dataTypeID) ?
|
|
135
|
+
const aligns = rs.fields.map((f) => NUMERIC_OIDS.has(f.dataTypeID) ? "right" : "left");
|
|
136
136
|
const cells = rs.rows.map((row) => row.map((cell) => renderCell(cell, nullPrint, topt.numericLocale)));
|
|
137
|
-
let buf =
|
|
137
|
+
let buf = "";
|
|
138
138
|
if (startTable) {
|
|
139
139
|
buf += `<table border="${String(topt.border)}"`;
|
|
140
140
|
if (topt.tableAttr)
|
|
141
141
|
buf += ` ${topt.tableAttr}`;
|
|
142
|
-
buf +=
|
|
142
|
+
buf += ">\n";
|
|
143
143
|
if (!tuplesOnly && title) {
|
|
144
|
-
buf +=
|
|
144
|
+
buf += " <caption>" + escapeHtml(title) + "</caption>\n";
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
let record = topt.prior + 1;
|
|
@@ -155,30 +155,30 @@ const printExpanded = (rs, opts, out) => {
|
|
|
155
155
|
}
|
|
156
156
|
row.forEach((value, idx) => {
|
|
157
157
|
buf += ' <tr valign="top">\n';
|
|
158
|
-
buf +=
|
|
158
|
+
buf += " <th>" + escapeHtml(headers[idx]) + "</th>\n";
|
|
159
159
|
buf += ` <td align="${aligns[idx]}">`;
|
|
160
160
|
if (isWhitespaceOnly(value)) {
|
|
161
|
-
buf +=
|
|
161
|
+
buf += " ";
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
164
|
buf += escapeHtml(value);
|
|
165
165
|
}
|
|
166
|
-
buf +=
|
|
167
|
-
buf +=
|
|
166
|
+
buf += "</td>\n";
|
|
167
|
+
buf += " </tr>\n";
|
|
168
168
|
});
|
|
169
169
|
});
|
|
170
170
|
if (stopTable) {
|
|
171
|
-
buf +=
|
|
171
|
+
buf += "</table>\n";
|
|
172
172
|
// Expanded mode never emits the default "(N rows)" footer; only
|
|
173
173
|
// user-supplied footers appear (matches print_html_vertical).
|
|
174
174
|
if (!tuplesOnly && footers && footers.length > 0) {
|
|
175
|
-
buf +=
|
|
175
|
+
buf += "<p>";
|
|
176
176
|
for (const f of footers) {
|
|
177
|
-
buf += escapeHtml(f) +
|
|
177
|
+
buf += escapeHtml(f) + "<br />\n";
|
|
178
178
|
}
|
|
179
|
-
buf +=
|
|
179
|
+
buf += "</p>";
|
|
180
180
|
}
|
|
181
|
-
buf +=
|
|
181
|
+
buf += "\n";
|
|
182
182
|
}
|
|
183
183
|
out.write(buf);
|
|
184
184
|
return Promise.resolve();
|
|
@@ -188,7 +188,7 @@ const effectiveFooters = (rs, topt, footers) => {
|
|
|
188
188
|
return footers;
|
|
189
189
|
if (topt.defaultFooter) {
|
|
190
190
|
const n = rs.rows.length;
|
|
191
|
-
return [`(${String(n)} ${n === 1 ?
|
|
191
|
+
return [`(${String(n)} ${n === 1 ? "row" : "rows"})`];
|
|
192
192
|
}
|
|
193
193
|
return [];
|
|
194
194
|
};
|
|
@@ -196,7 +196,7 @@ const isWhitespaceOnly = (s) => {
|
|
|
196
196
|
if (s.length === 0)
|
|
197
197
|
return true;
|
|
198
198
|
for (const ch of s) {
|
|
199
|
-
if (ch !==
|
|
199
|
+
if (ch !== " " && ch !== "\t")
|
|
200
200
|
return false;
|
|
201
201
|
}
|
|
202
202
|
return true;
|
|
@@ -205,32 +205,32 @@ const escapeHtml = (input) => {
|
|
|
205
205
|
// Upstream `html_escaped_print` walks the string byte-by-byte and
|
|
206
206
|
// converts leading spaces (per line) to ` ` so EXPLAIN output
|
|
207
207
|
// stays indented. We replicate that with a stateful pass.
|
|
208
|
-
let out =
|
|
208
|
+
let out = "";
|
|
209
209
|
let leadingSpace = true;
|
|
210
210
|
for (const ch of input) {
|
|
211
211
|
switch (ch) {
|
|
212
|
-
case
|
|
213
|
-
out +=
|
|
212
|
+
case "&":
|
|
213
|
+
out += "&";
|
|
214
214
|
break;
|
|
215
|
-
case
|
|
216
|
-
out +=
|
|
215
|
+
case "<":
|
|
216
|
+
out += "<";
|
|
217
217
|
break;
|
|
218
|
-
case
|
|
219
|
-
out +=
|
|
218
|
+
case ">":
|
|
219
|
+
out += ">";
|
|
220
220
|
break;
|
|
221
221
|
case '"':
|
|
222
|
-
out +=
|
|
222
|
+
out += """;
|
|
223
223
|
break;
|
|
224
|
-
case
|
|
225
|
-
out +=
|
|
224
|
+
case "\n":
|
|
225
|
+
out += "<br />\n";
|
|
226
226
|
break;
|
|
227
|
-
case
|
|
228
|
-
out += leadingSpace ?
|
|
227
|
+
case " ":
|
|
228
|
+
out += leadingSpace ? " " : " ";
|
|
229
229
|
break;
|
|
230
230
|
default:
|
|
231
231
|
out += ch;
|
|
232
232
|
}
|
|
233
|
-
if (ch !==
|
|
233
|
+
if (ch !== " ")
|
|
234
234
|
leadingSpace = false;
|
|
235
235
|
}
|
|
236
236
|
return out;
|
|
@@ -238,20 +238,20 @@ const escapeHtml = (input) => {
|
|
|
238
238
|
const renderCell = (cell, nullPrint, numericLocale) => {
|
|
239
239
|
if (cell === null || cell === undefined)
|
|
240
240
|
return nullPrint;
|
|
241
|
-
if (typeof cell ===
|
|
241
|
+
if (typeof cell === "string") {
|
|
242
242
|
return formatNumericLocale(cell, numericLocale);
|
|
243
243
|
}
|
|
244
|
-
if (typeof cell ===
|
|
244
|
+
if (typeof cell === "number" || typeof cell === "bigint") {
|
|
245
245
|
return formatNumericLocale(cell.toString(), numericLocale);
|
|
246
246
|
}
|
|
247
|
-
if (typeof cell ===
|
|
248
|
-
return cell ?
|
|
247
|
+
if (typeof cell === "boolean")
|
|
248
|
+
return cell ? "t" : "f";
|
|
249
249
|
if (cell instanceof Date)
|
|
250
250
|
return cell.toISOString();
|
|
251
251
|
if (cell instanceof Uint8Array) {
|
|
252
|
-
let hex =
|
|
252
|
+
let hex = "\\x";
|
|
253
253
|
for (const b of cell)
|
|
254
|
-
hex += b.toString(16).padStart(2,
|
|
254
|
+
hex += b.toString(16).padStart(2, "0");
|
|
255
255
|
return hex;
|
|
256
256
|
}
|
|
257
257
|
return JSON.stringify(cell);
|
package/dist/psql/print/json.js
CHANGED
|
@@ -30,9 +30,9 @@ const NUMERIC_TYPE_OIDS = new Set([
|
|
|
30
30
|
1700, // NUMERIC
|
|
31
31
|
]);
|
|
32
32
|
export const jsonPrinter = {
|
|
33
|
-
format:
|
|
33
|
+
format: "json",
|
|
34
34
|
printQuery(rs, opts, out) {
|
|
35
|
-
const pretty = opts.topt.expanded ===
|
|
35
|
+
const pretty = opts.topt.expanded === "on";
|
|
36
36
|
const objects = rs.rows.map((row) => {
|
|
37
37
|
const obj = {};
|
|
38
38
|
rs.fields.forEach((field, idx) => {
|
|
@@ -43,32 +43,32 @@ export const jsonPrinter = {
|
|
|
43
43
|
const serialized = pretty
|
|
44
44
|
? JSON.stringify(objects, null, 2)
|
|
45
45
|
: JSON.stringify(objects);
|
|
46
|
-
out.write(serialized +
|
|
46
|
+
out.write(serialized + "\n");
|
|
47
47
|
return Promise.resolve();
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
const renderCell = (cell, dataTypeID) => {
|
|
51
51
|
if (cell === null || cell === undefined)
|
|
52
52
|
return null;
|
|
53
|
-
if (typeof cell ===
|
|
53
|
+
if (typeof cell === "number") {
|
|
54
54
|
return Number.isFinite(cell) ? cell : cell.toString();
|
|
55
55
|
}
|
|
56
|
-
if (typeof cell ===
|
|
56
|
+
if (typeof cell === "bigint") {
|
|
57
57
|
// Preserve as string when outside safe integer range.
|
|
58
58
|
const asNum = Number(cell);
|
|
59
59
|
return BigInt(asNum) === cell ? asNum : cell.toString();
|
|
60
60
|
}
|
|
61
|
-
if (typeof cell ===
|
|
61
|
+
if (typeof cell === "boolean")
|
|
62
62
|
return cell;
|
|
63
63
|
if (cell instanceof Date)
|
|
64
64
|
return cell.toISOString();
|
|
65
65
|
if (cell instanceof Uint8Array) {
|
|
66
|
-
let hex =
|
|
66
|
+
let hex = "\\x";
|
|
67
67
|
for (const b of cell)
|
|
68
|
-
hex += b.toString(16).padStart(2,
|
|
68
|
+
hex += b.toString(16).padStart(2, "0");
|
|
69
69
|
return hex;
|
|
70
70
|
}
|
|
71
|
-
if (typeof cell ===
|
|
71
|
+
if (typeof cell === "string") {
|
|
72
72
|
if (NUMERIC_TYPE_OIDS.has(dataTypeID)) {
|
|
73
73
|
const parsed = Number(cell);
|
|
74
74
|
if (Number.isFinite(parsed) && String(parsed) === normalize(cell)) {
|
|
@@ -87,10 +87,10 @@ const renderCell = (cell, dataTypeID) => {
|
|
|
87
87
|
*/
|
|
88
88
|
const normalize = (s) => {
|
|
89
89
|
let v = s;
|
|
90
|
-
if (v.startsWith(
|
|
90
|
+
if (v.startsWith("+"))
|
|
91
91
|
v = v.slice(1);
|
|
92
|
-
if (v.includes(
|
|
93
|
-
v = v.replace(/0+$/,
|
|
92
|
+
if (v.includes(".")) {
|
|
93
|
+
v = v.replace(/0+$/, "").replace(/\.$/, "");
|
|
94
94
|
}
|
|
95
95
|
return v;
|
|
96
96
|
};
|