neon 9.9.4 → 9.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -638,7 +638,14 @@ auth env vars to pull. Provision it first (`neon deploy`, `neon config apply`, o
638
638
  Console), or drop auth from --service.
639
639
  ```
640
640
 
641
- `link`, `checkout`, and `config apply` invoke `env pull` automatically (see above). Those bundled pulls follow rules 2 and 3 above **without** the implied AI Gateway: minting a credential for a service you never named isn't something a side effect of another command should do. Run `neon env pull` to get it.
641
+ `link`, `checkout`, and `config apply` invoke `env pull` automatically (see above). Those bundled pulls follow rules 2 and 3 above, with two differences:
642
+
643
+ - **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.
644
+ - **No Object Storage when the file holds a value for `AWS_ACCESS_KEY_ID` or `AWS_SECRET_ACCESS_KEY` without a Neon `AWS_ENDPOINT_URL_S3`.** Those keys are your own (AWS, R2, MinIO), and writing would overwrite them. The summary says so:
645
+
646
+ ```text
647
+ Not pulled Object Storage, to keep the AWS_* keys already in .env. Use `neon env pull -s object-storage` to replace them.
648
+ ```
642
649
 
643
650
  If you'd rather not keep env vars on disk, inject them at runtime instead with `neon-env run -- <your dev command>` (from `@neon/env`) or `neon dev`, and pass `--no-env-pull` to `link` / `checkout`.
644
651
 
@@ -925,7 +932,7 @@ Without a TTY, pass `-y` or enough flags to answer every question. `-y` alone is
925
932
 
926
933
  `--project-id`, `--org-id`, `--project-name`, `--region-id`, and `--branch` are forwarded to `link`. They select linking. A linked directory is not relinked unless you pass one of those flags.
927
934
 
928
- Init pulls the branch's env vars once, after the `neon.ts` step, so the pull includes what `neon.ts` declares. A `neon.ts` written from the branch declares only services the branch already runs, so all of them are pulled. The AI Gateway and Functions need no deploy and are pulled immediately. When `neon.ts` declares Auth, the Data API, Object Storage, or Realtime, init pulls Postgres, plus the AI Gateway and the scaffolded function's URL when declared. `neon deploy` provisions the rest and pulls their env vars. An existing `neon.ts` is pulled by `link` as usual.
935
+ Init pulls the branch's env vars once, after the `neon.ts` step, so the pull includes what `neon.ts` declares. A `neon.ts` written from the branch declares only services the branch already runs, so all of them are pulled. The AI Gateway and Functions need no deploy and are pulled immediately. Auth, the Data API, Object Storage, and Realtime need a deploy unless the branch already has them: init pulls each one the branch has and skips the others. `neon deploy` provisions the rest and pulls their env vars. An existing `neon.ts` is pulled by `link` as usual.
929
936
 
930
937
  A failed step stops the rest. `--profile` and `--config-dir` are forwarded to each child. `--output json` and `--output yaml` are refused; the commands init runs print their own output.
931
938
 
@@ -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-aWCqnWaF.js";
16
- import { a as applyPolicyOnCreate, f as envFlag, l as createBranchFromPolicyOnCheckout } from "./config-CtP-1YSw.js";
17
- import { i as handler$1 } from "./link-Caoa3_y8.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";
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-aWCqnWaF.js";
15
+ import { c as pull } from "./env-C3HQJO8Z.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-aWCqnWaF.js";
29
+ import { n as autoPullEnvAfterPin } from "./env-C3HQJO8Z.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-CtP-1YSw.js";
3
+ import { f as envFlag, i as applyFlags, p as envPullFlag, r as applyCmd } from "./config-C8BQIoM2.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({
@@ -6,8 +6,8 @@ import { defaultDevEnvFiles, readEnvFile, resolveEnvFilePath } from "../env_file
6
6
  import { t as NEON_DEV_FUNCTION_PORTS } from "./env-EJU-0InB.js";
7
7
  import { branchIdResolve } from "../utils/enrichers.js";
8
8
  import { bundleEntry } from "../utils/esbuild.js";
9
- import { a as resolveDevEnv } from "./env-CFBmcKyo.js";
10
- import { f as envFlag } from "./config-CtP-1YSw.js";
9
+ import { a as resolveDevEnv } from "./env-BWvi2_2f.js";
10
+ import { f as envFlag } from "./config-C8BQIoM2.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";
@@ -382,7 +382,8 @@ const resolveClaimableNeonEnvVars = async (ctx) => {
382
382
  * buckets) into a config, then `fetchEnv` resolves what is actually enabled —
383
383
  * so a branch with a bucket gets its `AWS_*` storage vars pulled with no policy. With
384
384
  * {@link DevEnvContext.implyAiGateway}, the AI Gateway is added on top, since
385
- * `pullConfig` cannot read it back.
385
+ * `pullConfig` cannot read it back. {@link DevEnvContext.secretServices} narrows the
386
+ * credential-backed services.
386
387
  * 3. otherwise -> throw {@link MissingBranchContextError}.
387
388
  *
388
389
  * {@link DevEnvContext.claimable} keeps the same precedence. Credentials are not
@@ -415,15 +416,35 @@ const resolveNeonEnvVars = async (ctx) => {
415
416
  protected: pulled.branch.protected,
416
417
  ...pulled.branch.expiresAt ? { expiresAt: pulled.branch.expiresAt } : {}
417
418
  };
418
- if (!ctx.implyAiGateway) return await fetchAndProject(pulled.config, ctx, { resolvedBranch });
419
- return await resolveWithImpliedGateway(pulled.config, ctx, {
419
+ const { config, withheld } = withholdSecretServices(pulled.config, ctx.secretServices);
420
+ const resolved = ctx.implyAiGateway || (ctx.secretServices?.includes("ai-gateway") ?? false) ? await resolveWithImpliedGateway(config, ctx, {
420
421
  projectId: ctx.projectId,
421
422
  branchId: ctx.branchId,
422
- resolvedBranch
423
- });
423
+ resolvedBranch,
424
+ revokeSuperseded: ctx.secretServices === void 0 || config.preview?.buckets !== void 0
425
+ }) : await fetchAndProject(config, ctx, { resolvedBranch });
426
+ return withheld.length > 0 ? {
427
+ ...resolved,
428
+ withheld
429
+ } : resolved;
424
430
  }
425
431
  throw new MissingBranchContextError(`No project/branch context found. Link a branch (\`${getCliName()} link\` / \`${getCliName()} checkout\`) or pass --project-id and --branch.`);
426
432
  };
433
+ /** Drop the read-back object storage when `keep` does not name it. */
434
+ const withholdSecretServices = (config, keep) => {
435
+ if (keep === void 0 || keep.includes("object-storage") || config.preview?.buckets === void 0) return {
436
+ config,
437
+ withheld: []
438
+ };
439
+ const { buckets: _, ...preview } = config.preview;
440
+ return {
441
+ config: {
442
+ ...config,
443
+ preview
444
+ },
445
+ withheld: ["object-storage"]
446
+ };
447
+ };
427
448
  /** The same config with the AI Gateway enabled, leaving any other `preview` entries intact. */
428
449
  const withAiGateway = (config) => ({
429
450
  ...config,
@@ -456,7 +477,10 @@ const withAiGateway = (config) => ({
456
477
  */
457
478
  const resolveWithImpliedGateway = async (config, ctx, branch) => {
458
479
  const unreachable = await credentialsUnreachable(ctx, branch);
459
- if (unreachable === null) return await fetchAndProject(withAiGateway(config), ctx, { resolvedBranch: branch.resolvedBranch });
480
+ if (unreachable === null) return await fetchAndProject(withAiGateway(config), ctx, {
481
+ resolvedBranch: branch.resolvedBranch,
482
+ ...branch.revokeSuperseded === false ? { revokeSuperseded: false } : {}
483
+ });
460
484
  log.warning(`Could not reach the AI Gateway's credentials, so %s were not resolved. Everything else was. Either this project does not have the AI Gateway, or the call failed — \`${getCliName()} env pull -s ai-gateway\` will say which.\nDetails: %s`, [NEON_ENV_VAR_KEYS.aiGateway.apiKey, NEON_ENV_VAR_KEYS.aiGateway.baseUrl].join(" and "), unreachable);
461
485
  const pulled = await fetchAndProject(config, ctx, { resolvedBranch: branch.resolvedBranch });
462
486
  return {
@@ -497,15 +521,20 @@ const resolveSelectedServices = async (ctx, directServices, envKeys) => {
497
521
  const selectedKeys = envKeysForSelection(directServices, envKeys);
498
522
  const api = apiFor(ctx);
499
523
  const has = (service) => services.includes(service);
524
+ const optional = ctx.optionalServices ?? [];
525
+ const read = (service, load, absent) => optional.includes(service) ? absentWhenUnavailable(load, absent) : load();
500
526
  const checkAiGateway = has("ai-gateway") && !selectedKeys.includes(NEON_ENV_VAR_KEYS.aiGateway.apiKey);
501
527
  const [auth, dataApiEnabled, realtime, buckets, aiGatewayAvailable] = await Promise.all([
502
- has("auth") ? api.getNeonAuth(projectId, branchId) : null,
503
- has("data-api") ? readDataApiEnabled(api, projectId, branchId) : null,
504
- has("realtime") ? readRealtime(api, projectId, branchId) : null,
505
- has("object-storage") ? api.listBranchBuckets(projectId, branchId) : null,
528
+ has("auth") ? read("auth", () => api.getNeonAuth(projectId, branchId), null) : null,
529
+ has("data-api") ? read("data-api", () => readDataApiEnabled(api, projectId, branchId), false) : null,
530
+ has("realtime") ? read("realtime", () => readRealtime(api, projectId, branchId), {
531
+ enabled: false,
532
+ pending: false
533
+ }) : null,
534
+ has("object-storage") ? read("object-storage", () => api.listBranchBuckets(projectId, branchId), []) : null,
506
535
  checkAiGateway ? readAiGatewayAvailable(api, projectId, branchId) : null
507
536
  ]);
508
- const config = configForServices(services, branchId, {
537
+ const { config, skipped } = configForServices(services, branchId, {
509
538
  authEnabled: auth !== null,
510
539
  dataApiEnabled,
511
540
  realtimeEnabled: realtime === null ? false : realtime.enabled || realtime.pending,
@@ -513,12 +542,29 @@ const resolveSelectedServices = async (ctx, directServices, envKeys) => {
513
542
  aiGatewayAvailable: aiGatewayAvailable ?? true
514
543
  }, {
515
544
  directServices,
516
- envKeys
545
+ envKeys,
546
+ optional
517
547
  });
518
- return await fetchAndProject(config, ctx, {
548
+ const resolved = await fetchAndProject(config, ctx, {
519
549
  keys: selectedKeys,
520
550
  revokeSuperseded: false
521
551
  });
552
+ return skipped.length > 0 ? {
553
+ ...resolved,
554
+ skipped
555
+ } : resolved;
556
+ };
557
+ /**
558
+ * Read an optional service's live state, treating a feature the project or region lacks
559
+ * (`FeatureUnavailable`, or a route-level 404) as absent, as `pullConfig` does.
560
+ */
561
+ const absentWhenUnavailable = async (load, absent) => {
562
+ try {
563
+ return await load();
564
+ } catch (error) {
565
+ if (isPlatformError(error) && (error.code === ErrorCode.FeatureUnavailable || error.code === ErrorCode.NotFound && error.details.status === 404)) return absent;
566
+ throw error;
567
+ }
522
568
  };
523
569
  /**
524
570
  * Whether the branch has a Data API integration — or `null` when that cannot be determined.
@@ -557,7 +603,7 @@ const NEON_DEFAULT_DATABASE = "neondb";
557
603
  * {@link ServiceNotOnBranchError} for anything the branch does not have. Naming a service
558
604
  * that isn't there has to fail rather than contribute no vars, or a scoped pull would report
559
605
  * "no Neon env variables to pull" — which reads as a statement about the branch rather than
560
- * about the selection.
606
+ * about the selection. An optional service the branch lacks is returned in `skipped` instead.
561
607
  */
562
608
  const configForServices = (services, branchId, branch, selection) => {
563
609
  const provisionWith = {
@@ -579,28 +625,26 @@ const configForServices = (services, branchId, branch, selection) => {
579
625
  const names = selection.envKeys.filter((key) => serviceForEnvKey(key) === "ai-gateway").join(", ");
580
626
  throw new ServiceNotOnBranchError(`--env ${names}: ${reason}, so ${names} cannot be pulled. Use another project, or drop ${names} from --env.`);
581
627
  };
628
+ const skipped = [];
629
+ const onBranch = (service, present, what) => {
630
+ if (present) return true;
631
+ if (!selection.optional.includes(service)) notOnBranch(service, what);
632
+ skipped.push(service);
633
+ return false;
634
+ };
582
635
  const config = {};
583
- if (services.includes("auth")) {
584
- if (!branch.authEnabled) notOnBranch("auth", "Neon Auth integration");
585
- config.auth = true;
586
- }
587
- if (services.includes("data-api")) {
588
- if (branch.dataApiEnabled === false) notOnBranch("data-api", "Data API integration");
589
- config.dataApi = true;
590
- }
591
- if (services.includes("realtime")) {
592
- if (!branch.realtimeEnabled) notOnBranch("realtime", "Realtime integration");
593
- config.preview = { realtime: true };
594
- }
595
- if (services.includes("object-storage")) {
596
- if (branch.buckets.length === 0) notOnBranch("object-storage", "object-storage buckets");
597
- config.buckets = Object.fromEntries(branch.buckets.map((bucket) => [bucket.name, { access: bucket.accessLevel }]));
598
- }
636
+ if (services.includes("auth") && onBranch("auth", branch.authEnabled, "Neon Auth integration")) config.auth = true;
637
+ if (services.includes("data-api") && onBranch("data-api", branch.dataApiEnabled !== false, "Data API integration")) config.dataApi = true;
638
+ if (services.includes("realtime") && onBranch("realtime", branch.realtimeEnabled, "Realtime integration")) config.preview = { realtime: true };
639
+ if (services.includes("object-storage") && onBranch("object-storage", branch.buckets.length > 0, "object-storage buckets")) config.buckets = Object.fromEntries(branch.buckets.map((bucket) => [bucket.name, { access: bucket.accessLevel }]));
599
640
  if (services.includes("ai-gateway")) {
600
641
  if (!branch.aiGatewayAvailable) aiGatewayUnavailable();
601
642
  config.aiGateway = true;
602
643
  }
603
- return config;
644
+ return {
645
+ config,
646
+ skipped
647
+ };
604
648
  };
605
649
  /**
606
650
  * `neon dev`'s env resolver: {@link resolveNeonEnvVars} with graceful degradation.
@@ -8,7 +8,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
10
  import { fillSingleProject, resolveBranchRef } from "../utils/enrichers.js";
11
- import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-CFBmcKyo.js";
11
+ import { i as dropClaimableUnsupported, o as resolveNeonEnvVars } from "./env-BWvi2_2f.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";
@@ -78,9 +78,10 @@ const builder = (argv) => argv.usage("$0 env <sub-command> [options]").options({
78
78
  "API. Naming unsupported services with --service / --env warns",
79
79
  "and writes nothing for them.",
80
80
  "",
81
- "The pull bundled into link / checkout / config apply follows 2 and 3",
82
- "without the AI Gateway, so it never writes a gateway token you did",
83
- "not ask for. Run `env pull` to add it."
81
+ "The pull bundled into link / checkout / config apply follows 2 and 3,",
82
+ "with the AI Gateway only when the file already has its variables. It",
83
+ "leaves Object Storage out when the file holds AWS_* keys that are not",
84
+ "Neon's, so it never overwrites them."
84
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) => {
85
86
  const rawServices = servicesFlagValue(args.service);
86
87
  const rawEnvKeys = envPullFlagValue(args.env);
@@ -145,7 +146,7 @@ const pull = async (props, opts = {}) => {
145
146
  const targetPath = resolveEnvFilePath(location, props.file);
146
147
  const fileExisted = existsSync(targetPath);
147
148
  const existingEnv = fileExisted ? readEnvFile(targetPath) : {};
148
- const { vars, credential, skipped } = await resolveNeonEnvVars({
149
+ const { vars, credential, skipped, withheld } = await resolveNeonEnvVars({
149
150
  ...location,
150
151
  projectId: props.projectId,
151
152
  branchId,
@@ -154,6 +155,8 @@ const pull = async (props, opts = {}) => {
154
155
  ...existingEnv
155
156
  },
156
157
  ...props.services !== void 0 ? { services: props.services } : {},
158
+ ...props.optionalServices !== void 0 ? { optionalServices: props.optionalServices } : {},
159
+ ...opts.bundled ? { secretServices: bundledSecretServices(existingEnv) } : {},
157
160
  ...props.envKeys !== void 0 ? { envKeys: props.envKeys } : {},
158
161
  ...opts.implyAiGateway ? { implyAiGateway: true } : {},
159
162
  omitUnsetFunctionEnv: true,
@@ -174,7 +177,8 @@ const pull = async (props, opts = {}) => {
174
177
  written,
175
178
  removed,
176
179
  file: targetPath,
177
- ...credential && credential.keys.length > 0 ? { credential } : {}
180
+ ...credential && credential.keys.length > 0 ? { credential } : {},
181
+ ...withheld && withheld.length > 0 ? { withheld } : {}
178
182
  }, cwd, namedBranch));
179
183
  if (!fileExisted) ensureGitignored(targetPath);
180
184
  const gatewayBaseUrl = neonVars.NEON_AI_GATEWAY_BASE_URL;
@@ -193,10 +197,29 @@ const pull = async (props, opts = {}) => {
193
197
  removed,
194
198
  file: targetPath,
195
199
  ...credential && credential.keys.length > 0 ? { credential } : {},
196
- ...skipped && skipped.length > 0 ? { skipped } : {}
200
+ ...skipped && skipped.length > 0 ? { skipped } : {},
201
+ ...withheld && withheld.length > 0 ? { withheld } : {}
197
202
  };
198
203
  };
199
204
  /**
205
+ * The credential-backed services a bundled pull may resolve for this file. Object storage
206
+ * is left out when the file holds `AWS_*` keys not paired with a Neon branch storage
207
+ * endpoint: those are the user's own (AWS, R2, MinIO), and `AWS_*` is never pruned, so
208
+ * writing would overwrite them. The AI Gateway is included only when the file already has
209
+ * its variables, since nobody named it.
210
+ */
211
+ const bundledSecretServices = (env) => {
212
+ const has = (key) => (env[key] ?? "") !== "";
213
+ const endpoint = env[NEON_ENV_VAR_KEYS.storage.endpoint];
214
+ return [...(has(NEON_ENV_VAR_KEYS.storage.accessKeyId) || has(NEON_ENV_VAR_KEYS.storage.secretAccessKey)) && !(endpoint !== void 0 && isNeonStorageEndpoint(endpoint)) ? [] : ["object-storage"], ...Object.values(NEON_ENV_VAR_KEYS.aiGateway).some(has) ? ["ai-gateway"] : []];
215
+ };
216
+ /** `https://<branch id>.storage.<region host>`, the shape Neon's branch storage API returns. */
217
+ const isNeonStorageEndpoint = (endpoint) => {
218
+ if (!URL.canParse(endpoint)) return false;
219
+ const [branch, service] = new URL(endpoint).hostname.split(".");
220
+ return branch?.startsWith("br-") === true && service === "storage";
221
+ };
222
+ /**
200
223
  * Prevents scoped or unavailable services from pruning values they did not resolve. A pull
201
224
  * that covers functions also prunes the `NEON_FUNCTION_<SLUG>_BASE_URL` lines earlier
202
225
  * releases wrote, since nothing reads or refreshes them anymore.
@@ -256,7 +279,10 @@ const autoPullEnvAfterPin = async (props, branch) => {
256
279
  return { status: "skipped" };
257
280
  }
258
281
  try {
259
- return await pull(props, branch ? { branch } : {});
282
+ return await pull(props, {
283
+ bundled: true,
284
+ ...branch ? { branch } : {}
285
+ });
260
286
  } catch (err) {
261
287
  const message = err instanceof Error ? err.message : String(err);
262
288
  log.warning(`Branch pinned, but pulling its Neon env vars failed: %s
@@ -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-Caoa3_y8.js";
9
- import { o as handler$1 } from "./checkout-D9CSqjde.js";
8
+ import { o as quoteFlagValue } from "./link-BVa6Nfji.js";
9
+ import { o as handler$1 } from "./checkout-CLHGCpZx.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-aWCqnWaF.js";
17
- import { h as initCmd } from "./config-CtP-1YSw.js";
16
+ import { n as autoPullEnvAfterPin } from "./env-C3HQJO8Z.js";
17
+ import { h as initCmd } from "./config-C8BQIoM2.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-CtP-1YSw.js";
3
+ import { y as status } from "./config-C8BQIoM2.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-D9CSqjde.js";
1
+ export { t as builder, r as command, i as describe, a as formatCheckoutPolicyFailure, o as handler } from "../_chunks/checkout-CLHGCpZx.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-Dzsw8sdd.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-BoN9NPTy.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-CtP-1YSw.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-C8BQIoM2.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-DQNsheXC.js";
1
+ export { t as builder, n as command, i as describe, a as handler } from "../_chunks/deploy-BdipMGJE.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-EmQkh84H.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-DVB7fGiG.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-aWCqnWaF.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-C3HQJO8Z.js";
@@ -1,3 +1,4 @@
1
+ import { getCliName } from "../utils/cli_name.js";
1
2
  import { NEON_SERVICES, NEON_SERVICE_LABELS } from "../neon_services.js";
2
3
  import { BRANCH_ENV_KEYS, ENV_PULL_KEYS, isLegacyFunctionBaseUrlKey, serviceForEnvKey } from "../env_services.js";
3
4
  import { isAbsolute, relative } from "node:path";
@@ -57,10 +58,11 @@ const formatPulledEnv = (outcome, cwd, branch) => {
57
58
  }
58
59
  if (outcome.removed.length > 0) lines.push(row("Removed", `${outcome.removed.join(", ")} (not produced by this pull)`));
59
60
  if (outcome.removed.some(isLegacyFunctionBaseUrlKey)) lines.push(row("", "Use functionBaseUrl(\"<slug>\") from @neon/env instead."));
61
+ 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.`));
60
62
  if (fresh.size > 0) lines.push(" * new credential value");
61
63
  const credential = outcome.credential;
62
64
  if (credential?.issued && credential.revoked.length > 0) lines.push(`Revoked the credential it replaced (${credential.revoked.join(", ")}).`);
63
- else if (credential?.issued && credential.superseded.length > 0) lines.push(`Left the credential it replaced live (${credential.superseded.join(", ")}): an explicitly scoped pull can't tell which other variables still use it. Revoke it in the Neon Console if nothing does.`);
65
+ else if (credential?.issued && credential.superseded.length > 0) lines.push(`Left the credential it replaced live (${credential.superseded.join(", ")}): this pull can't tell which other variables still use it. Revoke it in the Neon Console if nothing does.`);
64
66
  return `${lines.join("\n")}\n`;
65
67
  };
66
68
  export { displayPath, formatPulledEnv, pulledBranch, row };
@@ -9,7 +9,7 @@ import { writer } from "../writer.js";
9
9
  import { formatInitDone, printInitDone } from "../init/chrome.js";
10
10
  import { FUNCTION_SLUG_PATTERN, deriveFunctionSlug } from "../utils/function_slug.js";
11
11
  import { displayPath } from "./env_output.js";
12
- import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-CtP-1YSw.js";
12
+ import { _ as missingDependencies, d as ensureConfigPackages, g as installCommandFrom } from "../_chunks/config-C8BQIoM2.js";
13
13
  import { recommendedOperations } from "../functions/registry.js";
14
14
  import { collidingFiles, operationsFromFlags, planConfigRegistration, planEnvExample, planScaffold, writeScaffold } from "../functions/scaffold.js";
15
15
  import { describeRegistrySources, openRegistry } from "../functions/source.js";
@@ -1 +1 @@
1
- export { t as aliases, n as builder, r as cleanup, i as command, a as describe, s as handler, c as install, l as partitionBranchesToPrune, u as status, d as sync, f as uninstall } from "../_chunks/git-DJ-QP4YF.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-CIXLNUoh.js";
@@ -2,29 +2,29 @@ import { r as auth_exports } from "../_chunks/auth-CFa969Ck.js";
2
2
  import { t as api_exports } from "../_chunks/api-1MKsfpY3.js";
3
3
  import { n as api_keys_exports } from "../_chunks/api_keys-CTFHd5m_.js";
4
4
  import { n as ask_exports } from "../_chunks/ask-Xlek1Pxh.js";
5
- import { o as env_exports } from "../_chunks/env-aWCqnWaF.js";
6
- import { c as config_exports } from "../_chunks/config-CtP-1YSw.js";
5
+ import { o as env_exports } from "../_chunks/env-C3HQJO8Z.js";
6
+ import { c as config_exports } from "../_chunks/config-C8BQIoM2.js";
7
7
  import { u as projects_exports } from "../_chunks/projects-a3X4OFEJ.js";
8
- import { a as link_exports } from "../_chunks/link-Caoa3_y8.js";
8
+ import { a as link_exports } from "../_chunks/link-BVa6Nfji.js";
9
9
  import { o as mcp_exports } from "../_chunks/mcp-g8C-BZIb.js";
10
10
  import { c as plugins_exports } from "../_chunks/plugins-BwUZQ6Ic.js";
11
11
  import { l as skills_exports } from "../_chunks/skills-Bv8oKKwE.js";
12
12
  import { t as bootstrap_exports } from "../_chunks/bootstrap-B73qVB39.js";
13
13
  import { r as branches_exports } from "../_chunks/branches-Bp-5z1lM.js";
14
14
  import { n as bucket_exports } from "../_chunks/bucket-D06bvDSa.js";
15
- import { n as checkout_exports } from "../_chunks/checkout-D9CSqjde.js";
16
- import { o as claim_exports } from "../_chunks/claim-Dzsw8sdd.js";
15
+ import { n as checkout_exports } from "../_chunks/checkout-CLHGCpZx.js";
16
+ import { o as claim_exports } from "../_chunks/claim-BoN9NPTy.js";
17
17
  import { o as connection_string_exports } from "../_chunks/connection_string-6WhV4WFx.js";
18
18
  import { a as credentials_exports } from "../_chunks/credentials-KV1jlK-n.js";
19
19
  import { r as data_api_exports } from "../_chunks/data_api-BpSGbdZf.js";
20
20
  import { s as databases_exports } from "../_chunks/databases-B-qY303S.js";
21
- import { r as deploy_exports } from "../_chunks/deploy-DQNsheXC.js";
22
- import { s as dev_exports } from "../_chunks/dev-EmQkh84H.js";
21
+ import { r as deploy_exports } from "../_chunks/deploy-BdipMGJE.js";
22
+ import { s as dev_exports } from "../_chunks/dev-DVB7fGiG.js";
23
23
  import { i as diff_exports } from "../_chunks/diff-dnxneH0u.js";
24
24
  import { c as docs_exports } from "../_chunks/docs-DjYRHjGY.js";
25
25
  import { o as feedback_exports } from "../_chunks/feedback-mQmdTRFn.js";
26
26
  import { o as functions_exports } from "../_chunks/functions-PHaU-kRb.js";
27
- import { o as git_exports } from "../_chunks/git-DJ-QP4YF.js";
27
+ import { o as git_exports } from "../_chunks/git-CIXLNUoh.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-DxNhjcco.js";
44
- import { a as status_exports } from "../_chunks/status-DLH8CtHh.js";
44
+ import { a as status_exports } from "../_chunks/status-BBnw48qR.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-Caoa3_y8.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-BVa6Nfji.js";
@@ -1 +1 @@
1
- export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-DLH8CtHh.js";
1
+ export { t as builder, n as command, r as describe, i as handler } from "../_chunks/status-BBnw48qR.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-CFBmcKyo.js";
3
+ import { o as resolveNeonEnvVars } from "../_chunks/env-BWvi2_2f.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-CFBmcKyo.js";
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";
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-aWCqnWaF.js";
7
+ import { c as pull } from "../_chunks/env-C3HQJO8Z.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;
@@ -27,20 +27,18 @@ const configPlanFromResolution = (resolution, accepted) => {
27
27
  * from the branch's compute host.
28
28
  */
29
29
  const DEPLOY_FREE_SERVICES = /* @__PURE__ */ new Set(["ai-gateway", "functions"]);
30
- const needsDeploy = (declared) => declared.some((service) => !DEPLOY_FREE_SERVICES.has(service));
30
+ const needsDeploy = (service) => !DEPLOY_FREE_SERVICES.has(service);
31
31
  const initEnvPullAfterConfig = (input) => {
32
32
  if (!input.projectId || !input.branch) return { kind: "skip" };
33
33
  if (!input.linkDeferredPull && !input.wroteNewFile) return { kind: "skip" };
34
34
  if (input.claimable && input.declared.length > 0) return { kind: "skip" };
35
- if (!needsDeploy(input.declared)) return { kind: "policy" };
35
+ const pending = input.declared.filter(needsDeploy);
36
+ if (pending.length === 0) return { kind: "policy" };
36
37
  return {
37
38
  kind: "services",
38
- services: [
39
- "postgres",
40
- ...input.declared.includes("ai-gateway") ? ["ai-gateway"] : [],
41
- ...input.declared.includes("functions") ? ["functions"] : []
42
- ],
43
- envKeys: []
39
+ services: ["postgres", ...input.declared],
40
+ envKeys: [],
41
+ optionalServices: pending
44
42
  };
45
43
  };
46
44
  export { INIT_CONFIG_SERVICES_CONFLICT, configPlanFromResolution, initEnvPullAfterConfig, resolveInitConfigChoice };
@@ -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-CtP-1YSw.js";
7
+ import { r as applyCmd } from "../_chunks/config-C8BQIoM2.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-Caoa3_y8.js";
7
+ import { s as runLink } from "../_chunks/link-BVa6Nfji.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-CtP-1YSw.js";
19
- import { o as quoteFlagValue, s as runLink } from "../_chunks/link-Caoa3_y8.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";
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-Dzsw8sdd.js";
29
+ import { l as create } from "../_chunks/claim-BoN9NPTy.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";
@@ -634,7 +634,8 @@ const runInit = async (props) => {
634
634
  branch,
635
635
  ...envPullPlan.kind === "services" ? {
636
636
  services: envPullPlan.services,
637
- envKeys: envPullPlan.envKeys
637
+ envKeys: envPullPlan.envKeys,
638
+ optionalServices: envPullPlan.optionalServices
638
639
  } : {}
639
640
  }));
640
641
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neon",
3
- "version": "9.9.4",
3
+ "version": "9.9.5",
4
4
  "description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
5
5
  "keywords": [
6
6
  "neon",