@neon/env 1.6.14 → 2.0.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.
- package/README.md +30 -12
- package/dist/cli.js +5 -9
- package/dist/cli.js.map +1 -1
- package/dist/env.js +49 -110
- package/dist/env.js.map +1 -1
- package/dist/index.d.ts +50 -54
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +72 -55
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/env.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorCode, PlatformError, createNeonApiFromOptions, deriveCredentialScopes,
|
|
1
|
+
import { ErrorCode, PlatformError, createNeonApiFromOptions, deriveCredentialScopes, resolveConfig } from "@neon/config/v1";
|
|
2
2
|
// ../../internals/env-core/dist/roles.js
|
|
3
3
|
/**
|
|
4
4
|
* Neon's default branch owner role, created with every project. This is the role a
|
|
@@ -52,13 +52,27 @@ function defaultConnectionRole(roleNames) {
|
|
|
52
52
|
* user added a second database next to `neondb`) auto-picks without asking.
|
|
53
53
|
*/
|
|
54
54
|
const NEON_DEFAULT_DATABASE = "neondb";
|
|
55
|
+
/**
|
|
56
|
+
* Set only by `neon dev`: a JSON object mapping each function it serves to its localhost port,
|
|
57
|
+
* which `functionBaseUrl` prefers over the deployed hostname.
|
|
58
|
+
*/
|
|
59
|
+
const NEON_DEV_FUNCTION_PORTS = "NEON_DEV_FUNCTION_PORTS";
|
|
55
60
|
const NEON_ENV_VAR_KEYS = {
|
|
56
61
|
/**
|
|
57
62
|
* Branch identity. `NEON_BRANCH` carries the branch **name** and is injected into the
|
|
58
63
|
* Neon Functions runtime on every branch (including the default) by default. `env pull` /
|
|
59
64
|
* `neon dev` / `neon-env run` emit it too so local dev mirrors the deployed runtime.
|
|
60
65
|
*/
|
|
61
|
-
branch: {
|
|
66
|
+
branch: {
|
|
67
|
+
name: "NEON_BRANCH",
|
|
68
|
+
id: "NEON_BRANCH_ID",
|
|
69
|
+
/**
|
|
70
|
+
* Shared by every function on the branch, with a leading dot
|
|
71
|
+
* (`.compute.c-2.us-east-2.aws.neon.tech`). A function's host is
|
|
72
|
+
* `<NEON_BRANCH_ID>-<slug><NEON_FUNCTION_HOST_SUFFIX>`.
|
|
73
|
+
*/
|
|
74
|
+
functionHostSuffix: "NEON_FUNCTION_HOST_SUFFIX"
|
|
75
|
+
},
|
|
62
76
|
postgres: {
|
|
63
77
|
databaseUrl: "DATABASE_URL",
|
|
64
78
|
databaseUrlUnpooled: "DATABASE_URL_UNPOOLED"
|
|
@@ -95,19 +109,6 @@ const NEON_ENV_VAR_KEYS = {
|
|
|
95
109
|
baseUrl: "NEON_AI_GATEWAY_BASE_URL"
|
|
96
110
|
}
|
|
97
111
|
};
|
|
98
|
-
const FUNCTION_SLUG = /^[a-z0-9]{1,20}$/;
|
|
99
|
-
const FUNCTION_BASE_URL_KEY = /^NEON_FUNCTION_([A-Z0-9]{1,20})_BASE_URL$/;
|
|
100
|
-
function functionBaseUrlKey(slug) {
|
|
101
|
-
if (!FUNCTION_SLUG.test(slug)) throw new Error(`functionBaseUrlKey: ${JSON.stringify(slug)} is not a function slug ([a-z0-9]{1,20}).`);
|
|
102
|
-
return `NEON_FUNCTION_${slug.toUpperCase()}_BASE_URL`;
|
|
103
|
-
}
|
|
104
|
-
function parseFunctionBaseUrlKey(key) {
|
|
105
|
-
const match = FUNCTION_BASE_URL_KEY.exec(key);
|
|
106
|
-
return match ? match[1].toLowerCase() : null;
|
|
107
|
-
}
|
|
108
|
-
function isFunctionBaseUrlKey(key) {
|
|
109
|
-
return parseFunctionBaseUrlKey(key) !== null;
|
|
110
|
-
}
|
|
111
112
|
async function fetchEnv(config, options) {
|
|
112
113
|
if (options.keys) assertStorageCredentialKeyPair(options.keys);
|
|
113
114
|
return fetchEnvKeys(config, options, options.keys ?? null);
|
|
@@ -217,24 +218,13 @@ async function fetchEnvKeysState(config, options, keys, policy) {
|
|
|
217
218
|
const wantsDataApi = desired.dataApiEnabled && wants(K.dataApi.url);
|
|
218
219
|
const wantsRealtime = desired.realtimePolicy === "enabled" && (wants(K.realtime.url) || wants(K.realtime.secret));
|
|
219
220
|
const gatewayEnabled = desired.preview?.aiGatewayEnabled ?? false;
|
|
220
|
-
const
|
|
221
|
-
const declaredSlugs = (desired.preview?.functions ?? []).map((fn) => fn.slug);
|
|
222
|
-
const selectedFunctionKeys = selection === null ? [] : [...selection].filter(isFunctionBaseUrlKey);
|
|
223
|
-
const constructSlugs = functionUrlSlugsToConstruct({
|
|
224
|
-
functionUrlMode,
|
|
225
|
-
selection,
|
|
226
|
-
declaredSlugs,
|
|
227
|
-
selectedFunctionKeys,
|
|
228
|
-
wants
|
|
229
|
-
});
|
|
230
|
-
const wantsAnyFunctionUrl = selection === null || selectedFunctionKeys.length > 0;
|
|
221
|
+
const wantsFunctionHostSuffix = wants(K.branch.functionHostSuffix) && (selection !== null || options.functionHostSuffix === "always" || (desired.preview?.functions.length ?? 0) > 0);
|
|
231
222
|
const storageEnabled = (desired.preview?.buckets.length ?? 0) > 0;
|
|
232
223
|
const wantsStorage = storageEnabled && (wants(K.storage.accessKeyId) || wants(K.storage.secretAccessKey) || wants(K.storage.endpoint) || wants(K.storage.region));
|
|
233
|
-
const
|
|
234
|
-
functionsRead?.catch(() => void 0);
|
|
235
|
-
const storageRead = wantsStorage ? started(() => api.getProjectBranchStorage(projectId, branch.id)) : null;
|
|
236
|
-
const needsUnpooled = wantsUnpooled || gatewayEnabled && wants(K.aiGateway.baseUrl) || constructSlugs.length > 0;
|
|
224
|
+
const needsUnpooled = wantsUnpooled || gatewayEnabled && wants(K.aiGateway.baseUrl);
|
|
237
225
|
const needsConnectionTarget = wantsPooled || needsUnpooled;
|
|
226
|
+
const storageRead = wantsStorage ? started(() => api.getProjectBranchStorage(projectId, branch.id)) : null;
|
|
227
|
+
const endpointsRead = wantsFunctionHostSuffix && !needsConnectionTarget ? started(() => api.listEndpoints(projectId)) : null;
|
|
238
228
|
const needsDatabase = needsConnectionTarget || wantsDataApi;
|
|
239
229
|
const [roles, databases] = await Promise.all([needsConnectionTarget ? api.listBranchRoles(projectId, branch.id) : Promise.resolve([]), needsDatabase ? api.listBranchDatabases(projectId, branch.id) : Promise.resolve([])]);
|
|
240
230
|
const databaseName = needsDatabase ? pickDatabaseName(databases, branch, options.databaseName) : null;
|
|
@@ -260,7 +250,16 @@ async function fetchEnvKeysState(config, options, keys, policy) {
|
|
|
260
250
|
if (wantsPooled) postgres.databaseUrl = requiredValue(pooled, "pooled connection URI response").uri;
|
|
261
251
|
if (wantsUnpooled) postgres.databaseUrlUnpooled = requiredValue(unpooled, "direct connection URI response").uri;
|
|
262
252
|
if (Object.keys(postgres).length > 0) result.postgres = postgres;
|
|
263
|
-
if (wants(K.branch.name)
|
|
253
|
+
if (wants(K.branch.name) || wants(K.branch.id) || wantsFunctionHostSuffix) {
|
|
254
|
+
const branchEnv = {};
|
|
255
|
+
if (wants(K.branch.name)) branchEnv.name = branch.name;
|
|
256
|
+
if (wants(K.branch.id)) branchEnv.id = branch.id;
|
|
257
|
+
if (wantsFunctionHostSuffix) {
|
|
258
|
+
const connectionUri = unpooled?.uri ?? pooled?.uri;
|
|
259
|
+
branchEnv.functionHostSuffix = functionHostSuffix(connectionUri !== void 0 ? new URL(connectionUri).hostname : branchComputeHost(await requiredValue(endpointsRead, "branch endpoint list"), branch));
|
|
260
|
+
}
|
|
261
|
+
result.branch = branchEnv;
|
|
262
|
+
}
|
|
264
263
|
if (wantsAuth) {
|
|
265
264
|
if (!authSnapshot) throw new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy enables auth but no Neon Auth integration is enabled on branch ${branch.name} (${branch.id}).`, "Enable it via `apply(config, { projectId, branchId })` (or `npx neon …`), in the Neon Console — then re-run fetchEnv. Or return auth.enabled=false."].join(" "), { details: {
|
|
266
265
|
projectId,
|
|
@@ -333,66 +332,7 @@ async function fetchEnvKeysState(config, options, keys, policy) {
|
|
|
333
332
|
result.aiGateway = gateway;
|
|
334
333
|
}
|
|
335
334
|
}
|
|
336
|
-
|
|
337
|
-
let functionUrlsUnavailable = false;
|
|
338
|
-
if (functionUrlMode === "all-live" && wantsAnyFunctionUrl) {
|
|
339
|
-
const listed = options.listedFunctions === void 0 ? await requiredValue(functionsRead, "function listing") : listedFromSnapshots(options.listedFunctions);
|
|
340
|
-
if (listed.status === "unavailable") {
|
|
341
|
-
if (selection === null) functionUrlsUnavailable = true;
|
|
342
|
-
} else for (const fn of listed.functions) {
|
|
343
|
-
if (!wants(functionBaseUrlKey(fn.slug))) continue;
|
|
344
|
-
functions[fn.slug] = { baseUrl: asEnvBaseUrl(fn.invocationUrl) };
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
const missingConstructSlugs = constructSlugs.filter((slug) => functions[slug] === void 0);
|
|
348
|
-
if (missingConstructSlugs.length > 0) {
|
|
349
|
-
const uri = requiredValue(unpooled, "direct connection URI for function invocation URLs").uri;
|
|
350
|
-
for (const slug of missingConstructSlugs) functions[slug] = { baseUrl: functionInvocationUrl(branch.id, slug, uri) };
|
|
351
|
-
}
|
|
352
|
-
assertSelectedFunctionUrls(selectedFunctionKeys, functions);
|
|
353
|
-
if (Object.keys(functions).length > 0) result.functions = functions;
|
|
354
|
-
return {
|
|
355
|
-
env: result,
|
|
356
|
-
functionUrlsUnavailable
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
function functionUrlSlugsToConstruct(args) {
|
|
360
|
-
const slugs = [];
|
|
361
|
-
if (args.functionUrlMode === "policy" && args.selection === null) {
|
|
362
|
-
for (const slug of args.declaredSlugs) if (args.wants(functionBaseUrlKey(slug))) slugs.push(slug);
|
|
363
|
-
return slugs;
|
|
364
|
-
}
|
|
365
|
-
for (const key of args.selectedFunctionKeys) {
|
|
366
|
-
const slug = parseFunctionBaseUrlKey(key);
|
|
367
|
-
if (slug !== null) slugs.push(slug);
|
|
368
|
-
}
|
|
369
|
-
return slugs;
|
|
370
|
-
}
|
|
371
|
-
function listedFromSnapshots(snapshots) {
|
|
372
|
-
return {
|
|
373
|
-
status: "ok",
|
|
374
|
-
functions: snapshots.filter((fn) => fn.invocationUrl !== "").map((fn) => ({
|
|
375
|
-
slug: fn.slug,
|
|
376
|
-
invocationUrl: fn.invocationUrl
|
|
377
|
-
})).sort((left, right) => left.slug.localeCompare(right.slug))
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
function assertSelectedFunctionUrls(keys, functions) {
|
|
381
|
-
for (const key of keys) {
|
|
382
|
-
const slug = parseFunctionBaseUrlKey(key);
|
|
383
|
-
if (slug === null || functions[slug] === void 0) throw new Error(`fetchEnv: missing ${key}.`);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
async function listFunctionInvocationUrls(api, projectId, branchId) {
|
|
387
|
-
try {
|
|
388
|
-
return listedFromSnapshots(await api.listBranchFunctions(projectId, branchId));
|
|
389
|
-
} catch (error) {
|
|
390
|
-
if (isPlatformError(error) && error.code === ErrorCode.FeatureUnavailable) return {
|
|
391
|
-
status: "unavailable",
|
|
392
|
-
error
|
|
393
|
-
};
|
|
394
|
-
throw error;
|
|
395
|
-
}
|
|
335
|
+
return { env: result };
|
|
396
336
|
}
|
|
397
337
|
/**
|
|
398
338
|
* Resolve the target branch and evaluate the policy against it — the first thing any
|
|
@@ -457,6 +397,8 @@ function policyEnvKeys(desired) {
|
|
|
457
397
|
K.postgres.databaseUrl,
|
|
458
398
|
K.postgres.databaseUrlUnpooled,
|
|
459
399
|
K.branch.name,
|
|
400
|
+
K.branch.id,
|
|
401
|
+
...(desired.preview?.functions.length ?? 0) > 0 ? [K.branch.functionHostSuffix] : [],
|
|
460
402
|
...desired.authEnabled ? [K.auth.baseUrl, K.auth.jwksUrl] : [],
|
|
461
403
|
...desired.dataApiEnabled ? [K.dataApi.url] : [],
|
|
462
404
|
...desired.realtimePolicy === "enabled" ? [K.realtime.url, K.realtime.secret] : [],
|
|
@@ -571,24 +513,20 @@ function aiGatewayHost(branchId, connectionUri) {
|
|
|
571
513
|
return `${branchId}-api.ai.${connectionHostSuffix(connectionUri)}`;
|
|
572
514
|
}
|
|
573
515
|
/**
|
|
574
|
-
*
|
|
575
|
-
*
|
|
516
|
+
* `NEON_FUNCTION_HOST_SUFFIX` from a compute host: the endpoint label is replaced by
|
|
517
|
+
* `compute`, as the Functions runtime does (`.compute.c-2.us-east-2.aws.neon.tech`).
|
|
576
518
|
*/
|
|
577
|
-
function
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
function functionInvocationUrl(branchId, slug, connectionUri) {
|
|
589
|
-
const suffix = connectionHostSuffix(connectionUri);
|
|
590
|
-
if (suffix === "") throw new Error(`fetchEnv: cannot derive the invocation URL for function "${slug}": the direct connection URI has no host suffix.`);
|
|
591
|
-
return `https://${branchId}-${slug}.compute.${suffix}`;
|
|
519
|
+
function functionHostSuffix(computeHost) {
|
|
520
|
+
const suffix = computeHost.split(".").slice(1).join(".");
|
|
521
|
+
if (suffix === "") throw new Error(`fetchEnv: cannot derive NEON_FUNCTION_HOST_SUFFIX from compute host ${JSON.stringify(computeHost)}.`);
|
|
522
|
+
return `.compute.${suffix}`;
|
|
523
|
+
}
|
|
524
|
+
/** The branch's read-write compute host, else its first compute host. */
|
|
525
|
+
function branchComputeHost(endpoints, branch) {
|
|
526
|
+
const own = endpoints.filter((endpoint) => endpoint.branchId === branch.id);
|
|
527
|
+
const endpoint = own.find((candidate) => candidate.type === "read_write") ?? own[0];
|
|
528
|
+
if (!endpoint?.host) throw new PlatformError(ErrorCode.NotFound, `fetchEnv: branch ${branch.name} (${branch.id}) has no compute endpoint, so NEON_FUNCTION_HOST_SUFFIX cannot be derived. Add a compute to the branch, then re-run.`, { details: { branchId: branch.id } });
|
|
529
|
+
return endpoint.host;
|
|
592
530
|
}
|
|
593
531
|
/** The AI Gateway's bare base URL (`NEON_AI_GATEWAY_BASE_URL`) on the branch gateway host. */
|
|
594
532
|
function aiGatewayBaseUrl(branchId, connectionUri) {
|
|
@@ -669,6 +607,8 @@ function toEntries(env) {
|
|
|
669
607
|
put(K.postgres.databaseUrl, env.postgres?.databaseUrl);
|
|
670
608
|
put(K.postgres.databaseUrlUnpooled, env.postgres?.databaseUrlUnpooled);
|
|
671
609
|
put(K.branch.name, env.branch?.name);
|
|
610
|
+
put(K.branch.id, env.branch?.id);
|
|
611
|
+
put(K.branch.functionHostSuffix, env.branch?.functionHostSuffix);
|
|
672
612
|
put(K.auth.baseUrl, env.auth?.baseUrl);
|
|
673
613
|
put(K.auth.jwksUrl, env.auth?.jwksUrl);
|
|
674
614
|
put(K.dataApi.url, env.dataApi?.url);
|
|
@@ -680,9 +620,8 @@ function toEntries(env) {
|
|
|
680
620
|
put(K.storage.region, env.storage?.region);
|
|
681
621
|
put(K.aiGateway.apiKey, env.aiGateway?.apiKey);
|
|
682
622
|
put(K.aiGateway.baseUrl, env.aiGateway?.baseUrl);
|
|
683
|
-
if (env.functions) for (const slug of Object.keys(env.functions).sort()) put(functionBaseUrlKey(slug), env.functions[slug]?.baseUrl);
|
|
684
623
|
return out;
|
|
685
624
|
}
|
|
686
|
-
export {
|
|
625
|
+
export { credentialName as a, fetchEnv as c, policyEnvKeys as d, resolveBranchPolicy as f, credentialEnvKeys as i, fetchEnvKeysState as l, NEON_ENV_VAR_KEYS as n, defaultAiGatewayCredential as o, toEntries as p, createApiFromOptions as r, defaultStorageCredential as s, NEON_DEV_FUNCTION_PORTS as t, isLiveCredential as u };
|
|
687
626
|
|
|
688
627
|
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.js","names":[],"sources":["../../../internals/env-core/dist/roles.js","../../../internals/env-core/dist/env.js"],"sourcesContent":["// src/roles.ts\n/**\n* Neon's default branch owner role, created with every project. This is the role a\n* `DATABASE_URL` should connect as.\n*/\nconst NEON_DEFAULT_OWNER_ROLE = \"neondb_owner\";\n/**\n* Roles Neon provisions for the Auth / Data API (PostgREST) stack. They exist to back\n* RLS-scoped Data API requests authenticated by JWT — never to hold a `DATABASE_URL` —\n* so they're skipped when auto-picking the connection role. Enabling Neon Auth or the\n* Data API (`neon config apply`) adds these next to the owner role, which is why a plain\n* branch routinely reports more than one role.\n*/\nconst NEON_MANAGED_AUTH_ROLES = /* @__PURE__ */ new Set([\n\t\"authenticator\",\n\t\"anonymous\",\n\t\"authenticated\"\n]);\n/** `undefined` when more than one app role remains (or none exist), so the caller has to ask. */\nfunction defaultConnectionRole(roleNames) {\n\tif (roleNames.length === 1) return roleNames[0];\n\tif (roleNames.includes(\"neondb_owner\")) return NEON_DEFAULT_OWNER_ROLE;\n\tconst appRoles = roleNames.filter((name) => !NEON_MANAGED_AUTH_ROLES.has(name));\n\treturn appRoles.length === 1 ? appRoles[0] : void 0;\n}\nexport { NEON_DEFAULT_OWNER_ROLE, defaultConnectionRole };\n\n//# sourceMappingURL=roles.js.map","import { NEON_DEFAULT_OWNER_ROLE, defaultConnectionRole } from \"./roles.js\";\nimport { ErrorCode, PlatformError, createNeonApiFromOptions, deriveCredentialScopes, isPlatformError, resolveConfig } from \"@neon/config/v1\";\n// src/env.ts\n/**\n* The Neon env core — resolving a branch's env from the Neon API, and projecting it into\n* OS-level `{ KEY: value }` pairs.\n*\n* Private, and bundled into both consumers: `@neon/env` publishes it as `fetchEnv` /\n* `toEntries`, and the `neon` CLI needs the credential-reuse half in `reuse-secrets.ts`.\n* See `README.md` for why it is not published.\n*\n* The counterpart that reads `process.env` — `parseEnv` and its zod schemas — is not here. It\n* has no consumer outside `@neon/env`, so it stays in that package and imports this.\n*/\n/**\n* Mapping between the {@link NeonEnv} property paths and the OS-level env-var keys used\n* for cross-process transport (via `.env` files, `env run -- <cmd>`, or anything else\n* that talks to `process.env`).\n*\n* Each top-level key here is a {@link NeonEnv} namespace; the inner record maps the\n* camelCase property names exposed to TypeScript to the UPPER_SNAKE env-var names used\n* by the OS. Keep this in sync with {@link postgresEnvSchema} / {@link authEnvSchema} /\n* {@link dataApiEnvSchema} / {@link realtimeEnvSchema}.\n*/\n/**\n* Neon's default database, created with every project. When a branch has several databases\n* and none was requested, this is preferred for the `DATABASE_URL` so the common case (a\n* user added a second database next to `neondb`) auto-picks without asking.\n*/\nconst NEON_DEFAULT_DATABASE = \"neondb\";\nconst NEON_ENV_VAR_KEYS = {\n\t/**\n\t* Branch identity. `NEON_BRANCH` carries the branch **name** and is injected into the\n\t* Neon Functions runtime on every branch (including the default) by default. `env pull` /\n\t* `neon dev` / `neon-env run` emit it too so local dev mirrors the deployed runtime.\n\t*/\n\tbranch: { name: \"NEON_BRANCH\" },\n\tpostgres: {\n\t\tdatabaseUrl: \"DATABASE_URL\",\n\t\tdatabaseUrlUnpooled: \"DATABASE_URL_UNPOOLED\"\n\t},\n\tauth: {\n\t\tbaseUrl: \"NEON_AUTH_BASE_URL\",\n\t\tjwksUrl: \"NEON_AUTH_JWKS_URL\"\n\t},\n\tdataApi: { url: \"NEON_DATA_API_URL\" },\n\trealtime: {\n\t\turl: \"NEON_REALTIME_URL\",\n\t\tsecret: \"NEON_REALTIME_SECRET\"\n\t},\n\t/**\n\t* Object storage (Preview). The S3 SDKs read `AWS_*` from their standard config chain, so\n\t* a branch credential + `neon dev` / `env pull` makes object storage work from env alone.\n\t* `region` is injected under the SDK-standard `AWS_REGION`.\n\t*/\n\tstorage: {\n\t\taccessKeyId: \"AWS_ACCESS_KEY_ID\",\n\t\tsecretAccessKey: \"AWS_SECRET_ACCESS_KEY\",\n\t\tendpoint: \"AWS_ENDPOINT_URL_S3\",\n\t\tregion: \"AWS_REGION\"\n\t},\n\t/**\n\t* AI Gateway (Preview). Exposed under the Neon-branded env vars the deployed Functions\n\t* runtime injects: `apiKey` is the minted credential's bearer (`NEON_AI_GATEWAY_TOKEN`)\n\t* and `baseUrl` is the bare branch gateway host (`NEON_AI_GATEWAY_BASE_URL`,\n\t* `scheme://host`, no path). Clients like `@neon/ai-sdk-provider` read these and append the\n\t* dialect route (`/v1`, `/openai/v1`, `/anthropic/v1`) themselves (https://github.com/vercel/ai/pull/15997).\n\t*/\n\taiGateway: {\n\t\tapiKey: \"NEON_AI_GATEWAY_TOKEN\",\n\t\tbaseUrl: \"NEON_AI_GATEWAY_BASE_URL\"\n\t}\n};\nconst FUNCTION_SLUG = /^[a-z0-9]{1,20}$/;\nconst FUNCTION_BASE_URL_KEY = /^NEON_FUNCTION_([A-Z0-9]{1,20})_BASE_URL$/;\nfunction functionBaseUrlKey(slug) {\n\tif (!FUNCTION_SLUG.test(slug)) throw new Error(`functionBaseUrlKey: ${JSON.stringify(slug)} is not a function slug ([a-z0-9]{1,20}).`);\n\treturn `NEON_FUNCTION_${slug.toUpperCase()}_BASE_URL`;\n}\nfunction parseFunctionBaseUrlKey(key) {\n\tconst match = FUNCTION_BASE_URL_KEY.exec(key);\n\treturn match ? match[1].toLowerCase() : null;\n}\nfunction isFunctionBaseUrlKey(key) {\n\treturn parseFunctionBaseUrlKey(key) !== null;\n}\nasync function fetchEnv(config, options) {\n\tif (options.keys) assertStorageCredentialKeyPair(options.keys);\n\treturn fetchEnvKeys(config, options, options.keys ?? null);\n}\nfunction assertStorageCredentialKeyPair(keys) {\n\tif (keys.includes(NEON_ENV_VAR_KEYS.storage.accessKeyId) === keys.includes(NEON_ENV_VAR_KEYS.storage.secretAccessKey)) return;\n\tthrow new TypeError(\"fetchEnv: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be selected together. Pass both in `keys`, or omit both.\");\n}\n/**\n* Starts a read now and keeps an unread rejection from crashing the process; the caller\n* awaits it (and sees the error) when its turn comes. The read is called synchronously and\n* its own promise returned, so errors surface in the same order as a direct call; a\n* synchronous throw becomes the returned rejection.\n*/\nfunction started(read) {\n\tlet promise;\n\ttry {\n\t\tpromise = read();\n\t} catch (error) {\n\t\tpromise = Promise.reject(error);\n\t}\n\tpromise.catch(() => void 0);\n\treturn promise;\n}\n/** Fail loudly when selected-key dependency planning and execution disagree. */\nfunction requiredValue(value, description) {\n\tif (value === null) throw new Error(`fetchEnv: missing ${description}.`);\n\treturn value;\n}\nconst REALTIME_POLL_INTERVAL_MS = 1e3;\n/**\n* Wait for asynchronous Realtime provisioning/rotation before reading its secret. The\n* secret endpoint deliberately returns 404 until provisioning finishes, and during a\n* rotation it can still expose the previous key while `pending` is true.\n*/\nasync function resolveRealtimeEnv(args) {\n\tconst getRealtime = args.api.getProjectBranchRealtime;\n\tif (!getRealtime) throw new PlatformError(ErrorCode.FeatureUnavailable, \"fetchEnv cannot resolve Realtime: this NeonApi adapter does not implement getProjectBranchRealtime.\");\n\tconst getSecret = args.api.getProjectBranchRealtimeSecret;\n\tlet resolvedEnv;\n\twhile (resolvedEnv === void 0) {\n\t\tconst snapshot = await getRealtime.call(args.api, args.projectId, args.branch.id);\n\t\tif (!snapshot.pending) {\n\t\t\tif (!snapshot.enabled) throw new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy enables realtime but Realtime is disabled on branch ${args.branch.name} (${args.branch.id}).`, \"Enable it via `apply(config, { projectId, branchId })` (or `npx neon deploy`) and re-run fetchEnv. Or set realtime to false or omit it.\"].join(\" \"), { details: {\n\t\t\t\tprojectId: args.projectId,\n\t\t\t\tbranchId: args.branch.id\n\t\t\t} });\n\t\t\tlet secret;\n\t\t\tif (args.wantsSecret) {\n\t\t\t\tif (!getSecret) throw new PlatformError(ErrorCode.FeatureUnavailable, \"fetchEnv cannot resolve NEON_REALTIME_SECRET: this NeonApi adapter does not implement getProjectBranchRealtimeSecret.\");\n\t\t\t\tsecret = await getSecret.call(args.api, args.projectId, args.branch.id);\n\t\t\t}\n\t\t\tif (!secret?.pending) resolvedEnv = {\n\t\t\t\t...args.wantsUrl ? { url: realtimeWebSocketUrl(requiredRealtimeInvocationUrl(snapshot, args.branch)) } : {},\n\t\t\t\t...secret ? { secret: secret.secret } : {}\n\t\t\t};\n\t\t}\n\t\tif (resolvedEnv === void 0) await new Promise((resolve) => setTimeout(resolve, REALTIME_POLL_INTERVAL_MS));\n\t}\n\treturn resolvedEnv;\n}\nfunction requiredRealtimeInvocationUrl(snapshot, branch) {\n\tif (snapshot.invocationUrl !== void 0 && snapshot.invocationUrl !== \"\") return snapshot.invocationUrl;\n\tthrow new PlatformError(ErrorCode.ServerError, `Realtime is enabled on branch ${branch.name} (${branch.id}), but the Neon API returned no invocation URL.`, { details: { branchId: branch.id } });\n}\n/** Normalize the control-plane invocation URL to the WebSocket URL the client SDK needs. */\nfunction realtimeWebSocketUrl(value) {\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new PlatformError(ErrorCode.ServerError, `Realtime invocation URL is invalid: ${JSON.stringify(value)}.`);\n\t}\n\tif (parsed.protocol === \"https:\") parsed.protocol = \"wss:\";\n\telse if (parsed.protocol === \"http:\") parsed.protocol = \"ws:\";\n\telse if (parsed.protocol !== \"wss:\" && parsed.protocol !== \"ws:\") throw new PlatformError(ErrorCode.ServerError, `Realtime invocation URL must use http(s) or ws(s): ${JSON.stringify(value)}.`);\n\treturn parsed.toString();\n}\n/**\n* The {@link fetchEnv} body, with the key selection as a plain argument and no generic\n* narrowing. Exists for callers that compute the selection at runtime — notably\n* {@link fetchEnvReusingSecrets}, which decides which keys it still needs by checking the\n* branch — since the public overload's `keys` is bound to a literal union those callers cannot\n* produce without asserting.\n*\n* `keys === null` selects everything the policy enables.\n*/\nasync function fetchEnvKeys(config, options, keys) {\n\treturn (await fetchEnvKeysState(config, options, keys)).env;\n}\n/**\n* `policy` is the {@link resolveBranchPolicy} result for this same `config` and branch, when\n* the caller already has it.\n*/\nasync function fetchEnvKeysState(config, options, keys, policy) {\n\tconst api = options.api ?? createApiFromOptions(options);\n\tconst projectId = options.projectId;\n\tconst { branch, desired } = policy ?? await resolveBranchPolicy(config, options, api);\n\tconst selection = keys ? new Set(keys) : null;\n\tconst omitted = new Set(options.omitKeys ?? []);\n\tconst wants = (key) => !omitted.has(key) && (selection === null || selection.has(key));\n\tconst result = {};\n\tconst K = NEON_ENV_VAR_KEYS;\n\tconst wantsPooled = wants(K.postgres.databaseUrl);\n\tconst wantsUnpooled = wants(K.postgres.databaseUrlUnpooled);\n\tconst wantsAuth = desired.authEnabled && (wants(K.auth.baseUrl) || wants(K.auth.jwksUrl));\n\tconst wantsDataApi = desired.dataApiEnabled && wants(K.dataApi.url);\n\tconst wantsRealtime = desired.realtimePolicy === \"enabled\" && (wants(K.realtime.url) || wants(K.realtime.secret));\n\tconst gatewayEnabled = desired.preview?.aiGatewayEnabled ?? false;\n\tconst functionUrlMode = options.functionUrls ?? \"policy\";\n\tconst declaredSlugs = (desired.preview?.functions ?? []).map((fn) => fn.slug);\n\tconst selectedFunctionKeys = selection === null ? [] : [...selection].filter(isFunctionBaseUrlKey);\n\tconst constructSlugs = functionUrlSlugsToConstruct({\n\t\tfunctionUrlMode,\n\t\tselection,\n\t\tdeclaredSlugs,\n\t\tselectedFunctionKeys,\n\t\twants\n\t});\n\tconst wantsAnyFunctionUrl = selection === null || selectedFunctionKeys.length > 0;\n\tconst storageEnabled = (desired.preview?.buckets.length ?? 0) > 0;\n\tconst wantsStorage = storageEnabled && (wants(K.storage.accessKeyId) || wants(K.storage.secretAccessKey) || wants(K.storage.endpoint) || wants(K.storage.region));\n\tconst functionsRead = functionUrlMode === \"all-live\" && wantsAnyFunctionUrl && options.listedFunctions === void 0 ? listFunctionInvocationUrls(api, projectId, branch.id) : null;\n\tfunctionsRead?.catch(() => void 0);\n\tconst storageRead = wantsStorage ? started(() => api.getProjectBranchStorage(projectId, branch.id)) : null;\n\tconst needsUnpooled = wantsUnpooled || gatewayEnabled && wants(K.aiGateway.baseUrl) || constructSlugs.length > 0;\n\tconst needsConnectionTarget = wantsPooled || needsUnpooled;\n\tconst needsDatabase = needsConnectionTarget || wantsDataApi;\n\tconst [roles, databases] = await Promise.all([needsConnectionTarget ? api.listBranchRoles(projectId, branch.id) : Promise.resolve([]), needsDatabase ? api.listBranchDatabases(projectId, branch.id) : Promise.resolve([])]);\n\tconst databaseName = needsDatabase ? pickDatabaseName(databases, branch, options.databaseName) : null;\n\tconst connectionTarget = needsConnectionTarget ? {\n\t\troleName: pickRoleName(roles, branch, options.roleName),\n\t\tdatabaseName: requiredValue(databaseName, \"database for a selected connection URI\")\n\t} : null;\n\tconst getConnectionUri = (pooled) => {\n\t\tconst target = requiredValue(connectionTarget, \"role and database for a selected connection URI\");\n\t\treturn api.getConnectionUri(projectId, {\n\t\t\tbranchId: branch.id,\n\t\t\t...target,\n\t\t\tpooled\n\t\t});\n\t};\n\tconst [pooled, unpooled, authSnapshot, dataApiSnapshot] = await Promise.all([\n\t\twantsPooled ? getConnectionUri(true) : Promise.resolve(null),\n\t\tneedsUnpooled ? getConnectionUri(false) : Promise.resolve(null),\n\t\twantsAuth ? api.getNeonAuth(projectId, branch.id) : Promise.resolve(null),\n\t\twantsDataApi ? api.getNeonDataApi(projectId, branch.id, requiredValue(databaseName, \"database for the selected Data API URL\")) : Promise.resolve(null)\n\t]);\n\tconst postgres = {};\n\tif (wantsPooled) postgres.databaseUrl = requiredValue(pooled, \"pooled connection URI response\").uri;\n\tif (wantsUnpooled) postgres.databaseUrlUnpooled = requiredValue(unpooled, \"direct connection URI response\").uri;\n\tif (Object.keys(postgres).length > 0) result.postgres = postgres;\n\tif (wants(K.branch.name)) result.branch = { name: branch.name };\n\tif (wantsAuth) {\n\t\tif (!authSnapshot) throw new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy enables auth but no Neon Auth integration is enabled on branch ${branch.name} (${branch.id}).`, \"Enable it via `apply(config, { projectId, branchId })` (or `npx neon …`), in the Neon Console — then re-run fetchEnv. Or return auth.enabled=false.\"].join(\" \"), { details: {\n\t\t\tprojectId,\n\t\t\tbranchId: branch.id\n\t\t} });\n\t\tconst auth = {};\n\t\tif (wants(K.auth.baseUrl)) auth.baseUrl = authSnapshot.baseUrl ?? \"\";\n\t\tif (wants(K.auth.jwksUrl)) auth.jwksUrl = authSnapshot.jwksUrl ?? \"\";\n\t\tresult.auth = auth;\n\t}\n\tif (wantsDataApi) {\n\t\tif (!dataApiSnapshot) {\n\t\t\tconst selectedDatabase = requiredValue(databaseName, \"database for the selected Data API URL\");\n\t\t\tthrow new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy enables dataApi but no Data API integration is enabled on branch ${branch.name} (${branch.id}) database ${selectedDatabase}.`, \"Enable it via `apply(config, { projectId, branchId })` or in the Neon Console — then re-run fetchEnv. Or return dataApi.enabled=false.\"].join(\" \"), { details: {\n\t\t\t\tprojectId,\n\t\t\t\tbranchId: branch.id,\n\t\t\t\tdatabaseName: selectedDatabase\n\t\t\t} });\n\t\t}\n\t\tresult.dataApi = { url: dataApiSnapshot.url };\n\t}\n\tif (wantsRealtime) {\n\t\tconst realtime = await resolveRealtimeEnv({\n\t\t\tapi,\n\t\t\tprojectId,\n\t\t\tbranch,\n\t\t\twantsUrl: wants(K.realtime.url),\n\t\t\twantsSecret: wants(K.realtime.secret)\n\t\t});\n\t\tconst realtimeEnv = {};\n\t\tif (wants(K.realtime.url)) realtimeEnv.url = requiredValue(realtime.url, \"WebSocket URL for enabled Realtime\");\n\t\tif (wants(K.realtime.secret)) realtimeEnv.secret = requiredValue(realtime.secret, \"shared secret for enabled Realtime\");\n\t\tresult.realtime = realtimeEnv;\n\t}\n\tconst wantsGateway = gatewayEnabled && (wants(K.aiGateway.apiKey) || wants(K.aiGateway.baseUrl));\n\tconst wantsStorageCredential = storageEnabled && (wants(K.storage.accessKeyId) || wants(K.storage.secretAccessKey));\n\tconst wantsGatewayCredential = gatewayEnabled && wants(K.aiGateway.apiKey);\n\tconst wantsCredential = wantsStorageCredential || wantsGatewayCredential;\n\tif (wantsStorage || wantsGateway) {\n\t\tlet storage = null;\n\t\tif (wantsStorage) {\n\t\t\tstorage = await requiredValue(storageRead, \"storage read\");\n\t\t\tif (!storage) throw new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy declares object storage (buckets) but storage is not enabled on branch ${branch.name} (${branch.id}).`, \"Enable it via `apply(config, { projectId, branchId })` (or in the Neon Console) — then re-run fetchEnv. Or remove buckets.\"].join(\" \"), { details: {\n\t\t\t\tprojectId,\n\t\t\t\tbranchId: branch.id\n\t\t\t} });\n\t\t}\n\t\tconst secrets = wantsCredential ? await resolveBranchCredentialSecrets({\n\t\t\tapi,\n\t\t\tprojectId,\n\t\t\tbranchId: branch.id,\n\t\t\tbranchName: branch.name,\n\t\t\tscopes: previewCredentialScopes(desired.preview, {\n\t\t\t\tstorage: wantsStorageCredential,\n\t\t\t\taiGateway: wantsGatewayCredential\n\t\t\t})\n\t\t}) : null;\n\t\tif (storage) {\n\t\t\tconst storageEnv = {};\n\t\t\tif (secrets && wants(K.storage.accessKeyId)) storageEnv.accessKeyId = secrets.accessKeyId;\n\t\t\tif (secrets && wants(K.storage.secretAccessKey)) storageEnv.secretAccessKey = secrets.secretAccessKey;\n\t\t\tif (wants(K.storage.endpoint)) storageEnv.endpoint = storage.s3Endpoint;\n\t\t\tif (wants(K.storage.region)) storageEnv.region = storage.region;\n\t\t\tresult.storage = storageEnv;\n\t\t}\n\t\tif (wantsGateway) {\n\t\t\tconst gateway = {};\n\t\t\tif (secrets && wants(K.aiGateway.apiKey)) gateway.apiKey = secrets.apiToken;\n\t\t\tif (wants(K.aiGateway.baseUrl)) gateway.baseUrl = aiGatewayBaseUrl(branch.id, requiredValue(unpooled, \"direct connection URI for the selected AI Gateway base URL\").uri);\n\t\t\tresult.aiGateway = gateway;\n\t\t}\n\t}\n\tconst functions = {};\n\tlet functionUrlsUnavailable = false;\n\tif (functionUrlMode === \"all-live\" && wantsAnyFunctionUrl) {\n\t\tconst listed = options.listedFunctions === void 0 ? await requiredValue(functionsRead, \"function listing\") : listedFromSnapshots(options.listedFunctions);\n\t\tif (listed.status === \"unavailable\") {\n\t\t\tif (selection === null) functionUrlsUnavailable = true;\n\t\t} else for (const fn of listed.functions) {\n\t\t\tif (!wants(functionBaseUrlKey(fn.slug))) continue;\n\t\t\tfunctions[fn.slug] = { baseUrl: asEnvBaseUrl(fn.invocationUrl) };\n\t\t}\n\t}\n\tconst missingConstructSlugs = constructSlugs.filter((slug) => functions[slug] === void 0);\n\tif (missingConstructSlugs.length > 0) {\n\t\tconst uri = requiredValue(unpooled, \"direct connection URI for function invocation URLs\").uri;\n\t\tfor (const slug of missingConstructSlugs) functions[slug] = { baseUrl: functionInvocationUrl(branch.id, slug, uri) };\n\t}\n\tassertSelectedFunctionUrls(selectedFunctionKeys, functions);\n\tif (Object.keys(functions).length > 0) result.functions = functions;\n\treturn {\n\t\tenv: result,\n\t\tfunctionUrlsUnavailable\n\t};\n}\nfunction functionUrlSlugsToConstruct(args) {\n\tconst slugs = [];\n\tif (args.functionUrlMode === \"policy\" && args.selection === null) {\n\t\tfor (const slug of args.declaredSlugs) if (args.wants(functionBaseUrlKey(slug))) slugs.push(slug);\n\t\treturn slugs;\n\t}\n\tfor (const key of args.selectedFunctionKeys) {\n\t\tconst slug = parseFunctionBaseUrlKey(key);\n\t\tif (slug !== null) slugs.push(slug);\n\t}\n\treturn slugs;\n}\nfunction listedFromSnapshots(snapshots) {\n\treturn {\n\t\tstatus: \"ok\",\n\t\tfunctions: snapshots.filter((fn) => fn.invocationUrl !== \"\").map((fn) => ({\n\t\t\tslug: fn.slug,\n\t\t\tinvocationUrl: fn.invocationUrl\n\t\t})).sort((left, right) => left.slug.localeCompare(right.slug))\n\t};\n}\nfunction assertSelectedFunctionUrls(keys, functions) {\n\tfor (const key of keys) {\n\t\tconst slug = parseFunctionBaseUrlKey(key);\n\t\tif (slug === null || functions[slug] === void 0) throw new Error(`fetchEnv: missing ${key}.`);\n\t}\n}\nasync function listFunctionInvocationUrls(api, projectId, branchId) {\n\ttry {\n\t\treturn listedFromSnapshots(await api.listBranchFunctions(projectId, branchId));\n\t} catch (error) {\n\t\tif (isPlatformError(error) && error.code === ErrorCode.FeatureUnavailable) return {\n\t\t\tstatus: \"unavailable\",\n\t\t\terror\n\t\t};\n\t\tthrow error;\n\t}\n}\n/**\n* Resolve the target branch and evaluate the policy against it — the first thing any\n* branch-scoped operation needs. Shared by {@link fetchEnv} and {@link fetchEnvReusingSecrets}\n* so the two agree on which branch they're talking about and what it has enabled.\n*/\nasync function resolveBranchPolicy(config, options, api, resolved) {\n\tconst branch = resolved ?? await listAndResolveBranch(options, api);\n\treturn {\n\t\tbranch,\n\t\tdesired: resolveConfig(config, {\n\t\t\tname: branch.name,\n\t\t\tid: branch.id,\n\t\t\texists: true,\n\t\t\t...branch.parentId ? { parentId: branch.parentId } : {},\n\t\t\tisDefault: branch.isDefault,\n\t\t\tisProtected: branch.protected,\n\t\t\t...branch.expiresAt ? { expiresAt: branch.expiresAt } : {}\n\t\t})\n\t};\n}\nasync function listAndResolveBranch(options, api) {\n\tconst projectId = options.projectId;\n\tconst branches = await api.listBranches(projectId);\n\tif (branches.length === 0) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: project ${projectId} has no branches.`, \"Deploy your neon.ts policy (or create a branch) first, or pick a different project id.\"].join(\" \"), { details: { projectId } });\n\tconst branchRef = options.branch ?? options.branchId;\n\tif (!branchRef) throw new PlatformError(ErrorCode.BranchNotFound, [\"fetchEnv: no branch provided.\", \"Pass `branch` with a branch name (e.g. `main`) or id (`br-…`).\"].join(\" \"), { details: { projectId } });\n\treturn resolveBranch(branchRef, branches);\n}\n/**\n* Scopes a minted fallback credential should carry. Only object storage and the AI Gateway\n* *require* secrets; functions never force a credential. `functions:invoke` rides along only\n* when this path still has to mint (defaults already cover storage and the gateway).\n*/\nfunction previewCredentialScopes(preview, selected) {\n\tif (!preview) return [];\n\tconst storage = preview.buckets.length > 0 && (selected?.storage ?? true);\n\tconst aiGateway = preview.aiGatewayEnabled && (selected?.aiGateway ?? true);\n\tif (!storage && !aiGateway) return [];\n\treturn deriveCredentialScopes({\n\t\tstorage,\n\t\taiGateway,\n\t\tfunctions: preview.functions.length > 0\n\t});\n}\n/** The `name` this tool stamps on every credential it mints, so it can recognize its own. */\nfunction credentialName(branchName) {\n\treturn `neon-env ${branchName}`;\n}\n/** The env-var keys a branch credential's secrets surface under, in emit order. */\nfunction credentialEnvKeys(flags) {\n\treturn [...flags.storage ? [NEON_ENV_VAR_KEYS.storage.accessKeyId, NEON_ENV_VAR_KEYS.storage.secretAccessKey] : [], ...flags.aiGateway ? [NEON_ENV_VAR_KEYS.aiGateway.apiKey] : []];\n}\n/**\n* Every OS-level env var a resolved branch policy produces, in emit order. Lets a caller\n* subtract the ones it already holds and pass the rest as {@link fetchEnv}'s `keys`, without\n* re-deriving which vars a policy implies.\n*/\nfunction policyEnvKeys(desired) {\n\tconst K = NEON_ENV_VAR_KEYS;\n\treturn [\n\t\tK.postgres.databaseUrl,\n\t\tK.postgres.databaseUrlUnpooled,\n\t\tK.branch.name,\n\t\t...desired.authEnabled ? [K.auth.baseUrl, K.auth.jwksUrl] : [],\n\t\t...desired.dataApiEnabled ? [K.dataApi.url] : [],\n\t\t...desired.realtimePolicy === \"enabled\" ? [K.realtime.url, K.realtime.secret] : [],\n\t\t...(desired.preview?.buckets.length ?? 0) > 0 ? [\n\t\t\tK.storage.accessKeyId,\n\t\t\tK.storage.secretAccessKey,\n\t\t\tK.storage.endpoint,\n\t\t\tK.storage.region\n\t\t] : [],\n\t\t...desired.preview?.aiGatewayEnabled ? [K.aiGateway.apiKey, K.aiGateway.baseUrl] : []\n\t];\n}\n/** Exact `name` values the credentials list endpoint returns for the platform defaults. */\nconst DEFAULT_AI_GATEWAY_CREDENTIAL_NAME = \"Default AI gateway credential\";\nconst DEFAULT_OBJECT_STORAGE_CREDENTIAL_NAME = \"Default object storage credential\";\n/** Whether an issued credential can still be used: not revoked, not past its expiry. */\nfunction isLiveCredential(meta, now) {\n\tif (meta.revokedAt !== void 0) return false;\n\tif (meta.expiresAt === void 0) return true;\n\tconst expiresAt = Date.parse(meta.expiresAt);\n\treturn Number.isNaN(expiresAt) || expiresAt > now;\n}\nfunction defaultStorageCredential(live, now) {\n\treturn live.find((meta) => meta.name === DEFAULT_OBJECT_STORAGE_CREDENTIAL_NAME && isLiveCredential(meta, now)) ?? null;\n}\nfunction defaultAiGatewayCredential(live, now) {\n\treturn live.find((meta) => meta.name === DEFAULT_AI_GATEWAY_CREDENTIAL_NAME && isLiveCredential(meta, now)) ?? null;\n}\n/**\n* Resolve secrets for object storage / the AI Gateway.\n*\n* Regions that expose those products already have platform defaults on every branch.\n* Reveal those by exact name instead of minting a combined `neon-env ${branch}` credential.\n* Mint only the half (or both) that has no default — regions without the credentials\n* endpoint still fail at list, same as before.\n*\n* A caller that already holds secrets for those defaults should leave the secret keys out\n* of `keys` (see {@link fetchEnvReusingSecrets}) instead of revealing them again.\n*/\nasync function resolveBranchCredentialSecrets(args) {\n\tconst needsStorage = args.scopes.includes(\"storage:read\") || args.scopes.includes(\"storage:write\");\n\tconst needsGateway = args.scopes.includes(\"ai_gateway:invoke\");\n\tconst live = await args.api.listCredentials(args.projectId, args.branchId);\n\tconst now = Date.now();\n\tconst storageDefault = defaultStorageCredential(live, now);\n\tconst gatewayDefault = defaultAiGatewayCredential(live, now);\n\tconst secrets = {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\",\n\t\tapiToken: \"\"\n\t};\n\tconst storageReveal = needsStorage && storageDefault ? started(() => args.api.revealCredential(args.projectId, args.branchId, storageDefault.tokenId)) : null;\n\tconst gatewayReveal = needsGateway && gatewayDefault ? started(() => args.api.revealCredential(args.projectId, args.branchId, gatewayDefault.tokenId)) : null;\n\tif (storageReveal) {\n\t\tconst revealed = await storageReveal;\n\t\tsecrets.accessKeyId = revealed.tokenId;\n\t\tsecrets.secretAccessKey = revealed.s3SecretAccessKey;\n\t}\n\tif (gatewayReveal) secrets.apiToken = (await gatewayReveal).apiToken;\n\tconst missingStorage = needsStorage && storageDefault === null;\n\tconst missingGateway = needsGateway && gatewayDefault === null;\n\tif (missingStorage || missingGateway) {\n\t\tconst minted = await mintBranchCredential({\n\t\t\t...args,\n\t\t\tscopes: deriveCredentialScopes({\n\t\t\t\tstorage: missingStorage,\n\t\t\t\taiGateway: missingGateway,\n\t\t\t\tfunctions: args.scopes.includes(\"functions:invoke\")\n\t\t\t})\n\t\t});\n\t\tif (missingStorage) {\n\t\t\tsecrets.accessKeyId = minted.accessKeyId;\n\t\t\tsecrets.secretAccessKey = minted.secretAccessKey;\n\t\t}\n\t\tif (missingGateway) secrets.apiToken = minted.apiToken;\n\t}\n\treturn secrets;\n}\nasync function mintBranchCredential(args) {\n\tconst minted = await args.api.createCredential(args.projectId, args.branchId, {\n\t\tscopes: args.scopes,\n\t\tprincipalType: \"user\",\n\t\tname: credentialName(args.branchName)\n\t});\n\treturn {\n\t\taccessKeyId: minted.tokenId,\n\t\tsecretAccessKey: minted.s3SecretAccessKey,\n\t\tapiToken: minted.apiToken\n\t};\n}\n/**\n* The AI Gateway is a **branch-scoped host** — `<branchId>-api.ai.<host-suffix>` — NOT the\n* control-plane API origin. Derive the suffix from the branch's own Postgres connection host\n* by dropping only the endpoint label (the first segment) and keeping everything after it,\n* including any infra cell prefix (`c-N.`): a connection host of\n* `ep-x.c-3.us-east-2.aws.neon.tech` yields the gateway host\n* `<branchId>-api.ai.c-3.us-east-2.aws.neon.tech`. The cell prefix is **load-bearing** —\n* the gateway is cell-routed, so dropping `c-N.` resolves to the wrong (or no) host.\n*\n* Function invocation URLs use the same suffix: `<branchId>-<slug>.compute.<suffix>`.\n*/\nfunction connectionHostSuffix(connectionUri) {\n\tlet connectionHost = \"\";\n\ttry {\n\t\tconnectionHost = new URL(connectionUri).hostname;\n\t} catch {\n\t\tconnectionHost = \"\";\n\t}\n\treturn connectionHost.split(\".\").slice(1).join(\".\");\n}\nfunction aiGatewayHost(branchId, connectionUri) {\n\treturn `${branchId}-api.ai.${connectionHostSuffix(connectionUri)}`;\n}\n/**\n* The API's `invocation_url` ends with `/` so paths concatenate onto it. Neon `*_BASE_URL`\n* vars are origin-only (`NEON_AUTH_BASE_URL`, `NEON_AI_GATEWAY_BASE_URL`).\n*/\nfunction asEnvBaseUrl(url) {\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(url);\n\t} catch {\n\t\tthrow new Error(`fetchEnv: function invocation URL is not a URL: ${JSON.stringify(url)}`);\n\t}\n\tif (parsed.protocol !== \"http:\" && parsed.protocol !== \"https:\") throw new Error(`fetchEnv: function invocation URL must be http(s): ${JSON.stringify(url)}`);\n\treturn parsed.origin;\n}\n/** Derived from the connection URI so undeployed functions have a cell-routed URL. */\nfunction functionInvocationUrl(branchId, slug, connectionUri) {\n\tconst suffix = connectionHostSuffix(connectionUri);\n\tif (suffix === \"\") throw new Error(`fetchEnv: cannot derive the invocation URL for function \"${slug}\": the direct connection URI has no host suffix.`);\n\treturn `https://${branchId}-${slug}.compute.${suffix}`;\n}\n/** The AI Gateway's bare base URL (`NEON_AI_GATEWAY_BASE_URL`) on the branch gateway host. */\nfunction aiGatewayBaseUrl(branchId, connectionUri) {\n\treturn `https://${aiGatewayHost(branchId, connectionUri)}`;\n}\nfunction createApiFromOptions(options) {\n\treturn createNeonApiFromOptions(\"fetchEnv\", {\n\t\t...options.apiKey ? { apiKey: options.apiKey } : {},\n\t\t...options.apiHost ? { apiHost: options.apiHost } : {}\n\t});\n}\n/**\n* Resolve a branch ref — a name or an id — to a concrete branch. Matches by id first\n* (exact `br-…`), then by name; both are unique within a project, so the lookup is\n* unambiguous. This lets `.neon` files written by `neonctl` (which pin the branch *name*)\n* and explicit `br-…` ids both work.\n*/\nfunction resolveBranch(branch, branches) {\n\tconst match = branches.find((b) => b.id === branch) ?? branches.find((b) => b.name === branch);\n\tif (match) return match;\n\tthrow new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: branch ${JSON.stringify(branch)} not found on project (matched by id or name).`, `Existing branches: ${branches.map((b) => `${b.name} (${b.id})`).join(\", \")}.`].join(\" \"), { details: {\n\t\tbranch,\n\t\tavailable: branches.map((b) => `${b.name} (${b.id})`)\n\t} });\n}\nfunction pickRoleName(roles, branch, requested) {\n\tif (requested) {\n\t\tif (!roles.some((r) => r.name === requested)) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: role \"${requested}\" not found on branch ${branch.name} (${branch.id}).`, `Existing roles: ${roles.map((r) => r.name).join(\", \") || \"(none)\"}.`].join(\" \"), { details: {\n\t\t\tbranchId: branch.id,\n\t\t\troleName: requested,\n\t\t\tavailableRoles: roles.map((r) => r.name)\n\t\t} });\n\t\treturn requested;\n\t}\n\tif (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 } });\n\tconst picked = defaultConnectionRole(roles.map((r) => r.name));\n\tif (picked) return picked;\n\tthrow 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: {\n\t\tbranchId: branch.id,\n\t\tavailableRoles: roles.map((r) => r.name)\n\t} });\n}\nfunction pickDatabaseName(databases, branch, requested) {\n\tif (requested) {\n\t\tif (!databases.some((d) => d.name === requested)) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: database \"${requested}\" not found on branch ${branch.name} (${branch.id}).`, `Existing databases: ${databases.map((d) => d.name).join(\", \") || \"(none)\"}.`].join(\" \"), { details: {\n\t\t\tbranchId: branch.id,\n\t\t\tdatabaseName: requested,\n\t\t\tavailableDatabases: databases.map((d) => d.name)\n\t\t} });\n\t\treturn requested;\n\t}\n\tif (databases.length === 0) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: branch ${branch.name} (${branch.id}) has no databases.`, \"Create one via the Neon console or pass `databaseName` explicitly.\"].join(\" \"), { details: { branchId: branch.id } });\n\tconst neondb = databases.find((d) => d.name === NEON_DEFAULT_DATABASE);\n\tif (neondb) return neondb.name;\n\tif (databases.length === 1) return databases[0].name;\n\tthrow new PlatformError(ErrorCode.AmbiguousBranchAuth, [`fetchEnv: branch ${branch.name} (${branch.id}) has ${databases.length} databases and none is named \"${NEON_DEFAULT_DATABASE}\"; cannot auto-pick.`, `Rename one to \"${NEON_DEFAULT_DATABASE}\" or keep a single database on the branch (or, when calling fetchEnv directly, pass \\`databaseName\\`). Available: ${databases.map((d) => d.name).join(\", \")}.`].join(\" \"), { details: {\n\t\tbranchId: branch.id,\n\t\tavailableDatabases: databases.map((d) => d.name)\n\t} });\n}\n/**\n* Project a fully-resolved {@link NeonEnv} into the OS-level `{ KEY: value }` pairs used\n* for cross-process transport. Named after the web-platform `.entries()` convention\n* (`URLSearchParams` / `Headers` / `FormData`); returns a `Record` rather than an\n* iterator of tuples since that's the shape env injection needs (wrap with\n* `Object.entries(...)` if you want literal `[key, value]` pairs). Used by `neon-env run`\n* to inject the vars into a subprocess's `process.env`.\n*\n* Walks the value at runtime so it works for any `NeonEnv<C>` regardless of which\n* conditional namespaces are present.\n*/\nfunction toEntries(env) {\n\tconst out = {};\n\tconst put = (key, value) => {\n\t\tif (value !== void 0) out[key] = value;\n\t};\n\tconst K = NEON_ENV_VAR_KEYS;\n\tput(K.postgres.databaseUrl, env.postgres?.databaseUrl);\n\tput(K.postgres.databaseUrlUnpooled, env.postgres?.databaseUrlUnpooled);\n\tput(K.branch.name, env.branch?.name);\n\tput(K.auth.baseUrl, env.auth?.baseUrl);\n\tput(K.auth.jwksUrl, env.auth?.jwksUrl);\n\tput(K.dataApi.url, env.dataApi?.url);\n\tput(K.realtime.url, env.realtime?.url);\n\tput(K.realtime.secret, env.realtime?.secret);\n\tput(K.storage.accessKeyId, env.storage?.accessKeyId);\n\tput(K.storage.secretAccessKey, env.storage?.secretAccessKey);\n\tput(K.storage.endpoint, env.storage?.endpoint);\n\tput(K.storage.region, env.storage?.region);\n\tput(K.aiGateway.apiKey, env.aiGateway?.apiKey);\n\tput(K.aiGateway.baseUrl, env.aiGateway?.baseUrl);\n\tif (env.functions) for (const slug of Object.keys(env.functions).sort()) put(functionBaseUrlKey(slug), env.functions[slug]?.baseUrl);\n\treturn out;\n}\nexport { NEON_ENV_VAR_KEYS, createApiFromOptions, credentialEnvKeys, credentialName, defaultAiGatewayCredential, defaultStorageCredential, fetchEnv, fetchEnvKeys, fetchEnvKeysState, functionBaseUrlKey, isFunctionBaseUrlKey, isLiveCredential, parseFunctionBaseUrlKey, policyEnvKeys, previewCredentialScopes, resolveBranchPolicy, toEntries };\n\n//# sourceMappingURL=env.js.map"],"mappings":";;;;;;AAKA,MAAM,0BAA0B;;;;;;;;AAQhC,MAAM,0CAA0C,IAAI,IAAI;CACvD;CACA;CACA;AACD,CAAC;;AAED,SAAS,sBAAsB,WAAW;CACzC,IAAI,UAAU,WAAW,GAAG,OAAO,UAAU;CAC7C,IAAI,UAAU,SAAS,cAAc,GAAG,OAAO;CAC/C,MAAM,WAAW,UAAU,QAAQ,SAAS,CAAC,wBAAwB,IAAI,IAAI,CAAC;CAC9E,OAAO,SAAS,WAAW,IAAI,SAAS,KAAK,KAAK;AACnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACKA,MAAM,wBAAwB;AAC9B,MAAM,oBAAoB;;;;;;CAMzB,QAAQ,EAAE,MAAM,cAAc;CAC9B,UAAU;EACT,aAAa;EACb,qBAAqB;CACtB;CACA,MAAM;EACL,SAAS;EACT,SAAS;CACV;CACA,SAAS,EAAE,KAAK,oBAAoB;CACpC,UAAU;EACT,KAAK;EACL,QAAQ;CACT;;;;;;CAMA,SAAS;EACR,aAAa;EACb,iBAAiB;EACjB,UAAU;EACV,QAAQ;CACT;;;;;;;;CAQA,WAAW;EACV,QAAQ;EACR,SAAS;CACV;AACD;AACA,MAAM,gBAAgB;AACtB,MAAM,wBAAwB;AAC9B,SAAS,mBAAmB,MAAM;CACjC,IAAI,CAA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K,EAAE,OAAO;CACnI,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"env.js","names":[],"sources":["../../../internals/env-core/dist/roles.js","../../../internals/env-core/dist/env.js"],"sourcesContent":["// src/roles.ts\n/**\n* Neon's default branch owner role, created with every project. This is the role a\n* `DATABASE_URL` should connect as.\n*/\nconst NEON_DEFAULT_OWNER_ROLE = \"neondb_owner\";\n/**\n* Roles Neon provisions for the Auth / Data API (PostgREST) stack. They exist to back\n* RLS-scoped Data API requests authenticated by JWT — never to hold a `DATABASE_URL` —\n* so they're skipped when auto-picking the connection role. Enabling Neon Auth or the\n* Data API (`neon config apply`) adds these next to the owner role, which is why a plain\n* branch routinely reports more than one role.\n*/\nconst NEON_MANAGED_AUTH_ROLES = /* @__PURE__ */ new Set([\n\t\"authenticator\",\n\t\"anonymous\",\n\t\"authenticated\"\n]);\n/** `undefined` when more than one app role remains (or none exist), so the caller has to ask. */\nfunction defaultConnectionRole(roleNames) {\n\tif (roleNames.length === 1) return roleNames[0];\n\tif (roleNames.includes(\"neondb_owner\")) return NEON_DEFAULT_OWNER_ROLE;\n\tconst appRoles = roleNames.filter((name) => !NEON_MANAGED_AUTH_ROLES.has(name));\n\treturn appRoles.length === 1 ? appRoles[0] : void 0;\n}\nexport { NEON_DEFAULT_OWNER_ROLE, defaultConnectionRole };\n\n//# sourceMappingURL=roles.js.map","import { NEON_DEFAULT_OWNER_ROLE, defaultConnectionRole } from \"./roles.js\";\nimport { ErrorCode, PlatformError, createNeonApiFromOptions, deriveCredentialScopes, resolveConfig } from \"@neon/config/v1\";\n// src/env.ts\n/**\n* The Neon env core — resolving a branch's env from the Neon API, and projecting it into\n* OS-level `{ KEY: value }` pairs.\n*\n* Private, and bundled into both consumers: `@neon/env` publishes it as `fetchEnv` /\n* `toEntries`, and the `neon` CLI needs the credential-reuse half in `reuse-secrets.ts`.\n* See `README.md` for why it is not published.\n*\n* The counterpart that reads `process.env` — `parseEnv` and its zod schemas — is not here. It\n* has no consumer outside `@neon/env`, so it stays in that package and imports this.\n*/\n/**\n* Mapping between the {@link NeonEnv} property paths and the OS-level env-var keys used\n* for cross-process transport (via `.env` files, `env run -- <cmd>`, or anything else\n* that talks to `process.env`).\n*\n* Each top-level key here is a {@link NeonEnv} namespace; the inner record maps the\n* camelCase property names exposed to TypeScript to the UPPER_SNAKE env-var names used\n* by the OS. Keep this in sync with {@link postgresEnvSchema} / {@link authEnvSchema} /\n* {@link dataApiEnvSchema} / {@link realtimeEnvSchema}.\n*/\n/**\n* Neon's default database, created with every project. When a branch has several databases\n* and none was requested, this is preferred for the `DATABASE_URL` so the common case (a\n* user added a second database next to `neondb`) auto-picks without asking.\n*/\nconst NEON_DEFAULT_DATABASE = \"neondb\";\n/**\n* Set only by `neon dev`: a JSON object mapping each function it serves to its localhost port,\n* which `functionBaseUrl` prefers over the deployed hostname.\n*/\nconst NEON_DEV_FUNCTION_PORTS = \"NEON_DEV_FUNCTION_PORTS\";\nconst NEON_ENV_VAR_KEYS = {\n\t/**\n\t* Branch identity. `NEON_BRANCH` carries the branch **name** and is injected into the\n\t* Neon Functions runtime on every branch (including the default) by default. `env pull` /\n\t* `neon dev` / `neon-env run` emit it too so local dev mirrors the deployed runtime.\n\t*/\n\tbranch: {\n\t\tname: \"NEON_BRANCH\",\n\t\tid: \"NEON_BRANCH_ID\",\n\t\t/**\n\t\t* Shared by every function on the branch, with a leading dot\n\t\t* (`.compute.c-2.us-east-2.aws.neon.tech`). A function's host is\n\t\t* `<NEON_BRANCH_ID>-<slug><NEON_FUNCTION_HOST_SUFFIX>`.\n\t\t*/\n\t\tfunctionHostSuffix: \"NEON_FUNCTION_HOST_SUFFIX\"\n\t},\n\tpostgres: {\n\t\tdatabaseUrl: \"DATABASE_URL\",\n\t\tdatabaseUrlUnpooled: \"DATABASE_URL_UNPOOLED\"\n\t},\n\tauth: {\n\t\tbaseUrl: \"NEON_AUTH_BASE_URL\",\n\t\tjwksUrl: \"NEON_AUTH_JWKS_URL\"\n\t},\n\tdataApi: { url: \"NEON_DATA_API_URL\" },\n\trealtime: {\n\t\turl: \"NEON_REALTIME_URL\",\n\t\tsecret: \"NEON_REALTIME_SECRET\"\n\t},\n\t/**\n\t* Object storage (Preview). The S3 SDKs read `AWS_*` from their standard config chain, so\n\t* a branch credential + `neon dev` / `env pull` makes object storage work from env alone.\n\t* `region` is injected under the SDK-standard `AWS_REGION`.\n\t*/\n\tstorage: {\n\t\taccessKeyId: \"AWS_ACCESS_KEY_ID\",\n\t\tsecretAccessKey: \"AWS_SECRET_ACCESS_KEY\",\n\t\tendpoint: \"AWS_ENDPOINT_URL_S3\",\n\t\tregion: \"AWS_REGION\"\n\t},\n\t/**\n\t* AI Gateway (Preview). Exposed under the Neon-branded env vars the deployed Functions\n\t* runtime injects: `apiKey` is the minted credential's bearer (`NEON_AI_GATEWAY_TOKEN`)\n\t* and `baseUrl` is the bare branch gateway host (`NEON_AI_GATEWAY_BASE_URL`,\n\t* `scheme://host`, no path). Clients like `@neon/ai-sdk-provider` read these and append the\n\t* dialect route (`/v1`, `/openai/v1`, `/anthropic/v1`) themselves (https://github.com/vercel/ai/pull/15997).\n\t*/\n\taiGateway: {\n\t\tapiKey: \"NEON_AI_GATEWAY_TOKEN\",\n\t\tbaseUrl: \"NEON_AI_GATEWAY_BASE_URL\"\n\t}\n};\nasync function fetchEnv(config, options) {\n\tif (options.keys) assertStorageCredentialKeyPair(options.keys);\n\treturn fetchEnvKeys(config, options, options.keys ?? null);\n}\nfunction assertStorageCredentialKeyPair(keys) {\n\tif (keys.includes(NEON_ENV_VAR_KEYS.storage.accessKeyId) === keys.includes(NEON_ENV_VAR_KEYS.storage.secretAccessKey)) return;\n\tthrow new TypeError(\"fetchEnv: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY must be selected together. Pass both in `keys`, or omit both.\");\n}\n/**\n* Starts a read now and keeps an unread rejection from crashing the process; the caller\n* awaits it (and sees the error) when its turn comes. The read is called synchronously and\n* its own promise returned, so errors surface in the same order as a direct call; a\n* synchronous throw becomes the returned rejection.\n*/\nfunction started(read) {\n\tlet promise;\n\ttry {\n\t\tpromise = read();\n\t} catch (error) {\n\t\tpromise = Promise.reject(error);\n\t}\n\tpromise.catch(() => void 0);\n\treturn promise;\n}\n/** Fail loudly when selected-key dependency planning and execution disagree. */\nfunction requiredValue(value, description) {\n\tif (value === null) throw new Error(`fetchEnv: missing ${description}.`);\n\treturn value;\n}\nconst REALTIME_POLL_INTERVAL_MS = 1e3;\n/**\n* Wait for asynchronous Realtime provisioning/rotation before reading its secret. The\n* secret endpoint deliberately returns 404 until provisioning finishes, and during a\n* rotation it can still expose the previous key while `pending` is true.\n*/\nasync function resolveRealtimeEnv(args) {\n\tconst getRealtime = args.api.getProjectBranchRealtime;\n\tif (!getRealtime) throw new PlatformError(ErrorCode.FeatureUnavailable, \"fetchEnv cannot resolve Realtime: this NeonApi adapter does not implement getProjectBranchRealtime.\");\n\tconst getSecret = args.api.getProjectBranchRealtimeSecret;\n\tlet resolvedEnv;\n\twhile (resolvedEnv === void 0) {\n\t\tconst snapshot = await getRealtime.call(args.api, args.projectId, args.branch.id);\n\t\tif (!snapshot.pending) {\n\t\t\tif (!snapshot.enabled) throw new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy enables realtime but Realtime is disabled on branch ${args.branch.name} (${args.branch.id}).`, \"Enable it via `apply(config, { projectId, branchId })` (or `npx neon deploy`) and re-run fetchEnv. Or set realtime to false or omit it.\"].join(\" \"), { details: {\n\t\t\t\tprojectId: args.projectId,\n\t\t\t\tbranchId: args.branch.id\n\t\t\t} });\n\t\t\tlet secret;\n\t\t\tif (args.wantsSecret) {\n\t\t\t\tif (!getSecret) throw new PlatformError(ErrorCode.FeatureUnavailable, \"fetchEnv cannot resolve NEON_REALTIME_SECRET: this NeonApi adapter does not implement getProjectBranchRealtimeSecret.\");\n\t\t\t\tsecret = await getSecret.call(args.api, args.projectId, args.branch.id);\n\t\t\t}\n\t\t\tif (!secret?.pending) resolvedEnv = {\n\t\t\t\t...args.wantsUrl ? { url: realtimeWebSocketUrl(requiredRealtimeInvocationUrl(snapshot, args.branch)) } : {},\n\t\t\t\t...secret ? { secret: secret.secret } : {}\n\t\t\t};\n\t\t}\n\t\tif (resolvedEnv === void 0) await new Promise((resolve) => setTimeout(resolve, REALTIME_POLL_INTERVAL_MS));\n\t}\n\treturn resolvedEnv;\n}\nfunction requiredRealtimeInvocationUrl(snapshot, branch) {\n\tif (snapshot.invocationUrl !== void 0 && snapshot.invocationUrl !== \"\") return snapshot.invocationUrl;\n\tthrow new PlatformError(ErrorCode.ServerError, `Realtime is enabled on branch ${branch.name} (${branch.id}), but the Neon API returned no invocation URL.`, { details: { branchId: branch.id } });\n}\n/** Normalize the control-plane invocation URL to the WebSocket URL the client SDK needs. */\nfunction realtimeWebSocketUrl(value) {\n\tlet parsed;\n\ttry {\n\t\tparsed = new URL(value);\n\t} catch {\n\t\tthrow new PlatformError(ErrorCode.ServerError, `Realtime invocation URL is invalid: ${JSON.stringify(value)}.`);\n\t}\n\tif (parsed.protocol === \"https:\") parsed.protocol = \"wss:\";\n\telse if (parsed.protocol === \"http:\") parsed.protocol = \"ws:\";\n\telse if (parsed.protocol !== \"wss:\" && parsed.protocol !== \"ws:\") throw new PlatformError(ErrorCode.ServerError, `Realtime invocation URL must use http(s) or ws(s): ${JSON.stringify(value)}.`);\n\treturn parsed.toString();\n}\n/**\n* The {@link fetchEnv} body, with the key selection as a plain argument and no generic\n* narrowing. Exists for callers that compute the selection at runtime — notably\n* {@link fetchEnvReusingSecrets}, which decides which keys it still needs by checking the\n* branch — since the public overload's `keys` is bound to a literal union those callers cannot\n* produce without asserting.\n*\n* `keys === null` selects everything the policy enables.\n*/\nasync function fetchEnvKeys(config, options, keys) {\n\treturn (await fetchEnvKeysState(config, options, keys)).env;\n}\n/**\n* `policy` is the {@link resolveBranchPolicy} result for this same `config` and branch, when\n* the caller already has it.\n*/\nasync function fetchEnvKeysState(config, options, keys, policy) {\n\tconst api = options.api ?? createApiFromOptions(options);\n\tconst projectId = options.projectId;\n\tconst { branch, desired } = policy ?? await resolveBranchPolicy(config, options, api);\n\tconst selection = keys ? new Set(keys) : null;\n\tconst omitted = new Set(options.omitKeys ?? []);\n\tconst wants = (key) => !omitted.has(key) && (selection === null || selection.has(key));\n\tconst result = {};\n\tconst K = NEON_ENV_VAR_KEYS;\n\tconst wantsPooled = wants(K.postgres.databaseUrl);\n\tconst wantsUnpooled = wants(K.postgres.databaseUrlUnpooled);\n\tconst wantsAuth = desired.authEnabled && (wants(K.auth.baseUrl) || wants(K.auth.jwksUrl));\n\tconst wantsDataApi = desired.dataApiEnabled && wants(K.dataApi.url);\n\tconst wantsRealtime = desired.realtimePolicy === \"enabled\" && (wants(K.realtime.url) || wants(K.realtime.secret));\n\tconst gatewayEnabled = desired.preview?.aiGatewayEnabled ?? false;\n\tconst wantsFunctionHostSuffix = wants(K.branch.functionHostSuffix) && (selection !== null || options.functionHostSuffix === \"always\" || (desired.preview?.functions.length ?? 0) > 0);\n\tconst storageEnabled = (desired.preview?.buckets.length ?? 0) > 0;\n\tconst wantsStorage = storageEnabled && (wants(K.storage.accessKeyId) || wants(K.storage.secretAccessKey) || wants(K.storage.endpoint) || wants(K.storage.region));\n\tconst needsUnpooled = wantsUnpooled || gatewayEnabled && wants(K.aiGateway.baseUrl);\n\tconst needsConnectionTarget = wantsPooled || needsUnpooled;\n\tconst storageRead = wantsStorage ? started(() => api.getProjectBranchStorage(projectId, branch.id)) : null;\n\tconst endpointsRead = wantsFunctionHostSuffix && !needsConnectionTarget ? started(() => api.listEndpoints(projectId)) : null;\n\tconst needsDatabase = needsConnectionTarget || wantsDataApi;\n\tconst [roles, databases] = await Promise.all([needsConnectionTarget ? api.listBranchRoles(projectId, branch.id) : Promise.resolve([]), needsDatabase ? api.listBranchDatabases(projectId, branch.id) : Promise.resolve([])]);\n\tconst databaseName = needsDatabase ? pickDatabaseName(databases, branch, options.databaseName) : null;\n\tconst connectionTarget = needsConnectionTarget ? {\n\t\troleName: pickRoleName(roles, branch, options.roleName),\n\t\tdatabaseName: requiredValue(databaseName, \"database for a selected connection URI\")\n\t} : null;\n\tconst getConnectionUri = (pooled) => {\n\t\tconst target = requiredValue(connectionTarget, \"role and database for a selected connection URI\");\n\t\treturn api.getConnectionUri(projectId, {\n\t\t\tbranchId: branch.id,\n\t\t\t...target,\n\t\t\tpooled\n\t\t});\n\t};\n\tconst [pooled, unpooled, authSnapshot, dataApiSnapshot] = await Promise.all([\n\t\twantsPooled ? getConnectionUri(true) : Promise.resolve(null),\n\t\tneedsUnpooled ? getConnectionUri(false) : Promise.resolve(null),\n\t\twantsAuth ? api.getNeonAuth(projectId, branch.id) : Promise.resolve(null),\n\t\twantsDataApi ? api.getNeonDataApi(projectId, branch.id, requiredValue(databaseName, \"database for the selected Data API URL\")) : Promise.resolve(null)\n\t]);\n\tconst postgres = {};\n\tif (wantsPooled) postgres.databaseUrl = requiredValue(pooled, \"pooled connection URI response\").uri;\n\tif (wantsUnpooled) postgres.databaseUrlUnpooled = requiredValue(unpooled, \"direct connection URI response\").uri;\n\tif (Object.keys(postgres).length > 0) result.postgres = postgres;\n\tif (wants(K.branch.name) || wants(K.branch.id) || wantsFunctionHostSuffix) {\n\t\tconst branchEnv = {};\n\t\tif (wants(K.branch.name)) branchEnv.name = branch.name;\n\t\tif (wants(K.branch.id)) branchEnv.id = branch.id;\n\t\tif (wantsFunctionHostSuffix) {\n\t\t\tconst connectionUri = unpooled?.uri ?? pooled?.uri;\n\t\t\tbranchEnv.functionHostSuffix = functionHostSuffix(connectionUri !== void 0 ? new URL(connectionUri).hostname : branchComputeHost(await requiredValue(endpointsRead, \"branch endpoint list\"), branch));\n\t\t}\n\t\tresult.branch = branchEnv;\n\t}\n\tif (wantsAuth) {\n\t\tif (!authSnapshot) throw new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy enables auth but no Neon Auth integration is enabled on branch ${branch.name} (${branch.id}).`, \"Enable it via `apply(config, { projectId, branchId })` (or `npx neon …`), in the Neon Console — then re-run fetchEnv. Or return auth.enabled=false.\"].join(\" \"), { details: {\n\t\t\tprojectId,\n\t\t\tbranchId: branch.id\n\t\t} });\n\t\tconst auth = {};\n\t\tif (wants(K.auth.baseUrl)) auth.baseUrl = authSnapshot.baseUrl ?? \"\";\n\t\tif (wants(K.auth.jwksUrl)) auth.jwksUrl = authSnapshot.jwksUrl ?? \"\";\n\t\tresult.auth = auth;\n\t}\n\tif (wantsDataApi) {\n\t\tif (!dataApiSnapshot) {\n\t\t\tconst selectedDatabase = requiredValue(databaseName, \"database for the selected Data API URL\");\n\t\t\tthrow new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy enables dataApi but no Data API integration is enabled on branch ${branch.name} (${branch.id}) database ${selectedDatabase}.`, \"Enable it via `apply(config, { projectId, branchId })` or in the Neon Console — then re-run fetchEnv. Or return dataApi.enabled=false.\"].join(\" \"), { details: {\n\t\t\t\tprojectId,\n\t\t\t\tbranchId: branch.id,\n\t\t\t\tdatabaseName: selectedDatabase\n\t\t\t} });\n\t\t}\n\t\tresult.dataApi = { url: dataApiSnapshot.url };\n\t}\n\tif (wantsRealtime) {\n\t\tconst realtime = await resolveRealtimeEnv({\n\t\t\tapi,\n\t\t\tprojectId,\n\t\t\tbranch,\n\t\t\twantsUrl: wants(K.realtime.url),\n\t\t\twantsSecret: wants(K.realtime.secret)\n\t\t});\n\t\tconst realtimeEnv = {};\n\t\tif (wants(K.realtime.url)) realtimeEnv.url = requiredValue(realtime.url, \"WebSocket URL for enabled Realtime\");\n\t\tif (wants(K.realtime.secret)) realtimeEnv.secret = requiredValue(realtime.secret, \"shared secret for enabled Realtime\");\n\t\tresult.realtime = realtimeEnv;\n\t}\n\tconst wantsGateway = gatewayEnabled && (wants(K.aiGateway.apiKey) || wants(K.aiGateway.baseUrl));\n\tconst wantsStorageCredential = storageEnabled && (wants(K.storage.accessKeyId) || wants(K.storage.secretAccessKey));\n\tconst wantsGatewayCredential = gatewayEnabled && wants(K.aiGateway.apiKey);\n\tconst wantsCredential = wantsStorageCredential || wantsGatewayCredential;\n\tif (wantsStorage || wantsGateway) {\n\t\tlet storage = null;\n\t\tif (wantsStorage) {\n\t\t\tstorage = await requiredValue(storageRead, \"storage read\");\n\t\t\tif (!storage) throw new PlatformError(ErrorCode.NotFound, [`fetchEnv: branch policy declares object storage (buckets) but storage is not enabled on branch ${branch.name} (${branch.id}).`, \"Enable it via `apply(config, { projectId, branchId })` (or in the Neon Console) — then re-run fetchEnv. Or remove buckets.\"].join(\" \"), { details: {\n\t\t\t\tprojectId,\n\t\t\t\tbranchId: branch.id\n\t\t\t} });\n\t\t}\n\t\tconst secrets = wantsCredential ? await resolveBranchCredentialSecrets({\n\t\t\tapi,\n\t\t\tprojectId,\n\t\t\tbranchId: branch.id,\n\t\t\tbranchName: branch.name,\n\t\t\tscopes: previewCredentialScopes(desired.preview, {\n\t\t\t\tstorage: wantsStorageCredential,\n\t\t\t\taiGateway: wantsGatewayCredential\n\t\t\t})\n\t\t}) : null;\n\t\tif (storage) {\n\t\t\tconst storageEnv = {};\n\t\t\tif (secrets && wants(K.storage.accessKeyId)) storageEnv.accessKeyId = secrets.accessKeyId;\n\t\t\tif (secrets && wants(K.storage.secretAccessKey)) storageEnv.secretAccessKey = secrets.secretAccessKey;\n\t\t\tif (wants(K.storage.endpoint)) storageEnv.endpoint = storage.s3Endpoint;\n\t\t\tif (wants(K.storage.region)) storageEnv.region = storage.region;\n\t\t\tresult.storage = storageEnv;\n\t\t}\n\t\tif (wantsGateway) {\n\t\t\tconst gateway = {};\n\t\t\tif (secrets && wants(K.aiGateway.apiKey)) gateway.apiKey = secrets.apiToken;\n\t\t\tif (wants(K.aiGateway.baseUrl)) gateway.baseUrl = aiGatewayBaseUrl(branch.id, requiredValue(unpooled, \"direct connection URI for the selected AI Gateway base URL\").uri);\n\t\t\tresult.aiGateway = gateway;\n\t\t}\n\t}\n\treturn { env: result };\n}\n/**\n* Resolve the target branch and evaluate the policy against it — the first thing any\n* branch-scoped operation needs. Shared by {@link fetchEnv} and {@link fetchEnvReusingSecrets}\n* so the two agree on which branch they're talking about and what it has enabled.\n*/\nasync function resolveBranchPolicy(config, options, api, resolved) {\n\tconst branch = resolved ?? await listAndResolveBranch(options, api);\n\treturn {\n\t\tbranch,\n\t\tdesired: resolveConfig(config, {\n\t\t\tname: branch.name,\n\t\t\tid: branch.id,\n\t\t\texists: true,\n\t\t\t...branch.parentId ? { parentId: branch.parentId } : {},\n\t\t\tisDefault: branch.isDefault,\n\t\t\tisProtected: branch.protected,\n\t\t\t...branch.expiresAt ? { expiresAt: branch.expiresAt } : {}\n\t\t})\n\t};\n}\nasync function listAndResolveBranch(options, api) {\n\tconst projectId = options.projectId;\n\tconst branches = await api.listBranches(projectId);\n\tif (branches.length === 0) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: project ${projectId} has no branches.`, \"Deploy your neon.ts policy (or create a branch) first, or pick a different project id.\"].join(\" \"), { details: { projectId } });\n\tconst branchRef = options.branch ?? options.branchId;\n\tif (!branchRef) throw new PlatformError(ErrorCode.BranchNotFound, [\"fetchEnv: no branch provided.\", \"Pass `branch` with a branch name (e.g. `main`) or id (`br-…`).\"].join(\" \"), { details: { projectId } });\n\treturn resolveBranch(branchRef, branches);\n}\n/**\n* Scopes a minted fallback credential should carry. Only object storage and the AI Gateway\n* *require* secrets; functions never force a credential. `functions:invoke` rides along only\n* when this path still has to mint (defaults already cover storage and the gateway).\n*/\nfunction previewCredentialScopes(preview, selected) {\n\tif (!preview) return [];\n\tconst storage = preview.buckets.length > 0 && (selected?.storage ?? true);\n\tconst aiGateway = preview.aiGatewayEnabled && (selected?.aiGateway ?? true);\n\tif (!storage && !aiGateway) return [];\n\treturn deriveCredentialScopes({\n\t\tstorage,\n\t\taiGateway,\n\t\tfunctions: preview.functions.length > 0\n\t});\n}\n/** The `name` this tool stamps on every credential it mints, so it can recognize its own. */\nfunction credentialName(branchName) {\n\treturn `neon-env ${branchName}`;\n}\n/** The env-var keys a branch credential's secrets surface under, in emit order. */\nfunction credentialEnvKeys(flags) {\n\treturn [...flags.storage ? [NEON_ENV_VAR_KEYS.storage.accessKeyId, NEON_ENV_VAR_KEYS.storage.secretAccessKey] : [], ...flags.aiGateway ? [NEON_ENV_VAR_KEYS.aiGateway.apiKey] : []];\n}\n/**\n* Every OS-level env var a resolved branch policy produces, in emit order. Lets a caller\n* subtract the ones it already holds and pass the rest as {@link fetchEnv}'s `keys`, without\n* re-deriving which vars a policy implies.\n*/\nfunction policyEnvKeys(desired) {\n\tconst K = NEON_ENV_VAR_KEYS;\n\treturn [\n\t\tK.postgres.databaseUrl,\n\t\tK.postgres.databaseUrlUnpooled,\n\t\tK.branch.name,\n\t\tK.branch.id,\n\t\t...(desired.preview?.functions.length ?? 0) > 0 ? [K.branch.functionHostSuffix] : [],\n\t\t...desired.authEnabled ? [K.auth.baseUrl, K.auth.jwksUrl] : [],\n\t\t...desired.dataApiEnabled ? [K.dataApi.url] : [],\n\t\t...desired.realtimePolicy === \"enabled\" ? [K.realtime.url, K.realtime.secret] : [],\n\t\t...(desired.preview?.buckets.length ?? 0) > 0 ? [\n\t\t\tK.storage.accessKeyId,\n\t\t\tK.storage.secretAccessKey,\n\t\t\tK.storage.endpoint,\n\t\t\tK.storage.region\n\t\t] : [],\n\t\t...desired.preview?.aiGatewayEnabled ? [K.aiGateway.apiKey, K.aiGateway.baseUrl] : []\n\t];\n}\n/** Exact `name` values the credentials list endpoint returns for the platform defaults. */\nconst DEFAULT_AI_GATEWAY_CREDENTIAL_NAME = \"Default AI gateway credential\";\nconst DEFAULT_OBJECT_STORAGE_CREDENTIAL_NAME = \"Default object storage credential\";\n/** Whether an issued credential can still be used: not revoked, not past its expiry. */\nfunction isLiveCredential(meta, now) {\n\tif (meta.revokedAt !== void 0) return false;\n\tif (meta.expiresAt === void 0) return true;\n\tconst expiresAt = Date.parse(meta.expiresAt);\n\treturn Number.isNaN(expiresAt) || expiresAt > now;\n}\nfunction defaultStorageCredential(live, now) {\n\treturn live.find((meta) => meta.name === DEFAULT_OBJECT_STORAGE_CREDENTIAL_NAME && isLiveCredential(meta, now)) ?? null;\n}\nfunction defaultAiGatewayCredential(live, now) {\n\treturn live.find((meta) => meta.name === DEFAULT_AI_GATEWAY_CREDENTIAL_NAME && isLiveCredential(meta, now)) ?? null;\n}\n/**\n* Resolve secrets for object storage / the AI Gateway.\n*\n* Regions that expose those products already have platform defaults on every branch.\n* Reveal those by exact name instead of minting a combined `neon-env ${branch}` credential.\n* Mint only the half (or both) that has no default — regions without the credentials\n* endpoint still fail at list, same as before.\n*\n* A caller that already holds secrets for those defaults should leave the secret keys out\n* of `keys` (see {@link fetchEnvReusingSecrets}) instead of revealing them again.\n*/\nasync function resolveBranchCredentialSecrets(args) {\n\tconst needsStorage = args.scopes.includes(\"storage:read\") || args.scopes.includes(\"storage:write\");\n\tconst needsGateway = args.scopes.includes(\"ai_gateway:invoke\");\n\tconst live = await args.api.listCredentials(args.projectId, args.branchId);\n\tconst now = Date.now();\n\tconst storageDefault = defaultStorageCredential(live, now);\n\tconst gatewayDefault = defaultAiGatewayCredential(live, now);\n\tconst secrets = {\n\t\taccessKeyId: \"\",\n\t\tsecretAccessKey: \"\",\n\t\tapiToken: \"\"\n\t};\n\tconst storageReveal = needsStorage && storageDefault ? started(() => args.api.revealCredential(args.projectId, args.branchId, storageDefault.tokenId)) : null;\n\tconst gatewayReveal = needsGateway && gatewayDefault ? started(() => args.api.revealCredential(args.projectId, args.branchId, gatewayDefault.tokenId)) : null;\n\tif (storageReveal) {\n\t\tconst revealed = await storageReveal;\n\t\tsecrets.accessKeyId = revealed.tokenId;\n\t\tsecrets.secretAccessKey = revealed.s3SecretAccessKey;\n\t}\n\tif (gatewayReveal) secrets.apiToken = (await gatewayReveal).apiToken;\n\tconst missingStorage = needsStorage && storageDefault === null;\n\tconst missingGateway = needsGateway && gatewayDefault === null;\n\tif (missingStorage || missingGateway) {\n\t\tconst minted = await mintBranchCredential({\n\t\t\t...args,\n\t\t\tscopes: deriveCredentialScopes({\n\t\t\t\tstorage: missingStorage,\n\t\t\t\taiGateway: missingGateway,\n\t\t\t\tfunctions: args.scopes.includes(\"functions:invoke\")\n\t\t\t})\n\t\t});\n\t\tif (missingStorage) {\n\t\t\tsecrets.accessKeyId = minted.accessKeyId;\n\t\t\tsecrets.secretAccessKey = minted.secretAccessKey;\n\t\t}\n\t\tif (missingGateway) secrets.apiToken = minted.apiToken;\n\t}\n\treturn secrets;\n}\nasync function mintBranchCredential(args) {\n\tconst minted = await args.api.createCredential(args.projectId, args.branchId, {\n\t\tscopes: args.scopes,\n\t\tprincipalType: \"user\",\n\t\tname: credentialName(args.branchName)\n\t});\n\treturn {\n\t\taccessKeyId: minted.tokenId,\n\t\tsecretAccessKey: minted.s3SecretAccessKey,\n\t\tapiToken: minted.apiToken\n\t};\n}\n/**\n* The AI Gateway is a **branch-scoped host** — `<branchId>-api.ai.<host-suffix>` — NOT the\n* control-plane API origin. Derive the suffix from the branch's own Postgres connection host\n* by dropping only the endpoint label (the first segment) and keeping everything after it,\n* including any infra cell prefix (`c-N.`): a connection host of\n* `ep-x.c-3.us-east-2.aws.neon.tech` yields the gateway host\n* `<branchId>-api.ai.c-3.us-east-2.aws.neon.tech`. The cell prefix is **load-bearing** —\n* the gateway is cell-routed, so dropping `c-N.` resolves to the wrong (or no) host.\n*\n* Function invocation URLs use the same suffix: `<branchId>-<slug>.compute.<suffix>`.\n*/\nfunction connectionHostSuffix(connectionUri) {\n\tlet connectionHost = \"\";\n\ttry {\n\t\tconnectionHost = new URL(connectionUri).hostname;\n\t} catch {\n\t\tconnectionHost = \"\";\n\t}\n\treturn connectionHost.split(\".\").slice(1).join(\".\");\n}\nfunction aiGatewayHost(branchId, connectionUri) {\n\treturn `${branchId}-api.ai.${connectionHostSuffix(connectionUri)}`;\n}\n/**\n* `NEON_FUNCTION_HOST_SUFFIX` from a compute host: the endpoint label is replaced by\n* `compute`, as the Functions runtime does (`.compute.c-2.us-east-2.aws.neon.tech`).\n*/\nfunction functionHostSuffix(computeHost) {\n\tconst suffix = computeHost.split(\".\").slice(1).join(\".\");\n\tif (suffix === \"\") throw new Error(`fetchEnv: cannot derive NEON_FUNCTION_HOST_SUFFIX from compute host ${JSON.stringify(computeHost)}.`);\n\treturn `.compute.${suffix}`;\n}\n/** The branch's read-write compute host, else its first compute host. */\nfunction branchComputeHost(endpoints, branch) {\n\tconst own = endpoints.filter((endpoint) => endpoint.branchId === branch.id);\n\tconst endpoint = own.find((candidate) => candidate.type === \"read_write\") ?? own[0];\n\tif (!endpoint?.host) throw new PlatformError(ErrorCode.NotFound, `fetchEnv: branch ${branch.name} (${branch.id}) has no compute endpoint, so NEON_FUNCTION_HOST_SUFFIX cannot be derived. Add a compute to the branch, then re-run.`, { details: { branchId: branch.id } });\n\treturn endpoint.host;\n}\n/** The AI Gateway's bare base URL (`NEON_AI_GATEWAY_BASE_URL`) on the branch gateway host. */\nfunction aiGatewayBaseUrl(branchId, connectionUri) {\n\treturn `https://${aiGatewayHost(branchId, connectionUri)}`;\n}\nfunction createApiFromOptions(options) {\n\treturn createNeonApiFromOptions(\"fetchEnv\", {\n\t\t...options.apiKey ? { apiKey: options.apiKey } : {},\n\t\t...options.apiHost ? { apiHost: options.apiHost } : {}\n\t});\n}\n/**\n* Resolve a branch ref — a name or an id — to a concrete branch. Matches by id first\n* (exact `br-…`), then by name; both are unique within a project, so the lookup is\n* unambiguous. This lets `.neon` files written by `neonctl` (which pin the branch *name*)\n* and explicit `br-…` ids both work.\n*/\nfunction resolveBranch(branch, branches) {\n\tconst match = branches.find((b) => b.id === branch) ?? branches.find((b) => b.name === branch);\n\tif (match) return match;\n\tthrow new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: branch ${JSON.stringify(branch)} not found on project (matched by id or name).`, `Existing branches: ${branches.map((b) => `${b.name} (${b.id})`).join(\", \")}.`].join(\" \"), { details: {\n\t\tbranch,\n\t\tavailable: branches.map((b) => `${b.name} (${b.id})`)\n\t} });\n}\nfunction pickRoleName(roles, branch, requested) {\n\tif (requested) {\n\t\tif (!roles.some((r) => r.name === requested)) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: role \"${requested}\" not found on branch ${branch.name} (${branch.id}).`, `Existing roles: ${roles.map((r) => r.name).join(\", \") || \"(none)\"}.`].join(\" \"), { details: {\n\t\t\tbranchId: branch.id,\n\t\t\troleName: requested,\n\t\t\tavailableRoles: roles.map((r) => r.name)\n\t\t} });\n\t\treturn requested;\n\t}\n\tif (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 } });\n\tconst picked = defaultConnectionRole(roles.map((r) => r.name));\n\tif (picked) return picked;\n\tthrow 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: {\n\t\tbranchId: branch.id,\n\t\tavailableRoles: roles.map((r) => r.name)\n\t} });\n}\nfunction pickDatabaseName(databases, branch, requested) {\n\tif (requested) {\n\t\tif (!databases.some((d) => d.name === requested)) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: database \"${requested}\" not found on branch ${branch.name} (${branch.id}).`, `Existing databases: ${databases.map((d) => d.name).join(\", \") || \"(none)\"}.`].join(\" \"), { details: {\n\t\t\tbranchId: branch.id,\n\t\t\tdatabaseName: requested,\n\t\t\tavailableDatabases: databases.map((d) => d.name)\n\t\t} });\n\t\treturn requested;\n\t}\n\tif (databases.length === 0) throw new PlatformError(ErrorCode.BranchNotFound, [`fetchEnv: branch ${branch.name} (${branch.id}) has no databases.`, \"Create one via the Neon console or pass `databaseName` explicitly.\"].join(\" \"), { details: { branchId: branch.id } });\n\tconst neondb = databases.find((d) => d.name === NEON_DEFAULT_DATABASE);\n\tif (neondb) return neondb.name;\n\tif (databases.length === 1) return databases[0].name;\n\tthrow new PlatformError(ErrorCode.AmbiguousBranchAuth, [`fetchEnv: branch ${branch.name} (${branch.id}) has ${databases.length} databases and none is named \"${NEON_DEFAULT_DATABASE}\"; cannot auto-pick.`, `Rename one to \"${NEON_DEFAULT_DATABASE}\" or keep a single database on the branch (or, when calling fetchEnv directly, pass \\`databaseName\\`). Available: ${databases.map((d) => d.name).join(\", \")}.`].join(\" \"), { details: {\n\t\tbranchId: branch.id,\n\t\tavailableDatabases: databases.map((d) => d.name)\n\t} });\n}\n/**\n* Project a fully-resolved {@link NeonEnv} into the OS-level `{ KEY: value }` pairs used\n* for cross-process transport. Named after the web-platform `.entries()` convention\n* (`URLSearchParams` / `Headers` / `FormData`); returns a `Record` rather than an\n* iterator of tuples since that's the shape env injection needs (wrap with\n* `Object.entries(...)` if you want literal `[key, value]` pairs). Used by `neon-env run`\n* to inject the vars into a subprocess's `process.env`.\n*\n* Walks the value at runtime so it works for any `NeonEnv<C>` regardless of which\n* conditional namespaces are present.\n*/\nfunction toEntries(env) {\n\tconst out = {};\n\tconst put = (key, value) => {\n\t\tif (value !== void 0) out[key] = value;\n\t};\n\tconst K = NEON_ENV_VAR_KEYS;\n\tput(K.postgres.databaseUrl, env.postgres?.databaseUrl);\n\tput(K.postgres.databaseUrlUnpooled, env.postgres?.databaseUrlUnpooled);\n\tput(K.branch.name, env.branch?.name);\n\tput(K.branch.id, env.branch?.id);\n\tput(K.branch.functionHostSuffix, env.branch?.functionHostSuffix);\n\tput(K.auth.baseUrl, env.auth?.baseUrl);\n\tput(K.auth.jwksUrl, env.auth?.jwksUrl);\n\tput(K.dataApi.url, env.dataApi?.url);\n\tput(K.realtime.url, env.realtime?.url);\n\tput(K.realtime.secret, env.realtime?.secret);\n\tput(K.storage.accessKeyId, env.storage?.accessKeyId);\n\tput(K.storage.secretAccessKey, env.storage?.secretAccessKey);\n\tput(K.storage.endpoint, env.storage?.endpoint);\n\tput(K.storage.region, env.storage?.region);\n\tput(K.aiGateway.apiKey, env.aiGateway?.apiKey);\n\tput(K.aiGateway.baseUrl, env.aiGateway?.baseUrl);\n\treturn out;\n}\nexport { NEON_DEV_FUNCTION_PORTS, NEON_ENV_VAR_KEYS, createApiFromOptions, credentialEnvKeys, credentialName, defaultAiGatewayCredential, defaultStorageCredential, fetchEnv, fetchEnvKeys, fetchEnvKeysState, isLiveCredential, policyEnvKeys, previewCredentialScopes, resolveBranchPolicy, toEntries };\n\n//# sourceMappingURL=env.js.map"],"mappings":";;;;;;AAKA,MAAM,0BAA0B;;;;;;;;AAQhC,MAAM,0CAA0C,IAAI,IAAI;CACvD;CACA;CACA;AACD,CAAC;;AAED,SAAS,sBAAsB,WAAW;CACzC,IAAI,UAAU,WAAW,GAAG,OAAO,UAAU;CAC7C,IAAI,UAAU,SAAS,cAAc,GAAG,OAAO;CAC/C,MAAM,WAAW,UAAU,QAAQ,SAAS,CAAC,wBAAwB,IAAI,IAAI,CAAC;CAC9E,OAAO,SAAS,WAAW,IAAI,SAAS,KAAK,KAAK;AACnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACKA,MAAM,wBAAwB;;;;;AAK9B,MAAM,0BAA0B;AAChC,MAAM,oBAAoB;;;;;;CAMzB,QAAQ;EACP,MAAM;EACN,IAAI;;;;;;EAMJ,oBAAoB;CACrB;CACA,UAAU;EACT,aAAa;EACb,qBAAqB;CACtB;CACA,MAAM;EACL,SAAS;EACT,SAAS;CACV;CACA,SAAS,EAAE,KAAK,oBAAoB;CACpC,UAAU;EACT,KAAK;EACL,QAAQ;CACT;;;;;;CAMA,SAAS;EACR,aAAa;EACb,iBAAiB;EACjB,UAAU;EACV,QAAQ;CACT;;;;;;;;CAQA,WAAW;EACV,QAAQ;EACR,SAAS;CACV;AACD;AACA,eAAe,SAAS,QAAQ,SAAS;CACxC,IAAI,QAAQ,MAAM,+BAA+B,QAAQ,IAAI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