neon 9.9.7 → 9.9.8

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.
@@ -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) => {
@@ -12,9 +12,9 @@ import { looksLikeBranchId } from "../utils/formats.js";
12
12
  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
- 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";
15
+ import { n as autoPullEnvAfterPin } from "./env-BIP63KZa.js";
16
+ import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-DrlP49no.js";
17
+ import { i as handler$1 } from "./link-D89GPFoO.js";
18
18
  import chalk from "chalk";
19
19
  import prompts from "prompts";
20
20
  // src/commands/checkout.ts
@@ -12,7 +12,7 @@ import { projectConfigPath } from "../project.js";
12
12
  import { resolveEnvFilePath } from "../env_file.js";
13
13
  import { writer } from "../writer.js";
14
14
  import { noPassthrough } from "../utils/flags.js";
15
- import { c as pull } from "./env-C3HQJO8Z.js";
15
+ import { c as pull } from "./env-BIP63KZa.js";
16
16
  import { existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
17
17
  import open from "open";
18
18
  import prompts from "prompts";
@@ -26,7 +26,7 @@ import { readGitContext } from "../utils/git.js";
26
26
  import { resolveHookEnv, runDeployAfterHook, runDeployBeforeHook } from "../utils/hooks.js";
27
27
  import { pickServicesInteractively } from "../utils/service_picker.js";
28
28
  import { zipBundle } from "../utils/zip.js";
29
- import { n as autoPullEnvAfterPin } from "./env-C3HQJO8Z.js";
29
+ import { n as autoPullEnvAfterPin } from "./env-BIP63KZa.js";
30
30
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
31
31
  import { dirname, join, relative, resolve } from "node:path";
32
32
  import chalk from "chalk";
@@ -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-DrlP49no.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({
@@ -4,12 +4,12 @@ import { getCliName } from "../utils/cli_name.js";
4
4
  import { isClaimableEnvTarget } from "../claimable/state.js";
5
5
  import { defaultDevEnvFiles, readEnvFile, resolveEnvFilePath } from "../env_file.js";
6
6
  import { t as NEON_DEV_FUNCTION_PORTS } from "./env-EJU-0InB.js";
7
- import { branchIdResolve } from "../utils/enrichers.js";
8
- import { bundleEntry } from "../utils/esbuild.js";
9
7
  import { a as resolveDevEnv } from "./env-BWvi2_2f.js";
10
- import { f as envFlag } from "./config-C8BQIoM2.js";
11
8
  import { findConfigFunctionBySource, resolveFunctionsFromConfig } from "../dev/functions.js";
12
9
  import { resolveWatchInputs } from "../dev/inputs.js";
10
+ import { branchIdResolve } from "../utils/enrichers.js";
11
+ import { bundleEntry } from "../utils/esbuild.js";
12
+ import { f as envFlag } from "./config-DrlP49no.js";
13
13
  import { existsSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
14
14
  import { basename, dirname, join, relative, resolve } from "node:path";
15
15
  import { fileURLToPath } from "node:url";
@@ -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-D89GPFoO.js";
9
+ import { o as handler$1 } from "./checkout-C4kfW64r.js";
10
10
  import { existsSync } from "node:fs";
11
11
  import { join } from "node:path";
12
12
  import chalk from "chalk";
@@ -13,8 +13,8 @@ import { writer } from "../writer.js";
13
13
  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
- import { n as autoPullEnvAfterPin } from "./env-C3HQJO8Z.js";
17
- import { h as initCmd } from "./config-C8BQIoM2.js";
16
+ import { n as autoPullEnvAfterPin } from "./env-BIP63KZa.js";
17
+ import { h as initCmd } from "./config-DrlP49no.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-DrlP49no.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 { 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-C4kfW64r.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-BoN9NPTy.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-u1NrKodG.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-DrlP49no.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-DnjB7HV_.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-wpD1Az-t.js";
@@ -1 +1 @@
1
- export { t as ENV_PULL_SKIPPED_HINT, n as autoPullEnvAfterPin, r as builder, i as command, a as describe, s as handler, c as pull } from "../_chunks/env-C3HQJO8Z.js";
1
+ export { t as ENV_PULL_SKIPPED_HINT, n as autoPullEnvAfterPin, r as builder, i as command, a as describe, s as handler, c as pull } from "../_chunks/env-BIP63KZa.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-DrlP49no.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-DWmx2prl.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
- import { o as env_exports } from "../_chunks/env-C3HQJO8Z.js";
6
- import { c as config_exports } from "../_chunks/config-C8BQIoM2.js";
5
+ import { o as env_exports } from "../_chunks/env-BIP63KZa.js";
6
+ import { c as config_exports } from "../_chunks/config-DrlP49no.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-D89GPFoO.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
12
  import { t as bootstrap_exports } from "../_chunks/bootstrap-yotTpFtF.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";
16
- import { o as claim_exports } from "../_chunks/claim-BoN9NPTy.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-C4kfW64r.js";
16
+ import { o as claim_exports } from "../_chunks/claim-u1NrKodG.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-DnjB7HV_.js";
22
+ import { s as dev_exports } from "../_chunks/dev-wpD1Az-t.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-DWmx2prl.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-DXp_w9U2.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-D89GPFoO.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-DXp_w9U2.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-BWvi2_2f.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", {
package/dist/init/auth.js CHANGED
@@ -4,7 +4,7 @@ import "../config.js";
4
4
  import "../auth.js";
5
5
  import { c as ensureAuth, l as existingApiClient } from "../_chunks/auth-CFa969Ck.js";
6
6
  import { recoverFrom401 } from "../auth_recovery.js";
7
- import { c as pull } from "../_chunks/env-C3HQJO8Z.js";
7
+ import { c as pull } from "../_chunks/env-BIP63KZa.js";
8
8
  import { c as setupNeonMcp } from "../_chunks/mcp-g8C-BZIb.js";
9
9
  // src/init/auth.ts
10
10
  const isUnauthorized = (error) => isNeonApiError(error) && error.status === 401;
@@ -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-DrlP49no.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-D89GPFoO.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-DrlP49no.js";
19
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-D89GPFoO.js";
20
20
  import { runAuthenticatedLink } from "./link.js";
21
21
  import { mcpInstallableAgents } from "../mcp/targets.js";
22
22
  import { skillsInstallableAgents } from "../skills/targets.js";
@@ -26,7 +26,7 @@ import { pullInitEnv, resolveInitConfigApi } from "./auth.js";
26
26
  import { InitCancelled, raceSigint, restoreCursor } from "./cancelled.js";
27
27
  import { pickAgentSetupInteractively, pickInitAgentsInteractively, pickInitConfigInteractively, pickInitMcpAuthInteractively, pickInitMcpConfigLocationInteractively, pickInitModeInteractively, pickInitPackageManagerInteractively, pickInitProjectSetupInteractively, pickInitServicesInteractively, pickInitSkillsInteractively } from "./wizard.js";
28
28
  import { runToolingSteps, toolingStepCommandText } from "./tooling.js";
29
- import { l as create } from "../_chunks/claim-BoN9NPTy.js";
29
+ import { l as create } from "../_chunks/claim-u1NrKodG.js";
30
30
  import { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice } from "./choices.js";
31
31
  import { detectInitEnvironment } from "./detect.js";
32
32
  import { createInitFunnel, emitInitStart, finishInitFunnel, initStartProperties, recordInitError, recordInitExit } from "./funnel.js";
@@ -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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.9.7",
3
+ "version": "9.9.8",
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",
76
+ "@neon/config": "1.14.7",
77
+ "@neon/config-runtime": "1.12.10",
78
78
  "@neon/realtime": "0.2.1",
79
- "@neon/sdk": "7.15.0"
79
+ "@neon/sdk": "7.16.0"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@napi-rs/keyring": "1.3.0",
@@ -112,10 +112,10 @@
112
112
  "tsx": "4.22.3",
113
113
  "typescript": "^5.9.0",
114
114
  "vitest": "^3.0.9",
115
+ "@neon-internals/env-core": "0.0.58",
115
116
  "@neon-internals/cli-core": "0.0.0",
116
- "@neon-internals/env-core": "0.0.57",
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": {
@@ -7,8 +7,8 @@ import { deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOpt
7
7
  import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
8
8
  import { n as NEON_ENV_VAR_KEYS } from "./env-EJU-0InB.js";
9
9
  import { ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, isLegacyFunctionBaseUrlKey, ownedEnvServiceKeys, parseEnvPullKeys } from "../env_services.js";
10
- import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
11
10
  import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-BWvi2_2f.js";
11
+ import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
12
12
  import { warnAiGateway } from "../utils/ai_gateway_notice.js";
13
13
  import { formatPulledEnv, pulledBranch } from "../commands/env_output.js";
14
14
  import { existsSync } from "node:fs";