neon 9.8.0 → 9.9.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 (48) hide show
  1. package/dist/_chunks/{auth-DY5Bm7Ym.js → auth-CEb642X3.js} +20 -9
  2. package/dist/_chunks/{auth_selection-CwGLN9Qz.js → auth_selection-D81EvEz9.js} +1 -1
  3. package/dist/_chunks/{checkout-DZa--fO4.js → checkout-F7PRl-Nf.js} +3 -3
  4. package/dist/_chunks/{claim-Dv5wARrN.js → claim-DHuMf7GY.js} +2 -2
  5. package/dist/_chunks/{computes-OKFUNFee.js → computes-Cgc9-J33.js} +4 -15
  6. package/dist/_chunks/{config-DFj1Btk-.js → config-Dyvrv889.js} +2 -2
  7. package/dist/_chunks/{credential_io-DbeSh3Pl.js → credential_io-BHwacMdt.js} +1 -1
  8. package/dist/_chunks/{deploy-CVJIahZE.js → deploy-fzFvEdZN.js} +1 -1
  9. package/dist/_chunks/{dev-CtIzg7vq.js → dev-ZgBcYqnZ.js} +3 -3
  10. package/dist/_chunks/{git-ax3xtNoz.js → git-Ov1-tWen.js} +2 -2
  11. package/dist/_chunks/{link-Z2_mLhVn.js → link-JQXbQuxd.js} +2 -2
  12. package/dist/_chunks/{postgres-BhR1vUFM.js → postgres-BbEt_7c9.js} +1 -1
  13. package/dist/_chunks/{profile-Qoyql0AR.js → profile-BVkmMwHO.js} +68 -28
  14. package/dist/_chunks/{profiles-DTazQtjK.js → profiles-kpRUx7gU.js} +32 -2
  15. package/dist/_chunks/{status-DRWS1u6H.js → status-CJMDKch2.js} +1 -1
  16. package/dist/analytics.js +1 -1
  17. package/dist/auth_recovery.js +2 -2
  18. package/dist/commands/auth.js +1 -1
  19. package/dist/commands/checkout.js +1 -1
  20. package/dist/commands/claim.js +1 -1
  21. package/dist/commands/computes.js +1 -1
  22. package/dist/commands/config.js +1 -1
  23. package/dist/commands/deploy.js +1 -1
  24. package/dist/commands/dev.js +1 -1
  25. package/dist/commands/env.js +1 -1
  26. package/dist/commands/functions_new.js +1 -1
  27. package/dist/commands/git.js +1 -1
  28. package/dist/commands/index.js +12 -12
  29. package/dist/commands/link.js +1 -1
  30. package/dist/commands/postgres.js +1 -1
  31. package/dist/commands/profile.js +1 -1
  32. package/dist/commands/status.js +1 -1
  33. package/dist/commands/subscribe.js +1 -1
  34. package/dist/credential_io.js +1 -1
  35. package/dist/hosts.js +130 -0
  36. package/dist/index.js +8 -6
  37. package/dist/init/auth.js +2 -2
  38. package/dist/init/deploy.js +2 -2
  39. package/dist/init/detect.js +3 -3
  40. package/dist/init/link.js +2 -2
  41. package/dist/init/run.js +3 -3
  42. package/dist/retire_credential.js +1 -1
  43. package/dist/utils/inspect_db.js +1 -1
  44. package/dist/utils/inspect_queries.js +43 -17
  45. package/dist/utils/middlewares.js +1 -1
  46. package/dist/utils/staging.js +6 -16
  47. package/package.json +6 -6
  48. package/dist/_chunks/{env-DxcO3oJk.js → env-Bko0oXq9.js} +1 -1
@@ -1,30 +1,30 @@
1
- import { r as auth_exports } from "../_chunks/auth-DY5Bm7Ym.js";
1
+ import { r as auth_exports } from "../_chunks/auth-CEb642X3.js";
2
2
  import { t as api_exports } from "../_chunks/api-1MKsfpY3.js";
3
3
  import { n as api_keys_exports } from "../_chunks/api_keys-CTFHd5m_.js";
4
4
  import { n as ask_exports } from "../_chunks/ask-Xlek1Pxh.js";
5
- import { o as env_exports } from "../_chunks/env-DxcO3oJk.js";
6
- import { c as config_exports } from "../_chunks/config-DFj1Btk-.js";
5
+ import { o as env_exports } from "../_chunks/env-Bko0oXq9.js";
6
+ import { c as config_exports } from "../_chunks/config-Dyvrv889.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-Z2_mLhVn.js";
8
+ import { a as link_exports } from "../_chunks/link-JQXbQuxd.js";
9
9
  import { o as mcp_exports } from "../_chunks/mcp-SvqWzHnT.js";
10
10
  import { c as plugins_exports } from "../_chunks/plugins-BwUZQ6Ic.js";
11
11
  import { l as skills_exports } from "../_chunks/skills-Bv8oKKwE.js";
12
12
  import { t as bootstrap_exports } from "../_chunks/bootstrap-B73qVB39.js";
13
13
  import { r as branches_exports } from "../_chunks/branches-Bp-5z1lM.js";
14
14
  import { n as bucket_exports } from "../_chunks/bucket-D06bvDSa.js";
15
- import { n as checkout_exports } from "../_chunks/checkout-DZa--fO4.js";
16
- import { o as claim_exports } from "../_chunks/claim-Dv5wARrN.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-F7PRl-Nf.js";
16
+ import { o as claim_exports } from "../_chunks/claim-DHuMf7GY.js";
17
17
  import { o as connection_string_exports } from "../_chunks/connection_string-6WhV4WFx.js";
18
18
  import { a as credentials_exports } from "../_chunks/credentials-KV1jlK-n.js";
19
19
  import { r as data_api_exports } from "../_chunks/data_api-BpSGbdZf.js";
20
20
  import { s as databases_exports } from "../_chunks/databases-B-qY303S.js";
21
- import { r as deploy_exports } from "../_chunks/deploy-CVJIahZE.js";
22
- import { s as dev_exports } from "../_chunks/dev-CtIzg7vq.js";
21
+ import { r as deploy_exports } from "../_chunks/deploy-fzFvEdZN.js";
22
+ import { s as dev_exports } from "../_chunks/dev-ZgBcYqnZ.js";
23
23
  import { i as diff_exports } from "../_chunks/diff-dnxneH0u.js";
24
24
  import { c as docs_exports } from "../_chunks/docs-DjYRHjGY.js";
25
25
  import { o as feedback_exports } from "../_chunks/feedback-mQmdTRFn.js";
26
26
  import { o as functions_exports } from "../_chunks/functions-PHaU-kRb.js";
27
- import { o as git_exports } from "../_chunks/git-ax3xtNoz.js";
27
+ import { o as git_exports } from "../_chunks/git-Ov1-tWen.js";
28
28
  import { o as incidents_exports } from "../_chunks/incidents-BSFkUu1P.js";
29
29
  import { a as init_exports } from "../_chunks/init-BSwLzxjX.js";
30
30
  import { o as inspect_exports } from "../_chunks/inspect-yFAb61qo.js";
@@ -36,12 +36,12 @@ import { c as operations_exports } from "../_chunks/operations-D7qGkKo3.js";
36
36
  import { o as orgs_exports } from "../_chunks/orgs-BrvAWM8Z.js";
37
37
  import { o as psql_exports } from "../_chunks/psql-BcxiPR4W.js";
38
38
  import { f as roles_exports } from "../_chunks/roles-BELJqjTy.js";
39
- import { o as postgres_exports } from "../_chunks/postgres-BhR1vUFM.js";
40
- import { o as profile_exports } from "../_chunks/profile-Qoyql0AR.js";
39
+ import { o as postgres_exports } from "../_chunks/postgres-BbEt_7c9.js";
40
+ import { o as profile_exports } from "../_chunks/profile-BVkmMwHO.js";
41
41
  import { s as realtime_exports } from "../_chunks/realtime-cV7-c2-O.js";
42
42
  import { a as set_context_exports } from "../_chunks/set_context-ompB6d2D.js";
43
43
  import { s as snapshots_exports } from "../_chunks/snapshots-DxNhjcco.js";
44
- import { a as status_exports } from "../_chunks/status-DRWS1u6H.js";
44
+ import { a as status_exports } from "../_chunks/status-CJMDKch2.js";
45
45
  import { d as triggers_exports } from "../_chunks/triggers-m3IBjiph.js";
46
46
  import { s as user_exports } from "../_chunks/user-C1pTJS9O.js";
47
47
  import { i as vpc_endpoints_exports } from "../_chunks/vpc_endpoints-C-Y4WK2M.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-Z2_mLhVn.js";
1
+ export { t as builder, n as command, r as describe, i as handler, o as quoteFlagValue, s as runLink, c as shouldOfferConfigInit } from "../_chunks/link-JQXbQuxd.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/postgres-BhR1vUFM.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/postgres-BbEt_7c9.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-Qoyql0AR.js";
1
+ export { t as aliases, n as builder, r as command, i as describe, a as handler } from "../_chunks/profile-BVkmMwHO.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-DRWS1u6H.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-CJMDKch2.js";
@@ -1,6 +1,6 @@
1
1
  import { writer } from "../writer.js";
2
- import { branchIdFromProps } from "../utils/enrichers.js";
3
2
  import { o as resolveNeonEnvVars } from "../_chunks/env-CFBmcKyo.js";
3
+ import { branchIdFromProps } from "../utils/enrichers.js";
4
4
  import YAML from "yaml";
5
5
  // src/commands/subscribe.ts
6
6
  const builder = (argv) => argv.usage("$0 realtime subscribe \"<query>\" [options]").positional("query", {
@@ -1 +1 @@
1
- export { t as storeFor } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ export { t as storeFor } from "./_chunks/credential_io-BHwacMdt.js";
package/dist/hosts.js ADDED
@@ -0,0 +1,130 @@
1
+ import { DEFAULT_API_HOST } from "./api.js";
2
+ import { r as defaultDir } from "./_chunks/paths-B55ZfOg1.js";
3
+ import { c as inspectProfiles, l as isHttpUrl, s as hostsOf } from "./_chunks/profiles-kpRUx7gU.js";
4
+ import { i as selectCredential } from "./_chunks/auth_selection-D81EvEz9.js";
5
+ import { Parser, hideBin } from "yargs/helpers";
6
+ // src/hosts.ts
7
+ /**
8
+ * # Which Neon API and OAuth hosts an invocation talks to
9
+ *
10
+ * Per host, each entry winning over the next:
11
+ *
12
+ * 1. `--api-host` / `--oauth-host`.
13
+ * 2. The host recorded on the named profile whose credential this invocation uses.
14
+ * 3. `NEON_API_HOST` / `NEON_OAUTH_HOST`.
15
+ * 4. Production.
16
+ *
17
+ * A recorded host outranks the environment variable for the reason `--profile` outranks
18
+ * `NEON_API_KEY`: the profile's credential is valid only on the environment that issued it, so an
19
+ * exported host must not send it somewhere else. Only a flag typed for this one command does.
20
+ *
21
+ * Hosts are recorded only from those flags, on `neon login --profile <name>` and `neon profile
22
+ * create <name>`. The environment variables are never written down, so exporting one keeps
23
+ * meaning "this shell", as it did before profiles could hold hosts.
24
+ *
25
+ * The arguments are read before yargs runs, because the staging gate decides which commands to
26
+ * register from the host, and the result becomes the yargs default so every handler receives it.
27
+ */
28
+ const DEFAULT_OAUTH_HOST = "https://oauth2.neon.tech";
29
+ const lastString = (value) => {
30
+ const last = Array.isArray(value) ? value.at(-1) : value;
31
+ return typeof last === "string" ? last : void 0;
32
+ };
33
+ const parseInvocation = (args, env) => {
34
+ const { argv } = Parser.detailed([...args], {
35
+ string: [
36
+ "api-host",
37
+ "oauth-host",
38
+ "profile",
39
+ "api-key",
40
+ "config-dir"
41
+ ],
42
+ alias: {
43
+ "api-host": ["apiHost"],
44
+ "oauth-host": ["oauthHost"],
45
+ "api-key": ["apiKey"],
46
+ "config-dir": ["configDir"]
47
+ },
48
+ narg: { "api-key": 1 },
49
+ configuration: {
50
+ "populate--": true,
51
+ "parse-positional-numbers": false
52
+ }
53
+ });
54
+ const apiHost = lastString(argv["api-host"]);
55
+ const oauthHost = lastString(argv["oauth-host"]);
56
+ return {
57
+ flags: {
58
+ ...apiHost !== void 0 ? { apiHost } : {},
59
+ ...oauthHost !== void 0 ? { oauthHost } : {}
60
+ },
61
+ configDir: lastString(argv["config-dir"]) ?? defaultDir,
62
+ profile: credentialProfile({
63
+ apiKeyFlag: lastString(argv["api-key"]) ?? "",
64
+ profileFlag: lastString(argv.profile) ?? "",
65
+ apiKeyEnv: env.NEON_API_KEY ?? "",
66
+ profileEnv: env.NEON_PROFILE ?? ""
67
+ })
68
+ };
69
+ };
70
+ const credentialProfile = (inputs) => {
71
+ try {
72
+ const selection = selectCredential(inputs);
73
+ return selection.source === "profile" ? selection.profile : void 0;
74
+ } catch {
75
+ return;
76
+ }
77
+ };
78
+ const resolveHosts = (flags, recorded, env = process.env) => ({
79
+ apiHost: flags.apiHost ?? recorded.apiHost ?? env.NEON_API_HOST ?? "https://console.neon.tech/api/v2",
80
+ oauthHost: flags.oauthHost ?? recorded.oauthHost ?? env.NEON_OAUTH_HOST ?? "https://oauth2.neon.tech"
81
+ });
82
+ /**
83
+ * The hosts recorded on a named profile. A missing or unreadable `profiles.json` yields none:
84
+ * every command that goes on to use the profile's credential fails on that file with its own
85
+ * message, and one that never touches the credential has no use for the hosts.
86
+ */
87
+ const recordedHosts = (configDir, profile) => {
88
+ if (profile === void 0 || profile === "DEFAULT") return {};
89
+ const read = inspectProfiles(configDir);
90
+ if (read.kind !== "ok") return {};
91
+ const entry = read.file.profiles[profile];
92
+ return entry === void 0 ? {} : hostsOf(entry);
93
+ };
94
+ /** The hosts this invocation uses, for the profile credential selection picks. */
95
+ const invocationHosts = (args = hideBin(process.argv), env = process.env) => {
96
+ const { flags, configDir, profile } = parseInvocation(args, env);
97
+ return resolveHosts(flags, recordedHosts(configDir, profile), env);
98
+ };
99
+ /** The hosts for a command that names its profile itself: `login --profile`, `profile <sub> <name>`. */
100
+ const hostsForProfile = (configDir, profile, args = hideBin(process.argv)) => resolveHosts(parseInvocation(args, process.env).flags, recordedHosts(configDir, profile));
101
+ /**
102
+ * Where a profile's stored credential was issued, for revoking it when it is replaced: its
103
+ * recorded hosts, else the ones this invocation uses.
104
+ */
105
+ const issuingHosts = (configDir, profile, current) => {
106
+ const recorded = recordedHosts(configDir, profile);
107
+ return {
108
+ apiHost: recorded.apiHost ?? current.apiHost,
109
+ oauthHost: recorded.oauthHost ?? current.oauthHost
110
+ };
111
+ };
112
+ /**
113
+ * What a sign-in or `profile create` writes to the profile's hosts: each typed flag, with the
114
+ * production URL removing the recorded host. DEFAULT records none. Call it before any request,
115
+ * so a mistyped URL fails having changed nothing.
116
+ */
117
+ const hostUpdateFor = (profile, args = hideBin(process.argv)) => {
118
+ if (profile === "DEFAULT") return {};
119
+ const { flags } = parseInvocation(args, process.env);
120
+ return {
121
+ ...hostUpdate("api-host", flags.apiHost, DEFAULT_API_HOST, "apiHost"),
122
+ ...hostUpdate("oauth-host", flags.oauthHost, DEFAULT_OAUTH_HOST, "oauthHost")
123
+ };
124
+ };
125
+ const hostUpdate = (flag, value, production, field) => {
126
+ if (value === void 0) return {};
127
+ if (!isHttpUrl(value)) throw new Error(`--${flag} must be an http or https URL, such as ${production}.`);
128
+ return { [field]: value.replace(/\/+$/, "") === production ? null : value };
129
+ };
130
+ export { DEFAULT_OAUTH_HOST, hostUpdateFor, hostsForProfile, invocationHosts, issuingHosts, resolveHosts };
package/dist/index.js CHANGED
@@ -8,8 +8,9 @@ import { currentContextFile, enrichFromContext } from "./context.js";
8
8
  import { NETWORK_ERROR_MESSAGE, isNetworkError, matchErrorCode } from "./errors.js";
9
9
  import { analyticsMiddleware, closeAnalytics, initAnalyticsClientMiddleware, isAnalyticsActive, recordCommandSuccessExtras, sendError, takeCommandSuccessExtras, trackCommandSuccess } from "./analytics.js";
10
10
  import { AuthRefreshError, defaultClientID } from "./auth.js";
11
+ import { invocationHosts } from "./hosts.js";
11
12
  import { getCliName } from "./utils/cli_name.js";
12
- import { c as ensureAuth } from "./_chunks/auth-DY5Bm7Ym.js";
13
+ import { c as ensureAuth } from "./_chunks/auth-CEb642X3.js";
13
14
  import { recoverFrom401 } from "./auth_recovery.js";
14
15
  import { UsageError, failOnUsageError, isBareParentCommand, showHelp, showUsageErrorHelp } from "./help.js";
15
16
  import { lazyCommands, preloadCommand } from "./commands/manifest.js";
@@ -18,9 +19,9 @@ import { recoverFromSSO } from "./sso_recovery.js";
18
19
  import { notifyIfUpdateAvailable, shouldRunSkillsNotifier } from "./update_notifier.js";
19
20
  import { fillInArgs, resolveApiKeyFromEnv } from "./utils/middlewares.js";
20
21
  import { collapseRepeatedFlags, declaredOptions } from "./utils/repeated_flags.js";
21
- import { stagingFeaturesEnabledForArgv } from "./utils/staging.js";
22
- import yargs from "yargs";
22
+ import { isStagingApiHost } from "./utils/staging.js";
23
23
  import { hideBin } from "yargs/helpers";
24
+ import yargs from "yargs";
24
25
  // src/index.ts
25
26
  const NO_SUBCOMMANDS_VERBS = [
26
27
  "api",
@@ -50,6 +51,7 @@ const NO_SUBCOMMANDS_VERBS = [
50
51
  "bootstrap",
51
52
  "status"
52
53
  ];
54
+ const hosts = invocationHosts(hideBin(process.argv));
53
55
  let builder = yargs(hideBin(process.argv));
54
56
  builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command> [options]").parserConfiguration({
55
57
  "populate--": true,
@@ -69,7 +71,7 @@ builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command>
69
71
  }).option("api-host", {
70
72
  describe: "The API host",
71
73
  hidden: true,
72
- default: process.env.NEON_API_HOST ?? "https://console.neon.tech/api/v2"
74
+ default: hosts.apiHost
73
75
  }).option("config-dir", {
74
76
  describe: "Path to config directory",
75
77
  group: "Global options:",
@@ -88,7 +90,7 @@ builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command>
88
90
  "oauth-host": {
89
91
  description: "URL to Neon OAuth host",
90
92
  hidden: true,
91
- default: process.env.NEON_OAUTH_HOST ?? "https://oauth2.neon.tech"
93
+ default: hosts.oauthHost
92
94
  },
93
95
  "client-id": {
94
96
  description: "OAuth client id",
@@ -139,7 +141,7 @@ builder = builder.scriptName(pkg_default.name).locale("en").usage("$0 <command>
139
141
  if (args.help) await showHelp(builder);
140
142
  }, true).middleware(async (args) => {
141
143
  if (args._.length === 1 && !NO_SUBCOMMANDS_VERBS.includes(args._[0]) || args._.length > 1 && isBareParentCommand(builder, args._)) await showHelp(builder);
142
- }).middleware(ensureAuth).middleware(enrichFromContext).middleware(analyticsMiddleware).command(lazyCommands({ staging: stagingFeaturesEnabledForArgv(hideBin(process.argv)) })).strictCommands().version(pkg_default.version).group("version", "Global options:").alias("version", "v").completion().scriptName(getCliName()).epilog("For more information, visit https://neon.com/docs/reference/neon-cli").wrap(null).fail(failOnUsageError);
144
+ }).middleware(ensureAuth).middleware(enrichFromContext).middleware(analyticsMiddleware).command(lazyCommands({ staging: isStagingApiHost(hosts.apiHost) })).strictCommands().version(pkg_default.version).group("version", "Global options:").alias("version", "v").completion().scriptName(getCliName()).epilog("For more information, visit https://neon.com/docs/reference/neon-cli").wrap(null).fail(failOnUsageError);
143
145
  async function handleError(msg, err, canRetry) {
144
146
  if (process.argv.some((arg) => arg === "--help" || arg === "-h")) {
145
147
  await showHelp(builder);
package/dist/init/auth.js CHANGED
@@ -2,9 +2,9 @@ import { isNeonApiError } from "../api.js";
2
2
  import { r as defaultDir } from "../_chunks/paths-B55ZfOg1.js";
3
3
  import "../config.js";
4
4
  import "../auth.js";
5
- import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-DY5Bm7Ym.js";
5
+ import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-CEb642X3.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { c as pull } from "../_chunks/env-DxcO3oJk.js";
7
+ import { c as pull } from "../_chunks/env-Bko0oXq9.js";
8
8
  import { c as setupNeonMcp } from "../_chunks/mcp-SvqWzHnT.js";
9
9
  // src/init/auth.ts
10
10
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
@@ -1,10 +1,10 @@
1
1
  import { isNeonApiError } from "../api.js";
2
2
  import { contextBranch, readContextFile } from "../context.js";
3
- import { c as ensureAuth } from "../_chunks/auth-DY5Bm7Ym.js";
3
+ import { c as ensureAuth } from "../_chunks/auth-CEb642X3.js";
4
4
  import { recoverFrom401 } from "../auth_recovery.js";
5
5
  import { loadProjectConfig } from "../project.js";
6
6
  import { loadEnvFileIntoProcess } from "../env_file.js";
7
- import { r as applyCmd } from "../_chunks/config-DFj1Btk-.js";
7
+ import { r as applyCmd } from "../_chunks/config-Dyvrv889.js";
8
8
  import { authContext } from "./auth.js";
9
9
  import { existsSync } from "node:fs";
10
10
  import { missingFunctionEnv } from "@neon/config";
@@ -1,7 +1,7 @@
1
- import { t as storeFor } from "../_chunks/credential_io-DbeSh3Pl.js";
1
+ import { t as storeFor } from "../_chunks/credential_io-BHwacMdt.js";
2
2
  import { isCi } from "../env.js";
3
- import { h as resolveProfile, u as locationOf } from "../_chunks/profiles-DTazQtjK.js";
4
- import { i as selectCredential, t as credentialInputs } from "../_chunks/auth_selection-CwGLN9Qz.js";
3
+ import { p as locationOf, v as resolveProfile } from "../_chunks/profiles-kpRUx7gU.js";
4
+ import { i as selectCredential, t as credentialInputs } from "../_chunks/auth_selection-D81EvEz9.js";
5
5
  import { detectInstalledAgents, detectProjectAgents, uniqueAgentIds } from "../mcp/agents.js";
6
6
  import "./agents.js";
7
7
  import { directoryIsEmpty } from "./plan.js";
package/dist/init/link.js CHANGED
@@ -2,9 +2,9 @@ import { isNeonApiError } from "../api.js";
2
2
  import { r as defaultDir } from "../_chunks/paths-B55ZfOg1.js";
3
3
  import "../config.js";
4
4
  import "../auth.js";
5
- import { c as ensureAuth } from "../_chunks/auth-DY5Bm7Ym.js";
5
+ import { c as ensureAuth } from "../_chunks/auth-CEb642X3.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { s as runLink } from "../_chunks/link-Z2_mLhVn.js";
7
+ import { s as runLink } from "../_chunks/link-JQXbQuxd.js";
8
8
  // src/init/link.ts
9
9
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
10
10
  const authenticationFailed = () => /* @__PURE__ */ new Error("Authentication failed.");
package/dist/init/run.js CHANGED
@@ -14,8 +14,8 @@ import { getAgentDisplayName } from "../mcp/agents.js";
14
14
  import { missingPluginsCommands, pluginsCommandProblemText, pluginsInstallableAgents, unusablePluginsCommands } from "../plugins/targets.js";
15
15
  import { AGENTS_NOT_INSTALLED, CANCELLED_BODY, CLAIMABLE_ACCOUNT_FLAGS, CLAIMABLE_ALREADY_LINKED, CLAIMABLE_MCP_API_KEY, CLAIMABLE_NO_LINK, MCP_API_KEY_NEEDS_AUTH, MCP_SCOPED_NEEDS_PROJECT, NON_TTY_LINK_NEEDS_AUTH, NO_AGENTS_FALLBACK_STATUS, PROGRESS, PROJECT_PINNED_OFFLINE, claimableNext, claimableThenServicesNext, configInitNext, envPullFailedNext, existingConfigNext, installFailedNext, mcpAfterLinkNext, mcpConfigLocationSkipped, mcpConfigLocationUnavailable, mcpKeyFailedNext, namedAgentsUnavailable, newConfigNext, offlinePinNext, skippedLinkNext, toolingFailedNext, unattendedUnauthedNext } from "./copy.js";
16
16
  import { agentsRowValue, configRowValue, formatInitDone, headingForKind, printInitBanner, printInitDone, printInitProgress, projectRowValue, shouldPrintInitBanner } from "./chrome.js";
17
- import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-DFj1Btk-.js";
18
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-Z2_mLhVn.js";
17
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-Dyvrv889.js";
18
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-JQXbQuxd.js";
19
19
  import { runAuthenticatedLink } from "./link.js";
20
20
  import { mcpInstallableAgents } from "../mcp/targets.js";
21
21
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -25,7 +25,7 @@ import { pullInitEnv, resolveInitConfigApi } from "./auth.js";
25
25
  import { InitCancelled, raceSigint, restoreCursor } from "./cancelled.js";
26
26
  import { pickAgentSetupInteractively, pickInitAgentsInteractively, pickInitConfigInteractively, pickInitMcpAuthInteractively, pickInitMcpConfigLocationInteractively, pickInitModeInteractively, pickInitPackageManagerInteractively, pickInitProjectSetupInteractively, pickInitServicesInteractively, pickInitSkillsInteractively } from "./wizard.js";
27
27
  import { runToolingSteps, toolingStepCommandText } from "./tooling.js";
28
- import { l as create } from "../_chunks/claim-Dv5wARrN.js";
28
+ import { l as create } from "../_chunks/claim-DHuMf7GY.js";
29
29
  import { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice } from "./choices.js";
30
30
  import { detectInitEnvironment } from "./detect.js";
31
31
  import { createInitFunnel, emitInitStart, finishInitFunnel, initStartProperties, recordInitError, recordInitExit } from "./funnel.js";
@@ -1,4 +1,4 @@
1
- import { a as OAUTH, d as scopeOf, i as API_KEY, l as interpretCredentials, t as storeFor, u as isSameCredential } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ import { a as OAUTH, d as scopeOf, i as API_KEY, l as interpretCredentials, t as storeFor, u as isSameCredential } from "./_chunks/credential_io-BHwacMdt.js";
2
2
  import { log } from "./log.js";
3
3
  import { getApiClient } from "./api.js";
4
4
  import { revokeToken } from "./auth.js";
@@ -215,7 +215,7 @@ const runInspectQuery = async (connectionUri, sql, options = {}) => {
215
215
  try {
216
216
  const ext = options.requiresExtension;
217
217
  if (ext) {
218
- if ((await connection.query(`SELECT 1 FROM pg_extension WHERE extname = '${ext}';`)).rows.length === 0) throw new Error(`This query needs the "${ext}" extension, which is not installed. Enable it with: CREATE EXTENSION ${ext};`);
218
+ if ((await connection.query(`SELECT /* neon inspect */ 1 FROM pg_extension WHERE extname = '${ext}';`)).rows.length === 0) throw new Error(`This query needs the "${ext}" extension, which is not installed. Enable it with: CREATE EXTENSION ${ext};`);
219
219
  }
220
220
  const result = await connection.query(sql);
221
221
  return rowsFrom(result);
@@ -1,4 +1,28 @@
1
1
  // src/utils/inspect_queries.ts
2
+ /**
3
+ * Drops `pg_stat_statements` rows (alias `s`) that the user's workload did not
4
+ * run: Neon's compute manager runs its setup as `cloud_admin`; Neon's proxy
5
+ * resets each pooled session it serves HTTP queries on with the listed
6
+ * statements, as the user's role; and every diagnostic here carries the
7
+ * `neon inspect` comment. The comment has to follow the statement's first
8
+ * keyword: Postgres drops a leading comment from the text it stores.
9
+ * `@neon/tools` keeps an identical copy for `database.inspect`.
10
+ *
11
+ * The role is matched by name because `--db-url` runs this against any
12
+ * Postgres, where an app may well log in as a superuser. `query` is NULL when
13
+ * Postgres cannot read its stored text, hence `COALESCE`.
14
+ */
15
+ const WORKLOAD_STATEMENTS_FILTER = `
16
+ NOT EXISTS (
17
+ SELECT 1 FROM pg_roles r
18
+ WHERE r.oid = s.userid AND r.rolname = 'cloud_admin'
19
+ )
20
+ AND COALESCE(s.query, '') NOT IN (
21
+ 'CLOSE ALL', 'SET SESSION AUTHORIZATION DEFAULT', 'RESET ALL',
22
+ 'DEALLOCATE ALL', 'UNLISTEN *', 'SELECT pg_advisory_unlock_all()',
23
+ 'DISCARD TEMP', 'DISCARD SEQUENCES'
24
+ )
25
+ AND COALESCE(s.query, '') NOT LIKE '%/* neon inspect */%'`;
2
26
  const INSPECT_QUERIES = {
3
27
  "table-sizes": {
4
28
  describe: "Size of each table (including TOAST), largest first (pg_table_size)",
@@ -10,7 +34,7 @@ const INSPECT_QUERIES = {
10
34
  ],
11
35
  emptyMessage: "No user tables found.",
12
36
  sql: `
13
- SELECT
37
+ SELECT /* neon inspect */
14
38
  n.nspname AS schema,
15
39
  c.relname AS name,
16
40
  pg_size_pretty(pg_table_size(c.oid)) AS size
@@ -32,7 +56,7 @@ const INSPECT_QUERIES = {
32
56
  ],
33
57
  emptyMessage: "No indexes found.",
34
58
  sql: `
35
- SELECT
59
+ SELECT /* neon inspect */
36
60
  n.nspname AS schema,
37
61
  c.relname AS name,
38
62
  pg_size_pretty(pg_relation_size(c.oid)) AS size
@@ -55,7 +79,7 @@ const INSPECT_QUERIES = {
55
79
  ],
56
80
  emptyMessage: "No unused indexes detected.",
57
81
  sql: `
58
- SELECT
82
+ SELECT /* neon inspect */
59
83
  s.schemaname || '.' || s.relname AS "table",
60
84
  s.indexrelname AS index,
61
85
  pg_size_pretty(pg_relation_size(s.indexrelid)) AS index_size,
@@ -78,7 +102,7 @@ const INSPECT_QUERIES = {
78
102
  ],
79
103
  emptyMessage: "No user tables found.",
80
104
  sql: `
81
- SELECT
105
+ SELECT /* neon inspect */
82
106
  schemaname AS schema,
83
107
  relname AS name,
84
108
  seq_scan AS count
@@ -98,7 +122,7 @@ const INSPECT_QUERIES = {
98
122
  emptyMessage: "No long-running queries in this database.",
99
123
  emptyMessageAll: "No long-running queries in any database.",
100
124
  sql: `
101
- SELECT
125
+ SELECT /* neon inspect */
102
126
  pid,
103
127
  (now() - query_start)::text AS duration,
104
128
  state,
@@ -124,7 +148,7 @@ const INSPECT_QUERIES = {
124
148
  ],
125
149
  emptyMessage: "No active queries running longer than 30 seconds.",
126
150
  sql: `
127
- WITH activity AS MATERIALIZED (
151
+ WITH /* neon inspect */ activity AS MATERIALIZED (
128
152
  SELECT *
129
153
  FROM pg_stat_activity
130
154
  WHERE state = 'active'
@@ -180,7 +204,7 @@ const INSPECT_QUERIES = {
180
204
  emptyMessage: "No locks held in this database.",
181
205
  emptyMessageAll: "No locks held in any database.",
182
206
  sql: `
183
- SELECT
207
+ SELECT /* neon inspect */
184
208
  a.pid,
185
209
  c.relname,
186
210
  l.mode,
@@ -198,7 +222,7 @@ const INSPECT_QUERIES = {
198
222
  `
199
223
  },
200
224
  outliers: {
201
- describe: "Queries taking the most cumulative execution time (needs pg_stat_statements)",
225
+ describe: "Queries taking the most cumulative execution time, leaving out Neon's own setup and session-reset statements and inspect's own queries (needs pg_stat_statements)",
202
226
  scope: "database",
203
227
  fields: [
204
228
  "total_exec_time",
@@ -209,7 +233,7 @@ const INSPECT_QUERIES = {
209
233
  emptyMessage: "No statements recorded yet.",
210
234
  requiresExtension: "pg_stat_statements",
211
235
  sql: `
212
- SELECT
236
+ SELECT /* neon inspect */
213
237
  (interval '1 millisecond' * total_exec_time)::text AS total_exec_time,
214
238
  to_char(
215
239
  (total_exec_time / nullif(sum(total_exec_time) OVER (), 0)) * 100,
@@ -220,12 +244,13 @@ const INSPECT_QUERIES = {
220
244
  FROM pg_stat_statements s
221
245
  JOIN pg_database d ON d.oid = s.dbid
222
246
  WHERE d.datname = current_database()
247
+ AND ${WORKLOAD_STATEMENTS_FILTER}
223
248
  ORDER BY total_exec_time DESC
224
249
  LIMIT 25;
225
250
  `
226
251
  },
227
252
  calls: {
228
- describe: "Most frequently called queries (needs pg_stat_statements)",
253
+ describe: "Most frequently called queries, leaving out Neon's own setup and session-reset statements and inspect's own queries (needs pg_stat_statements)",
229
254
  scope: "database",
230
255
  fields: [
231
256
  "ncalls",
@@ -236,7 +261,7 @@ const INSPECT_QUERIES = {
236
261
  emptyMessage: "No statements recorded yet.",
237
262
  requiresExtension: "pg_stat_statements",
238
263
  sql: `
239
- SELECT
264
+ SELECT /* neon inspect */
240
265
  calls AS ncalls,
241
266
  (interval '1 millisecond' * total_exec_time)::text AS total_exec_time,
242
267
  to_char(
@@ -247,6 +272,7 @@ const INSPECT_QUERIES = {
247
272
  FROM pg_stat_statements s
248
273
  JOIN pg_database d ON d.oid = s.dbid
249
274
  WHERE d.datname = current_database()
275
+ AND ${WORKLOAD_STATEMENTS_FILTER}
250
276
  ORDER BY calls DESC
251
277
  LIMIT 25;
252
278
  `
@@ -258,7 +284,7 @@ const INSPECT_QUERIES = {
258
284
  emptyMessage: "No LFC stats available.",
259
285
  requiresExtension: "neon",
260
286
  sql: `
261
- WITH lfc AS (
287
+ WITH /* neon inspect */ lfc AS (
262
288
  SELECT lfc_key AS k, lfc_value AS v
263
289
  FROM neon_get_lfc_stats() t(lfc_key text, lfc_value bigint)
264
290
  )
@@ -285,7 +311,7 @@ const INSPECT_QUERIES = {
285
311
  emptyMessage: "No working-set estimate available.",
286
312
  requiresExtension: "neon",
287
313
  sql: `
288
- SELECT
314
+ SELECT /* neon inspect */
289
315
  w.window,
290
316
  pg_size_pretty(w.working_set_bytes) AS working_set,
291
317
  pg_size_pretty(pg_size_bytes(current_setting('neon.file_cache_size_limit'))) AS lfc_size,
@@ -319,7 +345,7 @@ const INSPECT_QUERIES = {
319
345
  ],
320
346
  emptyMessage: "No user tables found.",
321
347
  sql: `
322
- SELECT
348
+ SELECT /* neon inspect */
323
349
  n.nspname AS schema,
324
350
  c.relname AS "table",
325
351
  to_char(psut.last_vacuum, 'YYYY-MM-DD HH24:MI') AS last_vacuum,
@@ -352,7 +378,7 @@ const INSPECT_QUERIES = {
352
378
  ],
353
379
  emptyMessage: "No bloat estimate available.",
354
380
  sql: `
355
- WITH constants AS (
381
+ WITH /* neon inspect */ constants AS (
356
382
  SELECT current_setting('block_size')::numeric AS bs, 23 AS hdr, 8 AS ma
357
383
  ),
358
384
  bloat_info AS (
@@ -417,7 +443,7 @@ const INSPECT_QUERIES = {
417
443
  ],
418
444
  emptyMessage: "No replication slots found.",
419
445
  sql: `
420
- SELECT
446
+ SELECT /* neon inspect */
421
447
  s.slot_name,
422
448
  s.slot_type,
423
449
  CASE
@@ -460,7 +486,7 @@ const INSPECT_QUERIES = {
460
486
  emptyMessage: "No subscriptions found on this database.",
461
487
  emptyMessageAll: "No subscriptions found on any database.",
462
488
  sql: `
463
- SELECT
489
+ SELECT /* neon inspect */
464
490
  sub.subname AS subscription,
465
491
  sr.srrelid::regclass::text AS table_name,
466
492
  CASE sr.srsubstate
@@ -1,4 +1,4 @@
1
- import { r as recordCredentialInputs } from "../_chunks/auth_selection-CwGLN9Qz.js";
1
+ import { r as recordCredentialInputs } from "../_chunks/auth_selection-D81EvEz9.js";
2
2
  // src/utils/middlewares.ts
3
3
  /**
4
4
  * Forwarding Yargs's default would turn ambient configuration into an explicit child override.
@@ -1,28 +1,18 @@
1
- import { Parser, hideBin } from "yargs/helpers";
1
+ import { invocationHosts } from "../hosts.js";
2
+ import { hideBin } from "yargs/helpers";
2
3
  // src/utils/staging.ts
3
4
  /**
4
5
  * Staging-only features ship in a release before their API reaches production. The CLI
5
- * exposes them only when the API host it sends requests to (`--api-host`, else
6
- * `NEON_API_HOST`) is Neon's staging console; with production or no host set, they are
7
- * hidden from help and fail with a "coming soon" message.
6
+ * exposes them only when the API host it sends requests to (`--api-host`, else the selected
7
+ * profile's recorded host, else `NEON_API_HOST`) is Neon's staging console; with production or
8
+ * no host set, they are hidden from help and fail with a "coming soon" message.
8
9
  */
9
10
  const STAGING_API_HOST = "https://console-stage.neon.build/api/v2";
10
11
  /** `NEON_STAGING_API_HOST` lets the CLI's tests treat their local mock API as staging. */
11
12
  const stagingHostname = () => new URL(process.env.NEON_STAGING_API_HOST ?? "https://console-stage.neon.build/api/v2").hostname;
12
13
  const isStagingApiHost = (apiHost) => apiHost !== void 0 && URL.canParse(apiHost) && new URL(apiHost).hostname === stagingHostname();
13
14
  /** The API host this process was invoked with, read before or without yargs. */
14
- const stagingFeaturesEnabledForArgv = (args = hideBin(process.argv)) => {
15
- const { argv } = Parser.detailed([...args], {
16
- string: ["api-host"],
17
- alias: { "api-host": ["apiHost"] },
18
- configuration: {
19
- "populate--": true,
20
- "parse-positional-numbers": false
21
- }
22
- });
23
- const flag = argv["api-host"];
24
- return isStagingApiHost(typeof flag === "string" ? flag : process.env.NEON_API_HOST);
25
- };
15
+ const stagingFeaturesEnabledForArgv = (args = hideBin(process.argv)) => isStagingApiHost(invocationHosts(args).apiHost);
26
16
  /** `apiHost` is a command's resolved host; without one, the host this process was invoked with. */
27
17
  const stagingFeaturesEnabled = (apiHost) => apiHost === void 0 ? stagingFeaturesEnabledForArgv() : isStagingApiHost(apiHost);
28
18
  /** A hard stop: callers that degrade other failures to warnings let this one through. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.8.0",
3
+ "version": "9.9.1",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",
@@ -73,10 +73,10 @@
73
73
  "yaml": "^2.9.0",
74
74
  "yargs": "17.7.2",
75
75
  "yoctocolors": "^2.1.2",
76
- "@neon/config-runtime": "1.12.8",
76
+ "@neon/config-runtime": "1.12.9",
77
+ "@neon/sdk": "7.15.0",
77
78
  "@neon/realtime": "0.2.1",
78
- "@neon/sdk": "7.14.3",
79
- "@neon/config": "1.14.5"
79
+ "@neon/config": "1.14.6"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@napi-rs/keyring": "1.3.0",
@@ -113,9 +113,9 @@
113
113
  "typescript": "^5.9.0",
114
114
  "vitest": "^3.0.9",
115
115
  "@neon-internals/cli-core": "0.0.0",
116
+ "@neon-internals/env-core": "0.0.57",
116
117
  "@neon/e2e-harness": "0.0.0",
117
- "@neon-internals/env-core": "0.0.56",
118
- "@neon/env": "2.1.8",
118
+ "@neon/env": "2.1.9",
119
119
  "@neon/functions": "0.11.0"
120
120
  },
121
121
  "publishConfig": {