envapt 8.0.0-next.3 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/CHANGELOG.md +23 -39
  2. package/package.json +8 -8
package/CHANGELOG.md CHANGED
@@ -1,28 +1,21 @@
1
1
  # envapt
2
2
 
3
- ## 8.0.0-next.3
3
+ ## 8.0.0
4
4
 
5
5
  ### Major Changes
6
6
 
7
- - 848fe50: Return `undefined` for a missing read with no fallback across every reader, including the decorators and converter dispatch that returned `null` before. No-fallback decorator field types drop `| null`, so retype such fields to `| undefined`. `getWith` now runs its custom converter on a missing key with `raw` as `undefined`. An explicit `undefined` fallback counts as no fallback everywhere, so `Envapter.parse(key, schema, undefined)` throws `MissingEnvValue`.
7
+ - Add `getRequired(key, converter)` and `getRequiredAll(spec, casing?)` for typed required reads. `getRequired` takes the converter positionally, returns the non-undefined value, and throws `MissingEnvValue` on a missing, empty, or unconvertible value. `getRequiredAll` reads a group in one call and returns a typed record, throwing once listing every missing key. Its spec values can be tokens, `array()` tokens, or custom parser functions, and an optional `casing` (`'camelCase'`, `'PascalCase'`, or `'kebab-case'`) renames the record keys.
8
8
 
9
- ## 8.0.0-next.2
10
-
11
- ### Major Changes
12
-
13
- - 13bd158: A built-in converter fallback must now be a value the converter would accept. One of the correct type but an invalid value throws `FallbackConverterTypeMismatch`: an out-of-range `Port`, a `NaN` `Number` or `Float`, a non-safe-integer `Integer`, an `Invalid Date`, or an `Email` that is not a valid address. Pass a valid fallback or omit it.
14
-
15
- ### Minor Changes
16
-
17
- - 13bd158: Add the `Email` and `Port` converters.
18
-
19
- `Converters.Email` validates with the WHATWG `input[type=email]` pattern and returns the address unchanged. `Converters.Port` accepts an integer in the `0-65535` range, including `0` for ephemeral binding. Both fall back on invalid input, throw under `getRequired`, and compose inside `Converters.array`.
9
+ **BREAKING:** the `{ required: true }` options-bag form of `getUsing` and `getWith` is removed, use `getRequired` instead. The `@Envapt` decorator's `{ required: true }` option is unchanged.
20
10
 
21
- ## 8.0.0-next.1
11
+ - Return `undefined` for a missing read with no fallback across every reader, including the decorators and converter dispatch that returned `null` before. No-fallback decorator field types drop `| null`, so retype such fields to `| undefined`. `getWith` now runs its custom converter on a missing key with `raw` as `undefined`. An explicit `undefined` fallback counts as no fallback everywhere, so `Envapter.parse(key, schema, undefined)` throws `MissingEnvValue`.
12
+ - Move the engine's mutable state and read cache into a module that the `exports` map does not include. They are no longer fields on the class and have no import path, so outside code cannot read or write them through an `as`-cast or a subclass. Drop the internal `TimeUnit` type and `isStrict()` method from the public exports.
13
+ - **BREAKING:** Tighten the `Integer` and `Float` converters.
22
14
 
23
- ### Major Changes
15
+ `Converters.Integer` parses with `Number` and requires `Number.isSafeInteger`, so trailing characters (`42abc`), non-integers (`3.9`), and values past 2^53 now fall back. `Converters.Float` parses with `Number`, so trailing characters (`3.14xyz`) now fall back. `Float` still accepts `Infinity`.
24
16
 
25
- - 60ba358: Unify the rule for when an environment value counts as missing, and use it in every read path, with the global `strict` flag as its only knob.
17
+ - Trim internal-only exports out of the public API surface, from 36 exported types down to a small core. Gone are the source shape interfaces, the decorator return types, the schema brands, the converter and inference machinery (including the `ConverterToken` and `EnvaptConverter` aliases), the `isArrayOf` guard, the `EnvKeyInput`/`ArrayOf`/`ArrayElement` helpers, and the redundant `InferSchemaInput`/`InferSchemaOutput` aliases. Type inference on the readers and decorators is unchanged, since these types are inferred at the call site or reproducible from the still-public `Source` and `StandardSchemaV1`. For a schema's output type, use your validator's own inference (`z.infer`, valibot's `InferOutput`, arktype's `.infer`) or `StandardSchemaV1.InferOutput`.
18
+ - Unify the rule for when an environment value counts as missing, and use it in every read path, with the global `strict` flag as its only knob.
26
19
 
27
20
  A value is missing when it is unset or an empty string (always), and additionally when it is whitespace-only under `Envapter.strict = true`. This one rule now applies to ordered-key reads, `getRequired` / `getRequiredAll`, `Envapter.require`, the `@Envapt({ required: true })` decorator, environment detection, and `${VAR}` template resolution, so their behavior stays consistent.
28
21
 
@@ -34,39 +27,30 @@
34
27
 
35
28
  Set `Envapter.strict = true` for the old whitespace-is-blank behavior.
36
29
 
37
- ### Patch Changes
38
-
39
- - 60ba358: Under `Envapter.debug = 'verbose'`, log when a present value cannot be parsed by a built-in converter and the read falls back to its default. This surfaces a malformed value (for example a non-numeric `PORT`) that would otherwise fall back silently.
40
- - 5be3e5c: Add `@see` links to the docs site on the public API TSDoc, so hovering a reader, converter, source, decorator, or error in an editor links to its documentation page.
41
-
42
- ## 8.0.0-next.0
43
-
44
- ### Major Changes
45
-
46
- - f889a67: Add `getRequired(key, converter)` and `getRequiredAll(spec, casing?)` for typed required reads. `getRequired` takes the converter positionally, returns the non-undefined value, and throws `MissingEnvValue` on a missing or empty key. `getRequiredAll` reads a group in one call and returns a typed record, throwing once listing every missing key. Its spec values can be tokens, `array()` tokens, or custom parser functions, and an optional `casing` (`'camelCase'`, `'PascalCase'`, or `'kebab-case'`) renames the record keys.
47
-
48
- **BREAKING:** the `{ required: true }` options-bag form of `getUsing` and `getWith` is removed, use `getRequired` instead. The `@Envapt` decorator's `{ required: true }` option is unchanged.
49
-
50
- - 5e02661: Move the engine's mutable state and read cache into a module that the `exports` map does not include. They are no longer fields on the class and have no import path, so outside code cannot read or write them through an `as`-cast or a subclass. Drop the internal `TimeUnit` type and `isStrict()` method from the public exports.
51
- - 651008e: **BREAKING:** Tighten the `Integer` and `Float` converters.
52
-
53
- `Converters.Integer` parses with `Number` and requires `Number.isSafeInteger`, so trailing characters (`42abc`), non-integers (`3.9`), and values past 2^53 now fall back. `Converters.Float` parses with `Number`, so trailing characters (`3.14xyz`) now fall back. `Float` still accepts `Infinity`.
54
-
55
- - d415d68: Trim internal-only types out of the public API surface, from 36 exported types down to 15. Gone are the source shape interfaces, the decorator return types, the schema brands, the converter/inference machinery, the `EnvKeyInput`/`ArrayOf`/`ArrayElement` helpers, and the redundant `InferSchemaInput`/`InferSchemaOutput` aliases. Type inference on the readers and decorators is unchanged, since these types are inferred at the call site or reproducible from the still-public `Source` and `StandardSchemaV1`. For a schema's output type, use your validator's own inference (`z.infer`, valibot's `InferOutput`, arktype's `.infer`) or `StandardSchemaV1.InferOutput`.
56
- - d415d68: Collapse to one portable build and a single universal `envapt` import, and rename the source classes. Three breaking changes.
30
+ - Collapse to one portable build and a single universal `envapt` import, and rename the source classes. Three breaking changes.
57
31
 
58
32
  1. The source classes drop the `Env` infix. `PortableSource` (was `ManualEnvSource` / `WorkerEnvSource`, which were the same class) is the one source for every runtime without a filesystem. `FileSource` (was `NodeEnvSource`) is the Node source. The `Source` type replaces `EnvSource`. The v7.1 deprecated aliases are removed.
59
33
  2. `Envapter.fileApiMode` defaults to `'warn'`. On the portable build the file-only config APIs (`envPaths`, `baseDir`, `envFileOptions`, `configureProfiles`, `resetProfiles`) now warn once and no-op by default. Set `Envapter.fileApiMode = 'throw'` to restore the previous throwing behavior. An unconfigured read still throws `NoSourceBound` on first access.
60
34
  3. The `envapt/workerd` and `envapt/browser` subpaths are removed. Import from `envapt` everywhere. The package exports route Workers, the browser, and the edge runtimes (workerd, edge-light, fastly, worker, browser, react-native) to the portable build, and Node, Bun, and Deno to the node build. The portable types now include the file APIs, so config shared between dev and deploy compiles on every runtime.
61
35
 
36
+ - A built-in converter fallback must now be a value the converter would accept. One of the correct type but an invalid value throws `FallbackConverterTypeMismatch`: an out-of-range `Port`, a `NaN` `Number` or `Float`, a non-safe-integer `Integer`, an `Invalid Date`, or an `Email` that is not a valid address. Pass a valid fallback or omit it.
37
+
62
38
  ### Minor Changes
63
39
 
64
- - 5dea9fb: Add `merge`, a source combinator that layers several sources with last-wins precedence. It keeps the `.env` cascade and file APIs on one filesystem-backed member, and throws `InvalidMergedSource` with no members or more than one file-backed member.
40
+ - Add the `Email` and `Port` converters.
41
+
42
+ `Converters.Email` validates with the WHATWG `input[type=email]` pattern and returns the address unchanged. `Converters.Port` accepts an integer in the `0-65535` range, including `0` for ephemeral binding. Both fall back on invalid input, throw under `getRequired`, and compose inside `Converters.array`.
43
+
44
+ - Add `merge`, a source combinator that layers several sources with last-wins precedence. It keeps the `.env` cascade and file APIs on one filesystem-backed member, and throws `InvalidMergedSource` with no members or more than one file-backed member.
45
+
46
+ `useSource` and `merge` also accept a reader function `(key) => string | undefined` as a source, for a runtime that reads one key at a time and cannot list its keys. envapt calls the reader on a cache miss and caches the result.
65
47
 
66
48
  ### Patch Changes
67
49
 
68
- - 5dea9fb: Fix the read cache rebuilding on every access when a bound source and the `.env` cascade resolve to no keys. It now builds once per `useSource`, matching a non-empty source.
69
- - 48d4f02: Move the engine read-path into module functions under core/ so a consumer subclass can no longer reach or mutate the read cache. No public API change.
50
+ - Under `Envapter.debug = 'verbose'`, log when a present value cannot be parsed by a built-in converter and the read falls back to its default. This surfaces a malformed value (for example a non-numeric `PORT`) that would otherwise fall back silently.
51
+ - Fix the read cache rebuilding on every access when a bound source and the `.env` cascade resolve to no keys. It now builds once per `useSource`, matching a non-empty source.
52
+ - Move the engine read-path into module functions under core/ so a consumer subclass can no longer reach or mutate the read cache. No public API change.
53
+ - Add `@see` links to the docs site on the public API TSDoc, so hovering a reader, converter, source, decorator, or error in an editor links to its documentation page.
70
54
 
71
55
  ## 7.1.0
72
56
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "envapt",
3
3
  "type": "module",
4
- "version": "8.0.0-next.3",
4
+ "version": "8.0.0",
5
5
  "description": "Type-safe config for TypeScript. Read typed values from any source, process.env, .env files, Cloudflare Workers bindings, browser bundles, or any object you supply. Zero runtime dependencies, one API across Node, Bun, Deno, Workers, and the browser. TC39 accessor decorators (legacy decorators at envapt/legacy), converters, and Standard Schema (zod/valibot/arktype) validation.",
6
6
  "types": "./dist/types/index.d.mts",
7
7
  "exports": {
@@ -186,14 +186,14 @@
186
186
  "provenance": true
187
187
  },
188
188
  "devDependencies": {
189
- "@cloudflare/vitest-pool-workers": "0.16.19",
190
- "@cloudflare/workers-types": "^4.20260623.1",
191
- "@vitest/browser": "4.1.9",
192
- "@vitest/browser-playwright": "4.1.9",
193
- "arktype": "^2.2.1",
189
+ "@cloudflare/vitest-pool-workers": "0.18.0",
190
+ "@cloudflare/workers-types": "^5.20260706.1",
191
+ "@vitest/browser": "4.1.10",
192
+ "@vitest/browser-playwright": "4.1.10",
193
+ "arktype": "^2.2.2",
194
194
  "esbuild": "^0.28.1",
195
- "playwright": "1.61.0",
196
- "valibot": "^1.4.1",
195
+ "playwright": "1.61.1",
196
+ "valibot": "^1.4.2",
197
197
  "zod": "4.4.3"
198
198
  },
199
199
  "scripts": {