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.
Files changed (135) hide show
  1. package/README.md +71 -71
  2. package/dist/analytics.js +35 -33
  3. package/dist/api.js +34 -34
  4. package/dist/auth.js +50 -44
  5. package/dist/cli.js +2 -2
  6. package/dist/commands/auth.js +58 -52
  7. package/dist/commands/bootstrap.js +115 -157
  8. package/dist/commands/branches.js +154 -147
  9. package/dist/commands/bucket.js +124 -118
  10. package/dist/commands/checkout.js +49 -49
  11. package/dist/commands/config.js +212 -88
  12. package/dist/commands/connection_string.js +62 -62
  13. package/dist/commands/data_api.js +96 -96
  14. package/dist/commands/databases.js +23 -23
  15. package/dist/commands/deploy.js +12 -12
  16. package/dist/commands/dev.js +114 -114
  17. package/dist/commands/env.js +43 -43
  18. package/dist/commands/functions.js +97 -98
  19. package/dist/commands/index.js +26 -26
  20. package/dist/commands/init.js +23 -22
  21. package/dist/commands/ip_allow.js +29 -29
  22. package/dist/commands/link.js +223 -166
  23. package/dist/commands/neon_auth.js +381 -363
  24. package/dist/commands/operations.js +11 -11
  25. package/dist/commands/orgs.js +8 -8
  26. package/dist/commands/projects.js +101 -99
  27. package/dist/commands/psql.js +31 -31
  28. package/dist/commands/roles.js +21 -21
  29. package/dist/commands/schema_diff.js +23 -23
  30. package/dist/commands/set_context.js +17 -17
  31. package/dist/commands/status.js +17 -17
  32. package/dist/commands/user.js +5 -5
  33. package/dist/commands/vpc_endpoints.js +50 -50
  34. package/dist/config.js +7 -7
  35. package/dist/config_format.js +5 -5
  36. package/dist/context.js +23 -16
  37. package/dist/current_branch_fast_path.js +6 -6
  38. package/dist/dev/env.js +34 -34
  39. package/dist/dev/functions.js +4 -4
  40. package/dist/dev/inputs.js +6 -6
  41. package/dist/dev/runtime.js +25 -25
  42. package/dist/env.js +14 -14
  43. package/dist/env_file.js +13 -13
  44. package/dist/errors.js +19 -19
  45. package/dist/functions_api.js +10 -10
  46. package/dist/help.js +15 -15
  47. package/dist/index.js +94 -92
  48. package/dist/log.js +2 -2
  49. package/dist/pkg.js +5 -5
  50. package/dist/psql/cli.js +4 -2
  51. package/dist/psql/command/cmd_cond.js +61 -61
  52. package/dist/psql/command/cmd_connect.js +159 -154
  53. package/dist/psql/command/cmd_copy.js +107 -97
  54. package/dist/psql/command/cmd_describe.js +368 -363
  55. package/dist/psql/command/cmd_format.js +276 -263
  56. package/dist/psql/command/cmd_io.js +269 -263
  57. package/dist/psql/command/cmd_lo.js +74 -66
  58. package/dist/psql/command/cmd_meta.js +148 -148
  59. package/dist/psql/command/cmd_misc.js +17 -17
  60. package/dist/psql/command/cmd_pipeline.js +142 -135
  61. package/dist/psql/command/cmd_restrict.js +25 -25
  62. package/dist/psql/command/cmd_show.js +183 -168
  63. package/dist/psql/command/dispatch.js +26 -26
  64. package/dist/psql/command/shared.js +14 -14
  65. package/dist/psql/complete/filenames.js +16 -16
  66. package/dist/psql/complete/index.js +4 -4
  67. package/dist/psql/complete/matcher.js +33 -32
  68. package/dist/psql/complete/psqlVars.js +173 -173
  69. package/dist/psql/complete/queries.js +5 -3
  70. package/dist/psql/complete/rules.js +900 -863
  71. package/dist/psql/core/common.js +136 -133
  72. package/dist/psql/core/help.js +343 -343
  73. package/dist/psql/core/mainloop.js +160 -153
  74. package/dist/psql/core/prompt.js +126 -123
  75. package/dist/psql/core/settings.js +111 -111
  76. package/dist/psql/core/sqlHelp.js +150 -150
  77. package/dist/psql/core/startup.js +211 -205
  78. package/dist/psql/core/syncVars.js +14 -14
  79. package/dist/psql/core/variables.js +24 -24
  80. package/dist/psql/describe/formatters.js +302 -289
  81. package/dist/psql/describe/processNamePattern.js +28 -28
  82. package/dist/psql/describe/queries.js +656 -651
  83. package/dist/psql/index.js +436 -411
  84. package/dist/psql/io/history.js +36 -36
  85. package/dist/psql/io/input.js +15 -15
  86. package/dist/psql/io/lineEditor/buffer.js +27 -25
  87. package/dist/psql/io/lineEditor/complete.js +15 -15
  88. package/dist/psql/io/lineEditor/filename.js +22 -22
  89. package/dist/psql/io/lineEditor/index.js +65 -62
  90. package/dist/psql/io/lineEditor/keymap.js +325 -318
  91. package/dist/psql/io/lineEditor/vt100.js +60 -60
  92. package/dist/psql/io/pgpass.js +18 -18
  93. package/dist/psql/io/pgservice.js +14 -14
  94. package/dist/psql/io/psqlrc.js +46 -46
  95. package/dist/psql/print/aligned.js +175 -166
  96. package/dist/psql/print/asciidoc.js +51 -51
  97. package/dist/psql/print/crosstab.js +34 -31
  98. package/dist/psql/print/csv.js +25 -22
  99. package/dist/psql/print/html.js +54 -54
  100. package/dist/psql/print/json.js +12 -12
  101. package/dist/psql/print/latex.js +118 -118
  102. package/dist/psql/print/pager.js +28 -26
  103. package/dist/psql/print/troff.js +48 -48
  104. package/dist/psql/print/unaligned.js +15 -14
  105. package/dist/psql/print/units.js +17 -17
  106. package/dist/psql/scanner/slash.js +48 -46
  107. package/dist/psql/scanner/sql.js +88 -84
  108. package/dist/psql/scanner/stringutils.js +21 -17
  109. package/dist/psql/types/index.js +7 -7
  110. package/dist/psql/types/scanner.js +8 -8
  111. package/dist/psql/wire/connection.js +341 -327
  112. package/dist/psql/wire/copy.js +7 -7
  113. package/dist/psql/wire/pipeline.js +26 -24
  114. package/dist/psql/wire/protocol.js +102 -102
  115. package/dist/psql/wire/sasl.js +62 -62
  116. package/dist/psql/wire/tls.js +79 -73
  117. package/dist/storage_api.js +15 -15
  118. package/dist/test_utils/fixtures.js +34 -31
  119. package/dist/test_utils/oauth_server.js +5 -5
  120. package/dist/utils/api_enums.js +13 -13
  121. package/dist/utils/branch_notice.js +5 -5
  122. package/dist/utils/branch_picker.js +26 -26
  123. package/dist/utils/compute_units.js +4 -4
  124. package/dist/utils/enrichers.js +20 -15
  125. package/dist/utils/esbuild.js +28 -28
  126. package/dist/utils/formats.js +1 -1
  127. package/dist/utils/middlewares.js +3 -3
  128. package/dist/utils/package_manager.js +68 -0
  129. package/dist/utils/point_in_time.js +12 -12
  130. package/dist/utils/psql.js +30 -30
  131. package/dist/utils/string.js +2 -2
  132. package/dist/utils/ui.js +9 -9
  133. package/dist/utils/zip.js +1 -1
  134. package/dist/writer.js +17 -17
  135. package/package.json +6 -7
@@ -1,4 +1,4 @@
1
- import { formatNumericLocale } from './units.js';
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: 'html',
55
+ format: "html",
56
56
  printQuery(rs, opts, out) {
57
57
  const topt = opts.topt;
58
- if (topt.expanded === 'on') {
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 !== '' ? opts.nullPrint : topt.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) ? 'right' : 'left');
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 += '>\n';
80
+ buf += ">\n";
81
81
  if (!tuplesOnly && title) {
82
- buf += ' <caption>' + escapeHtml(title) + '</caption>\n';
82
+ buf += " <caption>" + escapeHtml(title) + "</caption>\n";
83
83
  }
84
84
  if (!tuplesOnly) {
85
- buf += ' <tr>\n';
85
+ buf += " <tr>\n";
86
86
  for (const h of headers) {
87
- buf += ' <th align="center">' + escapeHtml(h) + '</th>\n';
87
+ buf += ' <th align="center">' + escapeHtml(h) + "</th>\n";
88
88
  }
89
- buf += ' </tr>\n';
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 += '&nbsp; ';
97
+ buf += "&nbsp; ";
98
98
  }
99
99
  else {
100
100
  buf += escapeHtml(value);
101
101
  }
102
- buf += '</td>\n';
102
+ buf += "</td>\n";
103
103
  });
104
- buf += ' </tr>\n';
104
+ buf += " </tr>\n";
105
105
  }
106
106
  if (stopTable) {
107
- buf += '</table>\n';
107
+ buf += "</table>\n";
108
108
  if (!tuplesOnly) {
109
109
  const effective = effectiveFooters(rs, topt, footers);
110
110
  if (effective.length > 0) {
111
- buf += '<p>';
111
+ buf += "<p>";
112
112
  for (const f of effective) {
113
- buf += escapeHtml(f) + '<br />\n';
113
+ buf += escapeHtml(f) + "<br />\n";
114
114
  }
115
- buf += '</p>';
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 += '\n';
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 !== '' ? opts.nullPrint : topt.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) ? 'right' : 'left');
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 += '>\n';
142
+ buf += ">\n";
143
143
  if (!tuplesOnly && title) {
144
- buf += ' <caption>' + escapeHtml(title) + '</caption>\n';
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 += ' <th>' + escapeHtml(headers[idx]) + '</th>\n';
158
+ buf += " <th>" + escapeHtml(headers[idx]) + "</th>\n";
159
159
  buf += ` <td align="${aligns[idx]}">`;
160
160
  if (isWhitespaceOnly(value)) {
161
- buf += '&nbsp; ';
161
+ buf += "&nbsp; ";
162
162
  }
163
163
  else {
164
164
  buf += escapeHtml(value);
165
165
  }
166
- buf += '</td>\n';
167
- buf += ' </tr>\n';
166
+ buf += "</td>\n";
167
+ buf += " </tr>\n";
168
168
  });
169
169
  });
170
170
  if (stopTable) {
171
- buf += '</table>\n';
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 += '<p>';
175
+ buf += "<p>";
176
176
  for (const f of footers) {
177
- buf += escapeHtml(f) + '<br />\n';
177
+ buf += escapeHtml(f) + "<br />\n";
178
178
  }
179
- buf += '</p>';
179
+ buf += "</p>";
180
180
  }
181
- buf += '\n';
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 ? 'row' : 'rows'})`];
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 !== ' ' && ch !== '\t')
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 `&nbsp;` 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 += '&amp;';
212
+ case "&":
213
+ out += "&amp;";
214
214
  break;
215
- case '<':
216
- out += '&lt;';
215
+ case "<":
216
+ out += "&lt;";
217
217
  break;
218
- case '>':
219
- out += '&gt;';
218
+ case ">":
219
+ out += "&gt;";
220
220
  break;
221
221
  case '"':
222
- out += '&quot;';
222
+ out += "&quot;";
223
223
  break;
224
- case '\n':
225
- out += '<br />\n';
224
+ case "\n":
225
+ out += "<br />\n";
226
226
  break;
227
- case ' ':
228
- out += leadingSpace ? '&nbsp;' : ' ';
227
+ case " ":
228
+ out += leadingSpace ? "&nbsp;" : " ";
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 === 'string') {
241
+ if (typeof cell === "string") {
242
242
  return formatNumericLocale(cell, numericLocale);
243
243
  }
244
- if (typeof cell === 'number' || typeof cell === 'bigint') {
244
+ if (typeof cell === "number" || typeof cell === "bigint") {
245
245
  return formatNumericLocale(cell.toString(), numericLocale);
246
246
  }
247
- if (typeof cell === 'boolean')
248
- return cell ? 't' : 'f';
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 = '\\x';
252
+ let hex = "\\x";
253
253
  for (const b of cell)
254
- hex += b.toString(16).padStart(2, '0');
254
+ hex += b.toString(16).padStart(2, "0");
255
255
  return hex;
256
256
  }
257
257
  return JSON.stringify(cell);
@@ -30,9 +30,9 @@ const NUMERIC_TYPE_OIDS = new Set([
30
30
  1700, // NUMERIC
31
31
  ]);
32
32
  export const jsonPrinter = {
33
- format: 'json',
33
+ format: "json",
34
34
  printQuery(rs, opts, out) {
35
- const pretty = opts.topt.expanded === 'on';
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 + '\n');
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 === 'number') {
53
+ if (typeof cell === "number") {
54
54
  return Number.isFinite(cell) ? cell : cell.toString();
55
55
  }
56
- if (typeof cell === 'bigint') {
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 === 'boolean')
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 = '\\x';
66
+ let hex = "\\x";
67
67
  for (const b of cell)
68
- hex += b.toString(16).padStart(2, '0');
68
+ hex += b.toString(16).padStart(2, "0");
69
69
  return hex;
70
70
  }
71
- if (typeof cell === 'string') {
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+$/, '').replace(/\.$/, '');
92
+ if (v.includes(".")) {
93
+ v = v.replace(/0+$/, "").replace(/\.$/, "");
94
94
  }
95
95
  return v;
96
96
  };