neon 9.9.9 → 9.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +15 -2
  2. package/dist/_chunks/{checkout-Dc70dN1v.js → checkout-BTx-7Ugs.js} +3 -3
  3. package/dist/_chunks/{claim-BoN9NPTy.js → claim-DHVe8ka_.js} +1 -1
  4. package/dist/_chunks/{config-BgVJkRBC.js → config-mxicyjDQ.js} +16 -4
  5. package/dist/_chunks/{deploy-B7MgbDYh.js → deploy-CuJqMaAd.js} +1 -1
  6. package/dist/_chunks/{dev-Hq6nGUAM.js → dev-mf3JrprU.js} +3 -3
  7. package/dist/_chunks/{env-BWvi2_2f.js → env-BGu2tBb6.js} +53 -21
  8. package/dist/_chunks/{env-EJU-0InB.js → env-BKdhhNv2.js} +1 -1
  9. package/dist/_chunks/{env-C3HQJO8Z.js → env-BioHtKQ6.js} +25 -16
  10. package/dist/_chunks/{git-DT3nMyGz.js → git-BOYyFLoz.js} +2 -2
  11. package/dist/_chunks/{link-CYAw3z0c.js → link-w2sFyjre.js} +2 -2
  12. package/dist/_chunks/{logs-CcVpwdDs.js → logs-CnfCN0pv.js} +13 -4
  13. package/dist/_chunks/{neon_auth-DE6X6FFV.js → neon_auth-CJvoSrXr.js} +59 -2
  14. package/dist/_chunks/{status-Bop_r6Va.js → status-dPnz6_k3.js} +1 -1
  15. package/dist/commands/checkout.js +1 -1
  16. package/dist/commands/claim.js +1 -1
  17. package/dist/commands/config.js +1 -1
  18. package/dist/commands/deploy.js +1 -1
  19. package/dist/commands/dev.js +1 -1
  20. package/dist/commands/env.js +1 -1
  21. package/dist/commands/env_output.js +17 -0
  22. package/dist/commands/functions_new.js +1 -1
  23. package/dist/commands/git.js +1 -1
  24. package/dist/commands/index.js +11 -11
  25. package/dist/commands/link.js +1 -1
  26. package/dist/commands/logs.js +1 -1
  27. package/dist/commands/neon_auth.js +1 -1
  28. package/dist/commands/status.js +1 -1
  29. package/dist/commands/subscribe.js +1 -1
  30. package/dist/dev/env.js +1 -1
  31. package/dist/env_services.js +1 -1
  32. package/dist/errors.js +3 -1
  33. package/dist/init/auth.js +1 -1
  34. package/dist/init/deploy.js +1 -1
  35. package/dist/init/funnel.js +3 -0
  36. package/dist/init/link.js +1 -1
  37. package/dist/init/run.js +9 -5
  38. package/dist/utils/hooks.js +1 -1
  39. package/package.json +9 -9
package/README.md CHANGED
@@ -609,6 +609,9 @@ neon env pull -s auth -e DATABASE_URL
609
609
 
610
610
  # The variables functionBaseUrl("<slug>") from @neon/env reads
611
611
  neon env pull -s functions
612
+
613
+ # Connect DATABASE_URL as app_owner on a branch with several roles and no neondb_owner
614
+ neon env pull --role-name app_owner
612
615
  ```
613
616
 
614
617
  Every services flag in the CLI takes those three spellings, the same value syntax, and the same service names — see [`config init --services`](#getting-a-neonts-config-init).
@@ -642,6 +645,14 @@ auth env vars to pull. Provision it first (`neon deploy`, `neon config apply`, o
642
645
  Console), or drop auth from --service.
643
646
  ```
644
647
 
648
+ When `neon.ts` declares a resource the branch does not have yet (a bucket, Neon Auth, the Data API, Realtime), `env pull` still writes the branch's other variables, such as `DATABASE_URL`, and names what `neon deploy` has to provision. `neon deploy` pulls env vars again once it has:
649
+
650
+ ```text
651
+ Not deployed bucket pipeline-data, declared in neon.ts. Run `neon deploy` to provision it and pull its variables.
652
+ ```
653
+
654
+ `neon dev` stops with an error instead, since the process it starts would run without those variables. Undeployed functions and triggers never block a pull, because the variables a pull writes do not depend on their deployment.
655
+
645
656
  `link`, `checkout`, and `config apply` invoke `env pull` automatically (see above). Those bundled pulls follow rules 2 and 3 above, with two differences:
646
657
 
647
658
  - **The AI Gateway only when the file already has `NEON_AI_GATEWAY_*`.** Minting a credential for a service you never named isn't something a side effect of another command should do; once you run `neon env pull`, later bundled pulls keep the gateway current, so `checkout` moves it to the new branch.
@@ -858,6 +869,8 @@ neon config plan --project-id polished-snowflake-12345678 --output json
858
869
  neon deploy --branch my-feature --update-existing
859
870
  ```
860
871
 
872
+ `apply`, `deploy`, and `checkout` wait for every Function build they start to finish, up to 10 minutes, and print the function URLs only after that. A failed or unfinished build exits 1 with the platform's reason, after the other changes are applied. `--no-wait` on `apply` and `deploy` returns once each deployment is accepted; a new function's URL answers 404 until its build finishes.
873
+
861
874
  Function deploys declared under `functions` are bundled with esbuild by default. A directory `source` is discovered as `index.ts`, then `index.js`, then `index.mjs`. Set `bundler: "none"` to ship a prebuilt directory as-is. `neon function deploy --no-bundle` is the same switch without a `neon.ts`.
862
875
 
863
876
  Point a domain you already own at a function with `neon function domains` (alias `domain`):
@@ -1273,9 +1286,9 @@ $ neon logs query --since 24h --output json
1273
1286
  }
1274
1287
  ```
1275
1288
 
1276
- Two combinations are rejected before the request: `--since` with `--start-time`, and `--logql` with any of `--source`, `--service-name`, `--scope-name`, `--minimum-severity`, `--severity-text`, `--body-contains` or `--trace-id`. `--minimum-severity` and `--severity-text` are independent filters and combine with AND. If Neon reports that `--minimum-severity` is unsupported, use `--severity-text` instead; `neon logs field-values severity_text` lists the exact values present on a branch.
1289
+ Two combinations are rejected before the request: `--since` with `--start-time`, and `--logql` with any of `--source`, `--service-name`, `--scope-name`, `--minimum-severity`, `--severity-text`, `--body-contains` (or its `--search` alias) or `--trace-id`. `--minimum-severity` and `--severity-text` are independent filters and combine with AND. If Neon reports that `--minimum-severity` is unsupported, use `--severity-text` instead; `neon logs field-values severity_text` lists the exact values present on a branch. `--source` accepts `functions` as an alias for the API value `function`.
1277
1290
 
1278
- `--body-contains` compares a case-sensitive substring against the rendered message. Structured bodies, including object storage records, are rendered as compact JSON, so match the JSON form (for example, `"http_status":200`).
1291
+ `--body-contains` (alias `--search`) compares a case-sensitive substring against the rendered message. Structured bodies, including object storage records, are rendered as compact JSON, so match the JSON form (for example, `"http_status":200`).
1279
1292
 
1280
1293
  ### Loki API (`logs loki`)
1281
1294
 
@@ -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-BgVJkRBC.js";
17
- import { i as handler$1 } from "./link-CYAw3z0c.js";
15
+ import { n as autoPullEnvAfterPin } from "./env-BioHtKQ6.js";
16
+ import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-mxicyjDQ.js";
17
+ import { i as handler$1 } from "./link-w2sFyjre.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-BioHtKQ6.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-BioHtKQ6.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";
@@ -109,6 +109,11 @@ const applyFlags = {
109
109
  describe: "Answer yes to every confirmation: --update-existing and --allow-protected",
110
110
  type: "boolean",
111
111
  default: false
112
+ },
113
+ wait: {
114
+ describe: "Wait for Function builds to finish. Use --no-wait to return once each deployment is accepted",
115
+ type: "boolean",
116
+ default: true
112
117
  }
113
118
  };
114
119
  /**
@@ -863,7 +868,9 @@ const applyCmd = async (props) => {
863
868
  event,
864
869
  cwd
865
870
  }),
866
- bundleFunction: neonctlBundler
871
+ bundleFunction: neonctlBundler,
872
+ ...props.wait === false ? { waitForFunctionBuilds: false } : {},
873
+ onWaitForFunctionBuilds: logWaitForFunctionBuilds
867
874
  });
868
875
  } catch (err) {
869
876
  if (err instanceof PushAbortedError) throw new Error(declined ? `Aborted: nothing was applied to branch "${err.branchName}".` : abortedApplyMessage(err));
@@ -1039,10 +1046,14 @@ const applyPolicyOnCreate = async (props) => {
1039
1046
  ...props.runtimeApi ? { api: props.runtimeApi } : {},
1040
1047
  updateExisting: true,
1041
1048
  allowProtectedBranch: true,
1042
- bundleFunction: neonctlBundler
1049
+ bundleFunction: neonctlBundler,
1050
+ onWaitForFunctionBuilds: logWaitForFunctionBuilds
1043
1051
  });
1044
1052
  logPolicyResult(result, { color: props.color !== false });
1045
1053
  };
1054
+ function logWaitForFunctionBuilds(slugs) {
1055
+ log.info("Waiting for Function builds to finish: %s…", slugs.join(", "));
1056
+ }
1046
1057
  /**
1047
1058
  * Report what applying a `neon.ts` policy changed, using the same `field → value` diff
1048
1059
  * `deploy` prints (see {@link renderAppliedChanges}) rather than a bare list of change
@@ -1102,7 +1113,8 @@ const createBranchFromPolicyOnCheckout = async (props) => {
1102
1113
  ...props.apiKey ? { apiKey: props.apiKey } : {},
1103
1114
  ...props.apiHost ? { apiHost: props.apiHost } : {},
1104
1115
  ...props.runtimeApi ? { api: props.runtimeApi } : {},
1105
- bundleFunction: neonctlBundler
1116
+ bundleFunction: neonctlBundler,
1117
+ onWaitForFunctionBuilds: logWaitForFunctionBuilds
1106
1118
  });
1107
1119
  log.info("Created branch %s (%s) from neon.ts policy.", branchName, branchId);
1108
1120
  logPolicyResult(result, { color: props.color !== false });
@@ -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-BgVJkRBC.js";
3
+ import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-mxicyjDQ.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({
@@ -3,11 +3,11 @@ import { log } from "../log.js";
3
3
  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
- import { t as NEON_DEV_FUNCTION_PORTS } from "./env-EJU-0InB.js";
6
+ import { t as NEON_DEV_FUNCTION_PORTS } from "./env-BKdhhNv2.js";
7
7
  import { branchIdResolve } from "../utils/enrichers.js";
8
8
  import { bundleEntry } from "../utils/esbuild.js";
9
- import { a as resolveDevEnv } from "./env-BWvi2_2f.js";
10
- import { f as envFlag } from "./config-BgVJkRBC.js";
9
+ import { a as resolveDevEnv } from "./env-BGu2tBb6.js";
10
+ import { f as envFlag } from "./config-mxicyjDQ.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";
@@ -2,11 +2,11 @@ import { log } from "../log.js";
2
2
  import { getCliName } from "../utils/cli_name.js";
3
3
  import { declaredNeonServices } from "../config_services.js";
4
4
  import { loadProjectConfig } from "../project.js";
5
- import { a as credentialName, d as policyEnvKeys, f as resolveBranchPolicy, i as credentialEnvKeys, l as fetchEnvKeysState, n as NEON_ENV_VAR_KEYS, o as defaultAiGatewayCredential, p as toEntries, r as createApiFromOptions, s as defaultStorageCredential, u as isLiveCredential } from "./env-EJU-0InB.js";
5
+ import { a as credentialName, d as policyEnvKeys, f as resolveBranchPolicy, i as credentialEnvKeys, l as fetchEnvKeysState, n as NEON_ENV_VAR_KEYS, o as defaultAiGatewayCredential, p as toEntries, r as createApiFromOptions, s as defaultStorageCredential, u as isLiveCredential } from "./env-BKdhhNv2.js";
6
6
  import { ENV_PULL_SERVICES, envKeysForSelection, serviceForEnvKey, servicesForEnvKeys } from "../env_services.js";
7
7
  import { formatInstallCommand, resolvePackageManager } from "../utils/package_manager.js";
8
8
  import { StagingOnlyError } from "../utils/staging.js";
9
- import { ErrorCode, PlatformError, createNeonApiFromOptions, isPlatformError } from "@neon/config";
9
+ import { ErrorCode, PlatformError, authoredBuckets, createNeonApiFromOptions, isPlatformError } from "@neon/config";
10
10
  import { credentialScopesSatisfied } from "@neon/config/v1";
11
11
  import { plan, pullConfig } from "@neon/config-runtime";
12
12
  // ../../internals/env-core/dist/reuse-secrets.js
@@ -374,9 +374,10 @@ const resolveClaimableNeonEnvVars = async (ctx) => {
374
374
  * 1. a `neon.ts` policy is found -> the policy is the source of truth. We first
375
375
  * check it against the branch's live state (`plan`); if it declares a resource
376
376
  * the branch is missing, we stop with a {@link DevEnvMismatchError} pointing at
377
- * `neonctl deploy`. Function declarations are excluded from that check: local env
378
- * does not depend on whether a function is deployed. Otherwise `fetchEnv` evaluates
379
- * the policy.
377
+ * `neonctl deploy`, or with {@link DevEnvContext.skipUndeployed} resolve the rest.
378
+ * Function and trigger declarations are excluded from that check: local env does
379
+ * not depend on whether either is deployed. Otherwise `fetchEnv` evaluates the
380
+ * policy.
380
381
  * 2. no `neon.ts`, but a project + branch are known -> `pullConfig` reads the
381
382
  * branch's live state (Auth / Data API / Realtime enablement plus any object-storage
382
383
  * buckets) into a config, then `fetchEnv` resolves what is actually enabled —
@@ -400,8 +401,17 @@ const resolveNeonEnvVars = async (ctx) => {
400
401
  const config = await loadNeonConfig(ctx);
401
402
  if (config) {
402
403
  if (!ctx.projectId || !ctx.branchId) throw new MissingBranchContextError(`Found a neon.ts but could not resolve the project/branch. Run \`${getCliName()} link\` and \`${getCliName()} checkout <branch>\`, or pass --project-id / --branch.`);
403
- await assertPolicyMatchesBranch(withoutDeclaredFunctions(config), ctx);
404
- return await fetchAndProject(config, ctx);
404
+ const undeployed = await undeployedResources(withoutFunctionsAndTriggers(config), ctx);
405
+ if (undeployed.length === 0) return await fetchAndProject(config, ctx);
406
+ if (!ctx.skipUndeployed) throwPolicyMissingOnBranch(undeployed.join(", "), ctx.branchId);
407
+ return {
408
+ ...await resolveSelectedServices(ctx, [
409
+ "postgres",
410
+ "functions",
411
+ ...deployedDeclaredServices(config, undeployed)
412
+ ], []),
413
+ undeployed
414
+ };
405
415
  }
406
416
  if (ctx.projectId && ctx.branchId) {
407
417
  const pulled = await pullConfig({
@@ -681,10 +691,14 @@ const resolveDevEnv = async (ctx) => {
681
691
  };
682
692
  }
683
693
  };
684
- /** Functions are omitted because `plan` treats undeployed functions as resources to create. */
685
- const withoutDeclaredFunctions = (config) => {
694
+ /**
695
+ * Functions and triggers are omitted because `plan` treats undeployed ones as resources to
696
+ * create, and local env does not depend on whether either is deployed.
697
+ */
698
+ const withoutFunctionsAndTriggers = (config) => {
686
699
  const next = { ...config };
687
700
  if (next.functions !== void 0) delete next.functions;
701
+ if (next.triggers !== void 0) delete next.triggers;
688
702
  if (next.preview?.functions) {
689
703
  const previewWithoutFunctions = { ...next.preview };
690
704
  delete previewWithoutFunctions.functions;
@@ -693,25 +707,42 @@ const withoutDeclaredFunctions = (config) => {
693
707
  return next;
694
708
  };
695
709
  /**
696
- * Tier-1 guard. Dry-run the policy against the branch's live state and stop if
697
- * it declares a branch-level resource the branch is missing. Built on `plan` so
698
- * it covers every present and future provisionable resource for free: any
699
- * `create` action is a resource `neonctl deploy` would provision.
710
+ * Tier-1 guard. Dry-run the policy against the branch's live state and return
711
+ * the plan identifiers of the branch-level resources it declares that the branch
712
+ * is missing. Built on `plan` so it covers every present and future provisionable
713
+ * resource for free: any `create` action is a resource `neonctl deploy` would
714
+ * provision.
700
715
  */
701
- const assertPolicyMatchesBranch = async (config, ctx) => {
702
- const missing = (await plan(config, {
716
+ const undeployedResources = async (config, ctx) => {
717
+ return (await plan(config, {
703
718
  projectId: ctx.projectId,
704
719
  branchId: ctx.branchId,
705
720
  ...apiOptions(ctx)
706
- })).applied.filter(isMissingResource);
707
- if (missing.length === 0) return;
708
- throwPolicyMissingOnBranch(missing.map((change) => change.identifier).join(", "), ctx.branchId);
721
+ })).applied.filter(isMissingResource).map((change) => change.identifier);
722
+ };
723
+ /**
724
+ * The services neon.ts declares minus those {@link undeployedResources} reported. Object
725
+ * storage stays while any declared bucket exists, because the branch's storage credential
726
+ * works for every bucket on it.
727
+ */
728
+ const deployedDeclaredServices = (config, undeployed) => {
729
+ const declaredBuckets = Object.keys(authoredBuckets(config) ?? {});
730
+ const undeployedBuckets = undeployed.filter((id) => id.startsWith("bucket:"));
731
+ return declaredNeonServices(config).filter((service) => {
732
+ switch (service) {
733
+ case "auth": return !undeployed.includes("auth");
734
+ case "data-api": return !undeployed.includes("dataApi");
735
+ case "realtime": return !undeployed.includes("realtime");
736
+ case "object-storage": return undeployedBuckets.length < declaredBuckets.length;
737
+ default: return true;
738
+ }
739
+ });
709
740
  };
710
741
  /**
711
742
  * A planned change that provisions a branch-level resource the branch lacks: a
712
- * `create` on a service (Neon Auth, Data API, a bucket, the AI Gateway). Branch
713
- * setting drift (`update`) and `noop`s are ignored — they don't block local dev
714
- * — and functions are excluded (see {@link assertPolicyMatchesBranch}).
743
+ * `create` on a service (Neon Auth, Data API, Realtime, a bucket). Branch setting
744
+ * drift (`update`) and `noop`s are ignored — they don't block local dev — and
745
+ * functions are excluded (see {@link withoutFunctionsAndTriggers}).
715
746
  */
716
747
  const isMissingResource = (change) => change.kind === "service" && change.action === "create" && !change.identifier.startsWith("function:");
717
748
  const fetchAndProject = async (config, ctx, opts = {}) => {
@@ -720,6 +751,7 @@ const fetchAndProject = async (config, ctx, opts = {}) => {
720
751
  branch: ctx.branchId,
721
752
  ...apiOptions(ctx),
722
753
  ...ctx.env ? { env: ctx.env } : {},
754
+ ...ctx.roleName ? { roleName: ctx.roleName } : {},
723
755
  ...opts.keys ? { keys: opts.keys } : {},
724
756
  ...opts.revokeSuperseded === false ? { revokeSuperseded: false } : {},
725
757
  ...opts.resolvedBranch ? { resolvedBranch: opts.resolvedBranch } : {},
@@ -532,7 +532,7 @@ function pickRoleName(roles, branch, requested) {
532
532
  if (roles.length === 0) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: branch ${branch.name} (${branch.id}) has no roles.`, "Create one via the Neon console or pass `roleName` explicitly."].join(" "), { details: { branchId: branch.id } });
533
533
  const picked = defaultConnectionRole(roles.map((r) => r.name));
534
534
  if (picked) return picked;
535
- throw new PlatformError(ErrorCode.AmbiguousBranchAuth, [`fetchEnv: branch ${branch.name} (${branch.id}) has ${roles.length} roles and none is "${NEON_DEFAULT_OWNER_ROLE}"; cannot auto-pick.`, `Pass \`roleName\` explicitly. Available: ${roles.map((r) => r.name).join(", ")}.`].join(" "), { details: {
535
+ throw new PlatformError(ErrorCode.AmbiguousBranchAuth, [`fetchEnv: branch ${branch.name} (${branch.id}) has ${roles.length} roles and none is "${NEON_DEFAULT_OWNER_ROLE}"; cannot auto-pick.`, `Pass \`roleName\` to fetchEnv, or \`--role-name\` to the Neon CLI's \`neon env pull\`. Available: ${roles.map((r) => r.name).join(", ")}.`].join(" "), { details: {
536
536
  branchId: branch.id,
537
537
  availableRoles: roles.map((r) => r.name)
538
538
  } });
@@ -5,10 +5,10 @@ import { getCliName } from "../utils/cli_name.js";
5
5
  import { isClaimableEnvTarget } from "../claimable/state.js";
6
6
  import { deprecatedServiceMessage, parseServices, servicesFlagValue, servicesOption } from "../neon_services.js";
7
7
  import { mergeEnvFile, readEnvFile, resolveEnvFilePath } from "../env_file.js";
8
- import { n as NEON_ENV_VAR_KEYS } from "./env-EJU-0InB.js";
8
+ import { n as NEON_ENV_VAR_KEYS } from "./env-BKdhhNv2.js";
9
9
  import { ENV_PULL_KEY_HELP, ENV_PULL_SERVICES, envKeysForSelection, envPullFlagValue, isLegacyFunctionBaseUrlKey, ownedEnvServiceKeys, parseEnvPullKeys } from "../env_services.js";
10
10
  import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
11
- import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-BWvi2_2f.js";
11
+ import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-BGu2tBb6.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";
@@ -60,6 +60,11 @@ const builder = (argv) => argv.usage("$0 env <sub-command> [options]").options({
60
60
  config: {
61
61
  describe: "Path to a neon.ts policy (defaults to the neon.ts next to .neon, or in cwd without one)",
62
62
  type: "string"
63
+ },
64
+ "role-name": {
65
+ describe: "Role for DATABASE_URL and DATABASE_URL_UNPOOLED. Defaults to the only role, else neondb_owner, else the only role besides the Data API and Neon Auth roles",
66
+ type: "string",
67
+ requiresArg: true
63
68
  }
64
69
  }).epilogue([
65
70
  "",
@@ -78,11 +83,15 @@ const builder = (argv) => argv.usage("$0 env <sub-command> [options]").options({
78
83
  "API. Naming unsupported services with --service / --env warns",
79
84
  "and writes nothing for them.",
80
85
  "",
86
+ "When neon.ts declares a service the branch does not have yet, the",
87
+ "pull writes the rest and names what `deploy` still has to provision.",
88
+ "",
81
89
  "The pull bundled into link / checkout / config apply follows 2 and 3,",
82
90
  "with the AI Gateway only when the file already has its variables. It",
83
91
  "leaves Object Storage out when the file holds AWS_* keys that are not",
84
92
  "Neon's, so it never overwrites them."
85
- ].join("\n")).example("$0 env pull", "Write the linked branch's Neon vars into .env.local (or .env if present)").example("$0 env pull --branch preview --file .env.preview", "Pull a specific branch into a specific file").example("$0 env pull -s ai-gateway -s postgres", "Pull only the AI Gateway and Postgres variables").example("$0 env pull -e DATABASE_URL", "Pull only the pooled Postgres connection string").example("$0 env pull -s auth -e DATABASE_URL", "Pull all Auth variables plus DATABASE_URL").example("$0 env pull -s functions", "Pull NEON_BRANCH_ID and NEON_FUNCTION_HOST_SUFFIX, which functionBaseUrl(\"<slug>\") from @neon/env reads").strict(), async (args) => {
93
+ ].join("\n")).example("$0 env pull", "Write the linked branch's Neon vars into .env.local (or .env if present)").example("$0 env pull --branch preview --file .env.preview", "Pull a specific branch into a specific file").example("$0 env pull -s ai-gateway -s postgres", "Pull only the AI Gateway and Postgres variables").example("$0 env pull -e DATABASE_URL", "Pull only the pooled Postgres connection string").example("$0 env pull -s auth -e DATABASE_URL", "Pull all Auth variables plus DATABASE_URL").example("$0 env pull -s functions", "Pull NEON_BRANCH_ID and NEON_FUNCTION_HOST_SUFFIX, which functionBaseUrl(\"<slug>\") from @neon/env reads").example("$0 env pull --role-name app_owner", "Connect DATABASE_URL as app_owner on a branch with several roles").strict(), async (args) => {
94
+ if (args.roleName === "") throw new Error("--role-name cannot be empty. Omit the flag to auto-pick the role.");
86
95
  const rawServices = servicesFlagValue(args.service);
87
96
  const rawEnvKeys = envPullFlagValue(args.env);
88
97
  const services = rawServices ? parseServices(rawServices, {
@@ -146,7 +155,7 @@ const pull = async (props, opts = {}) => {
146
155
  const targetPath = resolveEnvFilePath(location, props.file);
147
156
  const fileExisted = existsSync(targetPath);
148
157
  const existingEnv = fileExisted ? readEnvFile(targetPath) : {};
149
- const { vars, credential, skipped, withheld } = await resolveNeonEnvVars({
158
+ const { vars, credential, skipped, withheld, undeployed } = await resolveNeonEnvVars({
150
159
  ...location,
151
160
  projectId: props.projectId,
152
161
  branchId,
@@ -159,9 +168,11 @@ const pull = async (props, opts = {}) => {
159
168
  ...opts.bundled ? { secretServices: bundledSecretServices(existingEnv) } : {},
160
169
  ...props.envKeys !== void 0 ? { envKeys: props.envKeys } : {},
161
170
  ...opts.implyAiGateway ? { implyAiGateway: true } : {},
171
+ skipUndeployed: true,
162
172
  omitUnsetFunctionEnv: true,
163
173
  ...claimable ? { claimable: true } : {},
164
174
  ...props.config ? { config: props.config } : {},
175
+ ...props.roleName ? { roleName: props.roleName } : {},
165
176
  ...props.apiKey ? { apiKey: props.apiKey } : {},
166
177
  ...props.apiHost ? { apiHost: props.apiHost } : {},
167
178
  ...props.runtimeApi ? { api: props.runtimeApi } : {}
@@ -172,14 +183,20 @@ const pull = async (props, opts = {}) => {
172
183
  return { status: "empty" };
173
184
  }
174
185
  const { written, removed } = mergeEnvFile(targetPath, neonVars, { managedKeys: managedKeysFor(selectedKeys, unreachedButCurrent(skipped, existingEnv, branchId), existingEnv, props.services !== void 0 ? selectionServices : void 0) });
175
- process.stderr.write(formatPulledEnv({
186
+ const storageKeys = NEON_ENV_VAR_KEYS.storage;
187
+ const staleStorage = (undeployed ?? []).some((id) => id.startsWith("bucket:")) && neonVars[storageKeys.accessKeyId] === void 0 && isNeonStorageEndpoint(existingEnv[storageKeys.endpoint] ?? "");
188
+ const outcome = {
176
189
  status: "written",
177
190
  written,
178
191
  removed,
179
192
  file: targetPath,
180
193
  ...credential && credential.keys.length > 0 ? { credential } : {},
181
- ...withheld && withheld.length > 0 ? { withheld } : {}
182
- }, cwd, namedBranch));
194
+ ...skipped && skipped.length > 0 ? { skipped } : {},
195
+ ...withheld && withheld.length > 0 ? { withheld } : {},
196
+ ...undeployed && undeployed.length > 0 ? { undeployed } : {},
197
+ ...staleStorage ? { staleStorage } : {}
198
+ };
199
+ process.stderr.write(formatPulledEnv(outcome, cwd, namedBranch));
183
200
  if (!fileExisted) ensureGitignored(targetPath);
184
201
  const gatewayBaseUrl = neonVars.NEON_AI_GATEWAY_BASE_URL;
185
202
  const gatewayToken = neonVars.NEON_AI_GATEWAY_TOKEN;
@@ -191,15 +208,7 @@ const pull = async (props, opts = {}) => {
191
208
  token: gatewayToken
192
209
  }
193
210
  });
194
- return {
195
- status: "written",
196
- written,
197
- removed,
198
- file: targetPath,
199
- ...credential && credential.keys.length > 0 ? { credential } : {},
200
- ...skipped && skipped.length > 0 ? { skipped } : {},
201
- ...withheld && withheld.length > 0 ? { withheld } : {}
202
- };
211
+ return outcome;
203
212
  };
204
213
  /**
205
214
  * The credential-backed services a bundled pull may resolve for this file. Object storage
@@ -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-CYAw3z0c.js";
9
- import { o as handler$1 } from "./checkout-Dc70dN1v.js";
8
+ import { o as quoteFlagValue } from "./link-w2sFyjre.js";
9
+ import { o as handler$1 } from "./checkout-BTx-7Ugs.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-BgVJkRBC.js";
16
+ import { n as autoPullEnvAfterPin } from "./env-BioHtKQ6.js";
17
+ import { h as initCmd } from "./config-mxicyjDQ.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";
@@ -28,6 +28,14 @@ const LOG_SOURCES = Object.keys({
28
28
  pg_endpoint: true,
29
29
  neon_auth: true
30
30
  });
31
+ const LOG_SOURCE_ALIASES = { functions: "function" };
32
+ const LOG_SOURCE_CHOICES = [...LOG_SOURCES, ...Object.keys(LOG_SOURCE_ALIASES)];
33
+ const parseLogSource = (raw) => {
34
+ const value = single("source")(raw);
35
+ if (value === void 0) return void 0;
36
+ if (Object.prototype.hasOwnProperty.call(LOG_SOURCE_ALIASES, value)) return LOG_SOURCE_ALIASES[value];
37
+ return value;
38
+ };
31
39
  const LOG_SORT_ORDERS = ["asc", "desc"];
32
40
  const LOG_SEVERITIES = [
33
41
  "trace",
@@ -118,8 +126,8 @@ const builder = (argv) => argv.usage("$0 logs <sub-command> [options]").options(
118
126
  source: {
119
127
  describe: "Only records emitted by this service",
120
128
  type: "string",
121
- choices: LOG_SOURCES,
122
- coerce: single("source")
129
+ choices: LOG_SOURCE_CHOICES,
130
+ coerce: parseLogSource
123
131
  },
124
132
  "service-name": {
125
133
  describe: "Match the OpenTelemetry service.name resource attribute exactly",
@@ -145,6 +153,7 @@ const builder = (argv) => argv.usage("$0 logs <sub-command> [options]").options(
145
153
  "body-contains": {
146
154
  describe: "Match the case-sensitive rendered message. Structured bodies are rendered as compact JSON.",
147
155
  type: "string",
156
+ alias: "search",
148
157
  coerce: single("body-contains")
149
158
  },
150
159
  "trace-id": {
@@ -170,8 +179,8 @@ const builder = (argv) => argv.usage("$0 logs <sub-command> [options]").options(
170
179
  source: {
171
180
  describe: "Only consider records emitted by this service",
172
181
  type: "string",
173
- choices: LOG_SOURCES,
174
- coerce: single("source")
182
+ choices: LOG_SOURCE_CHOICES,
183
+ coerce: parseLogSource
175
184
  },
176
185
  limit: {
177
186
  describe: "Maximum number of distinct values to return (1-1000)",
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-BJohB4LM.js";
2
2
  import { log } from "../log.js";
3
- import { codeFromBody, isNeonApiError, retryOnLock } from "../api.js";
3
+ import { codeFromBody, isNeonApiError, messageFromBody, retryOnLock } from "../api.js";
4
4
  import { REDACTED_INVALID_VALUE, didYouMean } from "../errors.js";
5
5
  import { stripAnsi } from "../human_table.js";
6
6
  import { writer } from "../writer.js";
@@ -59,6 +59,10 @@ const OAUTH_PROVIDER_FIELDS = [
59
59
  "apple_key_id"
60
60
  ];
61
61
  const ALLOW_LOCALHOST_FIELDS = ["allow_localhost"];
62
+ const LOGS_EXPORT_FIELDS = ["enabled"];
63
+ const LOGS_EXPORT_UNAVAILABLE = "Neon Auth logs export isn't available for this project. During the beta it requires Managed Better Auth in a supported region.";
64
+ const LOGS_EXPORT_NOT_BETTER_AUTH = "Logs export is only available for Managed Better Auth branches.";
65
+ const LOGS_EXPORT_QUERY_HINT = "Read the exported events with neon logs query --source neon_auth. A query covers at most the last 7 days.";
62
66
  const SUPPORTED_OAUTH_PROVIDERS = [
63
67
  NeonAuthOauthProviderId.Google,
64
68
  NeonAuthOauthProviderId.Github,
@@ -506,7 +510,13 @@ const builder = (argv) => {
506
510
  }), async (args) => {
507
511
  await webhookUpdate(args);
508
512
  });
509
- });
513
+ }).command("logs-export", "Manage export of Neon Auth events to Neon logs (beta)", (yargs) => yargs.usage("$0 neon-auth config logs-export <sub-command> [options]").command("get", "Get the logs export setting", (yargs) => yargs.epilogue(LOGS_EXPORT_QUERY_HINT), async (args) => {
514
+ await logsExportGet(args);
515
+ }).command("enable", "Export Neon Auth events to Neon logs", (yargs) => yargs.epilogue(LOGS_EXPORT_QUERY_HINT), async (args) => {
516
+ await logsExportEnable(args);
517
+ }).command("disable", "Stop exporting Neon Auth events to Neon logs", (yargs) => yargs, async (args) => {
518
+ await logsExportDisable(args);
519
+ }).epilogue(LOGS_EXPORT_QUERY_HINT));
510
520
  }).command("plugins", "View Neon Auth plugin configurations", (yargs) => {
511
521
  return yargs.usage("$0 neon-auth plugins <sub-command> [options]").command("list", "List all plugin configurations", (yargs) => yargs, async (args) => {
512
522
  await pluginsList(args);
@@ -851,6 +861,53 @@ const allowLocalhostDisable = async (props) => {
851
861
  }));
852
862
  printMessage("Localhost connections restricted");
853
863
  };
864
+ const logsExportGet = async (props) => {
865
+ const branchId = await resolveBranch(props);
866
+ const data = await authSdk(props, (auth) => auth.plugins.get({
867
+ projectId: props.projectId,
868
+ branchId
869
+ }));
870
+ if (!data.logs_export) {
871
+ if (props.output === "json" || props.output === "yaml") {
872
+ writer(props).end({ available: false }, { fields: ["available"] });
873
+ return;
874
+ }
875
+ printMessage(LOGS_EXPORT_UNAVAILABLE);
876
+ return;
877
+ }
878
+ if (props.output === "json" || props.output === "yaml") {
879
+ writer(props).end(data.logs_export, { fields: LOGS_EXPORT_FIELDS });
880
+ return;
881
+ }
882
+ printKvBlock("Neon Auth logs export", [["Enabled:", String(data.logs_export.enabled)]]);
883
+ };
884
+ const isNotBetterAuthError = (err) => isNeonApiError(err) && err.status === 400 && /logs export is only supported for Neon Auth \(better_auth\)/i.test(messageFromBody(err.data) ?? "");
885
+ const updateLogsExport = async (props, enabled) => {
886
+ const branchId = await resolveBranch(props);
887
+ try {
888
+ await authSdk(props, (auth) => auth.logsExport.update({
889
+ projectId: props.projectId,
890
+ branchId,
891
+ enabled
892
+ }));
893
+ } catch (err) {
894
+ if (isNotBetterAuthError(err)) throw new Error(LOGS_EXPORT_NOT_BETTER_AUTH);
895
+ if (!enabled || !isNeonApiError(err)) throw err;
896
+ if (err.status === 404) throw new Error(LOGS_EXPORT_UNAVAILABLE);
897
+ if (err.status === 409) throw new Error("Neon Auth is busy with another change on this branch. Try again in a moment.");
898
+ if (err.status === 423) throw new Error("Neon Auth is still busy with another change on this branch after retrying. Try again later.");
899
+ if (err.status === 429 || err.status === 503) throw new Error("Neon Auth logs export is still unavailable after retrying. Try again later.");
900
+ throw err;
901
+ }
902
+ };
903
+ const logsExportEnable = async (props) => {
904
+ await updateLogsExport(props, true);
905
+ printMessage(`Neon Auth logs export enabled. ${LOGS_EXPORT_QUERY_HINT}`);
906
+ };
907
+ const logsExportDisable = async (props) => {
908
+ await updateLogsExport(props, false);
909
+ printMessage("Neon Auth logs export disabled");
910
+ };
854
911
  const printEmailPasswordEntries = (data) => [
855
912
  ["Enabled:", String(data.enabled)],
856
913
  ["Verification Method:", data.email_verification_method],
@@ -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-BgVJkRBC.js";
3
+ import { y as status } from "./config-mxicyjDQ.js";
4
4
  // src/commands/status.ts
5
5
  var status_exports = /* @__PURE__ */ __exportAll({
6
6
  builder: () => builder,
@@ -1 +1 @@
1
- export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-Dc70dN1v.js";
1
+ export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-BTx-7Ugs.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-DHVe8ka_.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-BgVJkRBC.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-mxicyjDQ.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-B7MgbDYh.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-CuJqMaAd.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-Hq6nGUAM.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-mf3JrprU.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-BioHtKQ6.js";
@@ -45,6 +45,18 @@ const groupKeys = (keys) => {
45
45
  return groups;
46
46
  };
47
47
  const pulledBranch = (branch) => `branch ${chalk.cyan.bold(branch.branchName)} ${chalk.dim(`(${branch.branchId}${branch.usedDefault ? ", project default" : ""})`)}`;
48
+ const PLAN_SERVICES = {
49
+ auth: "auth",
50
+ dataApi: "data-api",
51
+ realtime: "realtime"
52
+ };
53
+ /** `bucket:uploads` reads as "bucket uploads"; a service identifier as its label. */
54
+ const undeployedLabel = (identifier) => {
55
+ const service = PLAN_SERVICES[identifier];
56
+ if (service) return NEON_SERVICE_LABELS[service];
57
+ const separator = identifier.indexOf(":");
58
+ return separator === -1 ? identifier : `${identifier.slice(0, separator)} ${identifier.slice(separator + 1)}`;
59
+ };
48
60
  const formatPulledEnv = (outcome, cwd, branch) => {
49
61
  const fresh = new Set(outcome.credential?.fresh ?? []);
50
62
  const count = outcome.written.length;
@@ -59,6 +71,11 @@ const formatPulledEnv = (outcome, cwd, branch) => {
59
71
  if (outcome.removed.length > 0) lines.push(row("Removed", `${outcome.removed.join(", ")} (not produced by this pull)`));
60
72
  if (outcome.removed.some(isLegacyFunctionBaseUrlKey)) lines.push(row("", "Use functionBaseUrl(\"<slug>\") from @neon/env instead."));
61
73
  if (outcome.withheld?.includes("object-storage")) lines.push(row("Not pulled", `Object Storage, to keep the AWS_* keys already in ${displayPath(outcome.file, cwd)}. Use \`${getCliName()} env pull -s object-storage\` to replace them.`));
74
+ if (outcome.undeployed) {
75
+ const one = outcome.undeployed.length === 1;
76
+ lines.push(row("Not deployed", `${outcome.undeployed.map(undeployedLabel).join(", ")}, declared in neon.ts. Run \`${getCliName()} deploy\` to provision ${one ? "it" : "them"} and pull ${one ? "its" : "their"} variables.`));
77
+ }
78
+ if (outcome.staleStorage) lines.push(row("", `The AWS_* values already in ${displayPath(outcome.file, cwd)} were not updated and may belong to another branch.`));
62
79
  if (fresh.size > 0) lines.push(" * new credential value");
63
80
  const credential = outcome.credential;
64
81
  if (credential?.issued && credential.revoked.length > 0) lines.push(`Revoked the credential it replaced (${credential.revoked.join(", ")}).`);
@@ -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-BgVJkRBC.js";
13
+ import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-mxicyjDQ.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-DT3nMyGz.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-BOYyFLoz.js";
@@ -2,35 +2,35 @@ import { r as auth_exports } from "../_chunks/auth-CFa969Ck.js";
2
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-BgVJkRBC.js";
5
+ import { o as env_exports } from "../_chunks/env-BioHtKQ6.js";
6
+ import { c as config_exports } from "../_chunks/config-mxicyjDQ.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-CYAw3z0c.js";
8
+ import { a as link_exports } from "../_chunks/link-w2sFyjre.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-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-Dc70dN1v.js";
16
- import { o as claim_exports } from "../_chunks/claim-BoN9NPTy.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-BTx-7Ugs.js";
16
+ import { o as claim_exports } from "../_chunks/claim-DHVe8ka_.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-B7MgbDYh.js";
22
- import { s as dev_exports } from "../_chunks/dev-Hq6nGUAM.js";
21
+ import { r as deploy_exports } from "../_chunks/deploy-CuJqMaAd.js";
22
+ import { s as dev_exports } from "../_chunks/dev-mf3JrprU.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-DT3nMyGz.js";
27
+ import { o as git_exports } from "../_chunks/git-BOYyFLoz.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";
31
31
  import { a as ip_allow_exports } from "../_chunks/ip_allow-DBdxNEUa.js";
32
- import { l as logs_exports } from "../_chunks/logs-CcVpwdDs.js";
33
- import { a as neon_auth_exports } from "../_chunks/neon_auth-DE6X6FFV.js";
32
+ import { l as logs_exports } from "../_chunks/logs-CnfCN0pv.js";
33
+ import { a as neon_auth_exports } from "../_chunks/neon_auth-CJvoSrXr.js";
34
34
  import { a as open_exports } from "../_chunks/open-T2nI89Oh.js";
35
35
  import { c as operations_exports } from "../_chunks/operations-D7qGkKo3.js";
36
36
  import { o as orgs_exports } from "../_chunks/orgs-BrvAWM8Z.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-Bop_r6Va.js";
44
+ import { a as status_exports } from "../_chunks/status-dPnz6_k3.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-CYAw3z0c.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-w2sFyjre.js";
@@ -1 +1 @@
1
- export { t as assertReachableLogsPage, n as buildLogsQueryBody, r as builder, i as command, a as describe, o as escapeLogSingleLine, s as escapeLogTableCell, c as handler } from "../_chunks/logs-CcVpwdDs.js";
1
+ export { t as assertReachableLogsPage, n as buildLogsQueryBody, r as builder, i as command, a as describe, o as escapeLogSingleLine, s as escapeLogTableCell, c as handler } from "../_chunks/logs-CnfCN0pv.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/neon_auth-DE6X6FFV.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/neon_auth-CJvoSrXr.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-Bop_r6Va.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-dPnz6_k3.js";
@@ -1,6 +1,6 @@
1
1
  import { writer } from "../writer.js";
2
2
  import { branchIdFromProps } from "../utils/enrichers.js";
3
- import { o as resolveNeonEnvVars } from "../_chunks/env-BWvi2_2f.js";
3
+ import { o as resolveNeonEnvVars } from "../_chunks/env-BGu2tBb6.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/dev/env.js CHANGED
@@ -1 +1 @@
1
- export { t as DevEnvMismatchError, n as MissingBranchContextError, r as ServiceNotOnBranchError, i as dropClaimableUnsupported, a as resolveDevEnv, o as resolveNeonEnvVars } from "../_chunks/env-BWvi2_2f.js";
1
+ export { t as DevEnvMismatchError, n as MissingBranchContextError, r as ServiceNotOnBranchError, i as dropClaimableUnsupported, a as resolveDevEnv, o as resolveNeonEnvVars } from "../_chunks/env-BGu2tBb6.js";
@@ -1,6 +1,6 @@
1
1
  import { REDACTED_INVALID_VALUE, didYouMean } from "./errors.js";
2
2
  import { NEON_SERVICES } from "./neon_services.js";
3
- import { n as NEON_ENV_VAR_KEYS } from "./_chunks/env-EJU-0InB.js";
3
+ import { n as NEON_ENV_VAR_KEYS } from "./_chunks/env-BKdhhNv2.js";
4
4
  // src/env_services.ts
5
5
  const ENV_PULL_SERVICES = NEON_SERVICES;
6
6
  const ENV_PULL_KEYS = [
package/dist/errors.js CHANGED
@@ -27,7 +27,9 @@ const ERROR_MATCHERS = [
27
27
  [/^Could not reach neonstatus\.com /, "NETWORK_ERROR"],
28
28
  [/^Timed out waiting for neonstatus\.com /, "REQUEST_TIMEOUT"],
29
29
  [/ (is|are) no longer pulled\. Pull NEON_BRANCH_ID /, "LEGACY_FUNCTION_ENV_KEY"],
30
- [/^No Neon project is linked here/, "PROJECT_NOT_LINKED"]
30
+ [/^No Neon project is linked here/, "PROJECT_NOT_LINKED"],
31
+ [/ roles and none is "neondb_owner"; cannot auto-pick\./, "AMBIGUOUS_BRANCH_ROLE"],
32
+ [/function deployments were not confirmed complete/, "FUNCTION_BUILD_UNFINISHED"]
31
33
  ];
32
34
  const matchErrorCode = (message) => {
33
35
  if (!message) return "UNKNOWN_ERROR";
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-BioHtKQ6.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-BgVJkRBC.js";
7
+ import { r as applyCmd } from "../_chunks/config-mxicyjDQ.js";
8
8
  import { authContext } from "./auth.js";
9
9
  import { existsSync } from "node:fs";
10
10
  import { missingFunctionEnv } from "@neon/config";
@@ -103,6 +103,7 @@ const initEndProperties = (input) => {
103
103
  mode: input.mode,
104
104
  agent_setup: input.agentSetup,
105
105
  agents_installed: input.agentsInstalled,
106
+ tooling_installed: input.toolingInstalled,
106
107
  link: input.link,
107
108
  config: input.config,
108
109
  services: input.services,
@@ -125,6 +126,7 @@ const createInitFunnel = (initRunId = createInitRunId()) => ({
125
126
  mode: null,
126
127
  agentSetup: null,
127
128
  agentsInstalled: [],
129
+ toolingInstalled: [],
128
130
  link: null,
129
131
  config: null,
130
132
  services: null,
@@ -152,6 +154,7 @@ const finishInitFunnel = (state, outcome, analytics) => {
152
154
  mode: state.mode,
153
155
  agentSetup: state.agentSetup,
154
156
  agentsInstalled: state.agentsInstalled,
157
+ toolingInstalled: state.toolingInstalled,
155
158
  link: state.link,
156
159
  config: state.config,
157
160
  services: state.services,
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-CYAw3z0c.js";
7
+ import { s as runLink } from "../_chunks/link-w2sFyjre.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-BgVJkRBC.js";
19
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-CYAw3z0c.js";
18
+ import { h as initCmd, t as ConfigInstallFailed } from "../_chunks/config-mxicyjDQ.js";
19
+ import { o as quoteFlagValue, s as runLink } from "../_chunks/link-w2sFyjre.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-DHVe8ka_.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";
@@ -404,7 +404,10 @@ const runInit = async (props) => {
404
404
  recordInitError(funnel, toolingStep.kind, error);
405
405
  continue;
406
406
  }
407
- if (completed.includes(toolingStep.kind)) funnel.agentsInstalled = uniqueAgents([...funnel.agentsInstalled, ...agentsForStep(plan, toolingStep.kind)]);
407
+ if (completed.includes(toolingStep.kind)) {
408
+ funnel.toolingInstalled.push(toolingStep.kind);
409
+ funnel.agentsInstalled = uniqueAgents([...funnel.agentsInstalled, ...agentsForStep(plan, toolingStep.kind)]);
410
+ }
408
411
  }
409
412
  };
410
413
  const toolingSteps = planInitToolingSteps({
@@ -730,7 +733,8 @@ const runInit = async (props) => {
730
733
  takeCommandSuccessExtras();
731
734
  recordCommandSuccessExtras({
732
735
  init_kind: detection.emptyDirectory ? "empty-skip" : "existing",
733
- ...extrasSetup(funnel.agentSetup) !== void 0 ? { agent_setup: extrasSetup(funnel.agentSetup) } : {}
736
+ ...extrasSetup(funnel.agentSetup) !== void 0 ? { agent_setup: extrasSetup(funnel.agentSetup) } : {},
737
+ tooling_installed: funnel.toolingInstalled
734
738
  });
735
739
  } catch (error) {
736
740
  restoreCursor();
@@ -1,6 +1,6 @@
1
1
  import { log } from "../log.js";
2
2
  import { loadProjectConfig } from "../project.js";
3
- import { c as fetchEnvKeys } from "../_chunks/env-EJU-0InB.js";
3
+ import { c as fetchEnvKeys } from "../_chunks/env-BKdhhNv2.js";
4
4
  import { runHook } from "@neon/config-runtime";
5
5
  // src/utils/hooks.ts
6
6
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.9.9",
3
+ "version": "9.10.0",
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.7",
77
- "@neon/config-runtime": "1.12.10",
78
- "@neon/sdk": "7.16.0",
79
- "@neon/realtime": "0.2.1"
76
+ "@neon/config": "1.14.8",
77
+ "@neon/config-runtime": "1.13.0",
78
+ "@neon/realtime": "0.2.2",
79
+ "@neon/sdk": "7.16.0"
80
80
  },
81
81
  "optionalDependencies": {
82
82
  "@napi-rs/keyring": "1.3.0",
@@ -113,10 +113,10 @@
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.58",
117
- "@neon/e2e-harness": "0.0.0",
118
- "@neon/env": "2.1.10",
119
- "@neon/functions": "0.11.0"
116
+ "@neon-internals/env-core": "0.0.59",
117
+ "@neon/env": "2.1.11",
118
+ "@neon/functions": "0.11.0",
119
+ "@neon/e2e-harness": "0.0.0"
120
120
  },
121
121
  "publishConfig": {
122
122
  "access": "public",