neon 9.9.7 → 9.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -878,7 +878,7 @@ When a package cannot be bundled — a native addon with no esbuild loader, or a
878
878
 
879
879
  `neon bootstrap` copies a Neon starter template into a new (or current) directory — conceptually like `degit`, but it only pulls from a small set of templates we maintain in the public [`neondatabase/examples`](https://github.com/neondatabase/examples) repo. The template copy needs no Neon login: it downloads files from GitHub.
880
880
 
881
- After scaffolding, an interactive terminal asks about dependency install and git, then finishes agent setup before asking whether to link a Neon project. Dependency install is last, except when the template has a `neon.ts` and you chose to link — then install runs first so the link flow can pull env. `--default` / `-y` skips the template, install, git, and agent pickers, then installs agent tooling for project folders, else the host CLI agent. If none are found, it exits: pass `--agent <name>`, run from a supported agent, or omit `--default` / `-y` in a terminal to pick. `--agent` / `-a` names coding agents, skips agent selection, and is forwarded to `plugins`, or to `skills` and `mcp`, not both. Linking uses `neon link -y`: the only organization and project are selected, or their IDs are printed and the command exits. `--no-agent-setup` and `--no-link` skip those steps. Non-interactive without `--default` prints next steps and does not install, set up agents, or link.
881
+ After scaffolding, an interactive terminal asks about dependency install and git, then finishes agent setup before asking whether to link a Neon project. Dependency install is last, except when the template has a `neon.ts` and you chose to link — then install runs first so the link flow can pull env. `--default` / `-y` skips the template, install, git, and agent pickers, then installs agent tooling for project folders, else the host CLI agent. If none are found, it exits: pass `--agent <name>`, run from a supported agent, or omit `--default` / `-y` in a terminal to pick. `--agent` / `-a` names coding agents, skips agent selection, and is forwarded to `plugins`, or to `skills` and `mcp`, not both. Linking uses `neon link -y`: the only organization and project are selected, or their IDs are printed and the command exits. `--no-agent-setup` and `--no-link` skip those steps. Non-interactive without `--default` prints next steps and does not init git, set up agents, or link; it installs dependencies only when you pass `--install`.
882
882
 
883
883
  When the template has a `neon.ts` and its dependencies are installed and the project is linked, bootstrap checks the env vars its functions read against the env file link pulled into (`.env.local`). If all are set, a terminal asks `Deploy this project to Neon now?` and runs `neon deploy --env .env.local`; `--default` leaves that command under `Next:`. If some are unset, `Next:` names them. `--deploy` installs, links, and deploys without asking, and fails with `neon deploy`'s error when an env var is unset. It refuses `--no-install` and `--no-link`, and needs `--default` outside a terminal.
884
884
 
@@ -2,7 +2,6 @@ import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { codeFromBody, isNeonApiError } from "../api.js";
3
3
  import { REDACTED_INVALID_VALUE, didYouMean } from "../errors.js";
4
4
  import { writer } from "../writer.js";
5
- import { describeOperation, getEndpoints, loadSpec } from "../utils/openapi.js";
6
5
  import { readFileSync } from "node:fs";
7
6
  import { resolve } from "node:path";
8
7
  import chalk from "chalk";
@@ -147,13 +146,16 @@ async function readData(data) {
147
146
  }
148
147
  }
149
148
  const toStrings = (values) => (values ?? []).map(String);
149
+ const openapi = () => import("../utils/openapi.js");
150
150
  async function listEndpoints(args) {
151
+ const { DEFAULT_SPEC_URL, getEndpoints, loadSpec } = await openapi();
152
+ const specUrl = args.specUrl ?? DEFAULT_SPEC_URL;
151
153
  const spec = await loadSpec({
152
154
  configDir: args.configDir,
153
- specUrl: args.specUrl,
155
+ specUrl,
154
156
  refresh: args.refresh
155
157
  });
156
- if (!spec) throw new Error(`Could not load the Neon OpenAPI spec from ${args.specUrl}. Check your network connection or pass --spec-url.`);
158
+ if (!spec) throw new Error(`Could not load the Neon OpenAPI spec from ${specUrl}. Check your network connection or pass --spec-url.`);
157
159
  const endpoints = getEndpoints(spec).map((endpoint) => ({
158
160
  method: endpoint.method,
159
161
  path: endpoint.path,
@@ -192,12 +194,14 @@ async function describeRoute(args) {
192
194
  ...toStrings(args.query),
193
195
  ...toStrings(args.header)
194
196
  ].length > 0 || args.data !== void 0 || args.include) throw new Error("--describe prints the field list; it does not send a request. Drop -F, -f, -d, -Q, -H, and -i.");
197
+ const { DEFAULT_SPEC_URL, describeOperation, loadSpec } = await openapi();
198
+ const specUrl = args.specUrl ?? DEFAULT_SPEC_URL;
195
199
  const spec = await loadSpec({
196
200
  configDir: args.configDir,
197
- specUrl: args.specUrl,
201
+ specUrl,
198
202
  refresh: args.refresh
199
203
  });
200
- if (!spec) throw new Error(`Could not load the Neon OpenAPI spec from ${args.specUrl}. Check your network connection or pass --spec-url.`);
204
+ if (!spec) throw new Error(`Could not load the Neon OpenAPI spec from ${specUrl}. Check your network connection or pass --spec-url.`);
201
205
  const method = String(args.method ?? "GET").toUpperCase();
202
206
  assertMethod(method);
203
207
  const description = describeOperation(spec, path, method);
@@ -374,9 +378,9 @@ const builder = (argv) => argv.usage("$0 api <path> [options]").positional("path
374
378
  },
375
379
  "spec-url": {
376
380
  type: "string",
377
- default: process.env.NEON_API_SPEC_URL ?? "https://neon.com/api_spec/release/v2.json",
381
+ default: process.env.NEON_API_SPEC_URL,
378
382
  hidden: true,
379
- describe: "OpenAPI spec URL used by --list and --describe."
383
+ describe: "OpenAPI spec URL used by --list and --describe. Defaults to the released spec on neon.com."
380
384
  }
381
385
  }).example("$0 api /projects", "List your projects").example("$0 api /projects/{id}/branches -X POST -F branch.name=dev", "Create a branch").example("$0 api --list", "List every available API route").example("$0 api /projects --describe", "Show GET /projects query parameters").example("$0 api /projects -X POST --describe", "Show the create-project body fields");
382
386
  const handler = async (args) => {
@@ -55,9 +55,8 @@ const builder = (argv) => argv.usage("$0 bootstrap [directory] [options]").posit
55
55
  default: false
56
56
  },
57
57
  install: {
58
- describe: "Install dependencies after scaffolding. In interactive mode this is offered as a prompt; use --no-install to skip without being asked.",
59
- type: "boolean",
60
- default: true
58
+ describe: "Install dependencies after scaffolding. In interactive mode this is offered as a prompt; use --no-install to skip without being asked. Without a terminal, --install or --default installs.",
59
+ type: "boolean"
61
60
  },
62
61
  git: {
63
62
  describe: "Initialize a git repository after scaffolding. In interactive mode this is offered as a prompt; use --no-git to skip without being asked.",
@@ -200,17 +199,17 @@ const runPostScaffoldSteps = async (props, targetDir, interactive, template, nam
200
199
  const neonConfig = hasNeonConfig(targetDir);
201
200
  if (props.default) return runDefaultSteps(props, targetDir, defaultPm, neonConfig, template, named);
202
201
  if (!interactive) {
203
- const outcome = {
204
- installed: false,
205
- installFailed: false,
206
- gitFailed: false,
202
+ const outcome = await executePostScaffold(props, targetDir, {
203
+ yes: true,
204
+ lockAgentSetup: false,
205
+ pm: defaultPm,
207
206
  git: false,
208
207
  agentSetup: "skip",
209
- linked: false,
210
- skippedLinkForDeps: false,
211
- agentsRan: false,
212
- deployed: false
213
- };
208
+ install: props.install === true,
209
+ link: false,
210
+ hasNeonConfig: neonConfig,
211
+ named
212
+ });
214
213
  finishPostScaffold({
215
214
  heading: "Project scaffolded.",
216
215
  template,
@@ -224,7 +223,7 @@ const runPostScaffoldSteps = async (props, targetDir, interactive, template, nam
224
223
  return nestedResult(template, targetDir, neonConfig, outcome);
225
224
  }
226
225
  let pm = defaultPm;
227
- const wantInstall = props.install && (props.deploy === true || await confirm(installPrompt(inferred)));
226
+ const wantInstall = props.install !== false && (props.deploy === true || await confirm(installPrompt(inferred)));
228
227
  if (wantInstall) pm = inferred ?? await selectPackageManager();
229
228
  const wantGit = props.git && !isGitRepo(targetDir) && await confirm("Initialize a git repository?");
230
229
  const agentSetup = props.agentSetup === false ? "skip" : named.length > 0 ? chooseYesAgentTooling(named).setup : await (props.pickAgentSetup ?? pickAgentSetupInteractively)();
@@ -264,7 +263,7 @@ const runDefaultSteps = async (props, targetDir, pm, neonConfig, template, named
264
263
  pm,
265
264
  git: wantGit,
266
265
  agentSetup,
267
- install: props.install,
266
+ install: props.install !== false,
268
267
  link: props.link,
269
268
  hasNeonConfig: neonConfig,
270
269
  named
@@ -382,7 +381,7 @@ const executePostScaffold = async (props, targetDir, choices) => {
382
381
  };
383
382
  /**
384
383
  * `--deploy` installs and links without asking, so flags that skip those steps contradict
385
- * it. Outside a terminal, only `-y` runs the post-scaffold steps at all.
384
+ * it. Outside a terminal, only `-y` runs the link step.
386
385
  */
387
386
  const assertDeployable = (props, interactive) => {
388
387
  if (props.install === false || props.link === false) throw new BootstrapInputError("--deploy needs installed dependencies and a linked project. Remove --no-install and --no-link.", "DEPLOY_NEEDS_INSTALL_AND_LINK");
@@ -13,8 +13,8 @@ import { fillSingleProject, listAllProjectBranches } from "../utils/enrichers.js
13
13
  import { buildCheckoutEvent, readGitContext } from "../utils/git.js";
14
14
  import { buildHookBranch, loadHookConfig, resolveHookEnv, runCheckoutAfterHook, runCheckoutBeforeHook, runCreateAfterHook, runCreateBeforeHook } from "../utils/hooks.js";
15
15
  import { n as autoPullEnvAfterPin } from "./env-C3HQJO8Z.js";
16
- import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-C8BQIoM2.js";
17
- import { i as handler$1 } from "./link-BVa6Nfji.js";
16
+ import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-BgVJkRBC.js";
17
+ import { i as handler$1 } from "./link-CYAw3z0c.js";
18
18
  import chalk from "chalk";
19
19
  import prompts from "prompts";
20
20
  // src/commands/checkout.ts
@@ -128,11 +128,14 @@ const DEPENDENCY_FIELDS = [
128
128
  "peerDependencies",
129
129
  "optionalDependencies"
130
130
  ];
131
+ const isNpmPeerConflict = (pm, detail) => pm === "npm" && detail === "ERESOLVE";
132
+ const PEER_CONFLICT_HINT = "npm stops on a peer dependency conflict in this project's dependency tree. --force accepts the conflict, which npm reports as a warning, and installs the Neon packages along with any peer dependencies the tree is missing.";
131
133
  var ConfigInstallFailed = class extends DetailedError {
132
134
  constructor(command, pm, detail) {
133
135
  super(`Could not install the Neon dependencies with ${pm} (${detail}).`, detail);
134
136
  this.name = "ConfigInstallFailed";
135
137
  this.command = command;
138
+ this.hint = isNpmPeerConflict(pm, detail) ? PEER_CONFLICT_HINT : void 0;
136
139
  }
137
140
  };
138
141
  const isRecord = (value) => typeof value === "object" && value !== null;
@@ -293,8 +296,10 @@ const ensureConfigPackages = async (cwd, props) => {
293
296
  if (!props.silent) log.info("Installing %s with %s…", missing.join(", "), pm);
294
297
  const result = await run(pm, args, cwd);
295
298
  if (!result.ok) {
296
- if (props.requireInstall) throw new ConfigInstallFailed(installHint, pm, result.detail);
297
- log.warning("Could not install the config packages automatically with %s (%s). Run by hand: %s", pm, result.detail, installHint);
299
+ const peerConflict = isNpmPeerConflict(pm, result.detail);
300
+ const retry = installCommandFrom(cwd, pm, missing, { acceptPeerConflicts: peerConflict });
301
+ if (props.requireInstall) throw new ConfigInstallFailed(retry, pm, result.detail);
302
+ log.warning("Could not install the config packages automatically with %s (%s).%s Run by hand: %s", pm, result.detail, peerConflict ? ` ${PEER_CONFLICT_HINT}` : "", retry);
298
303
  }
299
304
  };
300
305
  /**
@@ -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 { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-C8BQIoM2.js";
3
+ import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-BgVJkRBC.js";
4
4
  import { DEPLOY_COMMANDS_EPILOGUE } from "../commands/deploy_help.js";
5
5
  // src/commands/deploy.ts
6
6
  var deploy_exports = /* @__PURE__ */ __exportAll({
@@ -7,7 +7,7 @@ import { t as NEON_DEV_FUNCTION_PORTS } from "./env-EJU-0InB.js";
7
7
  import { branchIdResolve } from "../utils/enrichers.js";
8
8
  import { bundleEntry } from "../utils/esbuild.js";
9
9
  import { a as resolveDevEnv } from "./env-BWvi2_2f.js";
10
- import { f as envFlag } from "./config-C8BQIoM2.js";
10
+ import { f as envFlag } from "./config-BgVJkRBC.js";
11
11
  import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
12
12
  import { resolveWatchInputs } from "../dev/inputs.js";
13
13
  import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -5,8 +5,8 @@ import { CONTEXT_FILE, contextBranch, gitBranchMap, gitBranchMapping, isUnfollow
5
5
  import { writer } from "../writer.js";
6
6
  import { neonSafeBranchName } from "../utils/branch_name.js";
7
7
  import { currentGitBranch, gitPull, gitRepoRoot, hasUpstream, installPostCheckoutHook, isGitRepo, isManagedHook, localGitBranches, postCheckoutHookPath, readGitContext, removePostCheckoutHook } from "../utils/git.js";
8
- import { o as quoteFlagValue } from "./link-BVa6Nfji.js";
9
- import { o as handler$1 } from "./checkout-CczPpuT9.js";
8
+ import { o as quoteFlagValue } from "./link-CYAw3z0c.js";
9
+ import { o as handler$1 } from "./checkout-Dc70dN1v.js";
10
10
  import { existsSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import chalk from "chalk";
@@ -14,7 +14,7 @@ import { createBranch, pickBranchInteractively } from "../utils/branch_picker.js
14
14
  import { looksLikeBranchId } from "../utils/formats.js";
15
15
  import { listAllProjectBranches } from "../utils/enrichers.js";
16
16
  import { n as autoPullEnvAfterPin } from "./env-C3HQJO8Z.js";
17
- import { h as initCmd } from "./config-C8BQIoM2.js";
17
+ import { h as initCmd } from "./config-BgVJkRBC.js";
18
18
  import { formatLinkSummary } from "../commands/link_output.js";
19
19
  import { r as REGIONS } from "./projects-a3X4OFEJ.js";
20
20
  import prompts from "prompts";
@@ -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-C8BQIoM2.js";
3
+ import { y as status } from "./config-BgVJkRBC.js";
4
4
  // src/commands/status.ts
5
5
  var status_exports = /* @__PURE__ */ __exportAll({
6
6
  builder: () => builder,
@@ -1 +1 @@
1
- export { n as buildBody, r as buildQuery, i as builder, a as colorizeJson, o as command, s as describe, c as handler, l as parseHeaders, u as parseKeyValue, d as parseTypedValue, f as setDeep } from "../_chunks/api-BZh2r_lx.js";
1
+ export { n as buildBody, r as buildQuery, i as builder, a as colorizeJson, o as command, s as describe, c as handler, l as parseHeaders, u as parseKeyValue, d as parseTypedValue, f as setDeep } from "../_chunks/api-Bus6PoKT.js";
@@ -1 +1 @@
1
- export { n as builder, r as command, i as describe, a as handler } from "../_chunks/bootstrap-yotTpFtF.js";
1
+ export { n as builder, r as command, i as describe, a as handler } from "../_chunks/bootstrap-CwIzCCcg.js";
@@ -1 +1 @@
1
- export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-CczPpuT9.js";
1
+ export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-Dc70dN1v.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-C8BQIoM2.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-BgVJkRBC.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-BdipMGJE.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-B7MgbDYh.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-DVB7fGiG.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-Hq6nGUAM.js";
@@ -10,7 +10,7 @@ import { writer } from "../writer.js";
10
10
  import { formatInitDone, printInitDone } from "../init/chrome.js";
11
11
  import { FUNCTION_SLUG_PATTERN, deriveFunctionSlug } from "../utils/function_slug.js";
12
12
  import { displayPath } from "./env_output.js";
13
- import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-C8BQIoM2.js";
13
+ import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-BgVJkRBC.js";
14
14
  import { recommendedOperations } from "../functions/registry.js";
15
15
  import { collidingFiles, operationsFromFlags, planConfigRegistration, planEnvExample, planScaffold, writeScaffold } from "../functions/scaffold.js";
16
16
  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-BZY1WeAw.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-DT3nMyGz.js";
@@ -1,30 +1,30 @@
1
1
  import { r as auth_exports } from "../_chunks/auth-CFa969Ck.js";
2
- import { t as api_exports } from "../_chunks/api-BZh2r_lx.js";
2
+ import { t as api_exports } from "../_chunks/api-Bus6PoKT.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-C3HQJO8Z.js";
6
- import { c as config_exports } from "../_chunks/config-C8BQIoM2.js";
6
+ import { c as config_exports } from "../_chunks/config-BgVJkRBC.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-BVa6Nfji.js";
8
+ import { a as link_exports } from "../_chunks/link-CYAw3z0c.js";
9
9
  import { o as mcp_exports } from "../_chunks/mcp-g8C-BZIb.js";
10
10
  import { c as plugins_exports } from "../_chunks/plugins-CEylQlgK.js";
11
11
  import { l as skills_exports } from "../_chunks/skills-Bv8oKKwE.js";
12
- import { t as bootstrap_exports } from "../_chunks/bootstrap-yotTpFtF.js";
12
+ import { t as bootstrap_exports } from "../_chunks/bootstrap-CwIzCCcg.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-CczPpuT9.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-Dc70dN1v.js";
16
16
  import { o as claim_exports } from "../_chunks/claim-BoN9NPTy.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-BdipMGJE.js";
22
- import { s as dev_exports } from "../_chunks/dev-DVB7fGiG.js";
21
+ import { r as deploy_exports } from "../_chunks/deploy-B7MgbDYh.js";
22
+ import { s as dev_exports } from "../_chunks/dev-Hq6nGUAM.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-v9z7zjWD.js";
27
- import { o as git_exports } from "../_chunks/git-BZY1WeAw.js";
27
+ import { o as git_exports } from "../_chunks/git-DT3nMyGz.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";
@@ -41,7 +41,7 @@ import { o as profile_exports } from "../_chunks/profile-DWyfpl03.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-BolN3uBz.js";
44
- import { a as status_exports } from "../_chunks/status-BBnw48qR.js";
44
+ import { a as status_exports } from "../_chunks/status-Bop_r6Va.js";
45
45
  import { d as triggers_exports } from "../_chunks/triggers-m3IBjiph.js";
46
46
  import { s as user_exports } from "../_chunks/user-iNYSe0KI.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-BVa6Nfji.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-CYAw3z0c.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-BBnw48qR.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-Bop_r6Va.js";
@@ -37,8 +37,8 @@ const parseConfigInitServices = (raw, onDeprecated) => parseServices(raw, {
37
37
  const FUNCTION_SLUG = "hello";
38
38
  const FUNCTION_NAME = "Hello World";
39
39
  const FUNCTION_FILENAME = "hello.ts";
40
- /** Name of the bucket scaffolded for `storage`. */
41
- const BUCKET_NAME = "assets";
40
+ /** Neon's Object Storage guides use this bucket name. */
41
+ const BUCKET_NAME = "uploads";
42
42
  /**
43
43
  * One indentation level in the emitted `neon.ts`. Two spaces, which is what every renderer
44
44
  * here produces and what `config_template.format.test.ts` holds them to.
package/dist/init/copy.js CHANGED
@@ -150,10 +150,11 @@ const claimableThenServicesNext = (expiresAt) => [
150
150
  "Refresh local environment variables:",
151
151
  `${getCliName()} env pull`
152
152
  ];
153
- const installFailedNext = (command, envPull, reason) => ({
153
+ const installFailedNext = (command, envPull, reason, hint) => ({
154
154
  heading: HEADING_FAILED,
155
155
  body: reason,
156
156
  next: [
157
+ ...hint ? [hint] : [],
157
158
  "Install the dependencies, then run neon init again:",
158
159
  command,
159
160
  ...envPull ? [
@@ -4,7 +4,7 @@ import { c as ensureAuth } from "../_chunks/auth-CFa969Ck.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-C8BQIoM2.js";
7
+ import { r as applyCmd } from "../_chunks/config-BgVJkRBC.js";
8
8
  import { authContext } from "./auth.js";
9
9
  import { existsSync } from "node:fs";
10
10
  import { missingFunctionEnv } from "@neon/config";
package/dist/init/link.js CHANGED
@@ -4,7 +4,7 @@ import "../config.js";
4
4
  import "../auth.js";
5
5
  import { c as ensureAuth } from "../_chunks/auth-CFa969Ck.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { s as runLink } from "../_chunks/link-BVa6Nfji.js";
7
+ import { s as runLink } from "../_chunks/link-CYAw3z0c.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
@@ -15,8 +15,8 @@ import { getAgentDisplayName } from "../mcp/agents.js";
15
15
  import { missingPluginsCommands, pluginsCommandProblemText, pluginsInstallableAgents, unusablePluginsCommands } from "../plugins/targets.js";
16
16
  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";
17
17
  import { agentsRowValue, configRowValue, formatInitDone, headingForKind, printInitBanner, printInitDone, printInitProgress, projectRowValue, shouldPrintInitBanner } from "./chrome.js";
18
- import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-C8BQIoM2.js";
19
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-BVa6Nfji.js";
18
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-BgVJkRBC.js";
19
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-CYAw3z0c.js";
20
20
  import { runAuthenticatedLink } from "./link.js";
21
21
  import { mcpInstallableAgents } from "../mcp/targets.js";
22
22
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -595,7 +595,7 @@ const runInit = async (props) => {
595
595
  });
596
596
  } catch (error) {
597
597
  if (error instanceof ConfigInstallFailed) {
598
- const failed = installFailedNext(error.command, linkDeferredPull, error.message);
598
+ const failed = installFailedNext(error.command, linkDeferredPull, error.message, error.hint);
599
599
  printInitDone(formatInitDone({
600
600
  heading: failed.heading,
601
601
  body: failed.body,
@@ -1,4 +1,4 @@
1
- import { CONFIG_INIT_SERVICES } from "../config_template.js";
1
+ import { BUCKET_NAME, CONFIG_INIT_SERVICES } from "../config_template.js";
2
2
  import { installedPackageManagers } from "../utils/package_manager.js";
3
3
  import { getAgentDisplayName, listMcpAgentIds } from "../mcp/agents.js";
4
4
  import { AGENT_DETECTED_DESCRIPTION, AGENT_MCP_PICKER_MESSAGE, AGENT_MCP_SKIP_MESSAGE, AGENT_OTHER_DESCRIPTION, AGENT_PICKER_MESSAGE, AGENT_PLUGIN_SKIP_MESSAGE, AGENT_SETUP_MESSAGE, AGENT_SETUP_PLUGIN_DESCRIPTION, AGENT_SETUP_PLUGIN_TITLE, AGENT_SETUP_SKILLS_DESCRIPTION, AGENT_SETUP_SKILLS_TITLE, AGENT_SETUP_SKIP_DESCRIPTION, AGENT_SETUP_SKIP_TITLE, AGENT_SKILLS_PICKER_MESSAGE, AGENT_SKILLS_SKIP_MESSAGE, CONFIG_CONFIRM_HINT, CONFIG_CONFIRM_MESSAGE, MCP_AUTH_API_KEY_DESCRIPTION, MCP_AUTH_API_KEY_TITLE, MCP_AUTH_MESSAGE, MCP_AUTH_OAUTH_DESCRIPTION, MCP_AUTH_OAUTH_TITLE, MCP_SCOPE_GLOBAL_DESCRIPTION, MCP_SCOPE_GLOBAL_TITLE, MCP_SCOPE_MESSAGE, MCP_SCOPE_PROJECT_DESCRIPTION, MCP_SCOPE_PROJECT_TITLE, MODE_CUSTOM_DESCRIPTION, MODE_CUSTOM_TITLE, MODE_MESSAGE, MODE_RECOMMENDED_DESCRIPTION, MODE_RECOMMENDED_TITLE, PACKAGE_MANAGER_MESSAGE, PROJECT_SETUP_CLAIMABLE_DESCRIPTION, PROJECT_SETUP_CLAIMABLE_TITLE, PROJECT_SETUP_LINK_DESCRIPTION, PROJECT_SETUP_LINK_TITLE, PROJECT_SETUP_MESSAGE, SERVICES_HINT, SERVICES_MESSAGE, SKILLS_PICKER_MESSAGE, agentUnusableCommandDescription } from "./copy.js";
@@ -187,7 +187,7 @@ const pickInitConfigInteractively = async () => {
187
187
  const pickInitServicesInteractively = async () => {
188
188
  requireInteractive();
189
189
  process.stdout.write(`${chalk.dim(SERVICES_HINT)}\n`);
190
- const { services } = await prompts({
190
+ const question = {
191
191
  onState: restoreCursorOnAbort,
192
192
  onRender() {
193
193
  keepPostgresSelected(this);
@@ -217,7 +217,7 @@ const pickInitServicesInteractively = async () => {
217
217
  {
218
218
  value: "object-storage",
219
219
  title: "Object Storage",
220
- description: "Declare a private S3-compatible bucket named assets."
220
+ description: `Declare a private S3-compatible bucket named ${BUCKET_NAME}.`
221
221
  },
222
222
  {
223
223
  value: "ai-gateway",
@@ -225,7 +225,8 @@ const pickInitServicesInteractively = async () => {
225
225
  description: "Declare AI Gateway access. Requires an eligible Neon plan."
226
226
  }
227
227
  ]
228
- });
228
+ };
229
+ const { services } = await prompts(question);
229
230
  if (!Array.isArray(services)) return aborted();
230
231
  return CONFIG_INIT_SERVICES.filter((service) => services.includes(service));
231
232
  };
@@ -1,44 +1,11 @@
1
1
  import { log } from "../log.js";
2
2
  import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
+ import { EndpointNotFoundError, NEON_OPENAPI_SPEC_URL, describeEndpoint, fetchOpenApiSpec, listEndpoints } from "@neon/sdk/openapi";
4
5
  // src/utils/openapi.ts
5
- /** Public URL of the released Neon OpenAPI v2 spec. */
6
- const DEFAULT_SPEC_URL = "https://neon.com/api_spec/release/v2.json";
6
+ const DEFAULT_SPEC_URL = NEON_OPENAPI_SPEC_URL;
7
7
  const CACHE_FILE = "openapi-spec.json";
8
8
  const CACHE_TTL_MS = 864e5;
9
- const FETCH_TIMEOUT_MS = 1e4;
10
- const HTTP_METHODS = /* @__PURE__ */ new Set([
11
- "get",
12
- "post",
13
- "put",
14
- "patch",
15
- "delete",
16
- "head",
17
- "options"
18
- ]);
19
- const DESCRIBE_METHODS = [
20
- "GET",
21
- "POST",
22
- "PUT",
23
- "PATCH",
24
- "DELETE"
25
- ];
26
- async function fetchSpec(url) {
27
- const controller = new AbortController();
28
- const timer = setTimeout(() => {
29
- controller.abort();
30
- }, FETCH_TIMEOUT_MS);
31
- try {
32
- const res = await fetch(url, {
33
- signal: controller.signal,
34
- headers: { Accept: "application/json" }
35
- });
36
- if (!res.ok) throw new Error(`Failed to fetch OpenAPI spec (${res.status} ${res.statusText})`);
37
- return await res.json();
38
- } finally {
39
- clearTimeout(timer);
40
- }
41
- }
42
9
  function readCache(cachePath) {
43
10
  try {
44
11
  return JSON.parse(readFileSync(cachePath, "utf8"));
@@ -71,7 +38,7 @@ async function loadSpec(opts) {
71
38
  }
72
39
  try {
73
40
  log.debug("Fetching OpenAPI spec from %s", specUrl);
74
- const spec = await fetchSpec(specUrl);
41
+ const spec = await fetchOpenApiSpec({ url: specUrl });
75
42
  writeCache(cachePath, {
76
43
  fetchedAt: Date.now(),
77
44
  specUrl,
@@ -88,372 +55,14 @@ async function loadSpec(opts) {
88
55
  return null;
89
56
  }
90
57
  }
91
- /** Flatten a spec into a sorted list of routes (by path, then method). */
92
- function getEndpoints(spec) {
93
- const endpoints = [];
94
- for (const [path, item] of Object.entries(spec.paths ?? {})) for (const [method, op] of Object.entries(item)) {
95
- if (!HTTP_METHODS.has(method.toLowerCase())) continue;
96
- const operation = op ?? {};
97
- endpoints.push({
98
- method: method.toUpperCase(),
99
- path,
100
- summary: operation.summary,
101
- operationId: operation.operationId,
102
- tags: operation.tags ?? []
103
- });
104
- }
105
- endpoints.sort((a, b) => a.path === b.path ? a.method.localeCompare(b.method) : a.path.localeCompare(b.path));
106
- return endpoints;
107
- }
108
- function isRecord(value) {
109
- return typeof value === "object" && value !== null && !Array.isArray(value);
110
- }
111
- function asStringArray(value) {
112
- if (!Array.isArray(value)) return [];
113
- return value.filter((item) => typeof item === "string");
114
- }
115
- function stringDesc(value) {
116
- if (!isRecord(value) || typeof value.description !== "string") return "";
117
- return value.description.trim();
118
- }
119
- function specRecord(spec) {
120
- return spec;
121
- }
122
- function resolveRef(spec, ref) {
123
- if (!ref.startsWith("#/")) throw new Error(`Unsupported $ref "${ref}". Only document-local refs are resolved.`);
124
- let node = specRecord(spec);
125
- for (const part of ref.slice(2).split("/")) {
126
- const key = part.replace(/~1/g, "/").replace(/~0/g, "~");
127
- if (!isRecord(node) || !(key in node)) throw new Error(`Unresolved $ref ${ref}.`);
128
- node = node[key];
129
- }
130
- return node;
131
- }
132
- function schemaType(schema) {
133
- const t = schema.type;
134
- if (typeof t === "string") return t;
135
- if (Array.isArray(t)) {
136
- const first = t.find((item) => typeof item === "string");
137
- if (first) return first;
138
- }
139
- if (schema.items !== void 0) return "array";
140
- if (isRecord(schema.properties) || schema.additionalProperties !== void 0) return "object";
141
- if (Array.isArray(schema.enum)) return "string";
142
- return "object";
143
- }
144
- function optionalEnum(schema) {
145
- return Array.isArray(schema.enum) ? { enum: schema.enum } : {};
146
- }
147
- function optionalNullable(schema) {
148
- return schema.nullable === true ? { nullable: true } : {};
149
- }
150
- function mergeSchema(base, overlay) {
151
- const properties = {
152
- ...isRecord(base.properties) ? base.properties : {},
153
- ...isRecord(overlay.properties) ? overlay.properties : {}
154
- };
155
- const required = [.../* @__PURE__ */ new Set([...asStringArray(base.required), ...asStringArray(overlay.required)])];
156
- const description = stringDesc(overlay) || stringDesc(base);
157
- return {
158
- ...base,
159
- ...overlay,
160
- properties,
161
- required,
162
- ...description ? { description } : {}
163
- };
164
- }
165
- function resolveSchema(spec, schema, stack) {
166
- if (!isRecord(schema)) return {};
167
- if (typeof schema.$ref === "string") {
168
- const ref = schema.$ref;
169
- const { $ref: _ref, ...siblings } = schema;
170
- if (stack.includes(ref)) return {
171
- type: "object",
172
- ...siblings
173
- };
174
- return mergeSchema(resolveSchema(spec, resolveRef(spec, ref), [...stack, ref]), siblings);
175
- }
176
- if (Array.isArray(schema.allOf)) {
177
- const { allOf, ...rest } = schema;
178
- let merged = {
179
- type: "object",
180
- properties: {},
181
- required: []
182
- };
183
- for (const part of allOf) merged = mergeSchema(merged, resolveSchema(spec, part, stack));
184
- return mergeSchema(merged, rest);
185
- }
186
- return schema;
187
- }
188
- function fieldFromSchema(location, name, required, schema) {
189
- return {
190
- in: location,
191
- name,
192
- required,
193
- type: schemaType(schema),
194
- description: stringDesc(schema),
195
- ...optionalEnum(schema),
196
- ...optionalNullable(schema)
197
- };
198
- }
199
- function pushedRefs(schema, stack) {
200
- if (!isRecord(schema)) return stack;
201
- let next = stack;
202
- if (typeof schema.$ref === "string" && !next.includes(schema.$ref)) next = [...next, schema.$ref];
203
- if (Array.isArray(schema.allOf)) for (const part of schema.allOf) next = pushedRefs(part, next);
204
- return next;
205
- }
206
- function arrayField(spec, name, required, schema, stack) {
207
- const items = isRecord(schema.items) ? resolveSchema(spec, schema.items, stack) : {};
208
- const itemType = schemaType(items);
209
- const properties = isRecord(items.properties) ? items.properties : void 0;
210
- const requiredItems = new Set(asStringArray(items.required));
211
- return {
212
- in: "body",
213
- name,
214
- required,
215
- type: "array",
216
- description: stringDesc(schema),
217
- items: {
218
- type: itemType,
219
- ...optionalEnum(items),
220
- ...optionalNullable(items),
221
- ...properties ? { properties: Object.entries(properties).map(([propName, propSchema]) => {
222
- const resolved = resolveSchema(spec, propSchema, stack);
223
- return {
224
- name: propName,
225
- type: schemaType(resolved),
226
- required: requiredItems.has(propName),
227
- description: stringDesc(resolved),
228
- ...optionalEnum(resolved),
229
- ...optionalNullable(resolved)
230
- };
231
- }) } : {}
232
- }
233
- };
234
- }
235
- function unionMembers(schema) {
236
- if (Array.isArray(schema.oneOf)) return schema.oneOf;
237
- if (Array.isArray(schema.anyOf)) return schema.anyOf;
238
- return [];
239
- }
240
- function discriminatorField(schema, prefix) {
241
- if (!isRecord(schema.discriminator)) return null;
242
- const propertyName = schema.discriminator.propertyName;
243
- if (typeof propertyName !== "string") return null;
244
- const mapping = schema.discriminator.mapping;
245
- const values = isRecord(mapping) ? Object.keys(mapping) : [];
246
- return {
247
- in: "body",
248
- name: prefix ? `${prefix}.${propertyName}` : propertyName,
249
- required: true,
250
- type: "string",
251
- description: "",
252
- ...values.length > 0 ? { enum: values } : {}
253
- };
254
- }
255
- function flattenUnion(spec, schema, prefix, stack) {
256
- const members = unionMembers(schema);
257
- const byName = /* @__PURE__ */ new Map();
258
- for (const member of members) {
259
- const seen = /* @__PURE__ */ new Set();
260
- for (const field of flattenBody(spec, member, prefix, stack)) {
261
- if (seen.has(field.name)) continue;
262
- seen.add(field.name);
263
- const copies = byName.get(field.name) ?? [];
264
- copies.push(field);
265
- byName.set(field.name, copies);
266
- }
267
- }
268
- const fields = [];
269
- for (const copies of byName.values()) fields.push({
270
- ...copies[0],
271
- required: copies.length === members.length && copies.every((field) => field.required)
272
- });
273
- const discriminator = discriminatorField(schema, prefix);
274
- if (discriminator && !byName.has(discriminator.name)) fields.unshift(discriminator);
275
- else if (discriminator) {
276
- const existing = fields.find((field) => field.name === discriminator.name);
277
- if (existing) {
278
- existing.required = true;
279
- if (!existing.enum && discriminator.enum) existing.enum = discriminator.enum;
280
- }
281
- }
282
- return fields;
283
- }
284
- function flattenBody(spec, schema, prefix, stack = []) {
285
- const nextStack = pushedRefs(schema, stack);
286
- const resolved = resolveSchema(spec, schema, stack);
287
- if (unionMembers(resolved).length > 0) return flattenUnion(spec, resolved, prefix, nextStack);
288
- const properties = isRecord(resolved.properties) ? resolved.properties : void 0;
289
- if (!properties) {
290
- if (prefix === "") return [];
291
- if (schemaType(resolved) === "array") return [arrayField(spec, prefix, false, resolved, nextStack)];
292
- return [fieldFromSchema("body", prefix, false, resolved)];
293
- }
294
- const requiredSet = new Set(asStringArray(resolved.required));
295
- const fields = [];
296
- for (const [key, prop] of Object.entries(properties)) {
297
- const name = prefix ? `${prefix}.${key}` : key;
298
- const required = requiredSet.has(key);
299
- const resolvedProp = resolveSchema(spec, prop, nextStack);
300
- const type = schemaType(resolvedProp);
301
- if (type === "object" && isRecord(resolvedProp.properties)) {
302
- fields.push(...flattenBody(spec, prop, name, nextStack));
303
- continue;
304
- }
305
- if (type === "array") {
306
- fields.push(arrayField(spec, name, required, resolvedProp, nextStack));
307
- continue;
308
- }
309
- fields.push(fieldFromSchema("body", name, required, resolvedProp));
310
- }
311
- return fields;
312
- }
313
- function resolveParameter(spec, parameter) {
314
- if (!isRecord(parameter)) return null;
315
- if (typeof parameter.$ref === "string") {
316
- const resolved = resolveRef(spec, parameter.$ref);
317
- if (!isRecord(resolved)) throw new Error(`Unresolved $ref ${parameter.$ref}.`);
318
- const { $ref: _ref, ...siblings } = parameter;
319
- const description = stringDesc(siblings) || stringDesc(resolved);
320
- return {
321
- ...resolved,
322
- ...siblings,
323
- ...description ? { description } : {}
324
- };
325
- }
326
- return parameter;
327
- }
328
- function paramToField(spec, param) {
329
- const location = param.in;
330
- if (location !== "path" && location !== "query" && location !== "header") return null;
331
- if (typeof param.name !== "string") return null;
332
- const schema = isRecord(param.schema) ? resolveSchema(spec, param.schema, []) : {};
333
- const required = location === "path" ? param.required !== false : param.required === true;
334
- const type = schemaType(schema);
335
- const itemSchema = type === "array" && isRecord(schema.items) ? resolveSchema(spec, schema.items, []) : null;
336
- return {
337
- in: location,
338
- name: param.name,
339
- required,
340
- type,
341
- description: stringDesc(param) || stringDesc(schema),
342
- ...optionalEnum(schema),
343
- ...optionalNullable(schema),
344
- ...itemSchema ? { items: {
345
- type: schemaType(itemSchema),
346
- ...optionalEnum(itemSchema),
347
- ...optionalNullable(itemSchema)
348
- } } : {}
349
- };
350
- }
351
- function pathParamNames(template) {
352
- return [...template.matchAll(/\{([^}]+)\}/g)].map((match) => match[1]);
353
- }
354
- function pathMatchesTemplate(path, template) {
355
- const pathParts = path.split("/");
356
- const templateParts = template.split("/");
357
- if (pathParts.length !== templateParts.length) return false;
358
- return templateParts.every((part, i) => {
359
- if (part.startsWith("{") && part.endsWith("}")) return pathParts[i] !== "";
360
- return part === pathParts[i];
361
- });
362
- }
363
- function matchPath(spec, requestPath) {
364
- const path = requestPath.split("?")[0] ?? requestPath;
365
- const paths = spec.paths ?? {};
366
- const exact = paths[path];
367
- if (isRecord(exact)) return {
368
- template: path,
369
- pathItem: exact
370
- };
371
- const matches = Object.entries(paths).filter(([template, item]) => isRecord(item) && pathMatchesTemplate(path, template));
372
- if (matches.length === 0) throw new Error(`No route matches "${path}". Run \`neon api --list\` to see available routes.`);
373
- matches.sort((a, b) => {
374
- const staticA = a[0].split("/").filter((p) => !p.startsWith("{")).length;
375
- return b[0].split("/").filter((p) => !p.startsWith("{")).length - staticA;
376
- });
377
- const [template, pathItem] = matches[0];
378
- if (!isRecord(pathItem)) throw new Error(`No route matches "${path}". Run \`neon api --list\` to see available routes.`);
379
- return {
380
- template,
381
- pathItem
382
- };
383
- }
384
- function availableMethods(pathItem) {
385
- return DESCRIBE_METHODS.filter((method) => isRecord(pathItem[method.toLowerCase()]));
386
- }
387
- function collectParameters(spec, pathItem, operation, template) {
388
- const raw = [...Array.isArray(pathItem.parameters) ? pathItem.parameters : [], ...Array.isArray(operation.parameters) ? operation.parameters : []];
389
- const byKey = /* @__PURE__ */ new Map();
390
- for (const entry of raw) {
391
- const resolved = resolveParameter(spec, entry);
392
- if (!resolved) continue;
393
- const field = paramToField(spec, resolved);
394
- if (!field) continue;
395
- byKey.set(`${field.in}:${field.name}`, field);
396
- }
397
- const pathFields = pathParamNames(template).map((name) => {
398
- const existing = byKey.get(`path:${name}`);
399
- if (existing) return existing;
400
- return {
401
- in: "path",
402
- name,
403
- required: true,
404
- type: "string",
405
- description: ""
406
- };
407
- });
408
- const query = [...byKey.values()].filter((field) => field.in === "query");
409
- const header = [...byKey.values()].filter((field) => field.in === "header");
410
- return [
411
- ...pathFields,
412
- ...query,
413
- ...header
414
- ];
415
- }
416
- function jsonBodySchema(spec, operation) {
417
- let requestBody = operation.requestBody;
418
- if (isRecord(requestBody) && typeof requestBody.$ref === "string") requestBody = resolveRef(spec, requestBody.$ref);
419
- if (!isRecord(requestBody)) return null;
420
- const content = requestBody.content;
421
- if (!isRecord(content)) return null;
422
- const json = content["application/json"];
423
- let contentType = "application/json";
424
- let selected = json;
425
- if (!isRecord(json)) {
426
- const entry = Object.entries(content).find(([, value]) => isRecord(value));
427
- if (!entry) return null;
428
- contentType = entry[0];
429
- selected = entry[1];
430
- }
431
- if (!isRecord(selected) || selected.schema === void 0) return null;
432
- return {
433
- schema: selected.schema,
434
- required: requestBody.required === true,
435
- contentType
436
- };
437
- }
58
+ /** `describeEndpoint` with the `neon api` flag to pass next in its errors. */
438
59
  function describeOperation(spec, path, method) {
439
- const methodUpper = method.toUpperCase();
440
- const { template, pathItem } = matchPath(spec, path);
441
- const available = availableMethods(pathItem);
442
- const operation = pathItem[methodUpper.toLowerCase()];
443
- if (!isRecord(operation)) {
444
- const hint = available.length > 0 ? ` Available: ${available.join(", ")}. Pass -X ${available[0]}.` : " Run `neon api --list` to see available routes.";
445
- throw new Error(`No ${methodUpper} ${template} in the spec.${hint}`);
60
+ try {
61
+ return describeEndpoint(spec, path, method);
62
+ } catch (err) {
63
+ if (!(err instanceof EndpointNotFoundError)) throw err;
64
+ const hint = err.available.length > 0 ? `Pass -X ${err.available[0]}.` : "Run `neon api --list` to see available routes.";
65
+ throw new Error(`${err.message} ${hint}`);
446
66
  }
447
- const body = jsonBodySchema(spec, operation);
448
- const fields = [...collectParameters(spec, pathItem, operation, template), ...body ? flattenBody(spec, body.schema, "") : []];
449
- return {
450
- method: methodUpper,
451
- path: template,
452
- summary: typeof operation.summary === "string" ? operation.summary : "",
453
- operationId: typeof operation.operationId === "string" ? operation.operationId : "",
454
- bodyRequired: body?.required === true,
455
- contentType: body?.contentType ?? "",
456
- fields
457
- };
458
67
  }
459
- export { DEFAULT_SPEC_URL, describeOperation, getEndpoints, loadSpec };
68
+ export { DEFAULT_SPEC_URL, describeOperation, listEndpoints as getEndpoints, loadSpec };
@@ -252,6 +252,7 @@ const workspaceRootFlag = (pm, dir) => {
252
252
  const installArgs = (pm, packages, options) => packages?.length ? [
253
253
  pm === "npm" ? "install" : "add",
254
254
  ...options?.dir === void 0 ? [] : workspaceRootFlag(pm, options.dir),
255
+ ...options?.acceptPeerConflicts && pm === "npm" ? ["--force"] : [],
255
256
  ...options?.dev ? ["-D"] : [],
256
257
  ...options?.exact ? ["-E"] : [],
257
258
  ...packages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.9.7",
3
+ "version": "9.9.9",
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": "1.14.6",
77
- "@neon/config-runtime": "1.12.9",
78
- "@neon/realtime": "0.2.1",
79
- "@neon/sdk": "7.15.0"
76
+ "@neon/config": "1.14.7",
77
+ "@neon/config-runtime": "1.12.10",
78
+ "@neon/sdk": "7.16.0",
79
+ "@neon/realtime": "0.2.1"
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
+ "@neon-internals/env-core": "0.0.58",
117
117
  "@neon/e2e-harness": "0.0.0",
118
- "@neon/env": "2.1.9",
118
+ "@neon/env": "2.1.10",
119
119
  "@neon/functions": "0.11.0"
120
120
  },
121
121
  "publishConfig": {