@neondatabase/env 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +21 -1
  2. package/dist/cli.js +1304 -6
  3. package/dist/cli.js.map +1 -1
  4. package/dist/{_shared/env-core/env.js → env.js} +62 -41
  5. package/dist/env.js.map +1 -0
  6. package/dist/index.d.ts +528 -3
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +197 -2
  9. package/dist/{lib/parse-env.js.map → index.js.map} +1 -1
  10. package/package.json +12 -7
  11. package/dist/_shared/auth_selection.d.ts +0 -95
  12. package/dist/_shared/auth_selection.d.ts.map +0 -1
  13. package/dist/_shared/auth_selection.js +0 -85
  14. package/dist/_shared/auth_selection.js.map +0 -1
  15. package/dist/_shared/credentials.d.ts +0 -186
  16. package/dist/_shared/credentials.d.ts.map +0 -1
  17. package/dist/_shared/credentials.js +0 -190
  18. package/dist/_shared/credentials.js.map +0 -1
  19. package/dist/_shared/env-core/env.d.ts +0 -424
  20. package/dist/_shared/env-core/env.d.ts.map +0 -1
  21. package/dist/_shared/env-core/env.js.map +0 -1
  22. package/dist/_shared/env-core/reuse-secrets.d.ts +0 -95
  23. package/dist/_shared/env-core/reuse-secrets.d.ts.map +0 -1
  24. package/dist/_shared/env-core/reuse-secrets.js +0 -181
  25. package/dist/_shared/env-core/reuse-secrets.js.map +0 -1
  26. package/dist/_shared/paths.d.ts +0 -116
  27. package/dist/_shared/paths.d.ts.map +0 -1
  28. package/dist/_shared/paths.js +0 -153
  29. package/dist/_shared/paths.js.map +0 -1
  30. package/dist/_shared/profiles.d.ts +0 -145
  31. package/dist/_shared/profiles.d.ts.map +0 -1
  32. package/dist/_shared/profiles.js +0 -228
  33. package/dist/_shared/profiles.js.map +0 -1
  34. package/dist/_shared/secure_file.d.ts +0 -25
  35. package/dist/_shared/secure_file.d.ts.map +0 -1
  36. package/dist/_shared/secure_file.js +0 -43
  37. package/dist/_shared/secure_file.js.map +0 -1
  38. package/dist/config/dist/lib/define-config.d.ts +0 -20
  39. package/dist/config/dist/lib/define-config.d.ts.map +0 -1
  40. package/dist/config/dist/lib/neon-api.d.ts +0 -375
  41. package/dist/config/dist/lib/neon-api.d.ts.map +0 -1
  42. package/dist/config/dist/lib/types.d.ts +0 -603
  43. package/dist/config/dist/lib/types.d.ts.map +0 -1
  44. package/dist/config/dist/v1.d.ts +0 -5
  45. package/dist/lib/cli/commands.d.ts +0 -68
  46. package/dist/lib/cli/commands.d.ts.map +0 -1
  47. package/dist/lib/cli/commands.js +0 -233
  48. package/dist/lib/cli/commands.js.map +0 -1
  49. package/dist/lib/cli/resolve-api-key.d.ts +0 -29
  50. package/dist/lib/cli/resolve-api-key.d.ts.map +0 -1
  51. package/dist/lib/cli/resolve-api-key.js +0 -74
  52. package/dist/lib/cli/resolve-api-key.js.map +0 -1
  53. package/dist/lib/cli/resolve-context.d.ts +0 -34
  54. package/dist/lib/cli/resolve-context.d.ts.map +0 -1
  55. package/dist/lib/cli/resolve-context.js +0 -88
  56. package/dist/lib/cli/resolve-context.js.map +0 -1
  57. package/dist/lib/parse-env.d.ts +0 -95
  58. package/dist/lib/parse-env.d.ts.map +0 -1
  59. package/dist/lib/parse-env.js +0 -198
package/README.md CHANGED
@@ -86,7 +86,14 @@ For example, [varlock](https://varlock.dev) can bulk-load Neon's branch env via
86
86
  # @setValuesBulk(exec(`neon-env export --format json`), format=json)
87
87
  ```
88
88
 
89
- Flags (both commands): `--config <path>`, `--project-id`, `--branch`, `--api-key`, `--debug`. `export` also takes `--format dotenv|json`.
89
+ Flags (both commands): `--config <path>`, `--project-id`, `--branch`, `--api-key`, `--profile`, `--debug`. `export` also takes `--format dotenv|json`.
90
+
91
+ `--api-key` and `NEON_API_KEY` skip stored credentials. Otherwise `neon-env` reads the same
92
+ Neon CLI profile the `neon` CLI does, including a secret stored in the OS keyring when that
93
+ profile's `profiles.json` pointer is `"keyring"`. `@neon/env` has no standalone binary; it
94
+ loads the OS keyring addon from npm. If that optional dependency is missing, a `"keyring"`
95
+ pointer is an error. Older releases treat the sentinel as a relative path. A keyring pointer
96
+ whose item cannot be read is an error, not "not signed in".
90
97
 
91
98
  ## Env vars produced
92
99
 
@@ -152,6 +159,19 @@ const { storage } = await fetchEnv(config, {
152
159
  storage.endpoint; // string — `accessKeyId` is absent, and never fetched
153
160
  ```
154
161
 
162
+ Inline key arrays autocomplete from the services enabled in `config`, reject unknown or disabled keys, and narrow the result exactly without `as const`. A runtime-built array returns the same selected values with optional namespaces and properties, because the array may contain any subset of its declared key union:
163
+
164
+ ```ts
165
+ const keys: Array<"DATABASE_URL" | "NEON_BRANCH"> =
166
+ process.env.INCLUDE_BRANCH ? ["DATABASE_URL", "NEON_BRANCH"] : ["DATABASE_URL"];
167
+ const selected = await fetchEnv(config, { projectId, branch: "main", keys });
168
+
169
+ selected.postgres?.databaseUrl; // string | undefined
170
+ selected.branch?.name; // string | undefined
171
+ ```
172
+
173
+ `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` are one credential and must be selected together. Literal lists that contain only one half are a type error; a runtime-built list that resolves to one half throws before any API request or credential issuance.
174
+
155
175
  Work is skipped, not just the result narrowed. Leave out `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` / `NEON_AI_GATEWAY_TOKEN` and **no credential is minted at all** — which is exactly how `fetchEnvReusingSecrets` refreshes everything else while keeping secrets you already have. The non-secret vars of those features (`AWS_ENDPOINT_URL_S3`, `AWS_REGION`, `NEON_AI_GATEWAY_BASE_URL`) are branch metadata and stay available on their own.
156
176
 
157
177
  ## Connection role & database selection