neon 9.7.2 → 9.9.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.
Files changed (53) hide show
  1. package/README.md +4 -4
  2. package/dist/_chunks/{auth-DY5Bm7Ym.js → auth-CEb642X3.js} +20 -9
  3. package/dist/_chunks/{auth_selection-CwGLN9Qz.js → auth_selection-D81EvEz9.js} +1 -1
  4. package/dist/_chunks/{checkout-B_hB_ELY.js → checkout-9zUY4N8W.js} +2 -2
  5. package/dist/_chunks/{claim-Dv5wARrN.js → claim-D7fATGLw.js} +1 -1
  6. package/dist/_chunks/{config-DFj1Btk-.js → config-CUWOp44_.js} +1 -1
  7. package/dist/_chunks/{credential_io-DbeSh3Pl.js → credential_io-BHwacMdt.js} +1 -1
  8. package/dist/_chunks/{credentials-BMBNmW0t.js → credentials-KV1jlK-n.js} +13 -2
  9. package/dist/_chunks/{data_api-CHDwvMTG.js → data_api-BpSGbdZf.js} +1 -1
  10. package/dist/_chunks/{deploy-CVJIahZE.js → deploy-BUkXtacE.js} +1 -1
  11. package/dist/_chunks/{dev-CtIzg7vq.js → dev-Dp6LuAe2.js} +1 -1
  12. package/dist/_chunks/{git-CIBowi6T.js → git-BISnX9MB.js} +2 -2
  13. package/dist/_chunks/{incidents-D6rDn1g2.js → incidents-BSFkUu1P.js} +5 -1
  14. package/dist/_chunks/{init-AKhj0lHa.js → init-BSwLzxjX.js} +3 -3
  15. package/dist/_chunks/{link-mdFXf8dW.js → link-CfbTC-or.js} +11 -13
  16. package/dist/_chunks/{profile-Qoyql0AR.js → profile-BVkmMwHO.js} +68 -28
  17. package/dist/_chunks/{profiles-DTazQtjK.js → profiles-kpRUx7gU.js} +32 -2
  18. package/dist/_chunks/{status-DRWS1u6H.js → status-BM42rYe1.js} +1 -1
  19. package/dist/analytics.js +1 -1
  20. package/dist/auth_recovery.js +2 -2
  21. package/dist/commands/auth.js +1 -1
  22. package/dist/commands/checkout.js +1 -1
  23. package/dist/commands/claim.js +1 -1
  24. package/dist/commands/config.js +1 -1
  25. package/dist/commands/credentials.js +1 -1
  26. package/dist/commands/data_api.js +1 -1
  27. package/dist/commands/deploy.js +1 -1
  28. package/dist/commands/dev.js +1 -1
  29. package/dist/commands/functions_new.js +1 -1
  30. package/dist/commands/git.js +1 -1
  31. package/dist/commands/incidents.js +1 -1
  32. package/dist/commands/index.js +14 -14
  33. package/dist/commands/init.js +1 -1
  34. package/dist/commands/link.js +1 -1
  35. package/dist/commands/profile.js +1 -1
  36. package/dist/commands/status.js +1 -1
  37. package/dist/credential_io.js +1 -1
  38. package/dist/dev/runtime.js +1 -1
  39. package/dist/functions/scaffold.js +3 -1
  40. package/dist/hosts.js +130 -0
  41. package/dist/index.js +8 -6
  42. package/dist/init/auth.js +1 -1
  43. package/dist/init/chrome.js +1 -0
  44. package/dist/init/copy.js +1 -1
  45. package/dist/init/deploy.js +2 -2
  46. package/dist/init/detect.js +3 -3
  47. package/dist/init/link.js +4 -5
  48. package/dist/init/run.js +16 -10
  49. package/dist/retire_credential.js +1 -1
  50. package/dist/utils/middlewares.js +1 -1
  51. package/dist/utils/package_manager.js +30 -3
  52. package/dist/utils/staging.js +6 -16
  53. package/package.json +9 -9
@@ -17,6 +17,16 @@ const isKeyringPointer = (credentials) => credentials === KEYRING_CREDENTIALS;
17
17
  const DEFAULT_PROFILE = "DEFAULT";
18
18
  /** Profile names become part of a filename, so keep them boring. */
19
19
  const NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
20
+ const HOST_FIELDS = ["apiHost", "oauthHost"];
21
+ const isHttpUrl = (value) => {
22
+ if (!URL.canParse(value)) return false;
23
+ const { protocol } = new URL(value);
24
+ return protocol === "https:" || protocol === "http:";
25
+ };
26
+ const hostsOf = (entry) => ({
27
+ ...entry.apiHost !== void 0 ? { apiHost: entry.apiHost } : {},
28
+ ...entry.oauthHost !== void 0 ? { oauthHost: entry.oauthHost } : {}
29
+ });
20
30
  const locationOf = (profile) => profile.storage === "keyring" ? {
21
31
  profile: profile.name,
22
32
  storage: CRED_STORAGE_KEYRING
@@ -67,6 +77,12 @@ const inspectProfiles = (dir) => {
67
77
  for (const [name, entry] of Object.entries(profiles)) {
68
78
  if (!NAME_PATTERN.test(name)) return broken(`"${name}" is not a valid profile name`);
69
79
  if (entry === null || typeof entry !== "object" || typeof entry.credentials !== "string" || entry.credentials.trim() === "") return broken(`profile "${name}" has no \`credentials\` pointer`);
80
+ for (const field of HOST_FIELDS) {
81
+ const value = entry[field];
82
+ if (value === void 0) continue;
83
+ if (name === "DEFAULT") return broken(`profile "${DEFAULT_PROFILE}" sets \`${field}\`, which only a named profile can. DEFAULT follows --api-host / --oauth-host and NEON_API_HOST / NEON_OAUTH_HOST`);
84
+ if (typeof value !== "string" || !isHttpUrl(value)) return broken(`profile "${name}" has an invalid \`${field}\`: expected an http or https URL`);
85
+ }
70
86
  }
71
87
  return {
72
88
  kind: "ok",
@@ -119,6 +135,7 @@ const resolveProfile = (dir, name) => {
119
135
  storage: CRED_STORAGE_KEYRING,
120
136
  ...entry.label ? { label: entry.label } : {},
121
137
  ...entry.userId ? { userId: entry.userId } : {},
138
+ ...hostsOf(entry),
122
139
  declared: true
123
140
  };
124
141
  return {
@@ -127,6 +144,7 @@ const resolveProfile = (dir, name) => {
127
144
  credentialsPath: resolveEntryPath(dir, entry.credentials),
128
145
  ...entry.label ? { label: entry.label } : {},
129
146
  ...entry.userId ? { userId: entry.userId } : {},
147
+ ...hostsOf(entry),
130
148
  declared: true
131
149
  };
132
150
  }
@@ -152,6 +170,11 @@ const newProfileCredentialsPath = (dir, name) => resolve(dir, `credentials.${nam
152
170
  */
153
171
  const upsertProfile = (dir, name, entry) => {
154
172
  assertValidProfileName(name);
173
+ if (name === "DEFAULT" && HOST_FIELDS.some((field) => typeof entry[field] === "string")) throw new Error(`Profile "${DEFAULT_PROFILE}" cannot record an API or OAuth host. Create a named profile for another Neon environment.`);
174
+ for (const field of HOST_FIELDS) {
175
+ const value = entry[field];
176
+ if (typeof value === "string" && !isHttpUrl(value)) throw new Error(`Cannot record "${value}" as profile "${name}"'s ${field}: expected an http or https URL.`);
177
+ }
155
178
  const path = profilesFilePath(dir);
156
179
  const read = inspectProfiles(dir);
157
180
  if (read.kind === "unusable") throw new Error(`${read.reason}. Refusing to rewrite it, because doing so would discard the profiles it defines. Fix or delete the file, then re-run.`);
@@ -159,10 +182,17 @@ const upsertProfile = (dir, name, entry) => {
159
182
  version: 1,
160
183
  profiles: { [DEFAULT_PROFILE]: { credentials: storedPointer(path, credentialsPath(dir)) } }
161
184
  };
185
+ const previous = file.profiles[name];
186
+ const host = (field) => {
187
+ const value = entry[field] === void 0 ? previous?.[field] : entry[field];
188
+ return typeof value === "string" ? { [field]: value } : {};
189
+ };
162
190
  file.profiles[name] = {
163
191
  credentials: storedPointer(path, entry.credentials),
164
192
  ...entry.label ? { label: entry.label } : {},
165
- ...entry.userId ? { userId: entry.userId } : {}
193
+ ...entry.userId ? { userId: entry.userId } : {},
194
+ ...host("apiHost"),
195
+ ...host("oauthHost")
166
196
  };
167
197
  writeProfiles(path, file);
168
198
  };
@@ -217,4 +247,4 @@ function nonEmpty(value) {
217
247
  const trimmed = value.trim();
218
248
  return trimmed === "" ? void 0 : trimmed;
219
249
  }
220
- export { upsertProfile as _, canDropProfilesFile as a, listProfiles as c, newProfileLocation as d, profilesFilePath as f, selectProfileName as g, resolveProfile as h, assertValidProfileName as i, locationForName as l, readProfiles as m, KEYRING_CREDENTIALS as n, credentialsDisplay as o, profilesUsingPath as p, assertProfilesUsable as r, isKeyringPointer as s, DEFAULT_PROFILE as t, locationOf as u, CRED_STORAGE_FILE as v, CRED_STORAGE_KEYRING as y };
250
+ export { CRED_STORAGE_KEYRING as S, readProfiles as _, canDropProfilesFile as a, upsertProfile as b, inspectProfiles as c, listProfiles as d, locationForName as f, profilesUsingPath as g, profilesFilePath as h, assertValidProfileName as i, isHttpUrl as l, newProfileLocation as m, KEYRING_CREDENTIALS as n, credentialsDisplay as o, locationOf as p, assertProfilesUsable as r, hostsOf as s, DEFAULT_PROFILE as t, isKeyringPointer as u, resolveProfile as v, CRED_STORAGE_FILE as x, selectProfileName as y };
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { fillSingleProject } from "../utils/enrichers.js";
3
- import { y as status } from "./config-DFj1Btk-.js";
3
+ import { y as status } from "./config-CUWOp44_.js";
4
4
  // src/commands/status.ts
5
5
  var status_exports = /* @__PURE__ */ __exportAll({
6
6
  builder: () => builder,
package/dist/analytics.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as OAUTH, t as storeFor } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ import { a as OAUTH, t as storeFor } from "./_chunks/credential_io-BHwacMdt.js";
2
2
  import { getCliAgent, getGithubEnvVars, getTty, isCi } from "./env.js";
3
3
  import { log } from "./log.js";
4
4
  import { getOrCreateAnonymousId } from "./anonymous_id.js";
@@ -1,8 +1,8 @@
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 { log } from "./log.js";
3
3
  import { authFailureMessage, getAuthContext, locationFromContext } from "./auth_context.js";
4
4
  import { AuthRefreshError } from "./auth.js";
5
- import { d as isAccessTokenUsable, p as refreshStoredCredentials } from "./_chunks/auth-DY5Bm7Ym.js";
5
+ import { d as isAccessTokenUsable, p as refreshStoredCredentials } from "./_chunks/auth-CEb642X3.js";
6
6
  // src/auth_recovery.ts
7
7
  const supersededOnDisk = (rejectedToken) => {
8
8
  if (rejectedToken === void 0) return false;
@@ -1 +1 @@
1
- export { t as aliases, n as authFlow, i as builder, a as command, o as deleteCredentialsAt, s as describe, c as ensureAuth, l as existingApiClient, u as handler, d as isAccessTokenUsable, f as locationForAuth, p as refreshStoredCredentials, m as usableCredential } from "../_chunks/auth-DY5Bm7Ym.js";
1
+ export { t as aliases, n as authFlow, i as builder, a as command, o as deleteCredentialsAt, s as describe, c as ensureAuth, l as existingApiClient, u as handler, d as isAccessTokenUsable, f as locationForAuth, p as refreshStoredCredentials, m as usableCredential } from "../_chunks/auth-CEb642X3.js";
@@ -1 +1 @@
1
- export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-B_hB_ELY.js";
1
+ export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-9zUY4N8W.js";
@@ -1 +1 @@
1
- export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-Dv5wARrN.js";
1
+ export { t as CLAIM_CREATE_FIELDS, n as CLAIM_LIST_FIELDS, r as aliases, i as builder, a as claimCreateFields, s as claimableCapabilities, c as command, l as create, u as describe, d as handler } from "../_chunks/claim-D7fATGLw.js";
@@ -1 +1 @@
1
- export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-DFj1Btk-.js";
1
+ export { t as ConfigInstallFailed, n as addCmd, r as applyCmd, i as applyFlags, a as applyPolicyOnCreate, o as builder, s as command, l as createBranchFromPolicyOnCheckout, u as describe, d as ensureConfigPackages, f as envFlag, p as envPullFlag, m as handler, h as initCmd, g as installCommandFrom, _ as missingDependencies, v as planCmd, y as status } from "../_chunks/config-CUWOp44_.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as command, i as create, o as describe, s as handler, c as list, l as reveal, u as revoke, d as rotate } from "../_chunks/credentials-BMBNmW0t.js";
1
+ export { t as aliases, n as builder, r as command, i as create, o as describe, s as handler, c as list, l as reveal, u as revoke, d as rotate } from "../_chunks/credentials-KV1jlK-n.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/data_api-CHDwvMTG.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/data_api-BpSGbdZf.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-CVJIahZE.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-BUkXtacE.js";
@@ -1 +1 @@
1
- export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionPortsEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-CtIzg7vq.js";
1
+ export { t as builder, n as captureShellEnv, r as command, i as describe, a as devBundleDir, o as devEnvContext, c as diffUnits, l as formatEnvFiles, u as formatEnvSummary, d as handler, f as loadDevEnvFiles, p as localFunctionPortsEnv, m as planFunctionsToUnits, h as reportDevCredential, g as sourceFunctionUrlOverlay } from "../_chunks/dev-Dp6LuAe2.js";
@@ -9,7 +9,7 @@ import { writer } from "../writer.js";
9
9
  import { formatInitDone, printInitDone } from "../init/chrome.js";
10
10
  import { FUNCTION_SLUG_PATTERN, deriveFunctionSlug } from "../utils/function_slug.js";
11
11
  import { displayPath } from "./env_output.js";
12
- import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-DFj1Btk-.js";
12
+ import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-CUWOp44_.js";
13
13
  import { recommendedOperations } from "../functions/registry.js";
14
14
  import { collidingFiles, operationsFromFlags, planConfigRegistration, planEnvExample, planScaffold, writeScaffold } from "../functions/scaffold.js";
15
15
  import { describeRegistrySources, openRegistry } from "../functions/source.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-CIBowi6T.js";
1
+ export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-BISnX9MB.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as fetchReport, a as handler, s as renderReport } from "../_chunks/incidents-D6rDn1g2.js";
1
+ export { t as builder, n as command, r as describe, i as fetchReport, a as handler, s as renderReport } from "../_chunks/incidents-BSFkUu1P.js";
@@ -1,32 +1,32 @@
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
5
  import { o as env_exports } from "../_chunks/env-DxcO3oJk.js";
6
- import { c as config_exports } from "../_chunks/config-DFj1Btk-.js";
6
+ import { c as config_exports } from "../_chunks/config-CUWOp44_.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-mdFXf8dW.js";
8
+ import { a as link_exports } from "../_chunks/link-CfbTC-or.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-B_hB_ELY.js";
16
- import { o as claim_exports } from "../_chunks/claim-Dv5wARrN.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-9zUY4N8W.js";
16
+ import { o as claim_exports } from "../_chunks/claim-D7fATGLw.js";
17
17
  import { o as connection_string_exports } from "../_chunks/connection_string-6WhV4WFx.js";
18
- import { a as credentials_exports } from "../_chunks/credentials-BMBNmW0t.js";
19
- import { r as data_api_exports } from "../_chunks/data_api-CHDwvMTG.js";
18
+ import { a as credentials_exports } from "../_chunks/credentials-KV1jlK-n.js";
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-BUkXtacE.js";
22
+ import { s as dev_exports } from "../_chunks/dev-Dp6LuAe2.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-CIBowi6T.js";
28
- import { o as incidents_exports } from "../_chunks/incidents-D6rDn1g2.js";
29
- import { a as init_exports } from "../_chunks/init-AKhj0lHa.js";
27
+ import { o as git_exports } from "../_chunks/git-BISnX9MB.js";
28
+ import { o as incidents_exports } from "../_chunks/incidents-BSFkUu1P.js";
29
+ import { a as init_exports } from "../_chunks/init-BSwLzxjX.js";
30
30
  import { o as inspect_exports } from "../_chunks/inspect-yFAb61qo.js";
31
31
  import { a as ip_allow_exports } from "../_chunks/ip_allow-DBdxNEUa.js";
32
32
  import { l as logs_exports } from "../_chunks/logs-CcVpwdDs.js";
@@ -37,11 +37,11 @@ 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
39
  import { o as postgres_exports } from "../_chunks/postgres-BhR1vUFM.js";
40
- import { o as profile_exports } from "../_chunks/profile-Qoyql0AR.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-BM42rYe1.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 } from "../_chunks/init-AKhj0lHa.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/init-BSwLzxjX.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-mdFXf8dW.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-CfbTC-or.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-BM42rYe1.js";
@@ -1 +1 @@
1
- export { t as storeFor } from "./_chunks/credential_io-DbeSh3Pl.js";
1
+ export { t as storeFor } from "./_chunks/credential_io-BHwacMdt.js";
@@ -20,7 +20,7 @@ const resolveFetchHandler = (mod) => {
20
20
  return (req) => target.fetch(req);
21
21
  }
22
22
  if (isFunction(defaultExport)) return defaultExport;
23
- throw new Error("No request handler found in the source module. Export one of:\n export default { fetch(req) { /* ... */ } }\n export default function (req) { /* ... */ }");
23
+ throw new Error("No request handler found in the source module. Export one of:\n const handler = { fetch(req) { /* ... */ } }; export default handler;\n export default function handler(req) { /* ... */ }");
24
24
  };
25
25
  const hasUpgradeMethod = (value) => typeof value === "object" && value !== null && "upgrade" in value && typeof value.upgrade === "function";
26
26
  /**
@@ -25,7 +25,7 @@ const routes: Record<
25
25
  ${operations.map((operation, index) => `\t${JSON.stringify(routeOf(operation))}: op${index},`).join("\n")}
26
26
  };
27
27
 
28
- export default {
28
+ const handler = {
29
29
  \tfetch(request: Request): Response | Promise<Response> {
30
30
  \t\tconst { pathname } = new URL(request.url);
31
31
  \t\tconst route = routes[pathname];
@@ -38,6 +38,8 @@ export default {
38
38
  \t\treturn route.fetch(request);
39
39
  \t},
40
40
  };
41
+
42
+ export default handler;
41
43
  `;
42
44
  };
43
45
  const sourceOf = (loaded, path) => {
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,7 +2,7 @@ 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
7
  import { c as pull } from "../_chunks/env-DxcO3oJk.js";
8
8
  import { c as setupNeonMcp } from "../_chunks/mcp-SvqWzHnT.js";
@@ -105,6 +105,7 @@ const configSummaryLabel = (summary) => {
105
105
  };
106
106
  const configRowValue = (config, filename) => {
107
107
  if (config === "created") return "neon.ts created";
108
+ if (config === "seeded") return "neon.ts created from the linked branch";
108
109
  if (config === "existing") return `existing ${filename ?? "Neon config"} preserved`;
109
110
  if (config === "skipped" || config === null) return "skipped";
110
111
  return config;
package/dist/init/copy.js CHANGED
@@ -4,7 +4,7 @@ import { pluginsCommandProblemText } from "../plugins/targets.js";
4
4
  const INIT_SUBTITLE = "Set up coding agents and this directory for Neon.";
5
5
  const MODE_MESSAGE = "How would you like to set up Neon?";
6
6
  const MODE_RECOMMENDED_TITLE = "Recommended setup";
7
- const MODE_RECOMMENDED_DESCRIPTION = "Set up detected agents, link a project, and add a default neon.ts in this directory.";
7
+ const MODE_RECOMMENDED_DESCRIPTION = "Set up detected agents, link a project, and add neon.ts in this directory.";
8
8
  const MODE_CUSTOM_TITLE = "Custom setup";
9
9
  const MODE_CUSTOM_DESCRIPTION = "Choose agent tooling, project setup, and the services declared in neon.ts.";
10
10
  const AGENT_SETUP_MESSAGE = "How should Neon be added to your coding agents?";
@@ -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-CUWOp44_.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-mdFXf8dW.js";
7
+ import { s as runLink } from "../_chunks/link-CfbTC-or.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.");
@@ -19,15 +19,14 @@ const runAuthenticatedLink = async (props) => {
19
19
  };
20
20
  await ensureAuth(authenticated);
21
21
  try {
22
- await runLink(authenticated);
23
- return;
22
+ return await runLink(authenticated);
24
23
  } catch (error) {
25
24
  if (!isUnauthorized(error)) throw error;
26
25
  if (!await recoverFrom401(true)) throw authenticationFailed();
27
26
  }
28
27
  await ensureAuth(authenticated);
29
28
  try {
30
- await runLink(authenticated);
29
+ return await runLink(authenticated);
31
30
  } catch (error) {
32
31
  if (!isUnauthorized(error)) throw error;
33
32
  await recoverFrom401(false);