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,8 +1,8 @@
1
- import { spawn } from 'child_process';
2
- import which from 'which';
3
- import { closeAnalytics, trackEvent } from '../analytics.js';
4
- import { log } from '../log.js';
5
- const FALLBACK_ENV = 'NEONCTL_PSQL_FALLBACK';
1
+ import { spawn } from "child_process";
2
+ import which from "which";
3
+ import { closeAnalytics, trackEvent } from "../analytics.js";
4
+ import { log } from "../log.js";
5
+ const FALLBACK_ENV = "NEONCTL_PSQL_FALLBACK";
6
6
  /** Max time we wait for the analytics flush before handing off to psql. */
7
7
  const ANALYTICS_FLUSH_TIMEOUT_MS = 3000;
8
8
  /**
@@ -12,28 +12,28 @@ const ANALYTICS_FLUSH_TIMEOUT_MS = 3000;
12
12
  * cases rather than a misleading `false`.
13
13
  */
14
14
  const planPsql = async (opts) => {
15
- if (opts.mode === 'ts') {
15
+ if (opts.mode === "ts") {
16
16
  return {
17
- implementation: 'ts',
18
- reason: 'forced_flag',
17
+ implementation: "ts",
18
+ reason: "forced_flag",
19
19
  nativeAvailable: null,
20
20
  nativePath: null,
21
21
  };
22
22
  }
23
- if (process.env[FALLBACK_ENV] === '1') {
23
+ if (process.env[FALLBACK_ENV] === "1") {
24
24
  return {
25
- implementation: 'ts',
26
- reason: 'forced_env',
25
+ implementation: "ts",
26
+ reason: "forced_env",
27
27
  nativeAvailable: null,
28
28
  nativePath: null,
29
29
  };
30
30
  }
31
- const nativePath = await which('psql', { nothrow: true });
31
+ const nativePath = await which("psql", { nothrow: true });
32
32
  const nativeAvailable = nativePath !== null;
33
- if (opts.mode === 'native') {
33
+ if (opts.mode === "native") {
34
34
  return {
35
- implementation: 'native',
36
- reason: 'forced_native',
35
+ implementation: "native",
36
+ reason: "forced_native",
37
37
  nativeAvailable,
38
38
  nativePath,
39
39
  };
@@ -41,14 +41,14 @@ const planPsql = async (opts) => {
41
41
  // 'auto' (or unset): strict fallback — prefer native, TS only if missing.
42
42
  return nativeAvailable
43
43
  ? {
44
- implementation: 'native',
45
- reason: 'native_available',
44
+ implementation: "native",
45
+ reason: "native_available",
46
46
  nativeAvailable,
47
47
  nativePath,
48
48
  }
49
49
  : {
50
- implementation: 'ts',
51
- reason: 'fallback_no_native',
50
+ implementation: "ts",
51
+ reason: "fallback_no_native",
52
52
  nativeAvailable,
53
53
  nativePath,
54
54
  };
@@ -64,7 +64,7 @@ const planPsql = async (opts) => {
64
64
  * analytics is disabled (`--analytics false`), since the client is absent.
65
65
  */
66
66
  const reportPsqlInvocation = async (plan) => {
67
- trackEvent('psql_invoked', {
67
+ trackEvent("psql_invoked", {
68
68
  implementation: plan.implementation,
69
69
  reason: plan.reason,
70
70
  nativeAvailable: plan.nativeAvailable,
@@ -72,11 +72,11 @@ const reportPsqlInvocation = async (plan) => {
72
72
  await closeAnalytics({ timeout: ANALYTICS_FLUSH_TIMEOUT_MS });
73
73
  };
74
74
  const execNative = async (binary, connection_uri, args) => {
75
- log.info('Connecting to the database using psql...');
75
+ log.info("Connecting to the database using psql...");
76
76
  const child = spawn(binary, [connection_uri, ...args], {
77
- stdio: 'inherit',
77
+ stdio: "inherit",
78
78
  });
79
- for (const signame of ['SIGINT', 'SIGTERM']) {
79
+ for (const signame of ["SIGINT", "SIGTERM"]) {
80
80
  process.on(signame, (code) => {
81
81
  if (!child.killed && code !== null) {
82
82
  child.kill(code);
@@ -84,15 +84,15 @@ const execNative = async (binary, connection_uri, args) => {
84
84
  });
85
85
  }
86
86
  return new Promise((_, reject) => {
87
- child.on('exit', (code) => {
87
+ child.on("exit", (code) => {
88
88
  process.exit(code === null ? 1 : code);
89
89
  });
90
- child.on('error', reject);
90
+ child.on("error", reject);
91
91
  });
92
92
  };
93
93
  const execTs = async (connection_uri, args) => {
94
- log.info('Connecting to the database using embedded psql (TypeScript)...');
95
- const { runPsql } = await import('../psql/index.js');
94
+ log.info("Connecting to the database using embedded psql (TypeScript)...");
95
+ const { runPsql } = await import("../psql/index.js");
96
96
  const code = await runPsql([connection_uri, ...args], {
97
97
  stdin: process.stdin,
98
98
  stdout: process.stdout,
@@ -103,9 +103,9 @@ const execTs = async (connection_uri, args) => {
103
103
  export const psql = async (connection_uri, args = [], opts = {}) => {
104
104
  const plan = await planPsql(opts);
105
105
  await reportPsqlInvocation(plan);
106
- if (plan.implementation === 'ts') {
107
- if (plan.reason === 'fallback_no_native') {
108
- log.info('psql binary not found on PATH; falling back to embedded TypeScript psql');
106
+ if (plan.implementation === "ts") {
107
+ if (plan.reason === "fallback_no_native") {
108
+ log.info("psql binary not found on PATH; falling back to embedded TypeScript psql");
109
109
  }
110
110
  return execTs(connection_uri, args);
111
111
  }
@@ -1,5 +1,5 @@
1
1
  export const toSnakeCase = (str) => str
2
- .split(' ')
2
+ .split(" ")
3
3
  .map((word) => word.toLowerCase())
4
- .join('_');
4
+ .join("_");
5
5
  export const isObject = (value) => value != null && value === Object(value);
package/dist/utils/ui.js CHANGED
@@ -4,7 +4,7 @@
4
4
  export const consumeNextMatching = (lines, matcher) => {
5
5
  while (lines.length > 0) {
6
6
  const line = lines.shift().trim();
7
- if (line === '') {
7
+ if (line === "") {
8
8
  continue;
9
9
  }
10
10
  if (matcher.test(line)) {
@@ -23,7 +23,7 @@ export const consumeBlockIfMatches = (lines, matcher) => {
23
23
  return result;
24
24
  }
25
25
  let line = lines.shift();
26
- while (line.trim() === '') {
26
+ while (line.trim() === "") {
27
27
  line = lines.shift();
28
28
  }
29
29
  if (!matcher.test(line)) {
@@ -33,7 +33,7 @@ export const consumeBlockIfMatches = (lines, matcher) => {
33
33
  result.push(line);
34
34
  while (lines.length > 0) {
35
35
  line = lines.shift();
36
- if (line.trim() === '') {
36
+ if (line.trim() === "") {
37
37
  break;
38
38
  }
39
39
  result.push(line);
@@ -42,18 +42,18 @@ export const consumeBlockIfMatches = (lines, matcher) => {
42
42
  };
43
43
  export const splitColumns = (line) => {
44
44
  const result = line.trim().split(/\s{2,}/);
45
- result[1] = result[1] ?? '';
45
+ result[1] = result[1] ?? "";
46
46
  if (result.length > 2) {
47
- result[1] = result.slice(1).join(' ');
47
+ result[1] = result.slice(1).join(" ");
48
48
  }
49
49
  return result;
50
50
  };
51
51
  export const drawPointer = (width) => {
52
52
  const result = [];
53
- result.push('');
53
+ result.push("");
54
54
  for (let i = 0; i < width - 4; i++) {
55
- result.push('');
55
+ result.push("");
56
56
  }
57
- result.push('>');
58
- return result.join('');
57
+ result.push(">");
58
+ return result.join("");
59
59
  };
package/dist/utils/zip.js CHANGED
@@ -1,4 +1,4 @@
1
- import { zipSync } from 'fflate';
1
+ import { zipSync } from "fflate";
2
2
  // Zip the esbuild output (index.mjs) into the archive the Functions deploy endpoint
3
3
  // expects. Compression level 6 matches the previous bundler.
4
4
  export const zipBundle = (entries) => zipSync(entries, { level: 6 });
package/dist/writer.js CHANGED
@@ -1,8 +1,8 @@
1
- import YAML from 'yaml';
2
- import Table from 'cli-table';
3
- import chalk from 'chalk';
4
- import { isCi } from './env.js';
5
- import { isObject, toSnakeCase } from './utils/string.js';
1
+ import chalk from "chalk";
2
+ import Table from "cli-table";
3
+ import YAML from "yaml";
4
+ import { isCi } from "./env.js";
5
+ import { isObject, toSnakeCase } from "./utils/string.js";
6
6
  const writeYaml = (chunks) => {
7
7
  return YAML.stringify(chunks.length === 1
8
8
  ? chunks[0].data
@@ -20,21 +20,21 @@ const writeJson = (chunks) => {
20
20
  ])), null, 2);
21
21
  };
22
22
  const writeTable = (chunks, out) => {
23
- chunks.forEach(({ data, config: { emptyMessage, fields, title, renderColumns = {} } }) => {
23
+ chunks.forEach(({ data, config: { emptyMessage, fields, title, renderColumns = {} }, }) => {
24
24
  const arrayData = Array.isArray(data) ? data : [data];
25
25
  if (!arrayData.length && emptyMessage) {
26
- out.write('\n' + emptyMessage + '\n');
26
+ out.write("\n" + emptyMessage + "\n");
27
27
  return;
28
28
  }
29
- const fieldsFiltered = fields.filter((field) => arrayData.some((item) => item[field] !== undefined && item[field] !== ''));
29
+ const fieldsFiltered = fields.filter((field) => arrayData.some((item) => item[field] !== undefined && item[field] !== ""));
30
30
  const table = new Table({
31
31
  style: {
32
- head: ['green'],
32
+ head: ["green"],
33
33
  },
34
34
  head: fieldsFiltered.map((field) => field
35
- .split('_')
35
+ .split("_")
36
36
  .map((word) => word[0].toUpperCase() + word.slice(1))
37
- .join(' ')),
37
+ .join(" ")),
38
38
  });
39
39
  arrayData.forEach((item) => {
40
40
  table.push(fieldsFiltered.map((field) => {
@@ -43,17 +43,17 @@ const writeTable = (chunks, out) => {
43
43
  return renderColumns[field]?.(item);
44
44
  }
45
45
  return Array.isArray(value)
46
- ? value.join('\n')
46
+ ? value.join("\n")
47
47
  : isObject(value)
48
48
  ? JSON.stringify(value, null, 2)
49
- : (value ?? '');
49
+ : (value ?? "");
50
50
  }));
51
51
  });
52
52
  if (title) {
53
- out.write((isCi() ? title : chalk.bold(title)) + '\n');
53
+ out.write((isCi() ? title : chalk.bold(title)) + "\n");
54
54
  }
55
55
  out.write(table.toString());
56
- out.write('\n');
56
+ out.write("\n");
57
57
  });
58
58
  };
59
59
  /**
@@ -85,10 +85,10 @@ export const writer = (props) => {
85
85
  if (args.length === 2) {
86
86
  chunks.push({ data: args[0], config: args[1] });
87
87
  }
88
- if (props.output == 'yaml') {
88
+ if (props.output == "yaml") {
89
89
  return out.write(writeYaml(chunks));
90
90
  }
91
- if (props.output == 'json') {
91
+ if (props.output == "json") {
92
92
  return out.write(writeJson(chunks));
93
93
  }
94
94
  writeTable(chunks, out);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neonctl",
3
- "version": "2.28.0",
3
+ "version": "2.29.1",
4
4
  "description": "CLI tool for Neon Serverless Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -51,10 +51,10 @@
51
51
  "which": "3.0.1",
52
52
  "yaml": "2.4.5",
53
53
  "yargs": "17.7.2",
54
+ "@neon/config": "0.8.1",
54
55
  "@neon/sdk": "0.1.0",
55
- "@neondatabase/config": "0.8.1",
56
- "@neondatabase/config-runtime": "0.8.1",
57
- "@neondatabase/env": "0.8.1"
56
+ "@neon/env": "0.9.0",
57
+ "@neon/config-runtime": "0.8.1"
58
58
  },
59
59
  "optionalDependencies": {
60
60
  "esbuild": "0.28.0"
@@ -82,7 +82,6 @@
82
82
  "node-pty": "1.1.0",
83
83
  "oauth2-mock-server": "8.1.0",
84
84
  "openapi-types": "12.1.3",
85
- "prettier": "3.3.3",
86
85
  "rollup": "3.29.4",
87
86
  "strip-ansi": "7.1.0",
88
87
  "tsx": "4.22.3",
@@ -114,8 +113,8 @@
114
113
  "build": "pnpm generateParams && pnpm clean && tsc -p tsconfig.build.json && cp src/*.html ./dist",
115
114
  "bundle": "node pkg.js",
116
115
  "typecheck": "tsc --noEmit",
117
- "lint": "pnpm typecheck && eslint src && prettier --check .",
118
- "lint:fix": "pnpm typecheck && eslint src --fix && prettier --w .",
116
+ "lint": "pnpm typecheck && eslint src",
117
+ "lint:fix": "pnpm typecheck && eslint src --fix",
119
118
  "test": "pnpm build && vitest run",
120
119
  "test:ci": "pnpm build && vitest run",
121
120
  "test:conformance": "vitest run --config tests/psql-conformance/vitest.config.ts"