@neondatabase/env 1.1.5 → 1.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["Config","CredentialScope","NeonApi","NeonBranchSnapshot","ResolvedPreviewConfig","resolveConfig","NEON_ENV_VAR_KEYS","NeonBranchEnv","NeonPostgresEnv","NeonAuthEnv","NeonDataApiEnv","NeonStorageEnv","NeonAiGatewayEnv","NoNamespace","Record","ServiceOn","T","HasKeys","HasBuckets","C","NonNullable","B","AiGatewayOn","A","NeonEnv","EnvKeysByNamespace","NamespaceEnv","EnvKeyToProp","SelectableEnvKey","FilteredNeonEnv","K","N","Extract","P","OptionalFilteredNeonEnv","IsUnion","Whole","TupleHasUnion","Head","Tail","SelectedNeonEnv","Keys","StorageCredentialEnvKey","StorageKeyPairError","TupleDefinitelyContains","Key","TupleDefinitelyContainsStoragePair","InvalidStorageKeyTuple","StorageKeyPairConstraint","FetchEnvKeysFromArgs","Args","StorageKeyPairArgsConstraint","StorageKeyUnionConstraint","FetchEnvOptions","fetchEnv","NoInfer","Promise","fetchEnvKeys","ResolvedNeonEnv","resolveBranchPolicy","Pick","ReturnType","previewCredentialScopes","credentialName","credentialEnvKeys","policyEnvKeys","createApiFromOptions","toEntries","Partial"],"sources":["../../../internals/env-core/dist/env.d.ts","../src/lib/parse-env.ts"],"sourcesContent":["import { Config, CredentialScope, NeonApi, NeonBranchSnapshot, ResolvedPreviewConfig, resolveConfig } from \"@neon/config/v1\";\n\n//#region src/env.d.ts\n\ndeclare const NEON_ENV_VAR_KEYS: {\n /**\n * Branch identity. `NEON_BRANCH` carries the branch **name** and is injected into the\n * Neon Functions runtime on every branch (including the default) by default. `env pull` /\n * `neon dev` / `neon-env run` emit it too so local dev mirrors the deployed runtime.\n */\n readonly branch: {\n readonly name: \"NEON_BRANCH\";\n };\n readonly postgres: {\n readonly databaseUrl: \"DATABASE_URL\";\n readonly databaseUrlUnpooled: \"DATABASE_URL_UNPOOLED\";\n };\n readonly auth: {\n readonly baseUrl: \"NEON_AUTH_BASE_URL\";\n readonly jwksUrl: \"NEON_AUTH_JWKS_URL\";\n };\n readonly dataApi: {\n readonly url: \"NEON_DATA_API_URL\";\n };\n /**\n * Object storage (Preview). The S3 SDKs read `AWS_*` from their standard config chain, so\n * a branch credential + `neon dev` / `env pull` makes object storage work from env alone.\n * `region` is injected under the SDK-standard `AWS_REGION`.\n */\n readonly storage: {\n readonly accessKeyId: \"AWS_ACCESS_KEY_ID\";\n readonly secretAccessKey: \"AWS_SECRET_ACCESS_KEY\";\n readonly endpoint: \"AWS_ENDPOINT_URL_S3\";\n readonly region: \"AWS_REGION\";\n };\n /**\n * AI Gateway (Preview). Exposed under the Neon-branded env vars the deployed Functions\n * runtime injects: `apiKey` is the minted credential's bearer (`NEON_AI_GATEWAY_TOKEN`)\n * and `baseUrl` is the bare branch gateway host (`NEON_AI_GATEWAY_BASE_URL`,\n * `scheme://host`, no path). Clients like `@neon/ai-sdk-provider` read these and append the\n * dialect route (`/v1`, `/openai/v1`, `/anthropic/v1`) themselves (https://github.com/vercel/ai/pull/15997).\n */\n readonly aiGateway: {\n readonly apiKey: \"NEON_AI_GATEWAY_TOKEN\";\n readonly baseUrl: \"NEON_AI_GATEWAY_BASE_URL\";\n };\n};\n/**\n * Branch identity for the resolved branch. Always present on a `fetchEnv` result (the branch\n * name is always known); on a `parseEnv` result it's present only when `NEON_BRANCH` was\n * injected into `process.env` (the Functions runtime injects it by default, as do `neon dev` /\n * `neon-env run` / `env pull`). `name` is the branch **name** (e.g. `main`, `preview/foo`).\n */\ninterface NeonBranchEnv {\n name: string;\n}\n/** Per-namespace inner shapes. Exposed so consumers can name the parts independently. */\ninterface NeonPostgresEnv {\n /**\n * Pooled connection string (via Neon's PgBouncer pooler). The right default for\n * serverless drivers (`@neondatabase/serverless`, edge runtimes, Postgres.js, …).\n */\n databaseUrl: string;\n /**\n * Direct (unpooled) connection string. Use this when you need session-level\n * features (`LISTEN`/`NOTIFY`, prepared statements across calls, transactions\n * spanning round-trips) that PgBouncer's transaction-mode pooling drops.\n */\n databaseUrlUnpooled: string;\n}\n/**\n * Bits of a Neon Auth integration for the resolved branch. Only present on `NeonEnv`\n * when the branch policy enables `auth`.\n *\n * Neon Auth exposes the `baseUrl` (which doubles as the publishable client identifier) and\n * the `jwksUrl` used to verify tokens it issues. `fetchEnv` reads both from the live\n * integration; `parseEnv` reads them from `process.env` (`NEON_AUTH_BASE_URL` /\n * `NEON_AUTH_JWKS_URL`).\n */\ninterface NeonAuthEnv {\n baseUrl: string;\n /** JWKS URL for verifying tokens issued by Neon Auth (`NEON_AUTH_JWKS_URL`). */\n jwksUrl: string;\n}\n/** Bits of a Neon Data API integration. Only present when the branch policy enables it. */\ninterface NeonDataApiEnv {\n url: string;\n}\n/**\n * S3-compatible object-storage access for the branch (Preview). Present on `NeonEnv` only\n * when the policy declares `preview.buckets`. Combines a minted branch credential's access\n * keys (`accessKeyId` = the credential's full token id, e.g. `nak_live_…`, which is what the\n * storage gateway authenticates against; `secretAccessKey` = its\n * `s3_secret_access_key`) with the branch's non-secret connection details\n * (`endpoint`/`region`, from `GET .../storage`). Projects to the AWS SDK's\n * standard config env (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_ENDPOINT_URL_S3`,\n * `AWS_REGION`) so the S3 client works from env alone. Neon's storage gateway always\n * requires path-style addressing, so set `forcePathStyle: true` on your S3 client.\n */\ninterface NeonStorageEnv {\n accessKeyId: string;\n secretAccessKey: string;\n /** S3-compatible endpoint URL for the branch. */\n endpoint: string;\n /** AWS region string (e.g. `us-east-2`). Injected as `AWS_REGION`. */\n region: string;\n}\n/**\n * AI Gateway access for the branch (Preview). Present on `NeonEnv` only when the policy\n * enables `preview.aiGateway`. `apiKey` is the minted credential's bearer (`api_token`);\n * `baseUrl` is the bare branch-scoped gateway host\n * (`https://<branchId>-api.ai.<region>.…`, no path). Projects to the Neon-branded env\n * (`NEON_AI_GATEWAY_TOKEN`, `NEON_AI_GATEWAY_BASE_URL`); clients like `@neon/ai-sdk-provider`\n * append the dialect route (`/v1`, `/openai/v1`, `/anthropic/v1`) themselves.\n */\ninterface NeonAiGatewayEnv {\n apiKey: string;\n baseUrl: string;\n}\n/**\n * Empty record alias used as the \"false\" branch of the conditional namespace adds below.\n * `Record<never, never>` is the no-op for intersection — the cleaner alternative to `{}`,\n * which biome rejects (it means \"any non-null\", not \"empty object\").\n */\ntype NoNamespace = Record<never, never>;\n/**\n * Resolve a **static** service toggle (the value of `config.auth` / `config.dataApi`) to a\n * type-level boolean. The whole-thing wrapping (`[T] extends […]`) turns off distribution\n * so a union/`undefined` is checked as one unit:\n *\n * - `false` / `{ enabled: false }` / `undefined` → `false`\n * - `true` / `{ enabled: true }` / any other object (`{}`, `{ enabled?: boolean }`) → `true`\n * (a present toggle defaults to enabled)\n * - the bare `boolean | ServiceToggle | undefined` (the default `Config` param, no literal\n * info) → `false`, so an untyped policy yields just `{ postgres }`.\n */\ntype ServiceOn<T> = [T] extends [false] ? false : [T] extends [{\n enabled: false;\n}] ? false : [T] extends [undefined] ? false : [T] extends [true] ? true : [T] extends [{\n enabled: true;\n}] ? true : [T] extends [object] ? true : false;\n/** True when `T` has at least one known key; `false` for `{}` / `never`. */\ntype HasKeys<T> = [keyof T] extends [never] ? false : true;\n/**\n * Whether the policy's **static** `preview` block declares at least one object-storage bucket\n * (`preview.buckets`). Drives whether {@link NeonEnv} carries the `storage` namespace.\n *\n * The leading `[never]` guard is load-bearing: when a policy has no `preview` at all,\n * `NonNullable<C[\"preview\"]>` is `never`, and without the guard the `extends { … }` probe\n * below would vacuously match (everything extends `never`-derived shapes) and `HasKeys<never>`\n * would resolve `true`, wrongly adding the namespace. The guard short-circuits to `false`.\n */\ntype HasBuckets<C extends Config> = [NonNullable<C[\"preview\"]>] extends [never] ? false : NonNullable<C[\"preview\"]> extends {\n buckets: infer B;\n} ? HasKeys<NonNullable<B>> : false;\n/**\n * Whether the policy's **static** `preview` block enables the AI Gateway\n * (`preview.aiGateway`). Drives whether {@link NeonEnv} carries the `aiGateway` namespace.\n *\n * The leading `[never]` guard is load-bearing for the same reason as {@link HasBuckets}: when\n * a policy has no `preview`, `NonNullable<C[\"preview\"]>` is `never`, and a naked `never` in the\n * `extends` below would *distribute* (collapsing the result — and the whole `NeonEnv`\n * intersection — to `never`). The tuple-wrapped guard short-circuits that to `false`.\n */\ntype AiGatewayOn<C extends Config> = [NonNullable<C[\"preview\"]>] extends [never] ? false : NonNullable<C[\"preview\"]> extends {\n aiGateway: infer A;\n} ? ServiceOn<NonNullable<A>> : false;\n/**\n * Static, namespaced shape of `fetchEnv` / `parseEnv`'s return value. Generic over the\n * {@link Config} so the type system knows which optional namespaces are present.\n *\n * Because the secret-bearing toggles now live in the **static** top-level `config.auth` /\n * `config.dataApi` (not inside a per-branch closure), the namespace presence is a direct\n * read of those fields — no union-across-branches, no default-config escape hatch:\n *\n * - `postgres` is always present.\n * - `auth` is added iff `config.auth` is statically enabled.\n * - `dataApi` is added iff `config.dataApi` is statically enabled.\n * - `storage` is added iff `config.preview.buckets` declares at least one bucket.\n * - `aiGateway` is added iff `config.preview.aiGateway` is statically enabled.\n */\ntype NeonEnv<C extends Config = Config> = {\n postgres: NeonPostgresEnv;\n /**\n * Branch identity (`NEON_BRANCH`). Optional because `parseEnv` only surfaces it when the\n * var was injected; `fetchEnv` always populates it.\n */\n branch?: NeonBranchEnv;\n} & (ServiceOn<NonNullable<C[\"auth\"]>> extends true ? {\n auth: NeonAuthEnv;\n} : NoNamespace) & (ServiceOn<NonNullable<C[\"dataApi\"]>> extends true ? {\n dataApi: NeonDataApiEnv;\n} : NoNamespace) & (HasBuckets<C> extends true ? {\n storage: NeonStorageEnv;\n} : NoNamespace) & (AiGatewayOn<C> extends true ? {\n aiGateway: NeonAiGatewayEnv;\n} : NoNamespace);\n/**\n * OS-level env-var keys grouped by the {@link NeonEnv} namespace they populate. Only the\n * **input** vars `parseEnv` validates are listed — the output-only aliases in\n * {@link NEON_ENV_VAR_KEYS} (`NEON_AI_GATEWAY_TOKEN`, …) are intentionally absent, so they\n * are not selectable in a `parseEnv(config, keys)` filter. Keep in sync with\n * {@link EnvKeyToProp}.\n */\ninterface EnvKeysByNamespace {\n postgres: \"DATABASE_URL\" | \"DATABASE_URL_UNPOOLED\";\n branch: \"NEON_BRANCH\";\n auth: \"NEON_AUTH_BASE_URL\" | \"NEON_AUTH_JWKS_URL\";\n dataApi: \"NEON_DATA_API_URL\";\n storage: \"AWS_ACCESS_KEY_ID\" | \"AWS_SECRET_ACCESS_KEY\" | \"AWS_ENDPOINT_URL_S3\" | \"AWS_REGION\";\n aiGateway: \"NEON_AI_GATEWAY_TOKEN\" | \"NEON_AI_GATEWAY_BASE_URL\";\n}\n/** The {@link NeonEnv} namespace interface backing each namespace key. */\ninterface NamespaceEnv {\n postgres: NeonPostgresEnv;\n branch: NeonBranchEnv;\n auth: NeonAuthEnv;\n dataApi: NeonDataApiEnv;\n storage: NeonStorageEnv;\n aiGateway: NeonAiGatewayEnv;\n}\n/** OS-level env-var key → the camelCase property it sets on its namespace object. */\ninterface EnvKeyToProp {\n DATABASE_URL: \"databaseUrl\";\n DATABASE_URL_UNPOOLED: \"databaseUrlUnpooled\";\n NEON_BRANCH: \"name\";\n NEON_AUTH_BASE_URL: \"baseUrl\";\n NEON_AUTH_JWKS_URL: \"jwksUrl\";\n NEON_DATA_API_URL: \"url\";\n AWS_ACCESS_KEY_ID: \"accessKeyId\";\n AWS_SECRET_ACCESS_KEY: \"secretAccessKey\";\n AWS_ENDPOINT_URL_S3: \"endpoint\";\n AWS_REGION: \"region\";\n NEON_AI_GATEWAY_TOKEN: \"apiKey\";\n NEON_AI_GATEWAY_BASE_URL: \"baseUrl\";\n}\n/**\n * The OS-level env-var keys selectable for a given policy: the union of input vars across\n * exactly the namespaces {@link NeonEnv}<C> carries. Drives the typesafe autocomplete of the\n * `keys` filter — selecting a var from a namespace the policy does not enable is a type error\n * (e.g. `NEON_AUTH_BASE_URL` is only offered once the policy turns on `auth`).\n */\ntype SelectableEnvKey<C extends Config> = EnvKeysByNamespace[keyof NeonEnv<C> & keyof EnvKeysByNamespace];\n/**\n * The result shape of a **filtered** `parseEnv(config, keys)` call: the namespaced\n * {@link NeonEnv} restricted to exactly the selected OS-level keys `K`. Namespaces with no\n * selected key are dropped, and within a kept namespace only the selected properties survive\n * — selecting just `[\"DATABASE_URL\"]` yields `{ postgres: { databaseUrl: string } }`, with no\n * `databaseUrlUnpooled`.\n *\n * The policy gating lives on the `parseEnv` overload (which binds `K` to\n * {@link SelectableEnvKey}); this type only needs the selection, so it takes a bare\n * `K extends string` and filters with `Extract`. The outer mapped type's `as` clause drops\n * any namespace whose intersection with the selection is empty (`[…] extends [never]`,\n * tuple-wrapped to switch off distribution); the inner one re-keys each selected OS var to its\n * camelCase property and looks the value type up on the canonical namespace interface, so it\n * stays correct if a field ever stops being a plain `string`.\n */\ntype FilteredNeonEnv<K extends string> = { [N in keyof EnvKeysByNamespace as [Extract<K, EnvKeysByNamespace[N]>] extends [never] ? never : N]: { [P in Extract<K, EnvKeysByNamespace[N]> as EnvKeyToProp[P & keyof EnvKeyToProp]]: NamespaceEnv[N][EnvKeyToProp[P & keyof EnvKeyToProp] & keyof NamespaceEnv[N]] } };\n/**\n * A filtered result when the exact runtime contents of a key array are unknown. Both the\n * namespace and its selected properties are optional because the array may omit any member of\n * its element union, or be empty.\n */\ntype OptionalFilteredNeonEnv<K extends string> = { [N in keyof EnvKeysByNamespace as [Extract<K, EnvKeysByNamespace[N]>] extends [never] ? never : N]?: { [P in Extract<K, EnvKeysByNamespace[N]> as EnvKeyToProp[P & keyof EnvKeyToProp]]?: NamespaceEnv[N][EnvKeyToProp[P & keyof EnvKeyToProp] & keyof NamespaceEnv[N]] } };\n/** Whether `T` is a union rather than one concrete type. */\ntype IsUnion<T, Whole = T> = T extends Whole ? [Whole] extends [T] ? false : true : never;\n/** Whether any fixed tuple position can hold more than one key at runtime. */\ntype TupleHasUnion<T extends readonly unknown[]> = T extends readonly [] ? false : T extends readonly [infer Head, ...infer Tail extends readonly unknown[]] ? true extends IsUnion<Head> ? true : TupleHasUnion<Tail> : true;\n/**\n * The sound result of selecting an array of OS-level env-var keys.\n *\n * Inline literal tuples remain exact. Widened arrays, rest tuples, and tuple positions whose\n * value is a union are conservative because their runtime contents may be any subset of the\n * element type. The leading conditional distributes unions of whole literal tuples, preserving\n * each exact alternative.\n */\ntype SelectedNeonEnv<Keys extends readonly string[]> = Keys extends readonly string[] ? number extends Keys[\"length\"] ? OptionalFilteredNeonEnv<Keys[number]> : TupleHasUnion<Keys> extends true ? OptionalFilteredNeonEnv<Keys[number]> : FilteredNeonEnv<Keys[number]> : never;\ntype StorageCredentialEnvKey = \"AWS_ACCESS_KEY_ID\" | \"AWS_SECRET_ACCESS_KEY\";\ntype StorageKeyPairError = {\n readonly \"fetchEnv keys must include AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY together\": never;\n};\ntype TupleDefinitelyContains<Keys extends readonly string[], Key extends string> = Keys extends readonly [infer Head extends string, ...infer Tail extends readonly string[]] ? [Head] extends [Key] ? true : TupleDefinitelyContains<Tail, Key> : false;\ntype TupleDefinitelyContainsStoragePair<Keys extends readonly string[]> = TupleDefinitelyContains<Keys, \"AWS_ACCESS_KEY_ID\"> extends true ? TupleDefinitelyContains<Keys, \"AWS_SECRET_ACCESS_KEY\"> extends true ? true : false : false;\n/**\n * Reject a fixed key tuple that contains only one half of the storage credential. Dynamic\n * arrays are checked at runtime because their contents are not known to TypeScript.\n */\ntype InvalidStorageKeyTuple<Keys extends readonly string[]> = Keys extends unknown ? number extends Keys[\"length\"] ? never : [Extract<Keys[number], StorageCredentialEnvKey>] extends [never] ? never : TupleDefinitelyContainsStoragePair<Keys> extends true ? never : Keys : never;\ntype StorageKeyPairConstraint<Keys extends readonly string[]> = [InvalidStorageKeyTuple<Keys>] extends [never] ? unknown : StorageKeyPairError;\ntype FetchEnvKeysFromArgs<Args extends readonly unknown[]> = Args[0] extends {\n keys: infer Keys extends readonly string[];\n} ? Keys : never;\ntype StorageKeyPairArgsConstraint<Args extends readonly unknown[]> = StorageKeyPairConstraint<FetchEnvKeysFromArgs<Args>>;\n/** Preserve the same pair rule for callers that explicitly provide the legacy `K` generic. */\ntype StorageKeyUnionConstraint<K extends string> = [Extract<K, StorageCredentialEnvKey>] extends [never] ? unknown : StorageCredentialEnvKey extends K ? unknown : StorageKeyPairError;\ninterface FetchEnvOptions {\n /**\n * Neon project id. **Required** — the management API addresses branches through their\n * project. Resolve it in your CLI (e.g. neonctl) and pass it in.\n */\n projectId: string;\n /**\n * Neon branch — its **name** (e.g. `main`) or its id (`br-…`). **Required** (or pass the\n * legacy {@link FetchEnvOptions.branchId}). Resolved against the project's branches by\n * id first, then by name, so either form works.\n */\n branch?: string;\n /**\n * @deprecated Legacy id-only field. Prefer {@link FetchEnvOptions.branch}, which accepts\n * a branch name or id. Still honored for backward compatibility; ignored when `branch`\n * is set.\n */\n branchId?: string;\n /**\n * Neon API key. Resolved via the standard chain (option → `NEON_API_KEY` →\n * `~/.config/neonctl/credentials.json`) when omitted. Ignored when a custom `api`\n * is supplied.\n */\n apiKey?: string;\n /**\n * Neon **management** API base URL (not the Auth base URL). Falls back to\n * `NEON_API_HOST`, then production. Ignored when a custom `api` is supplied.\n */\n apiHost?: string;\n /**\n * Inject a custom NeonApi adapter. Primarily used by tests; production callers can rely\n * on the default real adapter built from `apiKey`.\n */\n api?: NeonApi;\n /**\n * Role name to fetch credentials for. When omitted, the connection role is auto-picked:\n * the only role on the branch, else Neon's default owner (`neondb_owner`), else the\n * single role left after dropping the managed Auth/Data API roles\n * (`authenticator`/`anonymous`/`authenticated`). Throws {@link PlatformError} with\n * `PLATFORM_AMBIGUOUS_BRANCH_AUTH` only when more than one app role remains.\n */\n roleName?: string;\n /**\n * Database name. When omitted, it is auto-picked: Neon's default `neondb` if present,\n * else the only database on the branch. Throws {@link PlatformError} with\n * `PLATFORM_AMBIGUOUS_BRANCH_AUTH` when the branch has several databases and none is\n * `neondb` (pass `databaseName` to disambiguate), and `PLATFORM_BRANCH_NOT_FOUND` when\n * the branch has no databases or the requested `databaseName` does not exist.\n */\n databaseName?: string;\n}\n/**\n * Resolve the project + branch this process should target, then fetch live Neon\n * connection strings for that branch over the network. Async — calls the Neon API.\n *\n * Use this from build scripts and the `neon-env run` command, where top-level await is\n * fine. For application code that needs a synchronous bootstrap (most frameworks: Drizzle\n * config, Next.js, Vite, etc.), inject env vars via `neon-env run -- <cmd>` and use\n * {@link parseEnv} instead — same {@link NeonEnv} shape, but a sync call against\n * `process.env`.\n *\n * Filesystem- and env-agnostic: pass `projectId` and the target `branch` (name or id)\n * explicitly (resolve them in your CLI, e.g. neonctl).\n *\n * ```ts\n * import config from \"../neon\";\n * import { fetchEnv } from \"@neon/env\";\n *\n * const env = await fetchEnv(config, { projectId: \"patient-art-12345\", branch: \"main\" });\n * const db = drizzle(neon(env.postgres.databaseUrl), { schema });\n * ```\n *\n * Pass `keys` to fetch only some of them — see the overload below.\n *\n * The package does **not** read `process.env`, mutate it, or touch the filesystem. Everything\n * it returns comes from the Neon API, so a value the API cannot produce (a one-time secret\n * issued to a previous call) is minted afresh rather than recovered. Callers that hold\n * persisted secrets and want to keep them use {@link fetchEnvReusingSecrets}, which decides\n * what is still valid and narrows this call's `keys` accordingly.\n */\ndeclare function fetchEnv<const C extends Config, const Args extends readonly [options: FetchEnvOptions & {\n /**\n * Fetch only these OS-level env vars, instead of everything the policy enables. The\n * keys autocomplete from the policy ({@link SelectableEnvKey}), and the result is\n * narrowed to match ({@link SelectedNeonEnv}). Inline literal arrays produce an exact\n * result; runtime-built arrays make their possible namespaces and properties optional.\n * `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` must be selected together.\n *\n * The point is not just a smaller result: **work is skipped too.** Leave out\n * `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `NEON_AI_GATEWAY_TOKEN` and no branch\n * credential is minted at all, so a caller that already holds valid secrets can refresh\n * everything else without issuing a new one. The non-secret vars of the same features\n * (`AWS_ENDPOINT_URL_S3`, `AWS_REGION`, `NEON_AI_GATEWAY_BASE_URL`) are not\n * credential-backed and stay available on their own.\n *\n * The selection **intersects** with the policy rather than overriding it: naming a var\n * the branch policy does not enable is not an error, it simply yields nothing.\n */\n keys: readonly SelectableEnvKey<C>[];\n}]>(config: C, ...args: Args & StorageKeyPairArgsConstraint<NoInfer<Args>>): Promise<SelectedNeonEnv<FetchEnvKeysFromArgs<NoInfer<Args>>>>;\ndeclare function fetchEnv<const C extends Config, const K extends SelectableEnvKey<C> = never>(config: C, options: [NoInfer<K>] extends [never] ? never : FetchEnvOptions & {\n keys: readonly NoInfer<K>[];\n} & StorageKeyUnionConstraint<NoInfer<K>>): Promise<FilteredNeonEnv<NoInfer<K>>>;\ndeclare function fetchEnv<const C extends Config>(config: C, options: FetchEnvOptions & {\n keys?: never;\n}): Promise<NeonEnv<C>>;\n/** Diagnostic-only fallback: valid keyed calls resolve through the exact overload above. */\ndeclare function fetchEnv<const C extends Config, const Keys extends readonly SelectableEnvKey<C>[]>(config: C, options: FetchEnvOptions & {\n keys: Keys;\n} & StorageKeyPairError): Promise<never>;\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 */\ndeclare function fetchEnvKeys(config: Config, options: FetchEnvOptions, keys: readonly string[] | null): Promise<ResolvedNeonEnv>;\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 */\ndeclare function resolveBranchPolicy(config: Config, options: Pick<FetchEnvOptions, \"projectId\" | \"branch\" | \"branchId\">, api: NeonApi): Promise<{\n branch: NeonBranchSnapshot;\n desired: ReturnType<typeof resolveConfig>;\n}>;\n/**\n * Scopes the branch credential should carry for a resolved branch policy and optional key\n * selection. Only object storage and the AI Gateway *require* a credential; functions never\n * force one, but `functions:invoke` rides along when another selected feature mints one.\n */\ndeclare function previewCredentialScopes(preview: ResolvedPreviewConfig | undefined, selected?: {\n storage: boolean;\n aiGateway: boolean;\n}): CredentialScope[];\n/** The `name` this tool stamps on every credential it mints, so it can recognize its own. */\ndeclare function credentialName(branchName: string): string;\n/** The env-var keys a branch credential's secrets surface under, in emit order. */\ndeclare function credentialEnvKeys(flags: {\n storage: boolean;\n aiGateway: boolean;\n}): string[];\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 */\ndeclare function policyEnvKeys(desired: ReturnType<typeof resolveConfig>): string[];\ndeclare function createApiFromOptions(options: FetchEnvOptions): NeonApi;\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 */\ndeclare function toEntries(env: ResolvedNeonEnv): Record<string, string>;\n/**\n * Any resolved env {@link toEntries} can project: a full {@link NeonEnv}, or the narrowed\n * result of a `keys`-filtered {@link fetchEnv} / {@link parseEnv} call. Every namespace and\n * property is optional so a filtered result — which legitimately carries only what was asked\n * for — projects to exactly the vars it holds instead of failing to type-check.\n */\ntype ResolvedNeonEnv = { [N in keyof NamespaceEnv]?: Partial<NamespaceEnv[N]> };\n//#endregion\nexport { FetchEnvOptions, FilteredNeonEnv, NEON_ENV_VAR_KEYS, NeonAiGatewayEnv, NeonAuthEnv, NeonBranchEnv, NeonDataApiEnv, NeonEnv, NeonPostgresEnv, NeonStorageEnv, ResolvedNeonEnv, SelectableEnvKey, SelectedNeonEnv, createApiFromOptions, credentialEnvKeys, credentialName, fetchEnv, fetchEnvKeys, policyEnvKeys, previewCredentialScopes, resolveBranchPolicy, toEntries };\n//# sourceMappingURL=env.d.ts.map",null],"mappings":";;;;;AA8CC,cA1CaM,iBAiDS,EAAA;EAAA;AAIE;AAsBJ;AAMG;AAcA;EAgBE,SASrBO,MAAAA,EAAW;IAYXE,SAAAA,IAAS,EAAA,aAAA;EAAA,CAAA;EAAOC,SAAAA,QAAAA,EAAAA;IAA8BA,SAAAA,WAAAA,EAAAA,cAAAA;IAErCA,SAAAA,mBAAAA,EAAAA,uBAAAA;EAAkCA,CAAAA;EAA4BA,SAAAA,IAAAA,EAAAA;IAE/DA,SAAAA,OAAAA,EAAAA,oBAAAA;IAAC,SAAA,OAAA,EAAA,oBAAA;EAAA,CAAA;EAEY,SAUrBE,OAAU,EAAA;IAAA,SAAA,GAAA,EAAA,mBAAA;EAAWlB,CAAAA;EAAuBmB;AAAZC;AAAiED;AAAZC;AAElEC;EAAZD,SAAAA,OAAAA,EAAAA;IAARH,SAAAA,WAAAA,EAAAA,mBAAAA;IAAO,SAAA,eAAA,EAAA,uBAAA;IAUNK,SAAAA,QAAW,EAAA,qBAAA;IAAA,SAAA,MAAA,EAAA,YAAA;EAAWtB,CAAAA;EAAuBmB;AAAZC;AAAiED;AAAZC;AAEjEG;AAAZH;AAAVL;EAAS,SAAA,SAAA,EAAA;IAeRS,SAAAA,MAAO,EAAA,uBAAA;IAAA,SAAA,OAAA,EAAA,0BAAA;EAAWxB,CAAAA;AAASA,CAAAA;AACpBQ;AAKDD;AACgBY;AAAZC;AAAVL;AACGN;AACJI,UAzIMN,aAAAA,CAyINM;EAAsC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6BkLA,CC7B1K,CD6B0KA,CAAAA,GC7BrK,eD6BqKA,CC7BrJ,CD6BqJA,EC7BlJ,CD6BkJA,CAAAA;AAA9BC,iBC5BvI,QD4BuIA,CAAAA,gBC3BtI,MD2BsIA,EAAAA,gBC1BtI,gBD0BsIA,CC1BrH,CD0BqHA,CAAAA,CAAAA,CAAAA,MAAAA,ECzB7I,CDyB6IA,EAAAA,IAAAA,EAAAA,SCzB3H,CDyB2HA,EAAAA,CAAAA,ECzBrH,eDyBqHA,CCzBrG,CDyBqGA,CAAAA"}
1
+ {"version":3,"file":"index.d.ts","names":["Config","CredentialScope","NeonApi","NeonBranchSnapshot","ResolvedPreviewConfig","resolveConfig","NEON_ENV_VAR_KEYS","FunctionBaseUrlKey","Slug","Uppercase","functionBaseUrlKey","S","parseFunctionBaseUrlKey","isFunctionBaseUrlKey","FunctionUrlMode","NeonBranchEnv","NeonPostgresEnv","NeonAuthEnv","NeonDataApiEnv","NeonStorageEnv","NeonAiGatewayEnv","NeonFunctionUrlEnv","NoNamespace","Record","ServiceOn","T","HasKeys","HasBuckets","C","NonNullable","B","AiGatewayOn","A","HasFunctions","F","PreviewFunctionsOfConfig","FunctionSlugOfConfig","Extract","NeonFunctionsEnv","FunctionBaseUrlKeyOf","NeonEnv","EnvKeysByNamespace","NamespaceEnv","EnvKeyToProp","SelectableEnvKey","SelectedFunctionKeys","K","FunctionSlugFromKey","Lowercase","FunctionsFilteredEnv","P","OptionalFunctionsFilteredEnv","FilteredNeonEnv","N","OptionalFilteredNeonEnv","IsUnion","Whole","TupleHasUnion","Head","Tail","SelectedNeonEnv","Keys","StorageCredentialEnvKey","StorageKeyPairError","TupleDefinitelyContains","Key","TupleDefinitelyContainsStoragePair","InvalidStorageKeyTuple","StorageKeyPairConstraint","FetchEnvKeysFromArgs","Args","StorageKeyPairArgsConstraint","StorageKeyUnionConstraint","FetchEnvOptions","fetchEnv","NoInfer","Promise","fetchEnvKeys","FetchEnvKeysOptions","ResolvedNeonEnv","FetchEnvKeysState","ReadonlyArray","fetchEnvKeysState","resolveBranchPolicy","Pick","ReturnType","previewCredentialScopes","credentialName","credentialEnvKeys","policyEnvKeys","createApiFromOptions","toEntries","Partial"],"sources":["../../../internals/env-core/dist/env.d.ts","../src/lib/parse-env.ts"],"sourcesContent":["import { Config, CredentialScope, NeonApi, NeonBranchSnapshot, ResolvedPreviewConfig, resolveConfig } from \"@neon/config/v1\";\n\n//#region src/env.d.ts\n\ndeclare const NEON_ENV_VAR_KEYS: {\n /**\n * Branch identity. `NEON_BRANCH` carries the branch **name** and is injected into the\n * Neon Functions runtime on every branch (including the default) by default. `env pull` /\n * `neon dev` / `neon-env run` emit it too so local dev mirrors the deployed runtime.\n */\n readonly branch: {\n readonly name: \"NEON_BRANCH\";\n };\n readonly postgres: {\n readonly databaseUrl: \"DATABASE_URL\";\n readonly databaseUrlUnpooled: \"DATABASE_URL_UNPOOLED\";\n };\n readonly auth: {\n readonly baseUrl: \"NEON_AUTH_BASE_URL\";\n readonly jwksUrl: \"NEON_AUTH_JWKS_URL\";\n };\n readonly dataApi: {\n readonly url: \"NEON_DATA_API_URL\";\n };\n /**\n * Object storage (Preview). The S3 SDKs read `AWS_*` from their standard config chain, so\n * a branch credential + `neon dev` / `env pull` makes object storage work from env alone.\n * `region` is injected under the SDK-standard `AWS_REGION`.\n */\n readonly storage: {\n readonly accessKeyId: \"AWS_ACCESS_KEY_ID\";\n readonly secretAccessKey: \"AWS_SECRET_ACCESS_KEY\";\n readonly endpoint: \"AWS_ENDPOINT_URL_S3\";\n readonly region: \"AWS_REGION\";\n };\n /**\n * AI Gateway (Preview). Exposed under the Neon-branded env vars the deployed Functions\n * runtime injects: `apiKey` is the minted credential's bearer (`NEON_AI_GATEWAY_TOKEN`)\n * and `baseUrl` is the bare branch gateway host (`NEON_AI_GATEWAY_BASE_URL`,\n * `scheme://host`, no path). Clients like `@neon/ai-sdk-provider` read these and append the\n * dialect route (`/v1`, `/openai/v1`, `/anthropic/v1`) themselves (https://github.com/vercel/ai/pull/15997).\n */\n readonly aiGateway: {\n readonly apiKey: \"NEON_AI_GATEWAY_TOKEN\";\n readonly baseUrl: \"NEON_AI_GATEWAY_BASE_URL\";\n };\n};\ntype FunctionBaseUrlKey<Slug extends string = string> = `NEON_FUNCTION_${Uppercase<Slug>}_BASE_URL`;\ndeclare function functionBaseUrlKey<S extends string>(slug: S): FunctionBaseUrlKey<S>;\ndeclare function parseFunctionBaseUrlKey(key: string): string | null;\ndeclare function isFunctionBaseUrlKey(key: string): key is FunctionBaseUrlKey;\n/** `all-live` lists deployed functions. Policy mode derives declared slugs from the connection host. */\ntype FunctionUrlMode = \"policy\" | \"all-live\";\n/**\n * Branch identity for the resolved branch. Always present on a `fetchEnv` result (the branch\n * name is always known); on a `parseEnv` result it's present only when `NEON_BRANCH` was\n * injected into `process.env` (the Functions runtime injects it by default, as do `neon dev` /\n * `neon-env run` / `env pull`). `name` is the branch **name** (e.g. `main`, `preview/foo`).\n */\ninterface NeonBranchEnv {\n name: string;\n}\n/** Per-namespace inner shapes. Exposed so consumers can name the parts independently. */\ninterface NeonPostgresEnv {\n /**\n * Pooled connection string (via Neon's PgBouncer pooler). The right default for\n * serverless drivers (`@neondatabase/serverless`, edge runtimes, Postgres.js, …).\n */\n databaseUrl: string;\n /**\n * Direct (unpooled) connection string. Use this when you need session-level\n * features (`LISTEN`/`NOTIFY`, prepared statements across calls, transactions\n * spanning round-trips) that PgBouncer's transaction-mode pooling drops.\n */\n databaseUrlUnpooled: string;\n}\n/**\n * Bits of a Neon Auth integration for the resolved branch. Only present on `NeonEnv`\n * when the branch policy enables `auth`.\n *\n * Neon Auth exposes the `baseUrl` (which doubles as the publishable client identifier) and\n * the `jwksUrl` used to verify tokens it issues. `fetchEnv` reads both from the live\n * integration; `parseEnv` reads them from `process.env` (`NEON_AUTH_BASE_URL` /\n * `NEON_AUTH_JWKS_URL`).\n */\ninterface NeonAuthEnv {\n baseUrl: string;\n /** JWKS URL for verifying tokens issued by Neon Auth (`NEON_AUTH_JWKS_URL`). */\n jwksUrl: string;\n}\n/** Bits of a Neon Data API integration. Only present when the branch policy enables it. */\ninterface NeonDataApiEnv {\n url: string;\n}\n/**\n * S3-compatible object-storage access for the branch (Preview). Present on `NeonEnv` only\n * when the policy declares `preview.buckets`. Combines a minted branch credential's access\n * keys (`accessKeyId` = the credential's full token id, e.g. `nak_live_…`, which is what the\n * storage gateway authenticates against; `secretAccessKey` = its\n * `s3_secret_access_key`) with the branch's non-secret connection details\n * (`endpoint`/`region`, from `GET .../storage`). Projects to the AWS SDK's\n * standard config env (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_ENDPOINT_URL_S3`,\n * `AWS_REGION`) so the S3 client works from env alone. Neon's storage gateway always\n * requires path-style addressing, so set `forcePathStyle: true` on your S3 client.\n */\ninterface NeonStorageEnv {\n accessKeyId: string;\n secretAccessKey: string;\n /** S3-compatible endpoint URL for the branch. */\n endpoint: string;\n /** AWS region string (e.g. `us-east-2`). Injected as `AWS_REGION`. */\n region: string;\n}\n/**\n * AI Gateway access for the branch (Preview). Present on `NeonEnv` only when the policy\n * enables `preview.aiGateway`. `apiKey` is the minted credential's bearer (`api_token`);\n * `baseUrl` is the bare branch-scoped gateway host\n * (`https://<branchId>-api.ai.<region>.…`, no path). Projects to the Neon-branded env\n * (`NEON_AI_GATEWAY_TOKEN`, `NEON_AI_GATEWAY_BASE_URL`); clients like `@neon/ai-sdk-provider`\n * append the dialect route (`/v1`, `/openai/v1`, `/anthropic/v1`) themselves.\n */\ninterface NeonAiGatewayEnv {\n apiKey: string;\n baseUrl: string;\n}\ninterface NeonFunctionUrlEnv {\n baseUrl: string;\n}\n/**\n * Empty record alias used as the \"false\" branch of the conditional namespace adds below.\n * `Record<never, never>` is the no-op for intersection — the cleaner alternative to `{}`,\n * which biome rejects (it means \"any non-null\", not \"empty object\").\n */\ntype NoNamespace = Record<never, never>;\n/**\n * Resolve a **static** service toggle (the value of `config.auth` / `config.dataApi`) to a\n * type-level boolean. The whole-thing wrapping (`[T] extends […]`) turns off distribution\n * so a union/`undefined` is checked as one unit:\n *\n * - `false` / `{ enabled: false }` / `undefined` → `false`\n * - `true` / `{ enabled: true }` / any other object (`{}`, `{ enabled?: boolean }`) → `true`\n * (a present toggle defaults to enabled)\n * - the bare `boolean | ServiceToggle | undefined` (the default `Config` param, no literal\n * info) → `false`, so an untyped policy yields just `{ postgres }`.\n */\ntype ServiceOn<T> = [T] extends [false] ? false : [T] extends [{\n enabled: false;\n}] ? false : [T] extends [undefined] ? false : [T] extends [true] ? true : [T] extends [{\n enabled: true;\n}] ? true : [T] extends [object] ? true : false;\n/** True when `T` has at least one known key; `false` for `{}` / `never`. */\ntype HasKeys<T> = [keyof T] extends [never] ? false : true;\n/**\n * Whether the policy's **static** `preview` block declares at least one object-storage bucket\n * (`preview.buckets`). Drives whether {@link NeonEnv} carries the `storage` namespace.\n *\n * The leading `[never]` guard is load-bearing: when a policy has no `preview` at all,\n * `NonNullable<C[\"preview\"]>` is `never`, and without the guard the `extends { … }` probe\n * below would vacuously match (everything extends `never`-derived shapes) and `HasKeys<never>`\n * would resolve `true`, wrongly adding the namespace. The guard short-circuits to `false`.\n */\ntype HasBuckets<C extends Config> = [NonNullable<C[\"preview\"]>] extends [never] ? false : NonNullable<C[\"preview\"]> extends {\n buckets: infer B;\n} ? HasKeys<NonNullable<B>> : false;\n/**\n * Whether the policy's **static** `preview` block enables the AI Gateway\n * (`preview.aiGateway`). Drives whether {@link NeonEnv} carries the `aiGateway` namespace.\n *\n * The leading `[never]` guard is load-bearing for the same reason as {@link HasBuckets}: when\n * a policy has no `preview`, `NonNullable<C[\"preview\"]>` is `never`, and a naked `never` in the\n * `extends` below would *distribute* (collapsing the result — and the whole `NeonEnv`\n * intersection — to `never`). The tuple-wrapped guard short-circuits that to `false`.\n */\ntype AiGatewayOn<C extends Config> = [NonNullable<C[\"preview\"]>] extends [never] ? false : NonNullable<C[\"preview\"]> extends {\n aiGateway: infer A;\n} ? ServiceOn<NonNullable<A>> : false;\n/** The tuple guard prevents a missing preview block from enabling functions. */\ntype HasFunctions<C extends Config> = [NonNullable<C[\"preview\"]>] extends [never] ? false : NonNullable<C[\"preview\"]> extends {\n functions: infer F;\n} ? HasKeys<NonNullable<F>> : false;\ntype PreviewFunctionsOfConfig<C extends Config> = [NonNullable<C[\"preview\"]>] extends [never] ? Record<never, never> : NonNullable<C[\"preview\"]> extends {\n functions: infer F;\n} ? F : Record<never, never>;\ntype FunctionSlugOfConfig<C extends Config> = Extract<keyof PreviewFunctionsOfConfig<C>, string>;\ntype NeonFunctionsEnv<C extends Config> = { [S in FunctionSlugOfConfig<C>]: NeonFunctionUrlEnv };\ntype FunctionBaseUrlKeyOf<C extends Config> = FunctionSlugOfConfig<C> extends infer S ? S extends string ? FunctionBaseUrlKey<S> : never : never;\n/**\n * Static, namespaced shape of `fetchEnv` / `parseEnv`'s return value. Generic over the\n * {@link Config} so the type system knows which optional namespaces are present.\n *\n * Because the secret-bearing toggles now live in the **static** top-level `config.auth` /\n * `config.dataApi` (not inside a per-branch closure), the namespace presence is a direct\n * read of those fields — no union-across-branches, no default-config escape hatch:\n *\n * - `postgres` is always present.\n * - `auth` is added iff `config.auth` is statically enabled.\n * - `dataApi` is added iff `config.dataApi` is statically enabled.\n * - `storage` is added iff `config.preview.buckets` declares at least one bucket.\n * - `aiGateway` is added iff `config.preview.aiGateway` is statically enabled.\n * - `functions` is added iff `config.preview.functions` declares at least one slug.\n */\ntype NeonEnv<C extends Config = Config> = {\n postgres: NeonPostgresEnv;\n /**\n * Branch identity (`NEON_BRANCH`). Optional because `parseEnv` only surfaces it when the\n * var was injected; `fetchEnv` always populates it.\n */\n branch?: NeonBranchEnv;\n} & (ServiceOn<NonNullable<C[\"auth\"]>> extends true ? {\n auth: NeonAuthEnv;\n} : NoNamespace) & (ServiceOn<NonNullable<C[\"dataApi\"]>> extends true ? {\n dataApi: NeonDataApiEnv;\n} : NoNamespace) & (HasBuckets<C> extends true ? {\n storage: NeonStorageEnv;\n} : NoNamespace) & (AiGatewayOn<C> extends true ? {\n aiGateway: NeonAiGatewayEnv;\n} : NoNamespace) & (HasFunctions<C> extends true ? {\n functions: NeonFunctionsEnv<C>;\n} : NoNamespace);\n/**\n * OS-level env-var keys grouped by the {@link NeonEnv} namespace they populate. Only the\n * **input** vars `parseEnv` validates are listed — the output-only aliases in\n * {@link NEON_ENV_VAR_KEYS} (`NEON_AI_GATEWAY_TOKEN`, …) are intentionally absent, so they\n * are not selectable in a `parseEnv(config, keys)` filter. Keep in sync with\n * {@link EnvKeyToProp}.\n */\ninterface EnvKeysByNamespace {\n postgres: \"DATABASE_URL\" | \"DATABASE_URL_UNPOOLED\";\n branch: \"NEON_BRANCH\";\n auth: \"NEON_AUTH_BASE_URL\" | \"NEON_AUTH_JWKS_URL\";\n dataApi: \"NEON_DATA_API_URL\";\n storage: \"AWS_ACCESS_KEY_ID\" | \"AWS_SECRET_ACCESS_KEY\" | \"AWS_ENDPOINT_URL_S3\" | \"AWS_REGION\";\n aiGateway: \"NEON_AI_GATEWAY_TOKEN\" | \"NEON_AI_GATEWAY_BASE_URL\";\n}\n/** The {@link NeonEnv} namespace interface backing each namespace key. */\ninterface NamespaceEnv {\n postgres: NeonPostgresEnv;\n branch: NeonBranchEnv;\n auth: NeonAuthEnv;\n dataApi: NeonDataApiEnv;\n storage: NeonStorageEnv;\n aiGateway: NeonAiGatewayEnv;\n}\n/** OS-level env-var key → the camelCase property it sets on its namespace object. */\ninterface EnvKeyToProp {\n DATABASE_URL: \"databaseUrl\";\n DATABASE_URL_UNPOOLED: \"databaseUrlUnpooled\";\n NEON_BRANCH: \"name\";\n NEON_AUTH_BASE_URL: \"baseUrl\";\n NEON_AUTH_JWKS_URL: \"jwksUrl\";\n NEON_DATA_API_URL: \"url\";\n AWS_ACCESS_KEY_ID: \"accessKeyId\";\n AWS_SECRET_ACCESS_KEY: \"secretAccessKey\";\n AWS_ENDPOINT_URL_S3: \"endpoint\";\n AWS_REGION: \"region\";\n NEON_AI_GATEWAY_TOKEN: \"apiKey\";\n NEON_AI_GATEWAY_BASE_URL: \"baseUrl\";\n}\n/**\n * The OS-level env-var keys selectable for a given policy: the union of input vars across\n * exactly the namespaces {@link NeonEnv}<C> carries. Drives the typesafe autocomplete of the\n * `keys` filter — selecting a var from a namespace the policy does not enable is a type error\n * (e.g. `NEON_AUTH_BASE_URL` is only offered once the policy turns on `auth`).\n */\ntype SelectableEnvKey<C extends Config> = EnvKeysByNamespace[keyof NeonEnv<C> & keyof EnvKeysByNamespace] | FunctionBaseUrlKeyOf<C>;\n/**\n * The result shape of a **filtered** `parseEnv(config, keys)` call: the namespaced\n * {@link NeonEnv} restricted to exactly the selected OS-level keys `K`. Namespaces with no\n * selected key are dropped, and within a kept namespace only the selected properties survive\n * — selecting just `[\"DATABASE_URL\"]` yields `{ postgres: { databaseUrl: string } }`, with no\n * `databaseUrlUnpooled`.\n *\n * The policy gating lives on the `parseEnv` overload (which binds `K` to\n * {@link SelectableEnvKey}); this type only needs the selection, so it takes a bare\n * `K extends string` and filters with `Extract`. The outer mapped type's `as` clause drops\n * any namespace whose intersection with the selection is empty (`[…] extends [never]`,\n * tuple-wrapped to switch off distribution); the inner one re-keys each selected OS var to its\n * camelCase property and looks the value type up on the canonical namespace interface, so it\n * stays correct if a field ever stops being a plain `string`.\n */\ntype SelectedFunctionKeys<K extends string> = Extract<K, FunctionBaseUrlKey>;\ntype FunctionSlugFromKey<K extends string> = K extends `NEON_FUNCTION_${infer S}_BASE_URL` ? Lowercase<S> : never;\ntype FunctionsFilteredEnv<K extends string> = [SelectedFunctionKeys<K>] extends [never] ? unknown : {\n functions: { [P in SelectedFunctionKeys<K> as FunctionSlugFromKey<P>]: NeonFunctionUrlEnv };\n};\ntype OptionalFunctionsFilteredEnv<K extends string> = [SelectedFunctionKeys<K>] extends [never] ? unknown : {\n functions?: { [P in SelectedFunctionKeys<K> as FunctionSlugFromKey<P>]?: NeonFunctionUrlEnv };\n};\ntype FilteredNeonEnv<K extends string> = { [N in keyof EnvKeysByNamespace as [Extract<K, EnvKeysByNamespace[N]>] extends [never] ? never : N]: { [P in Extract<K, EnvKeysByNamespace[N]> as EnvKeyToProp[P & keyof EnvKeyToProp]]: NamespaceEnv[N][EnvKeyToProp[P & keyof EnvKeyToProp] & keyof NamespaceEnv[N]] } } & FunctionsFilteredEnv<K>;\n/**\n * A filtered result when the exact runtime contents of a key array are unknown. Both the\n * namespace and its selected properties are optional because the array may omit any member of\n * its element union, or be empty.\n */\ntype OptionalFilteredNeonEnv<K extends string> = { [N in keyof EnvKeysByNamespace as [Extract<K, EnvKeysByNamespace[N]>] extends [never] ? never : N]?: { [P in Extract<K, EnvKeysByNamespace[N]> as EnvKeyToProp[P & keyof EnvKeyToProp]]?: NamespaceEnv[N][EnvKeyToProp[P & keyof EnvKeyToProp] & keyof NamespaceEnv[N]] } } & OptionalFunctionsFilteredEnv<K>;\n/** Whether `T` is a union rather than one concrete type. */\ntype IsUnion<T, Whole = T> = T extends Whole ? [Whole] extends [T] ? false : true : never;\n/** Whether any fixed tuple position can hold more than one key at runtime. */\ntype TupleHasUnion<T extends readonly unknown[]> = T extends readonly [] ? false : T extends readonly [infer Head, ...infer Tail extends readonly unknown[]] ? true extends IsUnion<Head> ? true : TupleHasUnion<Tail> : true;\n/**\n * The sound result of selecting an array of OS-level env-var keys.\n *\n * Inline literal tuples remain exact. Widened arrays, rest tuples, and tuple positions whose\n * value is a union are conservative because their runtime contents may be any subset of the\n * element type. The leading conditional distributes unions of whole literal tuples, preserving\n * each exact alternative.\n */\ntype SelectedNeonEnv<Keys extends readonly string[]> = Keys extends readonly string[] ? number extends Keys[\"length\"] ? OptionalFilteredNeonEnv<Keys[number]> : TupleHasUnion<Keys> extends true ? OptionalFilteredNeonEnv<Keys[number]> : FilteredNeonEnv<Keys[number]> : never;\ntype StorageCredentialEnvKey = \"AWS_ACCESS_KEY_ID\" | \"AWS_SECRET_ACCESS_KEY\";\ntype StorageKeyPairError = {\n readonly \"fetchEnv keys must include AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY together\": never;\n};\ntype TupleDefinitelyContains<Keys extends readonly string[], Key extends string> = Keys extends readonly [infer Head extends string, ...infer Tail extends readonly string[]] ? [Head] extends [Key] ? true : TupleDefinitelyContains<Tail, Key> : false;\ntype TupleDefinitelyContainsStoragePair<Keys extends readonly string[]> = TupleDefinitelyContains<Keys, \"AWS_ACCESS_KEY_ID\"> extends true ? TupleDefinitelyContains<Keys, \"AWS_SECRET_ACCESS_KEY\"> extends true ? true : false : false;\n/**\n * Reject a fixed key tuple that contains only one half of the storage credential. Dynamic\n * arrays are checked at runtime because their contents are not known to TypeScript.\n */\ntype InvalidStorageKeyTuple<Keys extends readonly string[]> = Keys extends unknown ? number extends Keys[\"length\"] ? never : [Extract<Keys[number], StorageCredentialEnvKey>] extends [never] ? never : TupleDefinitelyContainsStoragePair<Keys> extends true ? never : Keys : never;\ntype StorageKeyPairConstraint<Keys extends readonly string[]> = [InvalidStorageKeyTuple<Keys>] extends [never] ? unknown : StorageKeyPairError;\ntype FetchEnvKeysFromArgs<Args extends readonly unknown[]> = Args[0] extends {\n keys: infer Keys extends readonly string[];\n} ? Keys : never;\ntype StorageKeyPairArgsConstraint<Args extends readonly unknown[]> = StorageKeyPairConstraint<FetchEnvKeysFromArgs<Args>>;\n/** Preserve the same pair rule for callers that explicitly provide the legacy `K` generic. */\ntype StorageKeyUnionConstraint<K extends string> = [Extract<K, StorageCredentialEnvKey>] extends [never] ? unknown : StorageCredentialEnvKey extends K ? unknown : StorageKeyPairError;\ninterface FetchEnvOptions {\n /**\n * Neon project id. **Required** — the management API addresses branches through their\n * project. Resolve it in your CLI (e.g. neonctl) and pass it in.\n */\n projectId: string;\n /**\n * Neon branch — its **name** (e.g. `main`) or its id (`br-…`). **Required** (or pass the\n * legacy {@link FetchEnvOptions.branchId}). Resolved against the project's branches by\n * id first, then by name, so either form works.\n */\n branch?: string;\n /**\n * @deprecated Legacy id-only field. Prefer {@link FetchEnvOptions.branch}, which accepts\n * a branch name or id. Still honored for backward compatibility; ignored when `branch`\n * is set.\n */\n branchId?: string;\n /**\n * Neon API key. Resolved via the standard chain (option → `NEON_API_KEY` →\n * `~/.config/neonctl/credentials.json`) when omitted. Ignored when a custom `api`\n * is supplied.\n */\n apiKey?: string;\n /**\n * Neon **management** API base URL (not the Auth base URL). Falls back to\n * `NEON_API_HOST`, then production. Ignored when a custom `api` is supplied.\n */\n apiHost?: string;\n /**\n * Inject a custom NeonApi adapter. Primarily used by tests; production callers can rely\n * on the default real adapter built from `apiKey`.\n */\n api?: NeonApi;\n /**\n * Role name to fetch credentials for. When omitted, the connection role is auto-picked:\n * the only role on the branch, else Neon's default owner (`neondb_owner`), else the\n * single role left after dropping the managed Auth/Data API roles\n * (`authenticator`/`anonymous`/`authenticated`). Throws {@link PlatformError} with\n * `PLATFORM_AMBIGUOUS_BRANCH_AUTH` only when more than one app role remains.\n */\n roleName?: string;\n /**\n * Database name. When omitted, it is auto-picked: Neon's default `neondb` if present,\n * else the only database on the branch. Throws {@link PlatformError} with\n * `PLATFORM_AMBIGUOUS_BRANCH_AUTH` when the branch has several databases and none is\n * `neondb` (pass `databaseName` to disambiguate), and `PLATFORM_BRANCH_NOT_FOUND` when\n * the branch has no databases or the requested `databaseName` does not exist.\n */\n databaseName?: string;\n}\n/**\n * Resolve the project + branch this process should target, then fetch live Neon\n * connection strings for that branch over the network. Async — calls the Neon API.\n *\n * Use this from build scripts and the `neon-env run` command, where top-level await is\n * fine. For application code that needs a synchronous bootstrap (most frameworks: Drizzle\n * config, Next.js, Vite, etc.), inject env vars via `neon-env run -- <cmd>` and use\n * {@link parseEnv} instead — same {@link NeonEnv} shape, but a sync call against\n * `process.env`.\n *\n * Filesystem- and env-agnostic: pass `projectId` and the target `branch` (name or id)\n * explicitly (resolve them in your CLI, e.g. neonctl).\n *\n * ```ts\n * import config from \"../neon\";\n * import { fetchEnv } from \"@neon/env\";\n *\n * const env = await fetchEnv(config, { projectId: \"patient-art-12345\", branch: \"main\" });\n * const db = drizzle(neon(env.postgres.databaseUrl), { schema });\n * ```\n *\n * Pass `keys` to fetch only some of them — see the overload below.\n *\n * The package does **not** read `process.env`, mutate it, or touch the filesystem. Everything\n * it returns comes from the Neon API, so a value the API cannot produce (a one-time secret\n * issued to a previous call) is minted afresh rather than recovered. Callers that hold\n * persisted secrets and want to keep them use {@link fetchEnvReusingSecrets}, which decides\n * what is still valid and narrows this call's `keys` accordingly.\n */\ndeclare function fetchEnv<const C extends Config, const Args extends readonly [options: FetchEnvOptions & {\n /**\n * Fetch only these OS-level env vars, instead of everything the policy enables. The\n * keys autocomplete from the policy ({@link SelectableEnvKey}), and the result is\n * narrowed to match ({@link SelectedNeonEnv}). Inline literal arrays produce an exact\n * result; runtime-built arrays make their possible namespaces and properties optional.\n * `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` must be selected together.\n *\n * The point is not just a smaller result: **work is skipped too.** Leave out\n * `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `NEON_AI_GATEWAY_TOKEN` and no branch\n * credential is minted at all, so a caller that already holds valid secrets can refresh\n * everything else without issuing a new one. The non-secret vars of the same features\n * (`AWS_ENDPOINT_URL_S3`, `AWS_REGION`, `NEON_AI_GATEWAY_BASE_URL`) are not\n * credential-backed and stay available on their own.\n *\n * The selection **intersects** with the policy rather than overriding it: naming a var\n * the branch policy does not enable is not an error, it simply yields nothing.\n */\n keys: readonly SelectableEnvKey<C>[];\n}]>(config: C, ...args: Args & StorageKeyPairArgsConstraint<NoInfer<Args>>): Promise<SelectedNeonEnv<FetchEnvKeysFromArgs<NoInfer<Args>>>>;\ndeclare function fetchEnv<const C extends Config, const K extends SelectableEnvKey<C> = never>(config: C, options: [NoInfer<K>] extends [never] ? never : FetchEnvOptions & {\n keys: readonly NoInfer<K>[];\n} & StorageKeyUnionConstraint<NoInfer<K>>): Promise<FilteredNeonEnv<NoInfer<K>>>;\ndeclare function fetchEnv<const C extends Config>(config: C, options: FetchEnvOptions & {\n keys?: never;\n}): Promise<NeonEnv<C>>;\n/** Diagnostic-only fallback: valid keyed calls resolve through the exact overload above. */\ndeclare function fetchEnv<const C extends Config, const Keys extends readonly SelectableEnvKey<C>[]>(config: C, options: FetchEnvOptions & {\n keys: Keys;\n} & StorageKeyPairError): Promise<never>;\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 */\ndeclare function fetchEnvKeys(config: Config, options: FetchEnvKeysOptions, keys: readonly string[] | null): Promise<ResolvedNeonEnv>;\ntype FetchEnvKeysState = {\n env: ResolvedNeonEnv;\n /** Prevents endpoint failure from being mistaken for a confirmed empty function list. */\n functionUrlsUnavailable: boolean;\n};\ntype FetchEnvKeysOptions = FetchEnvOptions & {\n functionUrls?: FunctionUrlMode;\n /**\n * Keys to skip even when {@link fetchEnvKeys} is unscoped (`keys === null`).\n * {@link fetchEnvReusingSecrets} uses this to keep already-verified secrets\n * without converting an unscoped fetch into a static policy-key list — that\n * list cannot name `NEON_FUNCTION_*_BASE_URL`, so it would drop function URLs.\n */\n omitKeys?: readonly string[];\n /**\n * Skip a second `listBranchFunctions` when the caller already listed.\n * `--service functions` uses this so a later `FeatureUnavailable` cannot be\n * swallowed as `skipped`.\n */\n listedFunctions?: ReadonlyArray<{\n slug: string;\n invocationUrl: string;\n }>;\n};\ndeclare function fetchEnvKeysState(config: Config, options: FetchEnvKeysOptions, keys: readonly string[] | null): Promise<FetchEnvKeysState>;\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 */\ndeclare function resolveBranchPolicy(config: Config, options: Pick<FetchEnvOptions, \"projectId\" | \"branch\" | \"branchId\">, api: NeonApi): Promise<{\n branch: NeonBranchSnapshot;\n desired: ReturnType<typeof resolveConfig>;\n}>;\n/**\n * Scopes the branch credential should carry for a resolved branch policy and optional key\n * selection. Only object storage and the AI Gateway *require* a credential; functions never\n * force one, but `functions:invoke` rides along when another selected feature mints one.\n */\ndeclare function previewCredentialScopes(preview: ResolvedPreviewConfig | undefined, selected?: {\n storage: boolean;\n aiGateway: boolean;\n}): CredentialScope[];\n/** The `name` this tool stamps on every credential it mints, so it can recognize its own. */\ndeclare function credentialName(branchName: string): string;\n/** The env-var keys a branch credential's secrets surface under, in emit order. */\ndeclare function credentialEnvKeys(flags: {\n storage: boolean;\n aiGateway: boolean;\n}): string[];\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 */\ndeclare function policyEnvKeys(desired: ReturnType<typeof resolveConfig>): string[];\ndeclare function createApiFromOptions(options: FetchEnvOptions): NeonApi;\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 */\ndeclare function toEntries(env: ResolvedNeonEnv): Record<string, string>;\n/**\n * Any resolved env {@link toEntries} can project: a full {@link NeonEnv}, or the narrowed\n * result of a `keys`-filtered {@link fetchEnv} / {@link parseEnv} call. Every namespace and\n * property is optional so a filtered result — which legitimately carries only what was asked\n * for — projects to exactly the vars it holds instead of failing to type-check.\n */\ntype ResolvedNeonEnv = { [N in keyof NamespaceEnv]?: Partial<NamespaceEnv[N]> } & {\n functions?: Record<string, NeonFunctionUrlEnv>;\n};\n//#endregion\nexport { FetchEnvKeysOptions, FetchEnvKeysState, FetchEnvOptions, FilteredNeonEnv, FunctionBaseUrlKey, FunctionUrlMode, NEON_ENV_VAR_KEYS, NeonAiGatewayEnv, NeonAuthEnv, NeonBranchEnv, NeonDataApiEnv, NeonEnv, NeonFunctionUrlEnv, NeonFunctionsEnv, NeonPostgresEnv, NeonStorageEnv, ResolvedNeonEnv, SelectableEnvKey, SelectedNeonEnv, createApiFromOptions, credentialEnvKeys, credentialName, fetchEnv, fetchEnvKeys, fetchEnvKeysState, functionBaseUrlKey, isFunctionBaseUrlKey, parseFunctionBaseUrlKey, policyEnvKeys, previewCredentialScopes, resolveBranchPolicy, toEntries };\n//# sourceMappingURL=env.d.ts.map",null],"mappings":";;;;;AA8CC,cA1CaM,iBA2CS,EAAA;EAAA;AAA4DE;AAAVC;AAAS;AAAA;EAC/C,SAAA,MAAA,EAAA;IAAyBE,SAAAA,IAAAA,EAAAA,aAAAA;EAAuBA,CAAAA;EAAnBJ,SAAAA,QAAAA,EAAAA;IAAkB,SAAA,WAAA,EAAA,cAAA;IACjEK,SAAAA,mBAAuB,EAAA,uBAAA;EAAA,CAAA;EAGpB,SAOVG,IAAAA,EAAAA;IAIAC,SAAAA,OAAAA,EAAe,oBAAA;IAsBfC,SAAAA,OAAW,EAAA,oBAAA;EAAA,CAAA;EAMG,SAcdE,OAAAA,EAAAA;IAgBAC,SAAAA,GAAAA,EAAAA,mBAAgB;EAAA,CAAA;EAIE;AAQH;AAYX;AAAOK;AAA8BA;EAErCA,SAAAA,OAAAA,EAAAA;IAAkCA,SAAAA,WAAAA,EAAAA,mBAAAA;IAA4BA,SAAAA,eAAAA,EAAAA,uBAAAA;IAE/DA,SAAAA,QAAAA,EAAAA,qBAAAA;IAAC,SAAA,MAAA,EAAA,YAAA;EAAA,CAAA;EAEY;AAUX;AAAWzB;AAAuB4B;AAAZC;A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jC0BA,CAAAA,CAAAA,MAAAA,ECiCV,CDjCUA,CAAAA,ECiCN,ODjCMA,CCiCE,CDjCFA,CAAAA;AAArBQ,iBC0C9B,QD1C8BA,CAAAA,gBC2C7B,MD3C6BA,EAAAA,gBC4C7B,cD5C6BA,CC4Cd,CD5CcA,CAAAA,CAAAA,CAAAA,MAAAA,EC8CrC,CD9CqCA,EAAAA,KAAAA,EC+CtC,kBD/CsCA,CC+CnB,CD/CmBA,EC+ChB,CD/CgBA,CAAAA,CAAAA,ECgD3C,ODhD2CA,CCgDnC,CDhDmCA,CAAAA,GCgD9B,eDhD8BA,CCgDd,CDhDcA,ECgDX,CDhDWA,CAAAA;AAA0CzB,iBCiDxE,QDjDwEA,CAAAA,gBCkDvE,MDlDuEA,EAAAA,gBCmDvE,gBDnDuEA,CCmDtD,CDnDsDA,CAAAA,CAAAA,CAAAA,MAAAA,ECoD9E,CDpD8EA,EAAAA,IAAAA,EAAAA,SCoD5D,CDpD4DA,EAAAA,CAAAA,ECoDtD,eDpDsDA,CCoDtC,CDpDsCA,CAAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as fetchEnv, t as NEON_ENV_VAR_KEYS, u as toEntries } from "./env.js";
1
+ import { a as fetchEnv, c as isFunctionBaseUrlKey, l as parseFunctionBaseUrlKey, p as toEntries, s as functionBaseUrlKey, t as NEON_ENV_VAR_KEYS } from "./env.js";
2
2
  import { ErrorCode, PlatformError } from "@neon/config/v1";
3
3
  import { z } from "zod";
4
4
  //#region src/lib/parse-env.ts
@@ -111,6 +111,17 @@ function parseEnv(config, scopeOrKeys) {
111
111
  };
112
112
  else for (const issue of aiGateway.error.issues) issues.push(issue.message);
113
113
  }
114
+ const declaredFunctionSlugs = Object.keys(config.preview?.functions ?? {}).sort();
115
+ if (declaredFunctionSlugs.length > 0) {
116
+ const functions = {};
117
+ for (const slug of declaredFunctionSlugs) {
118
+ const key = functionBaseUrlKey(slug);
119
+ const parsed = readFunctionBaseUrl(key, source[key]);
120
+ if (parsed.ok) functions[slug] = { baseUrl: parsed.value };
121
+ else issues.push(parsed.issue);
122
+ }
123
+ if (Object.keys(functions).length === declaredFunctionSlugs.length) result.functions = functions;
124
+ }
114
125
  if (scope !== void 0) {
115
126
  const fn = config.preview?.functions?.[scope];
116
127
  if (!fn) throw new PlatformError(ErrorCode.EnvNotInjected, [`parseEnv: no function "${scope}" is declared in this policy's preview.functions.`, "Pass a declared function slug (or omit the scope to read external env)."].join("\n"), { details: { scope } });
@@ -125,14 +136,47 @@ function parseEnv(config, scopeOrKeys) {
125
136
  if (issues.length > 0) throw new PlatformError(ErrorCode.EnvNotInjected, [
126
137
  "parseEnv: the required Neon env variables are not present in process.env.",
127
138
  ...issues.map((i) => ` - ${i}`),
128
- "Inject them via one of:",
129
- " - `neon dev` / `neon-env run -- <your dev command>` (wraps the command with the vars injected)",
130
- " - your hosting platform's Neon integration (Vercel, Fly, Railway, …)",
131
- " - for the `function` namespace: deploy the function (`neon deploy` / `config apply`) so its env is uploaded.",
139
+ ...parseEnvInjectHint(issues),
132
140
  "Or switch the call to `await fetchEnv(config, …)` if you're in a context that can do async I/O."
133
141
  ].join("\n"), { details: { missing: issues } });
134
142
  return result;
135
143
  }
144
+ function isFunctionBaseUrlIssue(issue) {
145
+ return /^NEON_FUNCTION_[A-Z0-9]+_BASE_URL (is missing|must not be empty|must be a URL)$/.test(issue);
146
+ }
147
+ function readFunctionBaseUrl(key, value) {
148
+ if (value === void 0) return {
149
+ ok: false,
150
+ issue: `${key} is missing`
151
+ };
152
+ if (value === "") return {
153
+ ok: false,
154
+ issue: `${key} must not be empty`
155
+ };
156
+ try {
157
+ new URL(value);
158
+ } catch {
159
+ return {
160
+ ok: false,
161
+ issue: `${key} must be a URL`
162
+ };
163
+ }
164
+ return {
165
+ ok: true,
166
+ value
167
+ };
168
+ }
169
+ function parseEnvInjectHint(issues) {
170
+ if (issues.length > 0 && issues.every(isFunctionBaseUrlIssue)) return ["Inject them via `neon env pull` or `neon-env run` (production URL), or `neon dev` (`http://localhost:<port>`)."];
171
+ const lines = [
172
+ "Inject them via one of:",
173
+ " - `neon dev` / `neon-env run -- <your dev command>` (wraps the command with the vars injected)",
174
+ " - your hosting platform's Neon integration (Vercel, Fly, Railway, …)"
175
+ ];
176
+ if (issues.some((issue) => issue.includes("(function \""))) lines.push(" - for the `function` namespace: deploy the function (`neon deploy` / `config apply`) so its env is uploaded.");
177
+ if (issues.some(isFunctionBaseUrlIssue)) lines.push(" - for NEON_FUNCTION_*_BASE_URL: `neon env pull` or `neon dev`.");
178
+ return lines;
179
+ }
136
180
  /**
137
181
  * Runtime reverse map for filtered `parseEnv`: OS-level env-var key → `[namespace, property]`
138
182
  * in the {@link NeonEnv} shape. The compile-time mirror is {@link EnvKeysByNamespace} /
@@ -163,7 +207,19 @@ const FILTERABLE_ENV_KEYS = {
163
207
  function parseFilteredEnv(source, keys) {
164
208
  const issues = [];
165
209
  const result = {};
210
+ const functionUrls = {};
166
211
  for (const key of keys) {
212
+ if (isFunctionBaseUrlKey(key)) {
213
+ const slug = parseFunctionBaseUrlKey(key);
214
+ if (slug === null) continue;
215
+ const parsed = readFunctionBaseUrl(key, source[key]);
216
+ if (!parsed.ok) {
217
+ issues.push(parsed.issue);
218
+ continue;
219
+ }
220
+ functionUrls[slug] = { baseUrl: parsed.value };
221
+ continue;
222
+ }
167
223
  if (!Object.hasOwn(FILTERABLE_ENV_KEYS, key)) {
168
224
  issues.push(`${key} is not a selectable Neon env variable`);
169
225
  continue;
@@ -182,17 +238,16 @@ function parseFilteredEnv(source, keys) {
182
238
  bucket[property] = value;
183
239
  result[namespace] = bucket;
184
240
  }
241
+ if (Object.keys(functionUrls).length > 0) result.functions = functionUrls;
185
242
  if (issues.length > 0) throw new PlatformError(ErrorCode.EnvNotInjected, [
186
243
  "parseEnv: the required Neon env variables are not present in process.env.",
187
244
  ...issues.map((i) => ` - ${i}`),
188
- "Inject them via one of:",
189
- " - `neon dev` / `neon-env run -- <your dev command>` (wraps the command with the vars injected)",
190
- " - your hosting platform's Neon integration (Vercel, Fly, Railway, …)",
245
+ ...parseEnvInjectHint(issues),
191
246
  "Or switch the call to `await fetchEnv(config, …)` if you're in a context that can do async I/O."
192
247
  ].join("\n"), { details: { missing: issues } });
193
248
  return result;
194
249
  }
195
250
  //#endregion
196
- export { NEON_ENV_VAR_KEYS, fetchEnv, parseEnv, toEntries };
251
+ export { NEON_ENV_VAR_KEYS, fetchEnv, functionBaseUrlKey, isFunctionBaseUrlKey, parseEnv, parseFunctionBaseUrlKey, toEntries };
197
252
 
198
253
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/lib/parse-env.ts"],"sourcesContent":["/**\n * `parseEnv` — the synchronous, network-free counterpart to `fetchEnv`: read the Neon env vars\n * already injected into `process.env`, validate them against the policy, and return them in the\n * same namespaced shape.\n *\n * Lives in this package rather than in `@neon-internals/env-core` because nothing else needs\n * it. The `neon` CLI resolves env from the API and injects it; it never reads it back. Keeping\n * it here also keeps `zod` out of that package, and so out of every consumer that bundles it.\n */\n\nimport {\n\ttype Config,\n\tErrorCode,\n\tPlatformError,\n\ttype ServiceToggleInput,\n} from \"@neon/config/v1\";\nimport {\n\ttype FilteredNeonEnv,\n\tNEON_ENV_VAR_KEYS,\n\ttype NeonAiGatewayEnv,\n\ttype NeonAuthEnv,\n\ttype NeonBranchEnv,\n\ttype NeonDataApiEnv,\n\ttype NeonEnv,\n\ttype NeonPostgresEnv,\n\ttype NeonStorageEnv,\n\ttype SelectableEnvKey,\n} from \"@neon-internals/env-core/env\";\nimport { z } from \"zod\";\n\n/** The static `preview.functions` record of a config, or an empty record when absent. */\ntype PreviewFunctionsOf<C extends Config> =\n\tNonNullable<C[\"preview\"]> extends {\n\t\tfunctions: infer F;\n\t}\n\t\t? F\n\t\t: Record<never, never>;\n\n/** The declared function slugs of a config (record keys), as a string union. */\nexport type FunctionSlugOf<C extends Config> = Extract<\n\tkeyof PreviewFunctionsOf<C>,\n\tstring\n>;\n\n/**\n * Human-readable hint surfaced as the **expected type** of `parseEnv`'s `scope` argument when\n * the policy declares no functions at all. Without it the argument's expected type is the bare\n * `never` {@link FunctionSlugOf} yields, and TypeScript reports the opaque `Type '\"x\"' is not\n * assignable to type 'never'`; the literal turns that into a sentence naming the fix (and the\n * editor offers it as the single completion, so the empty completion list is explained rather\n * than just empty). Mirrors `NeonAuthRequiredHint` in `@neon/config`.\n */\n// Exported (type-only) for the type tests in `env.test-d.ts`; intentionally not re-exported\n// from `index.ts`, so it stays an internal implementation detail.\nexport type NoFunctionScopeHint =\n\t\"this policy declares no `preview.functions`, so there is no function scope to read. Declare the function in `neon.ts` first, or omit the scope to read the branch env\";\n\n/**\n * The expected type of `parseEnv`'s function-slug `scope` argument: the caller's inferred slug\n * `S` normally, and the {@link NoFunctionScopeHint} message when the policy declares no\n * functions. Keeping `S` (rather than `FunctionSlugOf<C>`) in the enabled branch is what makes\n * the returned `function` namespace exact — it stays the one function's env keys instead of\n * widening to every declared function's.\n */\ntype FunctionScopeField<C extends Config, S extends string> = [\n\tFunctionSlugOf<C>,\n] extends [never]\n\t? NoFunctionScopeHint\n\t: S;\n\n/** The declared env-var keys of one function `S`, as a string union. */\ntype FunctionEnvKeysOf<\n\tC extends Config,\n\tS extends string,\n> = S extends keyof PreviewFunctionsOf<C>\n\t? NonNullable<PreviewFunctionsOf<C>[S]> extends { env: infer E }\n\t\t? Extract<keyof E, string>\n\t\t: never\n\t: never;\n\n/**\n * The extra `function` namespace added to `parseEnv`'s result when called with a function\n * slug scope: the declared env-var keys for that function, each resolved to a `string`.\n */\nexport type NeonFunctionEnv<C extends Config, S extends string> = {\n\tfunction: Record<FunctionEnvKeysOf<C, S>, string>;\n};\n\n// ───────────────────────── parseEnv ─────────────────────────\n\n/**\n * Per-namespace zod schemas. Each defines exactly the OS-level keys parsed from\n * `process.env` for its namespace. Keep in sync with {@link NEON_ENV_VAR_KEYS}.\n *\n * `z.string().url()` would be tighter than `min(1)` but Postgres URIs that include\n * URL-illegal characters in the password (rare but legal in Neon's connection-string\n * format) fail the WHATWG `URL` parse, so we settle for \"non-empty string\".\n */\nconst postgresEnvSchema = z.object({\n\tDATABASE_URL: z\n\t\t.string({ message: \"DATABASE_URL is missing\" })\n\t\t.min(1, \"DATABASE_URL must not be empty\"),\n\tDATABASE_URL_UNPOOLED: z\n\t\t.string({ message: \"DATABASE_URL_UNPOOLED is missing\" })\n\t\t.min(1, \"DATABASE_URL_UNPOOLED must not be empty\"),\n});\n\nconst authEnvSchema = z.object({\n\tNEON_AUTH_BASE_URL: z\n\t\t.string({ message: \"NEON_AUTH_BASE_URL is missing\" })\n\t\t.min(1, \"NEON_AUTH_BASE_URL must not be empty\"),\n\tNEON_AUTH_JWKS_URL: z\n\t\t.string({ message: \"NEON_AUTH_JWKS_URL is missing\" })\n\t\t.min(1, \"NEON_AUTH_JWKS_URL must not be empty\"),\n});\n\nconst dataApiEnvSchema = z.object({\n\tNEON_DATA_API_URL: z\n\t\t.string({ message: \"NEON_DATA_API_URL is missing\" })\n\t\t.min(1, \"NEON_DATA_API_URL must not be empty\"),\n});\n\nconst storageEnvSchema = z.object({\n\tAWS_ACCESS_KEY_ID: z\n\t\t.string({ message: \"AWS_ACCESS_KEY_ID is missing\" })\n\t\t.min(1, \"AWS_ACCESS_KEY_ID must not be empty\"),\n\tAWS_SECRET_ACCESS_KEY: z\n\t\t.string({ message: \"AWS_SECRET_ACCESS_KEY is missing\" })\n\t\t.min(1, \"AWS_SECRET_ACCESS_KEY must not be empty\"),\n\tAWS_ENDPOINT_URL_S3: z\n\t\t.string({ message: \"AWS_ENDPOINT_URL_S3 is missing\" })\n\t\t.min(1, \"AWS_ENDPOINT_URL_S3 must not be empty\"),\n\tAWS_REGION: z\n\t\t.string({ message: \"AWS_REGION is missing\" })\n\t\t.min(1, \"AWS_REGION must not be empty\"),\n});\n\nconst aiGatewayEnvSchema = z.object({\n\tNEON_AI_GATEWAY_TOKEN: z\n\t\t.string({ message: \"NEON_AI_GATEWAY_TOKEN is missing\" })\n\t\t.min(1, \"NEON_AI_GATEWAY_TOKEN must not be empty\"),\n\tNEON_AI_GATEWAY_BASE_URL: z\n\t\t.string({ message: \"NEON_AI_GATEWAY_BASE_URL is missing\" })\n\t\t.min(1, \"NEON_AI_GATEWAY_BASE_URL must not be empty\"),\n});\n\n/** Whether a **static** policy declares object storage (`preview.buckets`). No network. */\nfunction configWantsStorage(config: Config): boolean {\n\treturn Object.keys(config.preview?.buckets ?? {}).length > 0;\n}\n\n/** Whether a **static** policy enables the AI Gateway (`preview.aiGateway`). No network. */\nfunction configWantsAiGateway(config: Config): boolean {\n\treturn isServiceEnabledInput(config.preview?.aiGateway);\n}\n\n/** Static-toggle helper mirroring `config`'s `isServiceEnabled` for the env reader. */\nfunction isServiceEnabledInput(\n\ttoggle: ServiceToggleInput | undefined,\n): boolean {\n\tif (toggle === undefined) return false;\n\tif (typeof toggle === \"boolean\") return toggle;\n\treturn toggle.enabled !== false;\n}\n\n/**\n * Synchronous, network-free counterpart to {@link fetchEnv}. Reads `process.env`, validates\n * the required Neon env vars with zod, and returns the same {@link NeonEnv} shape — so the\n * rest of your app touches `env.postgres.databaseUrl` instead of stringly-typed\n * `process.env.DATABASE_URL` lookups.\n *\n * Designed for the **\"env-vars-already-injected\"** path:\n * - You wrapped your dev command with `neon-env run -- <cmd>` or `neon dev`.\n * - Your platform (Vercel, Fly, Railway, …) injected the vars via its own integration.\n * - You are **inside a deployed Neon Function**, whose env was uploaded at `config apply`.\n *\n * Unlike the old API, `parseEnv` does **not** take a branch name: the secret set is now\n * static (top-level `config.auth` / `config.dataApi`), so it reads those directly without\n * evaluating the per-branch closure.\n *\n * The second argument is a **scope** or a **key filter**:\n * - omitted — *external* scope (app bootstrap, build scripts, your dev machine). Returns the\n * full `{ postgres, auth?, dataApi?, … }` the policy enables.\n * - a **function slug** (a key of `config.preview.functions`) — *function* scope: you are\n * running inside that function. Returns the same branch secrets **plus** a typed\n * `function` namespace with the function's declared env-var keys. The slug autocompletes\n * from the policy ({@link FunctionSlugOf}) and an undeclared one is a type error.\n * - an **array of OS-level env-var keys** (e.g. `[\"DATABASE_URL\", \"NEON_AUTH_BASE_URL\"]`) —\n * *filtered* mode: only those vars are required and returned, as a narrowed namespaced\n * shape. The keys autocomplete from the policy ({@link SelectableEnvKey}), so you can only\n * pick vars the policy actually enables. Use this when a process needs just a subset (a\n * Next.js app that reads `DATABASE_URL` but not `DATABASE_URL_UNPOOLED`, say) and you don't\n * want `parseEnv` to throw over vars you never use.\n *\n * Throws `PlatformError(EnvNotInjected)` listing every missing/invalid var when the env\n * isn't fully populated, with a fix hint pointing back at `neon dev` / `neon-env run`.\n *\n * ```ts\n * import config from \"../neon\";\n * import { parseEnv } from \"@neon/env\";\n *\n * // External (app / build):\n * const env = parseEnv(config);\n * const db = drizzle(neon(env.postgres.databaseUrl), { schema });\n *\n * // Inside the \"hello\" function:\n * const env = parseEnv(config, \"hello\");\n * env.function.resendApiKey; // typed from hello's declared env keys\n *\n * // Filtered: only enforce + return the pooled URL.\n * const { postgres } = parseEnv(config, [\"DATABASE_URL\"]);\n * postgres.databaseUrl; // string — `databaseUrlUnpooled` is absent\n * ```\n */\nexport function parseEnv<const C extends Config>(config: C): NeonEnv<C>;\n// Overload order is load-bearing for **editor autocomplete**, not for type checking: when the\n// argument is a half-typed string literal the call resolves against no signature, and the\n// editor takes its string-literal completions from the first candidate overload. With the\n// `keys` overload listed first, the expected type of `parseEnv(config, \"…\")` is read as\n// `readonly K[]` — an array has no literal completions, so typing a function slug offered\n// nothing. Keep the slug overload ahead of the array one: `env.completions.test.ts` asserts the\n// completions through the language service, and `env.test-d.ts` locks the order itself (the\n// last overload is observable as `Parameters<typeof parseEnv>`), so `tsc` fails on a reorder.\nexport function parseEnv<\n\tconst C extends Config,\n\tconst S extends FunctionSlugOf<C>,\n>(\n\tconfig: C,\n\tscope: FunctionScopeField<C, S>,\n): NeonEnv<C> & NeonFunctionEnv<C, S>;\nexport function parseEnv<\n\tconst C extends Config,\n\tconst K extends SelectableEnvKey<C>,\n>(config: C, keys: readonly K[]): FilteredNeonEnv<K>;\nexport function parseEnv(\n\tconfig: Config,\n\tscopeOrKeys?: string | readonly string[],\n): unknown {\n\tconst source = process.env;\n\tif (Array.isArray(scopeOrKeys)) {\n\t\treturn parseFilteredEnv(source, scopeOrKeys);\n\t}\n\t// `Array.isArray` doesn't narrow a `readonly string[]` out of the union, so re-derive the\n\t// function-slug scope from the remaining `string` shape explicitly.\n\tconst scope = typeof scopeOrKeys === \"string\" ? scopeOrKeys : undefined;\n\tconst issues: string[] = [];\n\tconst result: Record<string, unknown> = {};\n\n\tconst pg = postgresEnvSchema.safeParse({\n\t\tDATABASE_URL: source.DATABASE_URL,\n\t\tDATABASE_URL_UNPOOLED: source.DATABASE_URL_UNPOOLED,\n\t});\n\tif (pg.success) {\n\t\tresult.postgres = {\n\t\t\tdatabaseUrl: pg.data.DATABASE_URL,\n\t\t\tdatabaseUrlUnpooled: pg.data.DATABASE_URL_UNPOOLED,\n\t\t} satisfies NeonPostgresEnv;\n\t} else {\n\t\tfor (const issue of pg.error.issues) issues.push(issue.message);\n\t}\n\n\t// Branch identity is optional: the Functions runtime injects `NEON_BRANCH` on every\n\t// branch by default and `neon dev` / `neon-env run` / `env pull` emit it too, but older\n\t// runtimes and platform integrations may not, so a missing value is not an error — we\n\t// just omit the namespace rather than failing the whole parse.\n\tconst branchName = source[NEON_ENV_VAR_KEYS.branch.name];\n\tif (branchName !== undefined && branchName !== \"\") {\n\t\tresult.branch = { name: branchName } satisfies NeonBranchEnv;\n\t}\n\n\tif (isServiceEnabledInput(config.auth)) {\n\t\tconst auth = authEnvSchema.safeParse({\n\t\t\tNEON_AUTH_BASE_URL: source.NEON_AUTH_BASE_URL,\n\t\t\tNEON_AUTH_JWKS_URL: source.NEON_AUTH_JWKS_URL,\n\t\t});\n\t\tif (auth.success) {\n\t\t\tresult.auth = {\n\t\t\t\tbaseUrl: auth.data.NEON_AUTH_BASE_URL,\n\t\t\t\tjwksUrl: auth.data.NEON_AUTH_JWKS_URL,\n\t\t\t} satisfies NeonAuthEnv;\n\t\t} else {\n\t\t\tfor (const issue of auth.error.issues) issues.push(issue.message);\n\t\t}\n\t}\n\n\tif (isServiceEnabledInput(config.dataApi)) {\n\t\tconst dataApi = dataApiEnvSchema.safeParse({\n\t\t\tNEON_DATA_API_URL: source.NEON_DATA_API_URL,\n\t\t});\n\t\tif (dataApi.success) {\n\t\t\tresult.dataApi = {\n\t\t\t\turl: dataApi.data.NEON_DATA_API_URL,\n\t\t\t} satisfies NeonDataApiEnv;\n\t\t} else {\n\t\t\tfor (const issue of dataApi.error.issues)\n\t\t\t\tissues.push(issue.message);\n\t\t}\n\t}\n\n\tif (configWantsStorage(config)) {\n\t\tconst storage = storageEnvSchema.safeParse({\n\t\t\tAWS_ACCESS_KEY_ID: source.AWS_ACCESS_KEY_ID,\n\t\t\tAWS_SECRET_ACCESS_KEY: source.AWS_SECRET_ACCESS_KEY,\n\t\t\tAWS_ENDPOINT_URL_S3: source.AWS_ENDPOINT_URL_S3,\n\t\t\tAWS_REGION: source.AWS_REGION,\n\t\t});\n\t\tif (storage.success) {\n\t\t\tresult.storage = {\n\t\t\t\taccessKeyId: storage.data.AWS_ACCESS_KEY_ID,\n\t\t\t\tsecretAccessKey: storage.data.AWS_SECRET_ACCESS_KEY,\n\t\t\t\tendpoint: storage.data.AWS_ENDPOINT_URL_S3,\n\t\t\t\tregion: storage.data.AWS_REGION,\n\t\t\t} satisfies NeonStorageEnv;\n\t\t} else {\n\t\t\tfor (const issue of storage.error.issues)\n\t\t\t\tissues.push(issue.message);\n\t\t}\n\t}\n\n\tif (configWantsAiGateway(config)) {\n\t\tconst aiGateway = aiGatewayEnvSchema.safeParse({\n\t\t\tNEON_AI_GATEWAY_TOKEN: source.NEON_AI_GATEWAY_TOKEN,\n\t\t\tNEON_AI_GATEWAY_BASE_URL: source.NEON_AI_GATEWAY_BASE_URL,\n\t\t});\n\t\tif (aiGateway.success) {\n\t\t\tresult.aiGateway = {\n\t\t\t\tapiKey: aiGateway.data.NEON_AI_GATEWAY_TOKEN,\n\t\t\t\tbaseUrl: aiGateway.data.NEON_AI_GATEWAY_BASE_URL,\n\t\t\t} satisfies NeonAiGatewayEnv;\n\t\t} else {\n\t\t\tfor (const issue of aiGateway.error.issues)\n\t\t\t\tissues.push(issue.message);\n\t\t}\n\t}\n\n\tif (scope !== undefined) {\n\t\tconst fn = config.preview?.functions?.[scope];\n\t\tif (!fn) {\n\t\t\tthrow new PlatformError(\n\t\t\t\tErrorCode.EnvNotInjected,\n\t\t\t\t[\n\t\t\t\t\t`parseEnv: no function \"${scope}\" is declared in this policy's preview.functions.`,\n\t\t\t\t\t\"Pass a declared function slug (or omit the scope to read external env).\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t{ details: { scope } },\n\t\t\t);\n\t\t}\n\t\tconst envOut: Record<string, string> = {};\n\t\tfor (const key of Object.keys(fn.env ?? {})) {\n\t\t\tconst value = source[key];\n\t\t\t// Only a truly *unset* var is \"not injected\". Function env values carry no\n\t\t\t// non-empty constraint (unlike DATABASE_URL / NEON_AUTH_BASE_URL), so a\n\t\t\t// deliberately empty value is a present, valid value and is passed through.\n\t\t\tif (value === undefined) {\n\t\t\t\tissues.push(`${key} is missing (function \"${scope}\")`);\n\t\t\t} else {\n\t\t\t\tenvOut[key] = value;\n\t\t\t}\n\t\t}\n\t\tresult.function = envOut;\n\t}\n\n\tif (issues.length > 0) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.EnvNotInjected,\n\t\t\t[\n\t\t\t\t\"parseEnv: the required Neon env variables are not present in process.env.\",\n\t\t\t\t...issues.map((i) => ` - ${i}`),\n\t\t\t\t\"Inject them via one of:\",\n\t\t\t\t\" - `neon dev` / `neon-env run -- <your dev command>` (wraps the command with the vars injected)\",\n\t\t\t\t\" - your hosting platform's Neon integration (Vercel, Fly, Railway, …)\",\n\t\t\t\t\" - for the `function` namespace: deploy the function (`neon deploy` / `config apply`) so its env is uploaded.\",\n\t\t\t\t\"Or switch the call to `await fetchEnv(config, …)` if you're in a context that can do async I/O.\",\n\t\t\t].join(\"\\n\"),\n\t\t\t{ details: { missing: issues } },\n\t\t);\n\t}\n\n\treturn result;\n}\n\n/**\n * Runtime reverse map for filtered `parseEnv`: OS-level env-var key → `[namespace, property]`\n * in the {@link NeonEnv} shape. The compile-time mirror is {@link EnvKeysByNamespace} /\n * {@link EnvKeyToProp}; keep all three in sync. Only input vars appear (no output-only\n * aliases).\n */\nconst FILTERABLE_ENV_KEYS: Record<string, readonly [string, string]> = {\n\tDATABASE_URL: [\"postgres\", \"databaseUrl\"],\n\tDATABASE_URL_UNPOOLED: [\"postgres\", \"databaseUrlUnpooled\"],\n\tNEON_BRANCH: [\"branch\", \"name\"],\n\tNEON_AUTH_BASE_URL: [\"auth\", \"baseUrl\"],\n\tNEON_AUTH_JWKS_URL: [\"auth\", \"jwksUrl\"],\n\tNEON_DATA_API_URL: [\"dataApi\", \"url\"],\n\tAWS_ACCESS_KEY_ID: [\"storage\", \"accessKeyId\"],\n\tAWS_SECRET_ACCESS_KEY: [\"storage\", \"secretAccessKey\"],\n\tAWS_ENDPOINT_URL_S3: [\"storage\", \"endpoint\"],\n\tAWS_REGION: [\"storage\", \"region\"],\n\tNEON_AI_GATEWAY_TOKEN: [\"aiGateway\", \"apiKey\"],\n\tNEON_AI_GATEWAY_BASE_URL: [\"aiGateway\", \"baseUrl\"],\n};\n\n/**\n * Filtered counterpart to the {@link parseEnv} body: validate and return only the explicitly\n * selected OS-level env-var keys, projected back into the narrowed namespaced shape. Unlike\n * the full reader it never consults the policy — the selection alone decides what's required —\n * so vars the caller didn't ask for (e.g. `DATABASE_URL_UNPOOLED`) can be absent without\n * throwing. Mirrors the same non-empty constraint and {@link PlatformError} aggregation.\n */\nfunction parseFilteredEnv(\n\tsource: NodeJS.ProcessEnv,\n\tkeys: readonly string[],\n): Record<string, Record<string, string>> {\n\tconst issues: string[] = [];\n\tconst result: Record<string, Record<string, string>> = {};\n\tfor (const key of keys) {\n\t\t// Unknown keys are blocked at the type level; a runtime caller bypassing the types\n\t\t// gets a clear error rather than a silently-dropped selection.\n\t\tif (!Object.hasOwn(FILTERABLE_ENV_KEYS, key)) {\n\t\t\tissues.push(`${key} is not a selectable Neon env variable`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst value = source[key];\n\t\tif (value === undefined) {\n\t\t\tissues.push(`${key} is missing`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (value === \"\") {\n\t\t\tissues.push(`${key} must not be empty`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst [namespace, property] = FILTERABLE_ENV_KEYS[key];\n\t\tconst bucket = result[namespace] ?? {};\n\t\tbucket[property] = value;\n\t\tresult[namespace] = bucket;\n\t}\n\tif (issues.length > 0) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.EnvNotInjected,\n\t\t\t[\n\t\t\t\t\"parseEnv: the required Neon env variables are not present in process.env.\",\n\t\t\t\t...issues.map((i) => ` - ${i}`),\n\t\t\t\t\"Inject them via one of:\",\n\t\t\t\t\" - `neon dev` / `neon-env run -- <your dev command>` (wraps the command with the vars injected)\",\n\t\t\t\t\" - your hosting platform's Neon integration (Vercel, Fly, Railway, …)\",\n\t\t\t\t\"Or switch the call to `await fetchEnv(config, …)` if you're in a context that can do async I/O.\",\n\t\t\t].join(\"\\n\"),\n\t\t\t{ details: { missing: issues } },\n\t\t);\n\t}\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkGA,MAAM,oBAAoB,EAAE,OAAO;CAClC,cAAc,EACZ,OAAO,EAAE,SAAS,0BAA0B,CAAC,CAAC,CAC9C,IAAI,GAAG,gCAAgC;CACzC,uBAAuB,EACrB,OAAO,EAAE,SAAS,mCAAmC,CAAC,CAAC,CACvD,IAAI,GAAG,yCAAyC;AACnD,CAAC;AAED,MAAM,gBAAgB,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`parseEnv` — the synchronous, network-free counterpart to `fetchEnv`: read the Neon env vars\n * already injected into `process.env`, validate them against the policy, and return them in the\n * same namespaced shape.\n *\n * Lives in this package rather than in `@neon-internals/env-core` because nothing else needs\n * it. The `neon` CLI resolves env from the API and injects it; it never reads it back. Keeping\n * it here also keeps `zod` out of that package, and so out of every consumer that bundles it.\n */\n\nimport {\n\ttype Config,\n\tErrorCode,\n\tPlatformError,\n\ttype ServiceToggleInput,\n} from \"@neon/config/v1\";\nimport {\n\ttype FilteredNeonEnv,\n\tfunctionBaseUrlKey,\n\tisFunctionBaseUrlKey,\n\tNEON_ENV_VAR_KEYS,\n\ttype NeonAiGatewayEnv,\n\ttype NeonAuthEnv,\n\ttype NeonBranchEnv,\n\ttype NeonDataApiEnv,\n\ttype NeonEnv,\n\ttype NeonFunctionUrlEnv,\n\ttype NeonPostgresEnv,\n\ttype NeonStorageEnv,\n\tparseFunctionBaseUrlKey,\n\ttype SelectableEnvKey,\n} from \"@neon-internals/env-core/env\";\nimport { z } from \"zod\";\n\n/** The static `preview.functions` record of a config, or an empty record when absent. */\ntype PreviewFunctionsOf<C extends Config> =\n\tNonNullable<C[\"preview\"]> extends {\n\t\tfunctions: infer F;\n\t}\n\t\t? F\n\t\t: Record<never, never>;\n\n/** The declared function slugs of a config (record keys), as a string union. */\nexport type FunctionSlugOf<C extends Config> = Extract<\n\tkeyof PreviewFunctionsOf<C>,\n\tstring\n>;\n\n/**\n * Human-readable hint surfaced as the **expected type** of `parseEnv`'s `scope` argument when\n * the policy declares no functions at all. Without it the argument's expected type is the bare\n * `never` {@link FunctionSlugOf} yields, and TypeScript reports the opaque `Type '\"x\"' is not\n * assignable to type 'never'`; the literal turns that into a sentence naming the fix (and the\n * editor offers it as the single completion, so the empty completion list is explained rather\n * than just empty). Mirrors `NeonAuthRequiredHint` in `@neon/config`.\n */\n// Exported (type-only) for the type tests in `env.test-d.ts`; intentionally not re-exported\n// from `index.ts`, so it stays an internal implementation detail.\nexport type NoFunctionScopeHint =\n\t\"this policy declares no `preview.functions`, so there is no function scope to read. Declare the function in `neon.ts` first, or omit the scope to read the branch env\";\n\n/**\n * The expected type of `parseEnv`'s function-slug `scope` argument: the caller's inferred slug\n * `S` normally, and the {@link NoFunctionScopeHint} message when the policy declares no\n * functions. Keeping `S` (rather than `FunctionSlugOf<C>`) in the enabled branch is what makes\n * the returned `function` namespace exact — it stays the one function's env keys instead of\n * widening to every declared function's.\n */\ntype FunctionScopeField<C extends Config, S extends string> = [\n\tFunctionSlugOf<C>,\n] extends [never]\n\t? NoFunctionScopeHint\n\t: S;\n\n/** The declared env-var keys of one function `S`, as a string union. */\ntype FunctionEnvKeysOf<\n\tC extends Config,\n\tS extends string,\n> = S extends keyof PreviewFunctionsOf<C>\n\t? NonNullable<PreviewFunctionsOf<C>[S]> extends { env: infer E }\n\t\t? Extract<keyof E, string>\n\t\t: never\n\t: never;\n\n/**\n * The extra `function` namespace added to `parseEnv`'s result when called with a function\n * slug scope: the declared env-var keys for that function, each resolved to a `string`.\n */\nexport type NeonFunctionEnv<C extends Config, S extends string> = {\n\tfunction: Record<FunctionEnvKeysOf<C, S>, string>;\n};\n\n// ───────────────────────── parseEnv ─────────────────────────\n\n/**\n * Per-namespace zod schemas. Each defines exactly the OS-level keys parsed from\n * `process.env` for its namespace. Keep in sync with {@link NEON_ENV_VAR_KEYS}.\n *\n * `z.string().url()` would be tighter than `min(1)` but Postgres URIs that include\n * URL-illegal characters in the password (rare but legal in Neon's connection-string\n * format) fail the WHATWG `URL` parse, so we settle for \"non-empty string\".\n */\nconst postgresEnvSchema = z.object({\n\tDATABASE_URL: z\n\t\t.string({ message: \"DATABASE_URL is missing\" })\n\t\t.min(1, \"DATABASE_URL must not be empty\"),\n\tDATABASE_URL_UNPOOLED: z\n\t\t.string({ message: \"DATABASE_URL_UNPOOLED is missing\" })\n\t\t.min(1, \"DATABASE_URL_UNPOOLED must not be empty\"),\n});\n\nconst authEnvSchema = z.object({\n\tNEON_AUTH_BASE_URL: z\n\t\t.string({ message: \"NEON_AUTH_BASE_URL is missing\" })\n\t\t.min(1, \"NEON_AUTH_BASE_URL must not be empty\"),\n\tNEON_AUTH_JWKS_URL: z\n\t\t.string({ message: \"NEON_AUTH_JWKS_URL is missing\" })\n\t\t.min(1, \"NEON_AUTH_JWKS_URL must not be empty\"),\n});\n\nconst dataApiEnvSchema = z.object({\n\tNEON_DATA_API_URL: z\n\t\t.string({ message: \"NEON_DATA_API_URL is missing\" })\n\t\t.min(1, \"NEON_DATA_API_URL must not be empty\"),\n});\n\nconst storageEnvSchema = z.object({\n\tAWS_ACCESS_KEY_ID: z\n\t\t.string({ message: \"AWS_ACCESS_KEY_ID is missing\" })\n\t\t.min(1, \"AWS_ACCESS_KEY_ID must not be empty\"),\n\tAWS_SECRET_ACCESS_KEY: z\n\t\t.string({ message: \"AWS_SECRET_ACCESS_KEY is missing\" })\n\t\t.min(1, \"AWS_SECRET_ACCESS_KEY must not be empty\"),\n\tAWS_ENDPOINT_URL_S3: z\n\t\t.string({ message: \"AWS_ENDPOINT_URL_S3 is missing\" })\n\t\t.min(1, \"AWS_ENDPOINT_URL_S3 must not be empty\"),\n\tAWS_REGION: z\n\t\t.string({ message: \"AWS_REGION is missing\" })\n\t\t.min(1, \"AWS_REGION must not be empty\"),\n});\n\nconst aiGatewayEnvSchema = z.object({\n\tNEON_AI_GATEWAY_TOKEN: z\n\t\t.string({ message: \"NEON_AI_GATEWAY_TOKEN is missing\" })\n\t\t.min(1, \"NEON_AI_GATEWAY_TOKEN must not be empty\"),\n\tNEON_AI_GATEWAY_BASE_URL: z\n\t\t.string({ message: \"NEON_AI_GATEWAY_BASE_URL is missing\" })\n\t\t.min(1, \"NEON_AI_GATEWAY_BASE_URL must not be empty\"),\n});\n\n/** Whether a **static** policy declares object storage (`preview.buckets`). No network. */\nfunction configWantsStorage(config: Config): boolean {\n\treturn Object.keys(config.preview?.buckets ?? {}).length > 0;\n}\n\n/** Whether a **static** policy enables the AI Gateway (`preview.aiGateway`). No network. */\nfunction configWantsAiGateway(config: Config): boolean {\n\treturn isServiceEnabledInput(config.preview?.aiGateway);\n}\n\n/** Static-toggle helper mirroring `config`'s `isServiceEnabled` for the env reader. */\nfunction isServiceEnabledInput(\n\ttoggle: ServiceToggleInput | undefined,\n): boolean {\n\tif (toggle === undefined) return false;\n\tif (typeof toggle === \"boolean\") return toggle;\n\treturn toggle.enabled !== false;\n}\n\n/**\n * Synchronous, network-free counterpart to {@link fetchEnv}. Reads `process.env`, validates\n * the required Neon env vars with zod, and returns the same {@link NeonEnv} shape — so the\n * rest of your app touches `env.postgres.databaseUrl` instead of stringly-typed\n * `process.env.DATABASE_URL` lookups.\n *\n * Designed for the **\"env-vars-already-injected\"** path:\n * - You wrapped your dev command with `neon-env run -- <cmd>` or `neon dev`.\n * - Your platform (Vercel, Fly, Railway, …) injected the vars via its own integration.\n * - You are **inside a deployed Neon Function**, whose env was uploaded at `config apply`.\n *\n * Unlike the old API, `parseEnv` does **not** take a branch name: the secret set is now\n * static (top-level `config.auth` / `config.dataApi`), so it reads those directly without\n * evaluating the per-branch closure.\n *\n * The second argument is a **scope** or a **key filter**:\n * - omitted — *external* scope (app bootstrap, build scripts, your dev machine). Returns the\n * full `{ postgres, auth?, dataApi?, … }` the policy enables.\n * - a **function slug** (a key of `config.preview.functions`) — *function* scope: you are\n * running inside that function. Returns the same branch secrets **plus** a typed\n * `function` namespace with the function's declared env-var keys. The slug autocompletes\n * from the policy ({@link FunctionSlugOf}) and an undeclared one is a type error.\n * - an **array of OS-level env-var keys** (e.g. `[\"DATABASE_URL\", \"NEON_AUTH_BASE_URL\"]`) —\n * *filtered* mode: only those vars are required and returned, as a narrowed namespaced\n * shape. The keys autocomplete from the policy ({@link SelectableEnvKey}), so you can only\n * pick vars the policy actually enables. Use this when a process needs just a subset (a\n * Next.js app that reads `DATABASE_URL` but not `DATABASE_URL_UNPOOLED`, say) and you don't\n * want `parseEnv` to throw over vars you never use.\n *\n * Throws `PlatformError(EnvNotInjected)` listing every missing/invalid var when the env\n * isn't fully populated, with a fix hint pointing back at `neon dev` / `neon-env run`.\n *\n * ```ts\n * import config from \"../neon\";\n * import { parseEnv } from \"@neon/env\";\n *\n * // External (app / build):\n * const env = parseEnv(config);\n * const db = drizzle(neon(env.postgres.databaseUrl), { schema });\n *\n * // Inside the \"hello\" function:\n * const env = parseEnv(config, \"hello\");\n * env.function.resendApiKey; // typed from hello's declared env keys\n *\n * // Filtered: only enforce + return the pooled URL.\n * const { postgres } = parseEnv(config, [\"DATABASE_URL\"]);\n * postgres.databaseUrl; // string — `databaseUrlUnpooled` is absent\n * ```\n */\nexport function parseEnv<const C extends Config>(config: C): NeonEnv<C>;\n// Overload order is load-bearing for **editor autocomplete**, not for type checking: when the\n// argument is a half-typed string literal the call resolves against no signature, and the\n// editor takes its string-literal completions from the first candidate overload. With the\n// `keys` overload listed first, the expected type of `parseEnv(config, \"…\")` is read as\n// `readonly K[]` — an array has no literal completions, so typing a function slug offered\n// nothing. Keep the slug overload ahead of the array one: `env.completions.test.ts` asserts the\n// completions through the language service, and `env.test-d.ts` locks the order itself (the\n// last overload is observable as `Parameters<typeof parseEnv>`), so `tsc` fails on a reorder.\nexport function parseEnv<\n\tconst C extends Config,\n\tconst S extends FunctionSlugOf<C>,\n>(\n\tconfig: C,\n\tscope: FunctionScopeField<C, S>,\n): NeonEnv<C> & NeonFunctionEnv<C, S>;\nexport function parseEnv<\n\tconst C extends Config,\n\tconst K extends SelectableEnvKey<C>,\n>(config: C, keys: readonly K[]): FilteredNeonEnv<K>;\nexport function parseEnv(\n\tconfig: Config,\n\tscopeOrKeys?: string | readonly string[],\n): unknown {\n\tconst source = process.env;\n\tif (Array.isArray(scopeOrKeys)) {\n\t\treturn parseFilteredEnv(source, scopeOrKeys);\n\t}\n\t// `Array.isArray` doesn't narrow a `readonly string[]` out of the union, so re-derive the\n\t// function-slug scope from the remaining `string` shape explicitly.\n\tconst scope = typeof scopeOrKeys === \"string\" ? scopeOrKeys : undefined;\n\tconst issues: string[] = [];\n\tconst result: Record<string, unknown> = {};\n\n\tconst pg = postgresEnvSchema.safeParse({\n\t\tDATABASE_URL: source.DATABASE_URL,\n\t\tDATABASE_URL_UNPOOLED: source.DATABASE_URL_UNPOOLED,\n\t});\n\tif (pg.success) {\n\t\tresult.postgres = {\n\t\t\tdatabaseUrl: pg.data.DATABASE_URL,\n\t\t\tdatabaseUrlUnpooled: pg.data.DATABASE_URL_UNPOOLED,\n\t\t} satisfies NeonPostgresEnv;\n\t} else {\n\t\tfor (const issue of pg.error.issues) issues.push(issue.message);\n\t}\n\n\t// Branch identity is optional: the Functions runtime injects `NEON_BRANCH` on every\n\t// branch by default and `neon dev` / `neon-env run` / `env pull` emit it too, but older\n\t// runtimes and platform integrations may not, so a missing value is not an error — we\n\t// just omit the namespace rather than failing the whole parse.\n\tconst branchName = source[NEON_ENV_VAR_KEYS.branch.name];\n\tif (branchName !== undefined && branchName !== \"\") {\n\t\tresult.branch = { name: branchName } satisfies NeonBranchEnv;\n\t}\n\n\tif (isServiceEnabledInput(config.auth)) {\n\t\tconst auth = authEnvSchema.safeParse({\n\t\t\tNEON_AUTH_BASE_URL: source.NEON_AUTH_BASE_URL,\n\t\t\tNEON_AUTH_JWKS_URL: source.NEON_AUTH_JWKS_URL,\n\t\t});\n\t\tif (auth.success) {\n\t\t\tresult.auth = {\n\t\t\t\tbaseUrl: auth.data.NEON_AUTH_BASE_URL,\n\t\t\t\tjwksUrl: auth.data.NEON_AUTH_JWKS_URL,\n\t\t\t} satisfies NeonAuthEnv;\n\t\t} else {\n\t\t\tfor (const issue of auth.error.issues) issues.push(issue.message);\n\t\t}\n\t}\n\n\tif (isServiceEnabledInput(config.dataApi)) {\n\t\tconst dataApi = dataApiEnvSchema.safeParse({\n\t\t\tNEON_DATA_API_URL: source.NEON_DATA_API_URL,\n\t\t});\n\t\tif (dataApi.success) {\n\t\t\tresult.dataApi = {\n\t\t\t\turl: dataApi.data.NEON_DATA_API_URL,\n\t\t\t} satisfies NeonDataApiEnv;\n\t\t} else {\n\t\t\tfor (const issue of dataApi.error.issues)\n\t\t\t\tissues.push(issue.message);\n\t\t}\n\t}\n\n\tif (configWantsStorage(config)) {\n\t\tconst storage = storageEnvSchema.safeParse({\n\t\t\tAWS_ACCESS_KEY_ID: source.AWS_ACCESS_KEY_ID,\n\t\t\tAWS_SECRET_ACCESS_KEY: source.AWS_SECRET_ACCESS_KEY,\n\t\t\tAWS_ENDPOINT_URL_S3: source.AWS_ENDPOINT_URL_S3,\n\t\t\tAWS_REGION: source.AWS_REGION,\n\t\t});\n\t\tif (storage.success) {\n\t\t\tresult.storage = {\n\t\t\t\taccessKeyId: storage.data.AWS_ACCESS_KEY_ID,\n\t\t\t\tsecretAccessKey: storage.data.AWS_SECRET_ACCESS_KEY,\n\t\t\t\tendpoint: storage.data.AWS_ENDPOINT_URL_S3,\n\t\t\t\tregion: storage.data.AWS_REGION,\n\t\t\t} satisfies NeonStorageEnv;\n\t\t} else {\n\t\t\tfor (const issue of storage.error.issues)\n\t\t\t\tissues.push(issue.message);\n\t\t}\n\t}\n\n\tif (configWantsAiGateway(config)) {\n\t\tconst aiGateway = aiGatewayEnvSchema.safeParse({\n\t\t\tNEON_AI_GATEWAY_TOKEN: source.NEON_AI_GATEWAY_TOKEN,\n\t\t\tNEON_AI_GATEWAY_BASE_URL: source.NEON_AI_GATEWAY_BASE_URL,\n\t\t});\n\t\tif (aiGateway.success) {\n\t\t\tresult.aiGateway = {\n\t\t\t\tapiKey: aiGateway.data.NEON_AI_GATEWAY_TOKEN,\n\t\t\t\tbaseUrl: aiGateway.data.NEON_AI_GATEWAY_BASE_URL,\n\t\t\t} satisfies NeonAiGatewayEnv;\n\t\t} else {\n\t\t\tfor (const issue of aiGateway.error.issues)\n\t\t\t\tissues.push(issue.message);\n\t\t}\n\t}\n\n\tconst declaredFunctionSlugs = Object.keys(\n\t\tconfig.preview?.functions ?? {},\n\t).sort();\n\tif (declaredFunctionSlugs.length > 0) {\n\t\tconst functions: Record<string, NeonFunctionUrlEnv> = {};\n\t\tfor (const slug of declaredFunctionSlugs) {\n\t\t\tconst key = functionBaseUrlKey(slug);\n\t\t\tconst parsed = readFunctionBaseUrl(key, source[key]);\n\t\t\tif (parsed.ok) {\n\t\t\t\tfunctions[slug] = { baseUrl: parsed.value };\n\t\t\t} else {\n\t\t\t\tissues.push(parsed.issue);\n\t\t\t}\n\t\t}\n\t\tif (Object.keys(functions).length === declaredFunctionSlugs.length) {\n\t\t\tresult.functions = functions;\n\t\t}\n\t}\n\n\tif (scope !== undefined) {\n\t\tconst fn = config.preview?.functions?.[scope];\n\t\tif (!fn) {\n\t\t\tthrow new PlatformError(\n\t\t\t\tErrorCode.EnvNotInjected,\n\t\t\t\t[\n\t\t\t\t\t`parseEnv: no function \"${scope}\" is declared in this policy's preview.functions.`,\n\t\t\t\t\t\"Pass a declared function slug (or omit the scope to read external env).\",\n\t\t\t\t].join(\"\\n\"),\n\t\t\t\t{ details: { scope } },\n\t\t\t);\n\t\t}\n\t\tconst envOut: Record<string, string> = {};\n\t\tfor (const key of Object.keys(fn.env ?? {})) {\n\t\t\tconst value = source[key];\n\t\t\t// Only a truly *unset* var is \"not injected\". Function env values carry no\n\t\t\t// non-empty constraint (unlike DATABASE_URL / NEON_AUTH_BASE_URL), so a\n\t\t\t// deliberately empty value is a present, valid value and is passed through.\n\t\t\tif (value === undefined) {\n\t\t\t\tissues.push(`${key} is missing (function \"${scope}\")`);\n\t\t\t} else {\n\t\t\t\tenvOut[key] = value;\n\t\t\t}\n\t\t}\n\t\tresult.function = envOut;\n\t}\n\n\tif (issues.length > 0) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.EnvNotInjected,\n\t\t\t[\n\t\t\t\t\"parseEnv: the required Neon env variables are not present in process.env.\",\n\t\t\t\t...issues.map((i) => ` - ${i}`),\n\t\t\t\t...parseEnvInjectHint(issues),\n\t\t\t\t\"Or switch the call to `await fetchEnv(config, …)` if you're in a context that can do async I/O.\",\n\t\t\t].join(\"\\n\"),\n\t\t\t{ details: { missing: issues } },\n\t\t);\n\t}\n\n\treturn result;\n}\n\nfunction isFunctionBaseUrlIssue(issue: string): boolean {\n\treturn /^NEON_FUNCTION_[A-Z0-9]+_BASE_URL (is missing|must not be empty|must be a URL)$/.test(\n\t\tissue,\n\t);\n}\n\nfunction readFunctionBaseUrl(\n\tkey: string,\n\tvalue: string | undefined,\n): { ok: true; value: string } | { ok: false; issue: string } {\n\tif (value === undefined) {\n\t\treturn { ok: false, issue: `${key} is missing` };\n\t}\n\tif (value === \"\") {\n\t\treturn { ok: false, issue: `${key} must not be empty` };\n\t}\n\ttry {\n\t\tnew URL(value);\n\t} catch {\n\t\treturn { ok: false, issue: `${key} must be a URL` };\n\t}\n\treturn { ok: true, value };\n}\n\nfunction parseEnvInjectHint(issues: readonly string[]): string[] {\n\tif (issues.length > 0 && issues.every(isFunctionBaseUrlIssue)) {\n\t\treturn [\n\t\t\t\"Inject them via `neon env pull` or `neon-env run` (production URL), or `neon dev` (`http://localhost:<port>`).\",\n\t\t];\n\t}\n\tconst lines = [\n\t\t\"Inject them via one of:\",\n\t\t\" - `neon dev` / `neon-env run -- <your dev command>` (wraps the command with the vars injected)\",\n\t\t\" - your hosting platform's Neon integration (Vercel, Fly, Railway, …)\",\n\t];\n\tif (issues.some((issue) => issue.includes('(function \"'))) {\n\t\tlines.push(\n\t\t\t\" - for the `function` namespace: deploy the function (`neon deploy` / `config apply`) so its env is uploaded.\",\n\t\t);\n\t}\n\tif (issues.some(isFunctionBaseUrlIssue)) {\n\t\tlines.push(\n\t\t\t\" - for NEON_FUNCTION_*_BASE_URL: `neon env pull` or `neon dev`.\",\n\t\t);\n\t}\n\treturn lines;\n}\n\n/**\n * Runtime reverse map for filtered `parseEnv`: OS-level env-var key → `[namespace, property]`\n * in the {@link NeonEnv} shape. The compile-time mirror is {@link EnvKeysByNamespace} /\n * {@link EnvKeyToProp}; keep all three in sync. Only input vars appear (no output-only\n * aliases).\n */\nconst FILTERABLE_ENV_KEYS: Record<string, readonly [string, string]> = {\n\tDATABASE_URL: [\"postgres\", \"databaseUrl\"],\n\tDATABASE_URL_UNPOOLED: [\"postgres\", \"databaseUrlUnpooled\"],\n\tNEON_BRANCH: [\"branch\", \"name\"],\n\tNEON_AUTH_BASE_URL: [\"auth\", \"baseUrl\"],\n\tNEON_AUTH_JWKS_URL: [\"auth\", \"jwksUrl\"],\n\tNEON_DATA_API_URL: [\"dataApi\", \"url\"],\n\tAWS_ACCESS_KEY_ID: [\"storage\", \"accessKeyId\"],\n\tAWS_SECRET_ACCESS_KEY: [\"storage\", \"secretAccessKey\"],\n\tAWS_ENDPOINT_URL_S3: [\"storage\", \"endpoint\"],\n\tAWS_REGION: [\"storage\", \"region\"],\n\tNEON_AI_GATEWAY_TOKEN: [\"aiGateway\", \"apiKey\"],\n\tNEON_AI_GATEWAY_BASE_URL: [\"aiGateway\", \"baseUrl\"],\n};\n\n/**\n * Filtered counterpart to the {@link parseEnv} body: validate and return only the explicitly\n * selected OS-level env-var keys, projected back into the narrowed namespaced shape. Unlike\n * the full reader it never consults the policy — the selection alone decides what's required —\n * so vars the caller didn't ask for (e.g. `DATABASE_URL_UNPOOLED`) can be absent without\n * throwing. Mirrors the same non-empty constraint and {@link PlatformError} aggregation.\n */\nfunction parseFilteredEnv(\n\tsource: NodeJS.ProcessEnv,\n\tkeys: readonly string[],\n): Record<string, unknown> {\n\tconst issues: string[] = [];\n\tconst result: Record<string, Record<string, unknown>> = {};\n\tconst functionUrls: Record<string, NeonFunctionUrlEnv> = {};\n\tfor (const key of keys) {\n\t\tif (isFunctionBaseUrlKey(key)) {\n\t\t\tconst slug = parseFunctionBaseUrlKey(key);\n\t\t\tif (slug === null) continue;\n\t\t\tconst parsed = readFunctionBaseUrl(key, source[key]);\n\t\t\tif (!parsed.ok) {\n\t\t\t\tissues.push(parsed.issue);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfunctionUrls[slug] = { baseUrl: parsed.value };\n\t\t\tcontinue;\n\t\t}\n\t\t// Unknown keys are blocked at the type level; a runtime caller bypassing the types\n\t\t// gets a clear error rather than a silently-dropped selection.\n\t\tif (!Object.hasOwn(FILTERABLE_ENV_KEYS, key)) {\n\t\t\tissues.push(`${key} is not a selectable Neon env variable`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst value = source[key];\n\t\tif (value === undefined) {\n\t\t\tissues.push(`${key} is missing`);\n\t\t\tcontinue;\n\t\t}\n\t\tif (value === \"\") {\n\t\t\tissues.push(`${key} must not be empty`);\n\t\t\tcontinue;\n\t\t}\n\t\tconst [namespace, property] = FILTERABLE_ENV_KEYS[key];\n\t\tconst bucket = result[namespace] ?? {};\n\t\tbucket[property] = value;\n\t\tresult[namespace] = bucket;\n\t}\n\tif (Object.keys(functionUrls).length > 0) {\n\t\tresult.functions = functionUrls;\n\t}\n\tif (issues.length > 0) {\n\t\tthrow new PlatformError(\n\t\t\tErrorCode.EnvNotInjected,\n\t\t\t[\n\t\t\t\t\"parseEnv: the required Neon env variables are not present in process.env.\",\n\t\t\t\t...issues.map((i) => ` - ${i}`),\n\t\t\t\t...parseEnvInjectHint(issues),\n\t\t\t\t\"Or switch the call to `await fetchEnv(config, …)` if you're in a context that can do async I/O.\",\n\t\t\t].join(\"\\n\"),\n\t\t\t{ details: { missing: issues } },\n\t\t);\n\t}\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsGA,MAAM,oBAAoB,EAAE,OAAO;CAClC,cAAc,EACZ,OAAO,EAAE,SAAS,0BAA0B,CAAC,CAAC,CAC9C,IAAI,GAAG,gCAAgC;CACzC,uBAAuB,EACrB,OAAO,EAAE,SAAS,mCAAmC,CAAC,CAAC,CACvD,IAAI,GAAG,yCAAyC;AACnD,CAAC;AAED,MAAM,gBAAgB,EAAE,OAAO;CAC9B,oBAAoB,EAClB,OAAO,EAAE,SAAS,gCAAgC,CAAC,CAAC,CACpD,IAAI,GAAG,sCAAsC;CAC/C,oBAAoB,EA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AI,GACX,EAAE,SAAS,EAAE,SAAS,OAAO,EAAE,CAChC;CAED,OAAO;AACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neondatabase/env",
3
- "version": "1.1.5",
3
+ "version": "1.2.0",
4
4
  "description": "Resolve and inject Neon connection strings for the branch selected by your neon.ts policy. fetchEnv / parseEnv plus a `neon-env` CLI with `run` and `export`.",
5
5
  "keywords": [
6
6
  "neon",
@@ -45,15 +45,15 @@
45
45
  "tsdown": "^0.14.1",
46
46
  "typescript": "^5.9.0",
47
47
  "vitest": "^3.0.9",
48
+ "@neon-internals/env-core": "0.0.7",
48
49
  "@neon/e2e-harness": "0.0.0",
49
- "@neon/sdk": "3.0.0",
50
- "@neon-internals/env-core": "0.0.5",
50
+ "@neon/sdk": "3.1.0",
51
51
  "@neon-internals/cli-core": "0.0.0"
52
52
  },
53
53
  "dependencies": {
54
54
  "zod": "^4.4.3",
55
55
  "yargs": "^18.0.0",
56
- "@neon/config": "1.0.5"
56
+ "@neon/config": "1.2.0"
57
57
  },
58
58
  "optionalDependencies": {
59
59
  "@napi-rs/keyring": "1.3.0"